Przeglądaj źródła

形式发票生成节点调整

zhangchenm 1 tydzień temu
rodzic
commit
8d598c32c3

+ 11 - 10
trade-client/src/main/java/com/trade/client/trade/salesorder/service/impl/SalesOrderCServiceImpl.java

@@ -196,16 +196,6 @@ public class SalesOrderCServiceImpl implements SalesOrderCService {
     public void submit(SalesOrderDTO salesOrderDTO) {
         log.info("提交销售订单Info:{}", salesOrderDTO.toString());
         save(salesOrderDTO, true);
-        SalesOrder salesOrder = salesOrderDTO.getSalesOrder();
-        SalesOrderInvoice salesOrderInvoice = new SalesOrderInvoice();
-        salesOrderInvoice.setOrderId(salesOrder.getId());
-        salesOrderInvoice.setInvoiceNo(serialNumberGenerator.nextValue(SaleOrderConstant.ORDER_INVOICE_NO_PREFIX));
-        salesOrderInvoice.setAmount(salesOrder.getAmount());
-        // 生成发票文件并保存文件ID
-        Long fileId = generateInvoiceFile(salesOrder, salesOrderDTO.getSalesOrderGoodsList(),
-                salesOrderInvoice.getInvoiceNo());
-        salesOrderInvoice.setFileId(fileId);
-        salesOrderInvoiceService.save(salesOrderInvoice);
     }
 
     /**
@@ -345,6 +335,17 @@ public class SalesOrderCServiceImpl implements SalesOrderCService {
         }
         salesOrder.setStatus(SaleOrderConstant.ORDER_STATUS_DELIVERING);
         salesOrderService.updateById(salesOrder);
+        // save invoice
+        SalesOrderInvoice salesOrderInvoice = new SalesOrderInvoice();
+        salesOrderInvoice.setOrderId(salesOrder.getId());
+        salesOrderInvoice.setInvoiceNo(serialNumberGenerator.nextValue(SaleOrderConstant.ORDER_INVOICE_NO_PREFIX));
+        salesOrderInvoice.setAmount(salesOrder.getAmount());
+        // 生成发票文件并保存文件ID
+        Long fileId = generateInvoiceFile(salesOrder,
+                salesOrderGoodsService.lambdaQuery().eq(SalesOrderGoods::getSaleOrderId, salesOrder.getId()).list(),
+                salesOrderInvoice.getInvoiceNo());
+        salesOrderInvoice.setFileId(fileId);
+        salesOrderInvoiceService.save(salesOrderInvoice);
     }
 
     @Override