| 
					
				 | 
			
			
				@@ -98,100 +98,100 @@ public class OrderCalcServiceImpl implements OrderCalcService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     public void calc(List<DistriOrderMessage> tradeOrderDO) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        // 获取到当前订单的所有人 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        List<Long> userId = tradeOrderDO.stream().map(DistriOrderMessage::getUserId).collect(Collectors.toList()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        OrderPercentageDO orderPercentageDO = orderPercentageService.queryStatus(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        // 当前计算百分比模板 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        String percentTemplate = JsonUtils.toJsonString(orderPercentageDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        // 每个订单收益 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        List<OrderCalcSaveReqVO> saveList = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        // 平台收益 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        List<PtProfitSaveReqVO> ptProfitSaveReqVOS = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        // 平台收益日志 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        List<PtProfitLogSaveReqVO> ptProfitLogSaveReqVOS = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        PtProfitDO ptProfitDO = ptProfitService.getPtProfit(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        tradeOrderDO.forEach(k -> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            // 计算利润: (价格 - 成本价格) * 产品数量 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            Integer profit = (k.getPrice() - k.getCostPrice()) * k.getProductCount(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            // 计算毛利: 利润 * 0.38 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            Integer grossProfit = profit * orderPercentageDO.getGrossProfitPerc(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            // 计算用户额度: 利润 * 0.38 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            Integer userProfit = grossProfit * orderPercentageDO.getGrossProfitUserQuotaPerc(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            // 计算直推人额度: 利润 * 0.38 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            Integer ancestorQuota = grossProfit * orderPercentageDO.getGrossProfitAncestorQuotaPerc(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            // 计算合赢奖: 利润 * 0.38 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            Integer bonusQuota = grossProfit * orderPercentageDO.getGrossProfitBonusQuotaPerc(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            // 计算平台收益: 利润 * 0.38 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            Integer platformQuota = grossProfit * orderPercentageDO.getGrossProfitPlatformQuotaPerc(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            // 计算 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            OrderCalcSaveReqVO orderCalcSaveReqVO = OrderCalcSaveReqVO.builder() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    .userId(k.getUserId()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    .orderNo(k.getNo()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    .cost(k.getCostPrice()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    .price(k.getPrice()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    .grossProfit(grossProfit) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    .grossProfitUserQuota(userProfit) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    .grossProfitAncestorQuota(ancestorQuota) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    .grossProfitBonusQuota(bonusQuota) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    .grossProfitPlatformQuota(platformQuota) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    .percentTemplate(percentTemplate) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    .build(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            saveList.add(orderCalcSaveReqVO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            // 每个订单计算的过程 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            // 增加平台收益 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            // 平台服务费 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            Integer ptGrossAdd = ptProfitDO.getPtGrossAdd() + platformQuota; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            // 平台收益 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            Integer ptAdd = ptProfitDO.getPtAdd() + grossProfit * (10000 - orderPercentageDO.getGrossProfitBonusQuotaPerc()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            // 平台总收益 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            Integer ptTotal = ptProfitDO.getPtTotalAdd() + ptGrossAdd + ptAdd; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            PtProfitSaveReqVO ptProfitSaveReqVO = PtProfitSaveReqVO.builder() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    .ptAdd(ptAdd) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    .ptGrossAdd(ptGrossAdd) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    .ptTotalAdd(ptTotal).build(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            ptProfitSaveReqVOS.add(ptProfitSaveReqVO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            // 平台记录 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            PtProfitLogSaveReqVO ptGrossAddLog = PtProfitLogSaveReqVO.builder() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    .orderId(k.getOrderId()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    .profitStatus(1) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    .amount(platformQuota) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    .afterAmount(ptProfitSaveReqVO.getPtGrossAdd()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    .percentTemplate(percentTemplate).build(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            PtProfitLogSaveReqVO ptAddLog = PtProfitLogSaveReqVO.builder() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    .orderId(k.getOrderId()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    .profitStatus(2) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    .amount(grossProfit * (PERCENT - orderPercentageDO.getGrossProfitBonusQuotaPerc())) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    .afterAmount(ptProfitSaveReqVO.getPtAdd()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    .percentTemplate(percentTemplate).build(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            ptProfitLogSaveReqVOS.add(ptGrossAddLog); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            ptProfitLogSaveReqVOS.add(ptAddLog); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        // 将信息存储到数据库中 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        orderCalcMapper.insertBatch(BeanUtils.toBean(saveList, OrderCalcDO.class)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        ptProfitService.saveBatch(ptProfitSaveReqVOS); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        ptProfitLogService.saveBatch(ptProfitLogSaveReqVOS); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        // todo 计算当天用户的碰撞 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//        // 获取到当前订单的所有人 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//        List<Long> userId = tradeOrderDO.stream().map(DistriOrderMessage::getUserId).collect(Collectors.toList()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//        OrderPercentageDO orderPercentageDO = orderPercentageService.queryStatus(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//        // 当前计算百分比模板 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//        String percentTemplate = JsonUtils.toJsonString(orderPercentageDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//        // 每个订单收益 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//        List<OrderCalcSaveReqVO> saveList = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//        // 平台收益 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//        List<PtProfitSaveReqVO> ptProfitSaveReqVOS = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//        // 平台收益日志 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//        List<PtProfitLogSaveReqVO> ptProfitLogSaveReqVOS = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//        PtProfitDO ptProfitDO = ptProfitService.getPtProfit(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//        tradeOrderDO.forEach(k -> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//            // 计算利润: (价格 - 成本价格) * 产品数量 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//            Integer profit = (k.getPrice() - k.getCostPrice()) * k.getProductCount(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//            // 计算毛利: 利润 * 0.38 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//            Integer grossProfit = profit * orderPercentageDO.getGrossProfitPerc(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//            // 计算用户额度: 利润 * 0.38 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//            Integer userProfit = grossProfit * orderPercentageDO.getGrossProfitUserQuotaPerc(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//            // 计算直推人额度: 利润 * 0.38 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//            Integer ancestorQuota = grossProfit * orderPercentageDO.getGrossProfitAncestorQuotaPerc(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//            // 计算合赢奖: 利润 * 0.38 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//            Integer bonusQuota = grossProfit * orderPercentageDO.getGrossProfitBonusQuotaPerc(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//            // 计算平台收益: 利润 * 0.38 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//            Integer platformQuota = grossProfit * orderPercentageDO.getGrossProfitPlatformQuotaPerc(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//            // 计算 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//            OrderCalcSaveReqVO orderCalcSaveReqVO = OrderCalcSaveReqVO.builder() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                    .userId(k.getUserId()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                    .orderNo(k.getNo()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                    .cost(k.getCostPrice()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                    .price(k.getPrice()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                    .grossProfit(grossProfit) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                    .grossProfitUserQuota(userProfit) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                    .grossProfitAncestorQuota(ancestorQuota) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                    .grossProfitBonusQuota(bonusQuota) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                    .grossProfitPlatformQuota(platformQuota) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                    .percentTemplate(percentTemplate) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                    .build(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//            saveList.add(orderCalcSaveReqVO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//            // 每个订单计算的过程 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//            // 增加平台收益 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//            // 平台服务费 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//            Integer ptGrossAdd = ptProfitDO.getPtGrossAdd() + platformQuota; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//            // 平台收益 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//            Integer ptAdd = ptProfitDO.getPtAdd() + grossProfit * (10000 - orderPercentageDO.getGrossProfitBonusQuotaPerc()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//            // 平台总收益 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//            Integer ptTotal = ptProfitDO.getPtTotalAdd() + ptGrossAdd + ptAdd; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//            PtProfitSaveReqVO ptProfitSaveReqVO = PtProfitSaveReqVO.builder() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                    .ptAdd(ptAdd) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                    .ptGrossAdd(ptGrossAdd) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                    .ptTotalAdd(ptTotal).build(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//            ptProfitSaveReqVOS.add(ptProfitSaveReqVO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//            // 平台记录 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//            PtProfitLogSaveReqVO ptGrossAddLog = PtProfitLogSaveReqVO.builder() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                    .orderId(k.getOrderId()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                    .profitStatus(1) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                    .amount(platformQuota) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                    .afterAmount(ptProfitSaveReqVO.getPtGrossAdd()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                    .percentTemplate(percentTemplate).build(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//            PtProfitLogSaveReqVO ptAddLog = PtProfitLogSaveReqVO.builder() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                    .orderId(k.getOrderId()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                    .profitStatus(2) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                    .amount(grossProfit * (PERCENT - orderPercentageDO.getGrossProfitBonusQuotaPerc())) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                    .afterAmount(ptProfitSaveReqVO.getPtAdd()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                    .percentTemplate(percentTemplate).build(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//            ptProfitLogSaveReqVOS.add(ptGrossAddLog); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//            ptProfitLogSaveReqVOS.add(ptAddLog); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//        }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//        // 将信息存储到数据库中 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//        orderCalcMapper.insertBatch(BeanUtils.toBean(saveList, OrderCalcDO.class)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//        ptProfitService.saveBatch(ptProfitSaveReqVOS); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//        ptProfitLogService.saveBatch(ptProfitLogSaveReqVOS); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//        // todo 计算当天用户的碰撞 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 |