소스 검색

形式发票生成节点调整

zhangchenm 1 주 전
부모
커밋
8d598c32c3
1개의 변경된 파일11개의 추가작업 그리고 10개의 파일을 삭제
  1. 11 10
      trade-client/src/main/java/com/trade/client/trade/salesorder/service/impl/SalesOrderCServiceImpl.java

+ 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