Browse Source

Merge branch 'dev/2024/0822/update-admin-Y' of Harper/feifan-backend-zx-admin into master

修改充值消费分倍率计算规则
Yangzw 2 months ago
parent
commit
4b99ba8b5f

+ 5 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/consumptiontopuplog/vo/ConsumptionInfoVO.java

@@ -24,4 +24,9 @@ public class ConsumptionInfoVO {
      * 充值的倍率
      */
     private String consumptionMagnification;
+
+    /**
+     * 触发倍率的最低金额
+     */
+    private String triggerMagnificationPoints;
 }

+ 2 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/orderpercentage/vo/OrderPercentagePageReqVO.java

@@ -80,5 +80,7 @@ public class OrderPercentagePageReqVO extends PageParam {
     @Schema(description = "用户充值消费分的额度")
     private String userTopUpConsumptionPoints;
 
+    @Schema(description = "触发倍率的最低金额")
+    private String triggerMagnificationPoints;
 
 }

+ 4 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/orderpercentage/vo/OrderPercentageRespVO.java

@@ -98,4 +98,8 @@ public class OrderPercentageRespVO {
     @Schema(description = "用户充值消费分的额度")
     @ExcelProperty("用户充值消费分的额度")
     private String userTopUpConsumptionPoints;
+
+    @Schema(description = "触发倍率的最低金额")
+    @ExcelProperty("触发倍率的最低金额")
+    private String triggerMagnificationPoints;
 }

+ 2 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/orderpercentage/vo/OrderPercentageSaveReqVO.java

@@ -73,4 +73,6 @@ public class OrderPercentageSaveReqVO {
     @Schema(description = "用户充值消费分的额度")
     private String userTopUpConsumptionPoints;
 
+    @Schema(description = "触发倍率的最低金额")
+    private String triggerMagnificationPoints;
 }

+ 5 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/dal/dataobject/orderpercentage/OrderPercentageDO.java

@@ -118,6 +118,11 @@ public class OrderPercentageDO extends BaseDO {
      */
     private String userTopUpConsumptionPoints;
 
+    /**
+     * 触发倍率的最低金额
+     */
+    private String triggerMagnificationPoints;
+
     public String getGrossProfitBonusQuotaPerc() {
         double grossProfitBonusQuotaPerc = Double.parseDouble(this.grossProfitBonusQuotaPerc);
         if(grossProfitBonusQuotaPerc > GROSS_PROFIT_BONUS_QUOTA_PERC){

+ 20 - 10
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/service/consumptiontopuplog/ConsumptionTopUpLogServiceImpl.java

@@ -70,7 +70,11 @@ public class ConsumptionTopUpLogServiceImpl implements ConsumptionTopUpLogServic
         createReqVO.setConsumptionPoints(createReqVO.getConsumptionPoints() * DistriConstants.MILLION);
 
         // 充值倍率
-        createReqVO.setPracticalConsumptionPoints((long) (createReqVO.getConsumptionPoints() * Double.parseDouble(orderPercentageDO.getConsumptionMagnification())));
+        if (createReqVO.getConsumptionPoints() >= Long.parseLong(orderPercentageDO.getTriggerMagnificationPoints()) * DistriConstants.MILLION) {
+            createReqVO.setPracticalConsumptionPoints((long) (createReqVO.getConsumptionPoints() * Double.parseDouble(orderPercentageDO.getConsumptionMagnification())));
+        } else {
+            createReqVO.setPracticalConsumptionPoints(createReqVO.getConsumptionPoints());
+        }
 
 
         // 插入
@@ -104,16 +108,21 @@ public class ConsumptionTopUpLogServiceImpl implements ConsumptionTopUpLogServic
      * @param orderPercentageDO 设定额度
      */
     private void quotaVerify(Long userId, Long consumptionPoints, OrderPercentageDO orderPercentageDO) {
-        // 充值额度校验
-        Long quota = Long.parseLong(orderPercentageDO.getFollowUpConsumption());      // 后续充值
-        if (consumptionTopUpLogMapper.selectList(ConsumptionTopUpLogDO::getUserId, userId).isEmpty()) {
-            // 首次充值
-            quota = Long.parseLong(orderPercentageDO.getFirstTopUpConsumption());
-        }
-        if (consumptionPoints < quota) {
-            ErrorCode ERROR = new ErrorCode(1_002_030_035, "充值的额度不能小于规定额度");
-            throw exception(ERROR);
+        // 金额不小于1就行
+        if (consumptionPoints < 1) {
+            throw exception(new ErrorCode(1_002_030_035, "充值额度不能小于1"));
         }
+
+//        // 充值额度校验
+//        Long quota = Long.parseLong(orderPercentageDO.getFollowUpConsumption());      // 后续充值
+//        if (consumptionTopUpLogMapper.selectList(ConsumptionTopUpLogDO::getUserId, userId).isEmpty()) {
+//            // 首次充值
+//            quota = Long.parseLong(orderPercentageDO.getFirstTopUpConsumption());
+//        }
+//        if (consumptionPoints < quota) {
+//            ErrorCode ERROR = new ErrorCode(1_002_030_035, "充值的额度不能小于规定额度");
+//            throw exception(ERROR);
+//        }
     }
 
     @Override
@@ -163,6 +172,7 @@ public class ConsumptionTopUpLogServiceImpl implements ConsumptionTopUpLogServic
             build.setMinimumConsumptionPoints(Long.valueOf(orderPercentageDO.getFollowUpConsumption()));
         }
         build.setConsumptionMagnification(orderPercentageDO.getConsumptionMagnification());
+        build.setTriggerMagnificationPoints(orderPercentageDO.getTriggerMagnificationPoints());
         return build;
     }
 

+ 2 - 1
sql/mysql/建空库SQL/22_20240822.sql

@@ -163,7 +163,8 @@ CREATE TABLE distri_user_top_up_consumption_points_order (
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC COMMENT='用户充值消费分订单';
 
 ALTER TABLE distri_order_percentage
-    ADD COLUMN   `user_top_up_consumption_points` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '用户充值消费分的额度';
+    ADD COLUMN   `user_top_up_consumption_points` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '用户充值消费分的额度',
+    ADD COLUMN `trigger_magnification_points` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '触发倍率的最低金额';