浏览代码

完善代码

yuansh 1 月之前
父节点
当前提交
1e56b2ef47
共有 19 个文件被更改,包括 375 次插入66 次删除
  1. 12 0
      srm-module-code/src/main/java/org/jeecg/modules/platCode/controller/PlatCommissionContractController.java
  2. 4 0
      srm-module-code/src/main/java/org/jeecg/modules/platCode/controller/PlatCommissionOrderController.java
  3. 4 0
      srm-module-code/src/main/java/org/jeecg/modules/platCode/entity/PlatCommissionContract.java
  4. 2 0
      srm-module-code/src/main/java/org/jeecg/modules/platCode/service/impl/PlatCommissionContractServiceImpl.java
  5. 88 53
      srm-module-code/src/main/java/org/jeecg/modules/platCode/service/impl/PlatCommissionOrderServiceImpl.java
  6. 2 0
      srm-module-code/src/main/java/org/jeecg/modules/platCode/vo/PlatCommissionContractPage.java
  7. 2 2
      srm-module-code/src/main/java/org/jeecg/modules/purCode/controller/PurOrderController.java
  8. 2 1
      srm-module-code/src/main/java/org/jeecg/modules/purCode/service/IPurOrderService.java
  9. 94 0
      srm-module-code/src/main/java/org/jeecg/modules/purCode/service/impl/PurOrderServiceImpl.java
  10. 2 2
      srm-module-code/src/main/java/org/jeecg/modules/saleCode/controller/SaleContractController.java
  11. 2 2
      srm-module-code/src/main/java/org/jeecg/modules/saleCode/controller/SaleOrderController.java
  12. 2 2
      srm-module-code/src/main/java/org/jeecg/modules/saleCode/controller/SaleQuotationController.java
  13. 1 1
      srm-module-code/src/main/java/org/jeecg/modules/saleCode/mapper/xml/SaleInquiryFormProductMapper.xml
  14. 2 1
      srm-module-code/src/main/java/org/jeecg/modules/saleCode/service/ISaleContractService.java
  15. 2 1
      srm-module-code/src/main/java/org/jeecg/modules/saleCode/service/ISaleOrderService.java
  16. 2 1
      srm-module-code/src/main/java/org/jeecg/modules/saleCode/service/ISaleQuotationService.java
  17. 32 0
      srm-module-code/src/main/java/org/jeecg/modules/saleCode/service/impl/SaleContractServiceImpl.java
  18. 69 0
      srm-module-code/src/main/java/org/jeecg/modules/saleCode/service/impl/SaleOrderServiceImpl.java
  19. 51 0
      srm-module-code/src/main/java/org/jeecg/modules/saleCode/service/impl/SaleQuotationServiceImpl.java

+ 12 - 0
srm-module-code/src/main/java/org/jeecg/modules/platCode/controller/PlatCommissionContractController.java

@@ -15,6 +15,8 @@ import javax.servlet.http.HttpServletResponse;
 
 import org.apache.commons.lang.StringUtils;
 import org.jeecg.modules.baseCode.service.ISerialPatternService;
+import org.jeecg.modules.platCode.entity.PlatCommissionOrder;
+import org.jeecg.modules.platCode.service.IPlatCommissionOrderService;
 import org.jeecg.modules.purCode.entity.PurOrder;
 import org.jeecgframework.poi.excel.ExcelImportUtil;
 import org.jeecgframework.poi.excel.def.NormalExcelConstants;
@@ -65,6 +67,8 @@ public class PlatCommissionContractController {
     @Autowired
     private IPlatCommissionContractProductService platCommissionContractProductService;
 
+    @Autowired
+    private IPlatCommissionOrderService platCommissionOrderService;
     @Autowired
     private ISerialPatternService serialPatternService;
 
@@ -290,6 +294,14 @@ public class PlatCommissionContractController {
                 continue;
             }
 
+            QueryWrapper<PlatCommissionOrder> ent = new QueryWrapper<>();
+            ent.eq("commission_contract",o.getId());
+            ent.eq("del_flag","0");
+            List<PlatCommissionOrder> listEnt = platCommissionOrderService.list(ent);
+            if(listEnt.size() > 0){
+                sb.append("单号" + code).append("已被佣金订单"+listEnt.get(0).getBillCode()+"使用,无法执行此操作;");
+                continue;
+            }
         }
 
         if (StringUtils.isNotBlank(sb.toString())) {

+ 4 - 0
srm-module-code/src/main/java/org/jeecg/modules/platCode/controller/PlatCommissionOrderController.java

@@ -15,7 +15,9 @@ import javax.servlet.http.HttpServletResponse;
 
 import org.apache.commons.lang.StringUtils;
 import org.jeecg.modules.baseCode.service.ISerialPatternService;
+import org.jeecg.modules.platCode.entity.PlatCommissionContract;
 import org.jeecg.modules.platCode.entity.PlatCommissionOrder;
+import org.jeecg.modules.platCode.service.IPlatCommissionContractService;
 import org.jeecgframework.poi.excel.ExcelImportUtil;
 import org.jeecgframework.poi.excel.def.NormalExcelConstants;
 import org.jeecgframework.poi.excel.entity.ExportParams;
@@ -65,6 +67,8 @@ public class PlatCommissionOrderController {
 	@Autowired
 	private IPlatCommissionOrderProductService platCommissionOrderProductService;
 
+	 @Autowired
+	 private IPlatCommissionContractService platCommissionContractService;
 	 @Autowired
 	 private ISerialPatternService serialPatternService;
 	

+ 4 - 0
srm-module-code/src/main/java/org/jeecg/modules/platCode/entity/PlatCommissionContract.java

@@ -65,6 +65,10 @@ public class PlatCommissionContract implements Serializable {
     @ApiModelProperty(value = "关闭(close)1是0否")
     @Dict(dicCode = "yes_or_no")
     private String close;
+
+    @ApiModelProperty(value = "是否被佣金订单使用")
+    @Dict(dicCode = "yes_or_no")
+    private Integer isUsed;
 	/**删除状态(0-正常,1-已删除)*/
 	@Excel(name = "删除状态(0-正常,1-已删除)", width = 15)
     @ApiModelProperty(value = "删除状态(0-正常,1-已删除)")

+ 2 - 0
srm-module-code/src/main/java/org/jeecg/modules/platCode/service/impl/PlatCommissionContractServiceImpl.java

@@ -34,6 +34,7 @@ public class PlatCommissionContractServiceImpl extends ServiceImpl<PlatCommissio
 		if(platCommissionContractProductList!=null && platCommissionContractProductList.size()>0) {
 			for(PlatCommissionContractProduct entity:platCommissionContractProductList) {
 				//外键设置
+				entity.setId(null);
 				entity.setHeadId(platCommissionContract.getId());
 				platCommissionContractProductMapper.insert(entity);
 			}
@@ -52,6 +53,7 @@ public class PlatCommissionContractServiceImpl extends ServiceImpl<PlatCommissio
 		if(platCommissionContractProductList!=null && platCommissionContractProductList.size()>0) {
 			for(PlatCommissionContractProduct entity:platCommissionContractProductList) {
 				//外键设置
+				entity.setId(null);
 				entity.setHeadId(platCommissionContract.getId());
 				platCommissionContractProductMapper.insert(entity);
 			}

+ 88 - 53
srm-module-code/src/main/java/org/jeecg/modules/platCode/service/impl/PlatCommissionOrderServiceImpl.java

@@ -1,7 +1,10 @@
 package org.jeecg.modules.platCode.service.impl;
 
+import org.apache.commons.lang.StringUtils;
+import org.jeecg.modules.platCode.entity.PlatCommissionContract;
 import org.jeecg.modules.platCode.entity.PlatCommissionOrder;
 import org.jeecg.modules.platCode.entity.PlatCommissionOrderProduct;
+import org.jeecg.modules.platCode.mapper.PlatCommissionContractMapper;
 import org.jeecg.modules.platCode.mapper.PlatCommissionOrderProductMapper;
 import org.jeecg.modules.platCode.mapper.PlatCommissionOrderMapper;
 import org.jeecg.modules.platCode.service.IPlatCommissionOrderService;
@@ -9,6 +12,7 @@ import org.springframework.stereotype.Service;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.transaction.annotation.Transactional;
+
 import java.io.Serializable;
 import java.util.List;
 import java.util.Collection;
@@ -16,62 +20,93 @@ import java.util.Collection;
 /**
  * @Description: 佣金订单
  * @Author: jeecg-boot
- * @Date:   2025-02-12
+ * @Date: 2025-02-12
  * @Version: V1.0
  */
 @Service
 public class PlatCommissionOrderServiceImpl extends ServiceImpl<PlatCommissionOrderMapper, PlatCommissionOrder> implements IPlatCommissionOrderService {
 
-	@Autowired
-	private PlatCommissionOrderMapper platCommissionOrderMapper;
-	@Autowired
-	private PlatCommissionOrderProductMapper platCommissionOrderProductMapper;
-	
-	@Override
-	@Transactional(rollbackFor = Exception.class)
-	public void saveMain(PlatCommissionOrder platCommissionOrder, List<PlatCommissionOrderProduct> platCommissionOrderProductList) {
-		platCommissionOrderMapper.insert(platCommissionOrder);
-		if(platCommissionOrderProductList!=null && platCommissionOrderProductList.size()>0) {
-			for(PlatCommissionOrderProduct entity:platCommissionOrderProductList) {
-				//外键设置
-				entity.setHeadId(platCommissionOrder.getId());
-				platCommissionOrderProductMapper.insert(entity);
-			}
-		}
-	}
-
-	@Override
-	@Transactional(rollbackFor = Exception.class)
-	public void updateMain(PlatCommissionOrder platCommissionOrder,List<PlatCommissionOrderProduct> platCommissionOrderProductList) {
-		platCommissionOrderMapper.updateById(platCommissionOrder);
-		
-		//1.先删除子表数据
-		platCommissionOrderProductMapper.deleteByMainId(platCommissionOrder.getId());
-		
-		//2.子表数据重新插入
-		if(platCommissionOrderProductList!=null && platCommissionOrderProductList.size()>0) {
-			for(PlatCommissionOrderProduct entity:platCommissionOrderProductList) {
-				//外键设置
-				entity.setHeadId(platCommissionOrder.getId());
-				platCommissionOrderProductMapper.insert(entity);
-			}
-		}
-	}
-
-	@Override
-	@Transactional(rollbackFor = Exception.class)
-	public void delMain(String id) {
-		platCommissionOrderProductMapper.deleteByMainId(id);
-		platCommissionOrderMapper.deleteById(id);
-	}
-
-	@Override
-	@Transactional(rollbackFor = Exception.class)
-	public void delBatchMain(Collection<? extends Serializable> idList) {
-		for(Serializable id:idList) {
-			platCommissionOrderProductMapper.deleteByMainId(id.toString());
-			platCommissionOrderMapper.deleteById(id);
-		}
-	}
-	
+    @Autowired
+    private PlatCommissionOrderMapper platCommissionOrderMapper;
+    @Autowired
+    private PlatCommissionOrderProductMapper platCommissionOrderProductMapper;
+
+    @Autowired
+    private PlatCommissionContractMapper platCommissionContractMapper;
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void saveMain(PlatCommissionOrder platCommissionOrder, List<PlatCommissionOrderProduct> platCommissionOrderProductList) {
+        platCommissionOrderMapper.insert(platCommissionOrder);
+
+        String getCommissionContract = platCommissionOrder.getCommissionContract();
+        if (StringUtils.isNotBlank(getCommissionContract)) {
+            PlatCommissionContract ent = platCommissionContractMapper.selectById(getCommissionContract);
+            ent.setIsUsed(1);
+            platCommissionContractMapper.selectById(ent);
+        }
+
+
+        if (platCommissionOrderProductList != null && platCommissionOrderProductList.size() > 0) {
+            for (PlatCommissionOrderProduct entity : platCommissionOrderProductList) {
+                //外键设置
+                entity.setId(null);
+                entity.setHeadId(platCommissionOrder.getId());
+                platCommissionOrderProductMapper.insert(entity);
+            }
+        }
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void updateMain(PlatCommissionOrder platCommissionOrder, List<PlatCommissionOrderProduct> platCommissionOrderProductList) {
+
+        PlatCommissionOrder platCommissionOrderOld = platCommissionOrderMapper.selectById(platCommissionOrder.getId());
+        String getCommissionContractOld = platCommissionOrderOld.getCommissionContract();
+
+        String getCommissionContract = platCommissionOrder.getCommissionContract();
+
+        if(StringUtils.isNotBlank(getCommissionContractOld) && !getCommissionContractOld.equals(getCommissionContract)){
+            PlatCommissionContract ent = platCommissionContractMapper.selectById(getCommissionContractOld);
+            ent.setIsUsed(0);
+            platCommissionContractMapper.selectById(ent);
+        }
+
+        platCommissionOrderMapper.updateById(platCommissionOrder);
+
+        if (StringUtils.isNotBlank(getCommissionContract)) {
+            PlatCommissionContract ent = platCommissionContractMapper.selectById(getCommissionContract);
+            ent.setIsUsed(1);
+            platCommissionContractMapper.selectById(ent);
+        }
+        //1.先删除子表数据
+        platCommissionOrderProductMapper.deleteByMainId(platCommissionOrder.getId());
+
+        //2.子表数据重新插入
+        if (platCommissionOrderProductList != null && platCommissionOrderProductList.size() > 0) {
+            for (PlatCommissionOrderProduct entity : platCommissionOrderProductList) {
+                //外键设置
+                entity.setId(null);
+                entity.setHeadId(platCommissionOrder.getId());
+                platCommissionOrderProductMapper.insert(entity);
+            }
+        }
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void delMain(String id) {
+        platCommissionOrderProductMapper.deleteByMainId(id);
+        platCommissionOrderMapper.deleteById(id);
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void delBatchMain(Collection<? extends Serializable> idList) {
+        for (Serializable id : idList) {
+            platCommissionOrderProductMapper.deleteByMainId(id.toString());
+            platCommissionOrderMapper.deleteById(id);
+        }
+    }
+
 }

+ 2 - 0
srm-module-code/src/main/java/org/jeecg/modules/platCode/vo/PlatCommissionContractPage.java

@@ -58,6 +58,8 @@ public class PlatCommissionContractPage {
 	@Excel(name = "关闭(close)1是0否", width = 15)
 	@ApiModelProperty(value = "关闭(close)1是0否")
     private String close;
+	@ApiModelProperty(value = "是否被佣金订单使用 1是0否")
+	private Integer isUsed;
 	/**删除状态(0-正常,1-已删除)*/
 	@Excel(name = "删除状态(0-正常,1-已删除)", width = 15)
 	@ApiModelProperty(value = "删除状态(0-正常,1-已删除)")

+ 2 - 2
srm-module-code/src/main/java/org/jeecg/modules/purCode/controller/PurOrderController.java

@@ -299,8 +299,8 @@ public class PurOrderController {
 
         purOrder.setVersion(String.valueOf(newV));
 
-        purOrderService.updateMain(purOrder, purOrderPage.getPurOrderShipList(), purOrderPage.getPurOrderProductList());
-        return Result.OK("编辑成功!");
+        purOrderService.updateMainHis(purOrder, purOrderPage.getPurOrderShipList(), purOrderPage.getPurOrderProductList());
+        return Result.OK("修订成功!");
     }
 
     /**

+ 2 - 1
srm-module-code/src/main/java/org/jeecg/modules/purCode/service/IPurOrderService.java

@@ -35,7 +35,8 @@ public interface IPurOrderService extends IService<PurOrder> {
    * @param purOrderProductList
 	 */
 	public void updateMain(PurOrder purOrder,List<PurOrderShip> purOrderShipList,List<PurOrderProduct> purOrderProductList);
-	
+	public void updateMainHis(PurOrder purOrder,List<PurOrderShip> purOrderShipList,List<PurOrderProduct> purOrderProductList);
+
 	/**
 	 * 删除一对多
 	 *

+ 94 - 0
srm-module-code/src/main/java/org/jeecg/modules/purCode/service/impl/PurOrderServiceImpl.java

@@ -186,6 +186,100 @@ public class PurOrderServiceImpl extends ServiceImpl<PurOrderMapper, PurOrder> i
 		}
 	}
 
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void updateMainHis(PurOrder purOrder,List<PurOrderShip> purOrderShipList,List<PurOrderProduct> purOrderProductList) {
+
+		List<PurOrderProduct> detailsList = purOrderProductMapper.selectByMainId(purOrder.getId());
+		if (detailsList != null && detailsList.size() > 0) {
+
+			for(PurOrderProduct entity:detailsList) {
+
+				String sourceId = entity.getSourceId();
+				if (StringUtils.isNotBlank(sourceId)) {
+
+					BigDecimal quantity = entity.getQuantity() == null ? BigDecimal.ZERO : entity.getQuantity();//采购数量
+					SaleOrderProduct arrival = saleOrderProductMapper.selectById(sourceId);
+
+					if (arrival != null) {
+						BigDecimal arrivalQuantity = arrival.getPurchaseQuantity() == null ? BigDecimal.ZERO : arrival.getPurchaseQuantity();//已采购数量
+
+						arrivalQuantity = arrivalQuantity.subtract(quantity);
+
+						if (arrivalQuantity.compareTo(BigDecimal.ZERO) < 1) {
+							arrival.setPurchaseQuantity(BigDecimal.ZERO);
+						} else {
+
+							arrival.setPurchaseQuantity(arrivalQuantity);
+						}
+
+						saleOrderProductMapper.updateById(arrival);
+
+					}
+				}
+
+			}
+
+		}
+
+		BigDecimal totalAmount = BigDecimal.ZERO;
+		if(purOrderProductList!=null && purOrderProductList.size()>0) {
+			for(PurOrderProduct entity:purOrderProductList) {
+				BigDecimal amount = entity.getTaxAmount()==null ? BigDecimal.ZERO : entity.getTaxAmount();
+				totalAmount = totalAmount.add(amount);
+			}
+		}
+		purOrder.setTotalAmount(totalAmount);
+
+		purOrderMapper.updateById(purOrder);
+
+		//1.先删除子表数据
+//		purOrderShipMapper.deleteByMainId(purOrder.getId());
+//		purOrderProductMapper.deleteByMainId(purOrder.getId());
+
+		//2.子表数据重新插入
+		if(purOrderShipList!=null && purOrderShipList.size()>0) {
+			for(PurOrderShip entity:purOrderShipList) {
+				//外键设置
+//				entity.setId(null);
+//				entity.setHeadId(purOrder.getId());
+				purOrderShipMapper.updateById(entity);
+			}
+		}
+		if(purOrderProductList!=null && purOrderProductList.size()>0) {
+			for(PurOrderProduct entity:purOrderProductList) {
+				//外键设置
+//				entity.setId(null);
+//				entity.setHeadId(purOrder.getId());
+				entity.setDelFlag(0);
+				int updateR = purOrderProductMapper.updateById(entity);
+				if(updateR == 0){
+					//外键设置
+					entity.setId(null);
+					entity.setHeadId(purOrder.getId());
+					purOrderProductMapper.insert(entity);
+				}
+
+				String sourceId = entity.getSourceId();
+
+				if (StringUtils.isNotBlank(sourceId)) {
+
+					BigDecimal quantity = entity.getQuantity() == null ? BigDecimal.ZERO : entity.getQuantity();//采购数量
+
+					SaleOrderProduct arrival = saleOrderProductMapper.selectById(sourceId);
+					if (arrival != null) {
+						BigDecimal arrivalQuantity = arrival.getPurchaseQuantity() == null ? BigDecimal.ZERO : arrival.getPurchaseQuantity();//已采购数量
+
+						arrivalQuantity = arrivalQuantity.add(quantity);
+						arrival.setPurchaseQuantity(arrivalQuantity);
+						saleOrderProductMapper.updateById(arrival);
+					}
+				}
+
+			}
+		}
+	}
+
 	/**
 	 * 提交时执行B2B操作
 	 * @param list

+ 2 - 2
srm-module-code/src/main/java/org/jeecg/modules/saleCode/controller/SaleContractController.java

@@ -239,8 +239,8 @@ public class SaleContractController {
 
         saleContract.setVersion(String.valueOf(newV));
 
-        saleContractService.updateMain(saleContract, saleContractPage.getSaleContractShipList(), saleContractPage.getSaleContractProductList());
-        return Result.OK("编辑成功!");
+        saleContractService.updateMainHis(saleContract, saleContractPage.getSaleContractShipList(), saleContractPage.getSaleContractProductList());
+        return Result.OK("修订成功!");
     }
 
 

+ 2 - 2
srm-module-code/src/main/java/org/jeecg/modules/saleCode/controller/SaleOrderController.java

@@ -379,8 +379,8 @@ public class SaleOrderController {
 
         saleOrder.setVersion(String.valueOf(newV));
 
-        saleOrderService.updateMain(saleOrder, saleOrderPage.getSaleOrderShipList(), saleOrderPage.getSaleOrderProductList());
-        return Result.OK("编辑成功!");
+        saleOrderService.updateMainHis(saleOrder, saleOrderPage.getSaleOrderShipList(), saleOrderPage.getSaleOrderProductList());
+        return Result.OK("修订成功!");
     }
 
 

+ 2 - 2
srm-module-code/src/main/java/org/jeecg/modules/saleCode/controller/SaleQuotationController.java

@@ -310,8 +310,8 @@ public class SaleQuotationController {
 
         saleQuotation.setVersion(String.valueOf(newV));
 
-        saleQuotationService.updateMain(saleQuotation, saleQuotationPage.getSaleQuotationShipList(), saleQuotationPage.getSaleQuotationProductList());
-        return Result.OK("编辑成功!");
+        saleQuotationService.updateMainHis(saleQuotation, saleQuotationPage.getSaleQuotationShipList(), saleQuotationPage.getSaleQuotationProductList());
+        return Result.OK("修订成功!");
     }
 
     /**

+ 1 - 1
srm-module-code/src/main/java/org/jeecg/modules/saleCode/mapper/xml/SaleInquiryFormProductMapper.xml

@@ -44,7 +44,7 @@
 
                  where a.del_flag = 0
                    and a.submit = 1
-                   and a.status = 0
+                   <!--and a.status = 0-->
                    and b.del_flag = 0
              ) a
             ${ew.customSqlSegment}

+ 2 - 1
srm-module-code/src/main/java/org/jeecg/modules/saleCode/service/ISaleContractService.java

@@ -33,7 +33,8 @@ public interface ISaleContractService extends IService<SaleContract> {
    * @param saleContractProductList
 	 */
 	public void updateMain(SaleContract saleContract,List<SaleContractShip> saleContractShipList,List<SaleContractProduct> saleContractProductList);
-	
+	public void updateMainHis(SaleContract saleContract,List<SaleContractShip> saleContractShipList,List<SaleContractProduct> saleContractProductList);
+
 	/**
 	 * 删除一对多
 	 *

+ 2 - 1
srm-module-code/src/main/java/org/jeecg/modules/saleCode/service/ISaleOrderService.java

@@ -34,7 +34,8 @@ public interface ISaleOrderService extends IService<SaleOrder> {
    * @param saleOrderProductList
 	 */
 	public void updateMain(SaleOrder saleOrder,List<SaleOrderShip> saleOrderShipList,List<SaleOrderProduct> saleOrderProductList);
-	
+	public void updateMainHis(SaleOrder saleOrder,List<SaleOrderShip> saleOrderShipList,List<SaleOrderProduct> saleOrderProductList);
+
 	/**
 	 * 删除一对多
 	 *

+ 2 - 1
srm-module-code/src/main/java/org/jeecg/modules/saleCode/service/ISaleQuotationService.java

@@ -33,7 +33,8 @@ public interface ISaleQuotationService extends IService<SaleQuotation> {
    * @param saleQuotationProductList
 	 */
 	public void updateMain(SaleQuotation saleQuotation,List<SaleQuotationShip> saleQuotationShipList,List<SaleQuotationProduct> saleQuotationProductList);
-	
+	public void updateMainHis(SaleQuotation saleQuotation,List<SaleQuotationShip> saleQuotationShipList,List<SaleQuotationProduct> saleQuotationProductList);
+
 	/**
 	 * 删除一对多
 	 *

+ 32 - 0
srm-module-code/src/main/java/org/jeecg/modules/saleCode/service/impl/SaleContractServiceImpl.java

@@ -81,6 +81,38 @@ public class SaleContractServiceImpl extends ServiceImpl<SaleContractMapper, Sal
 		}
 	}
 
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void updateMainHis(SaleContract saleContract,List<SaleContractShip> saleContractShipList,List<SaleContractProduct> saleContractProductList) {
+		saleContractMapper.updateById(saleContract);
+
+		//1.先删除子表数据
+		saleContractShipMapper.deleteByMainId(saleContract.getId());
+		saleContractProductMapper.deleteByMainId(saleContract.getId());
+
+		//2.子表数据重新插入
+		if(saleContractShipList!=null && saleContractShipList.size()>0) {
+			for(SaleContractShip entity:saleContractShipList) {
+				//外键设置
+//				entity.setId(null);
+//				entity.setHeadId(saleContract.getId());
+				saleContractShipMapper.updateById(entity);
+			}
+		}
+		if(saleContractProductList!=null && saleContractProductList.size()>0) {
+			for(SaleContractProduct entity:saleContractProductList) {
+				//外键设置
+				int updateR = saleContractProductMapper.updateById(entity);
+				if(updateR == 0){
+
+					entity.setId(null);
+					entity.setHeadId(saleContract.getId());
+					saleContractProductMapper.insert(entity);
+				}
+			}
+		}
+	}
+
 	@Override
 	@Transactional(rollbackFor = Exception.class)
 	public void delMain(String id) {

+ 69 - 0
srm-module-code/src/main/java/org/jeecg/modules/saleCode/service/impl/SaleOrderServiceImpl.java

@@ -154,6 +154,75 @@ public class SaleOrderServiceImpl extends ServiceImpl<SaleOrderMapper, SaleOrder
 		}
 	}
 
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void updateMainHis(SaleOrder saleOrder,List<SaleOrderShip> saleOrderShipList,List<SaleOrderProduct> saleOrderProductList) {
+
+
+		if(saleOrderShipList!=null && saleOrderShipList.size()>0) {
+
+			List<String> shipIds = saleOrderShipList.stream().map(SaleOrderShip::getId).collect(Collectors.toList());
+			QueryWrapper<BaseShipArchive> queryShip = new QueryWrapper<>();
+			queryShip.eq("id",shipIds);
+			queryShip.eq("del_flag",0);
+			List<BaseShipArchive> shipList = baseShipArchiveMapper.selectList(queryShip);
+			if(shipList.size() > 0){
+				String imos = shipList.stream().map(BaseShipArchive::getImo).collect(Collectors.joining(","));
+				saleOrder.setImo(imos);
+			}
+
+			String names = saleOrderShipList.stream().map(SaleOrderShip::getShipName).collect(Collectors.joining(","));
+			saleOrder.setShipName(names);
+		}
+
+
+		BigDecimal discountedAmount = BigDecimal.ZERO;
+		BigDecimal taxAmount = BigDecimal.ZERO;
+		if(saleOrderProductList!=null && saleOrderProductList.size()>0) {
+			for(SaleOrderProduct entity:saleOrderProductList) {
+				BigDecimal getDiscountedAmount = entity.getDiscountedAmount() == null ?BigDecimal.ZERO :entity.getDiscountedAmount();
+				BigDecimal getTaxAmount = entity.getTaxAmount() == null ?BigDecimal.ZERO :entity.getTaxAmount();
+				discountedAmount = discountedAmount.add(getDiscountedAmount);
+				taxAmount = taxAmount.add(getTaxAmount);
+			}
+		}
+		saleOrder.setOrderMoney(taxAmount);
+		saleOrder.setConvertedAmount(discountedAmount);
+
+
+		saleOrderMapper.updateById(saleOrder);
+
+		//1.先删除子表数据
+		saleOrderShipMapper.deleteByMainId(saleOrder.getId());
+		saleOrderProductMapper.deleteByMainId(saleOrder.getId());
+
+		//2.子表数据重新插入
+		if(saleOrderShipList!=null && saleOrderShipList.size()>0) {
+			for(SaleOrderShip entity:saleOrderShipList) {
+				//外键设置
+//				entity.setId(null);
+//				entity.setHeadId(saleOrder.getId());
+//				saleOrderShipMapper.insert(entity);
+				saleOrderShipMapper.updateById(entity);
+			}
+		}
+		if(saleOrderProductList!=null && saleOrderProductList.size()>0) {
+			for(SaleOrderProduct entity:saleOrderProductList) {
+				//外键设置
+//				entity.setId(null);
+//				entity.setHeadId(saleOrder.getId());
+//				saleOrderProductMapper.insert(entity);
+				int updateR = saleOrderProductMapper.updateById(entity);
+				if(updateR == 0){
+					//外键设置
+					entity.setId(null);
+					entity.setHeadId(saleOrder.getId());
+					saleOrderProductMapper.insert(entity);
+				}
+			}
+		}
+	}
+
 	@Override
 	@Transactional(rollbackFor = Exception.class)
 	public void delMain(String id) {

+ 51 - 0
srm-module-code/src/main/java/org/jeecg/modules/saleCode/service/impl/SaleQuotationServiceImpl.java

@@ -118,6 +118,57 @@ public class SaleQuotationServiceImpl extends ServiceImpl<SaleQuotationMapper, S
 		}
 	}
 
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void updateMainHis(SaleQuotation saleQuotation,List<SaleQuotationShip> saleQuotationShipList,List<SaleQuotationProduct> saleQuotationProductList) {
+
+		BigDecimal purchaseAmount = BigDecimal.ZERO;
+		BigDecimal saleAmount = BigDecimal.ZERO;
+
+		if(saleQuotationProductList!=null && saleQuotationProductList.size()>0) {
+			for(SaleQuotationProduct entity:saleQuotationProductList) {
+				BigDecimal getPurchaseAmount = entity.getPurchaseAmount() == null ?BigDecimal.ZERO :entity.getPurchaseAmount();
+				BigDecimal getTaxAmount = entity.getTaxAmount() == null ?BigDecimal.ZERO :entity.getTaxAmount();
+
+				purchaseAmount = purchaseAmount.add(getPurchaseAmount);
+				saleAmount = saleAmount.add(getTaxAmount);
+
+			}
+		}
+		saleQuotation.setPurchaseAmount(purchaseAmount);
+		saleQuotation.setSaleAmount(saleAmount);
+
+		saleQuotationMapper.updateById(saleQuotation);
+
+		//1.先删除子表数据
+		saleQuotationShipMapper.deleteByMainId(saleQuotation.getId());
+		saleQuotationProductMapper.deleteByMainId(saleQuotation.getId());
+
+		//2.子表数据重新插入
+		if(saleQuotationShipList!=null && saleQuotationShipList.size()>0) {
+			for(SaleQuotationShip entity:saleQuotationShipList) {
+				//外键设置
+//				entity.setId(null);
+//				entity.setHeadId(saleQuotation.getId());
+//
+//				saleQuotationShipMapper.insert(entity);
+				saleQuotationShipMapper.updateById(entity);
+			}
+		}
+		if(saleQuotationProductList!=null && saleQuotationProductList.size()>0) {
+			for(SaleQuotationProduct entity:saleQuotationProductList) {
+				//外键设置
+				int updateR = saleQuotationProductMapper.updateById(entity);
+				if(updateR == 0){
+					entity.setId(null);
+					entity.setHeadId(saleQuotation.getId());
+					saleQuotationProductMapper.insert(entity);
+				}
+
+			}
+		}
+	}
+
 	@Override
 	@Transactional(rollbackFor = Exception.class)
 	public void delMain(String id) {