Browse Source

完善代码

yuansh 2 tháng trước cách đây
mục cha
commit
a4b036d34c

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

@@ -10,6 +10,7 @@ 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.math.BigDecimal;
 import java.util.List;
 import java.util.Collection;
 
@@ -30,6 +31,16 @@ public class PurCommissionRequestServiceImpl extends ServiceImpl<PurCommissionRe
 	@Override
 	@Transactional(rollbackFor = Exception.class)
 	public void saveMain(PurCommissionRequest purCommissionRequest, List<PurCommissionRequestDetails> purCommissionRequestDetailsList) {
+
+		BigDecimal approveMoney = BigDecimal.ZERO;
+		if(purCommissionRequestDetailsList!=null && purCommissionRequestDetailsList.size()>0) {
+			for(PurCommissionRequestDetails entity:purCommissionRequestDetailsList) {
+				BigDecimal applyMoney = entity.getApplyMoney() == null ? BigDecimal.ZERO : entity.getApplyMoney();
+				approveMoney = approveMoney.add(applyMoney);
+			}
+		}
+		purCommissionRequest.setApproveMoney(approveMoney);
+
 		purCommissionRequestMapper.insert(purCommissionRequest);
 		if(purCommissionRequestDetailsList!=null && purCommissionRequestDetailsList.size()>0) {
 			for(PurCommissionRequestDetails entity:purCommissionRequestDetailsList) {
@@ -44,6 +55,17 @@ public class PurCommissionRequestServiceImpl extends ServiceImpl<PurCommissionRe
 	@Override
 	@Transactional(rollbackFor = Exception.class)
 	public void updateMain(PurCommissionRequest purCommissionRequest,List<PurCommissionRequestDetails> purCommissionRequestDetailsList) {
+
+		BigDecimal approveMoney = BigDecimal.ZERO;
+		if(purCommissionRequestDetailsList!=null && purCommissionRequestDetailsList.size()>0) {
+			for(PurCommissionRequestDetails entity:purCommissionRequestDetailsList) {
+				BigDecimal applyMoney = entity.getApplyMoney() == null ? BigDecimal.ZERO : entity.getApplyMoney();
+				approveMoney = approveMoney.add(applyMoney);
+			}
+		}
+		purCommissionRequest.setApproveMoney(approveMoney);
+
+
 		purCommissionRequestMapper.updateById(purCommissionRequest);
 		
 		//1.先删除子表数据