fix(sales): 修复销售台账产品生产数据重复添加问题
- 在addProductionData方法中添加检查逻辑,避免重复创建生产订单
- 移动生产数据添加逻辑到循环外部,确保每个产品都执行生产数据创建
- 防止因重复调用导致的数据异常和业务流程错误
| | |
| | | * 新增生产数据 |
| | | */ |
| | | public void addProductionData(SalesLedgerProduct salesLedgerProduct) { |
| | | List<ProductOrder> productOrders = productOrderMapper.selectList(new QueryWrapper<ProductOrder>().lambda().eq(ProductOrder::getSaleLedgerProductId, salesLedgerProduct.getId())); |
| | | if (!productOrders.isEmpty()) { |
| | | return; |
| | | } |
| | | ProductOrder productOrder = new ProductOrder(); |
| | | productOrder.setSalesLedgerId(salesLedgerProduct.getSalesLedgerId()); |
| | | productOrder.setProductModelId(salesLedgerProduct.getProductModelId()); |
| | |
| | | salesLedgerProduct.setNoInvoiceAmount(salesLedgerProduct.getTaxInclusiveTotalPrice()); |
| | | salesLedgerProduct.setPendingInvoiceTotal(salesLedgerProduct.getTaxInclusiveTotalPrice()); |
| | | salesLedgerProductMapper.insert(salesLedgerProduct); |
| | | // 添加生产数据 |
| | | if (isProduce) { |
| | | salesLedgerProductServiceImpl.addProductionData(salesLedgerProduct); |
| | | |
| | | } |
| | | } |
| | | if (isProduce) { |
| | | for (SalesLedgerProduct salesLedgerProduct : products) { |
| | | // 添加生产数据 |
| | | salesLedgerProductServiceImpl.addProductionData(salesLedgerProduct); |
| | | } |
| | | } |
| | | } |
| | | |