| 
					
				 | 
			
			
				@@ -5,6 +5,8 @@ import cn.newfeifan.mall.framework.mybatis.core.query.LambdaQueryWrapperX; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import cn.newfeifan.mall.module.distri.controller.admin.integral.vo.IntegralSaveReqVO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import cn.newfeifan.mall.module.distri.controller.admin.partitionbrothers.vo.PartitionBrothersSaveReqVO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import cn.newfeifan.mall.module.distri.controller.admin.partitionson.vo.PartitionSonSaveReqVO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import cn.newfeifan.mall.module.distri.controller.admin.ptprofit.vo.PtProfitSaveReqVO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import cn.newfeifan.mall.module.distri.controller.admin.ptprofitlog.vo.PtProfitLogSaveReqVO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import cn.newfeifan.mall.module.distri.dal.dataobject.duser.DuserDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import cn.newfeifan.mall.module.distri.dal.dataobject.integral.IntegralDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import cn.newfeifan.mall.module.distri.dal.dataobject.ordercalc.OrderCalcDO; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -18,14 +20,18 @@ import cn.newfeifan.mall.module.distri.service.partitionbrothers.PartitionBrothe 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import cn.newfeifan.mall.module.distri.service.partitionson.PartitionSonService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import cn.newfeifan.mall.module.distri.service.ptprofit.PtProfitService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import cn.newfeifan.mall.module.distri.service.ptprofitlog.PtProfitLogService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import cn.newfeifan.mall.module.distri.tools.LoginMessageTool; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import lombok.extern.slf4j.Slf4j; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.context.annotation.Lazy; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.stereotype.Service; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import cn.newfeifan.mall.module.distri.service.sharepath.SharePathService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import javax.annotation.Resource; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.validation.annotation.Validated; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.math.BigDecimal; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.math.RoundingMode; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.time.LocalDate; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.time.LocalDateTime; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.time.LocalTime; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -41,6 +47,7 @@ import cn.newfeifan.mall.framework.common.util.object.BeanUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import cn.newfeifan.mall.module.distri.dal.mysql.partitioncrash.PartitionCrashMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import static cn.newfeifan.mall.framework.common.exception.util.ServiceExceptionUtil.exception; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import static cn.newfeifan.mall.module.distri.constant.DistriConstants.PT_ID; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import static cn.newfeifan.mall.module.distri.enums.ErrorCodeConstants.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 /** 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -50,6 +57,7 @@ import static cn.newfeifan.mall.module.distri.enums.ErrorCodeConstants.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 @Service 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 @Validated 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+@Slf4j 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 public class PartitionCrashServiceImpl implements PartitionCrashService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Resource 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -133,14 +141,33 @@ public class PartitionCrashServiceImpl implements PartitionCrashService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if (duserDOS.isEmpty()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             return; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<HashMap<Long, Integer>> afterCrashMap = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         // 获取当前合赢奖百分比 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         OrderPercentageDO orderPercentageDO = orderPercentageService.queryStatus(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        List<HashMap<Long, Integer>> afterCrashMap = duserDOS.stream().map(k -> CompletableFuture.supplyAsync(() -> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 获取用户的钱包信息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<IntegralDO> integralDOS = integralService.selectAllUser(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Map<Long, IntegralDO> integralDOMap = integralDOS.stream().collect(Collectors.toMap(IntegralDO::getUserId, k -> k)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 获取当前所有用户的父亲 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Map<Long, Long> sonAndParent = new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<Long> userIds = duserDOS.stream().map(DuserDO::getUserId).collect(Collectors.toList()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        userIds.stream().map(k -> CompletableFuture.supplyAsync(() -> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            Long parent = sharePathService.queryParentBySonUserId(k); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            sonAndParent.put(k, parent); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return parent; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        })).collect(Collectors.toList()).stream().map(CompletableFuture::join).collect(Collectors.toList()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<PartitionSonSaveReqVO> partitionSonSaveReqVOS = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<PartitionBrothersSaveReqVO> partitionBrothersSaveReqVOS = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<PartitionCrashSaveReqVO> partitionCrashSaveReqVOS = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        duserDOS.forEach(k -> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             // 获取当前用户的钱包 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            IntegralDO integralDO = integralService.selectByUser(k.getUserId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            IntegralDO integralDO = integralDOMap.get(k.getUserId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             // 获取当前父亲的钱包 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            IntegralDO parentIntegralDo = integralService.selectUserParent(k.getUserId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            Long parent = sonAndParent.get(k.getUserId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            IntegralDO parentIntegralDo = integralDOMap.get(parent); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             // 创建一个分区编号 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             String todayNo = crashTodayNo(k.getUserId()); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -150,11 +177,13 @@ public class PartitionCrashServiceImpl implements PartitionCrashService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             PartitionBrothersSaveReqVO.PartitionBrothersSaveReqVOBuilder brotherBuilder = PartitionBrothersSaveReqVO.builder(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             PartitionCrashSaveReqVO.PartitionCrashSaveReqVOBuilder crashSaveReqVOBuilder = PartitionCrashSaveReqVO.builder(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             sonBuilder.partNo(todayNo); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            sonBuilder.userId(k.getUserId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             sonBuilder.name(k.getName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             sonBuilder.nickName(k.getNickName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             sonBuilder.hasHit(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             brotherBuilder.partNo(todayNo); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            brotherBuilder.userId(k.getUserId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             brotherBuilder.name(k.getName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             brotherBuilder.nickName(k.getNickName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             brotherBuilder.hasHit(1); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -170,11 +199,10 @@ public class PartitionCrashServiceImpl implements PartitionCrashService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 // 插入空数据 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 sonBuilder = addSonEmpty(sonBuilder, k); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 crashSaveReqVOBuilder.sonPrice(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                partitionSonService.createPartitionSon(sonBuilder.build()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             // 合计儿子分支额度 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             Integer sonSumPrice = sonOrderCalcDOS.stream().mapToInt(OrderCalcDO::getGrossProfitBonusQuota).sum(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            crashSaveReqVOBuilder.sonPrice(sonSumPrice); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            sonBuilder.price(sonSumPrice); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             // 获取当前用户的兄弟分区 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             List<OrderCalcDO> brothersOrderCalcDOS = sharePathService.selectBrothers(k.getUserId(), userId); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -182,21 +210,22 @@ public class PartitionCrashServiceImpl implements PartitionCrashService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 // 插入空数据 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 brotherBuilder = addBrotherEmpty(brotherBuilder, k); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 crashSaveReqVOBuilder.brotherPrice(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                partitionBrothersService.createPartitionBrothers(brotherBuilder.build()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             // 合并兄弟分支额度 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             Integer brotherSumPrice = brothersOrderCalcDOS.stream().mapToInt(OrderCalcDO::getGrossProfitBonusQuota).sum(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            crashSaveReqVOBuilder.brotherPrice(sonSumPrice); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            brotherBuilder.price(brotherSumPrice); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             // 判断,昨天是否有存余的分支 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             PartitionCrashDO yesterdayCrash = partitionCrashMapper.selectOne(new LambdaQueryWrapperX<PartitionCrashDO>().eqIfPresent(PartitionCrashDO::getPartNo, yesterdayNo)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             // 如果不为空, 则判断增加到哪个分支中 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if (yesterdayCrash.getSonPrice() >= yesterdayCrash.getBrotherPrice()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                sonSumPrice = sonSumPrice + yesterdayCrash.getSonPrice(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                brotherSumPrice = brotherSumPrice + yesterdayCrash.getBrotherPrice(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (yesterdayCrash != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if (yesterdayCrash.getSonPrice() >= yesterdayCrash.getBrotherPrice()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    sonSumPrice = sonSumPrice + yesterdayCrash.getSonPrice(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    brotherSumPrice = brotherSumPrice + yesterdayCrash.getBrotherPrice(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             int afterCrash = 0; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -226,7 +255,7 @@ public class PartitionCrashServiceImpl implements PartitionCrashService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             Integer parentHighQuota = parentIntegralDo.getHighQuota(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             BigDecimal smallBigDecimal = new BigDecimal(String.valueOf(smallQuota)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            BigDecimal multiply = smallBigDecimal.multiply(new BigDecimal(String.valueOf(orderPercentageDO.getDivideIntoPerc()))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            BigDecimal multiply = smallBigDecimal.divide(new BigDecimal("2.0"), 4, RoundingMode.DOWN); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if (compare(highQuota, multiply)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 Integer currentQuota = integralDO.getCurrentQuota(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 integralDO.setCurrentQuota(currentQuota + multiply.intValue()); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -239,16 +268,42 @@ public class PartitionCrashServiceImpl implements PartitionCrashService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 parentIntegralDo.setCurrentQuota(currentQuota + multiply.intValue()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 // 碰撞后的额度添加到日志中 增加日志模块 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 integralService.updateIntegral(BeanUtils.toBean(parentIntegralDo, IntegralSaveReqVO.class)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                LoginMessageTool.messageSave(() -> PtProfitLogSaveReqVO.builder() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        .amount(currentQuota) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        .afterAmount(currentQuota + parentIntegralDo.getCurrentQuota()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        .userId(parentIntegralDo.getUserId()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        .percentTemplate(JsonUtils.toJsonString(orderPercentageDO)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        .profitStatus(CaclEnum.SMALL_QUOTA_CRASH.getType()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        .build()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 ptProfitLogService.addMessage(parentIntegralDo.getUserId(), CaclEnum.SMALL_QUOTA_CRASH, currentQuota, parentIntegralDo.getCurrentQuota(), JsonUtils.toJsonString(orderPercentageDO)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             // 获取计算后积分, Long为userId, Integer为碰撞后额度 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             HashMap<Long, Integer> map = new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            map.put(k.getUserId(), multiply.intValue()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            map.put(parentIntegralDo.getUserId(), multiply.intValue()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            return map; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            // 如果为当前用户为平台,则不需要存入这个地方 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (!k.getUserId().equals(PT_ID)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                map.put(k.getUserId(), multiply.intValue()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (!parentIntegralDo.getUserId().equals(PT_ID)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                map.put(parentIntegralDo.getUserId(), multiply.intValue()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            afterCrashMap.add(map); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            log.info(k.getNickName() + "用户合赢奖已经计算: 该用户合赢奖为: \t" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    "兄弟分区为: " + brotherBuilder.build() + "\t" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    "后代分区为: " + sonBuilder.build() + "\t" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    "碰撞分区为: " + crashSaveReqVOBuilder.build() + "\t"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            partitionSonSaveReqVOS.add(sonBuilder.build()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            partitionBrothersSaveReqVOS.add(brotherBuilder.build()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            partitionCrashSaveReqVOS.add(crashSaveReqVOBuilder.build()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        })).collect(Collectors.toList()).stream().map(CompletableFuture::join).collect(Collectors.toList()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        partitionSonService.saveBatch(partitionSonSaveReqVOS); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        partitionBrothersService.saveBatch(partitionBrothersSaveReqVOS); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        saveBatch(partitionCrashSaveReqVOS); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         // 计算平台积分 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         // 获取当前平台的额度 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -256,18 +311,27 @@ public class PartitionCrashServiceImpl implements PartitionCrashService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         // 遍历hashMap 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         for (HashMap<Long, Integer> longIntegerHashMap : afterCrashMap) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             for (Map.Entry<Long, Integer> entry : longIntegerHashMap.entrySet()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                if (ptProfit.getPtTotalAdd() <= 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if (ptProfit.getPtGrossAdd() <= 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 // 当前平台总积分 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                Integer ptTotalAdd = ptProfit.getPtTotalAdd(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                Integer ptTotalAdd = ptProfit.getPtTotalAdd(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                // 扣除平台收益 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                log.info("扣除平台收益[合赢奖] " + "用户 " + entry.getKey() + "额度: " + entry.getValue()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                ptProfit.setPtGrossAdd(ptProfit.getPtGrossAdd() - entry.getValue()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 // 平台扣除积分 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 ptProfit.setPtTotalAdd(ptProfit.getPtTotalAdd() - entry.getValue()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 // 碰撞后的额度添加到日志中 增加日志模块 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 ptProfitLogService.addMessage(entry.getKey(), CaclEnum.AFTER_CRASH_CALC_PT_TOTAL_QUOTA 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        , ptTotalAdd, ptProfit.getPtTotalAdd() - entry.getValue(), JsonUtils.toJsonString(orderPercentageDO)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        , -entry.getValue(), ptProfit.getPtTotalAdd() - entry.getValue(), JsonUtils.toJsonString(orderPercentageDO)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                ptProfitLogService.addMessage(entry.getKey(), CaclEnum.AFTER_CRASH_CALC_PT_TOTAL_GROSS_QUOTA 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        , -entry.getValue(), ptProfit.getPtTotalAdd() - entry.getValue(), JsonUtils.toJsonString(orderPercentageDO)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        ptProfitService.updatePtProfit(PtProfitSaveReqVO.builder().id(ptProfit.getId()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                .ptAdd(ptProfit.getPtAdd()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                .ptGrossAdd(ptProfit.getPtGrossAdd()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                .ptTotalAdd(ptProfit.getPtTotalAdd()).build()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     public Boolean compare(Integer highQuota, BigDecimal afterCrash) { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -276,6 +340,11 @@ public class PartitionCrashServiceImpl implements PartitionCrashService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return i >= 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public void saveBatch(List<PartitionCrashSaveReqVO> partitionCrashSaveReqVOS) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<PartitionCrashDO> ptProfit = BeanUtils.toBean(partitionCrashSaveReqVOS, PartitionCrashDO.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        partitionCrashMapper.insertBatch(ptProfit); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private PartitionBrothersSaveReqVO.PartitionBrothersSaveReqVOBuilder addBrotherEmpty(PartitionBrothersSaveReqVO.PartitionBrothersSaveReqVOBuilder brotherBuilder, DuserDO duserDO) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -303,7 +372,7 @@ public class PartitionCrashServiceImpl implements PartitionCrashService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     public String crashTodayNo(Long userId) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         LocalDateTime todayStart = LocalDateTime.of(LocalDate.now(), LocalTime.MIDNIGHT); // 今天的开始时间,即午夜12点 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         String todayStartString = todayStart.toString(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        return "CRASH:" + userId + todayStartString; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return "CRASH:" + userId + ":" + todayStartString; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -312,7 +381,7 @@ public class PartitionCrashServiceImpl implements PartitionCrashService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         LocalDateTime todayStart = LocalDateTime.of(LocalDate.now(), LocalTime.MIDNIGHT); // 今天的开始时间,即午夜12点 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         LocalDateTime localDateTime = todayStart.minusDays(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         String yesterdayString = localDateTime.toString(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        return "CRASH:" + userId + yesterdayString; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return "CRASH:" + userId + ":" + yesterdayString; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 |