yuansh 2 mesi fa
parent
commit
2516f58c06

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

@@ -16,6 +16,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;
 import java.util.stream.Collectors;
@@ -58,6 +59,16 @@ public class SaleOrderServiceImpl extends ServiceImpl<SaleOrderMapper, SaleOrder
 			saleOrder.setShipName(names);
 		}
 
+		BigDecimal discountedAmount = BigDecimal.ZERO;
+		if(saleOrderProductList!=null && saleOrderProductList.size()>0) {
+			for(SaleOrderProduct entity:saleOrderProductList) {
+				BigDecimal getDiscountedAmount = entity.getDiscountedAmount() == null ?BigDecimal.ZERO :entity.getDiscountedAmount();
+				discountedAmount = discountedAmount.add(getDiscountedAmount);
+
+			}
+		}
+		saleOrder.setOrderMoney(discountedAmount);
+
 		saleOrderMapper.insert(saleOrder);
 		if(saleOrderShipList!=null && saleOrderShipList.size()>0) {
 			for(SaleOrderShip entity:saleOrderShipList) {
@@ -97,6 +108,17 @@ public class SaleOrderServiceImpl extends ServiceImpl<SaleOrderMapper, SaleOrder
 			String names = saleOrderShipList.stream().map(SaleOrderShip::getShipName).collect(Collectors.joining(","));
 			saleOrder.setShipName(names);
 		}
+
+		BigDecimal discountedAmount = BigDecimal.ZERO;
+		if(saleOrderProductList!=null && saleOrderProductList.size()>0) {
+			for(SaleOrderProduct entity:saleOrderProductList) {
+				BigDecimal getDiscountedAmount = entity.getDiscountedAmount() == null ?BigDecimal.ZERO :entity.getDiscountedAmount();
+				discountedAmount = discountedAmount.add(getDiscountedAmount);
+
+			}
+		}
+		saleOrder.setOrderMoney(discountedAmount);
+
 		saleOrderMapper.updateById(saleOrder);
 		
 		//1.先删除子表数据