Bläddra i källkod

修改合赢奖计算, 修改营销数据计算

gaohp 10 månader sedan
förälder
incheckning
0f0fa56159

+ 10 - 9
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/service/ordercalc/OrderCalcServiceImpl.java

@@ -201,10 +201,10 @@ public class OrderCalcServiceImpl implements OrderCalcService {
             }
 
             // 用户所得: 毛利 * 0.35
-            BigDecimal ancestorQuota = grossProfit.multiply(new BigDecimal(orderPercentageDO.getGrossProfitUserQuotaPerc())).setScale(4, RoundingMode.DOWN);
+            BigDecimal descendantQuota = grossProfit.multiply(new BigDecimal(orderPercentageDO.getGrossProfitUserQuotaPerc())).setScale(4, RoundingMode.DOWN);
 
-            // 直推奖: 毛利 * 0.35
-            BigDecimal descendantQuota = grossProfit.multiply(new BigDecimal(orderPercentageDO.getGrossProfitAncestorQuotaPerc())).setScale(4, RoundingMode.DOWN);
+            // 直推奖: 毛利 * 0.35 (上一级)
+            BigDecimal ancestorQuota = grossProfit.multiply(new BigDecimal(orderPercentageDO.getGrossProfitAncestorQuotaPerc())).setScale(4, RoundingMode.DOWN);
 
             // 合赢将: 毛利 * 0.08
             BigDecimal bonusQuota = grossProfit.multiply(new BigDecimal(orderPercentageDO.getGrossProfitBonusQuotaPerc())).setScale(4, RoundingMode.DOWN);
@@ -243,18 +243,17 @@ public class OrderCalcServiceImpl implements OrderCalcService {
                     .nickName(k.getNickName())
                     .name(k.getName())
                     .grossProfit(grossProfitInt)
-                    .grossProfitUserQuota(ancestorQuotaInt)
-                    .grossProfitAncestorQuota(descendantQuotaInt)
+                    .grossProfitUserQuota(descendantQuotaInt)
+                    .grossProfitAncestorQuota(ancestorQuotaInt)
                     .grossProfitBonusQuota(bonusQuotaInt)
                     .grossProfitPlatformQuota(platformQuotaInt)
                     .percentTemplate(percentTemplate).build();
             saveList.add(orderCalcSaveReqVO);            // ========== 修改用户钱包 =================
-            changeUserWallet(integralSaveReqVOS, integralDO, integralDOAncestor, ptIntegral, ancestorQuotaInt, descendantQuotaInt, highQuotaInt, grossProfitInt, platformQuotaInt);
+            changeUserWallet(integralSaveReqVOS, integralDO, integralDOAncestor, ptIntegral, ancestorQuotaInt, descendantQuotaInt, highQuotaInt, grossProfitAfterBonusInt, platformQuotaInt);
             // ========== 修改平台信息 =================
             // 每个订单计算的过程
             // 增加平台收益
             // 平台服务费
-
             PtProfitSaveReqVO ptProfitSaveReqVO = PtProfitSaveReqVO.builder().ptAdd(platformQuotaInt).ptGrossAdd(grossProfitAfterBonusInt).ptTotalAdd(platformQuotaInt + grossProfitAfterBonusInt).build();
             ptProfitSaveReqVOS.add(ptProfitSaveReqVO);
             // ========== 增加日志记录 =================
@@ -362,13 +361,15 @@ public class OrderCalcServiceImpl implements OrderCalcService {
         // 修改用户钱包
         // 增加直推人额度
         integralDO.setHighQuota(integralDO.getHighQuota() + highQuota);
+        // todo 增加累计额度
+
         integralDO.setCurrentQuota(integralDO.getCurrentQuota() + descendantQuota);
 
 
         // 增加推荐人额度
-        integralDOAncestor.setCurrentQuota(integralDO.getCurrentQuota() + ancestorQuota);
+        integralDOAncestor.setCurrentQuota(integralDOAncestor.getCurrentQuota() + ancestorQuota);
         // 增加平台额度
-        pt.setCurrentQuota(integralDO.getCurrentQuota() + ptA + ptB);
+        pt.setCurrentQuota(pt.getCurrentQuota() + ptA + ptB);
 
 //        integralSaveReqVOS.add(BeanUtils.toBean(integralDO, IntegralSaveReqVO.class));
 //        integralSaveReqVOS.add(BeanUtils.toBean(integralDOAncestor, IntegralSaveReqVO.class));

+ 9 - 15
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/service/partitioncrash/PartitionCrashServiceImpl.java

@@ -257,34 +257,28 @@ public class PartitionCrashServiceImpl implements PartitionCrashService {
             BigDecimal smallBigDecimal = new BigDecimal(String.valueOf(smallQuota));
             BigDecimal multiply = smallBigDecimal.divide(new BigDecimal("2.0"), 4, RoundingMode.DOWN);
             if (compare(highQuota, multiply)) {
-                Long currentQuota = integralDO.getCurrentQuota();
-                integralDO.setCurrentQuota(currentQuota + multiply.intValue());
+                integralDO.setCurrentQuota(integralDO.getCurrentQuota() + multiply.intValue());
+                integralDO.setHighQuota(parentIntegralDo.getHighQuota() - multiply.intValue());
                 // 碰撞后的额度添加到日志中 增加日志模块
                 integralService.updateIntegral(BeanUtils.toBean(integralDO, IntegralSaveReqVO.class));
-                ptProfitLogService.addMessage(k.getUserId(), CaclEnum.SMALL_QUOTA_CRASH, currentQuota, integralDO.getCurrentQuota(), JsonUtils.toJsonString(orderPercentageDO));
+                ptProfitLogService.addMessage(k.getUserId(), CaclEnum.SMALL_QUOTA_CRASH, Long.parseLong(String.valueOf(multiply.intValue())), integralDO.getCurrentQuota(), JsonUtils.toJsonString(orderPercentageDO));
             }
             if (compare(parentHighQuota, multiply)) {
-                Long currentQuota = parentIntegralDo.getCurrentQuota();
-                parentIntegralDo.setCurrentQuota(currentQuota + multiply.intValue());
+                // 减去最高额度
+                parentIntegralDo.setCurrentQuota(parentIntegralDo.getCurrentQuota() + multiply.intValue());
+                parentIntegralDo.setHighQuota(parentIntegralDo.getHighQuota() - 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));
+                ptProfitLogService.addMessage(parentIntegralDo.getUserId(), CaclEnum.SMALL_QUOTA_CRASH, Long.parseLong(String.valueOf(multiply.intValue())), parentIntegralDo.getCurrentQuota(), JsonUtils.toJsonString(orderPercentageDO));
             }
 
             // 获取计算后积分, Long为userId, Integer为碰撞后额度
             HashMap<Long, Long> map = new HashMap<>();
             // 如果为当前用户为平台,则不需要存入这个地方
-            if (!k.getUserId().equals(PT_ID)){
+            if (!k.getUserId().equals(PT_ID)) {
                 map.put(k.getUserId(), multiply.longValue());
             }
-            if (!parentIntegralDo.getUserId().equals(PT_ID)){
+            if (!parentIntegralDo.getUserId().equals(PT_ID)) {
                 map.put(parentIntegralDo.getUserId(), multiply.longValue());
             }
             afterCrashMap.add(map);

+ 6 - 2
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/service/sharepath/SharePathServiceImpl.java

@@ -172,7 +172,7 @@ public class SharePathServiceImpl implements SharePathService {
         if (maxDepth > 1) {
             List<Long> descs = sharePathDOS.stream().filter(k -> k.getDepth() > 1).map(SharePathDO::getDescendant).collect(Collectors.toList());
             // 获取大于1层级的数据
-            if (!descs.isEmpty()){
+            if (!descs.isEmpty()) {
                 List<SharePathDO> descList = sharePathMapper.selectList(new LambdaQueryWrapperX<SharePathDO>().ne(SharePathDO::getAncestor, 1).in(SharePathDO::getDescendant, descs));
                 List<TreeNode> treeNodes1 = sharePathDO2TreeNode(descList);
                 deep = deep.stream().filter(k -> k.getDeep() == 1).collect(Collectors.toList());
@@ -348,7 +348,11 @@ public class SharePathServiceImpl implements SharePathService {
 
 
     public List<Long> unionList(List<Long> orderUserId, List<Long> userId) {
-        return Stream.concat(orderUserId.stream(), userId.stream()).distinct().collect(Collectors.toList());
+        return userId.stream()
+                .filter(orderUserId::contains)
+                .collect(Collectors.toList());
+
+//        return Stream.concat(orderUserId.stream(), userId.stream()).distinct().collect(Collectors.toList());
 
     }
 

+ 2 - 1
feifan-module-distri/feifan-module-distri-biz/src/main/resources/mapper/sharepath/SharePathMapper.xml

@@ -93,7 +93,8 @@
         FROM distri_share_path a
                  JOIN distri_share_path b ON a.ancestor = b.ancestor
         WHERE b.descendant = #{descendantId}
-          AND a.sort &lt; b.sort
+          AND a.sort &gt; b.sort
+          AND b.depth = 1
     </select>
 
 

+ 1 - 1
feifan-server/src/main/resources/application.yaml

@@ -3,7 +3,7 @@ spring:
     name: feifan-server
 
   profiles:
-    active: local
+    active: prod
 
   main:
     allow-circular-references: true # 允许循环依赖,因为项目是三层架构,无法避免这个情况。