Browse Source

修改退款程序:增加退款时,会退回推荐人冻结积分的功能
修改积分日志枚举

Ben 5 months ago
parent
commit
27b0eddda5

+ 16 - 5
feifan-module-distri/feifan-module-distri-api/src/main/java/cn/newfeifan/mall/module/distri/enums/CaclEnum.java

@@ -15,12 +15,23 @@ public enum CaclEnum {
     SMALL_QUOTA_CRASH(7, "小区额度分配"),
     AFTER_CRASH_CALC_PT_TOTAL_QUOTA(8, "碰撞后计算平台总收益"),
     ORDER_PAY_INTEGRAL(9,"购物使用积分"),//支付了一部分积分作购物用
-    ORDER_REFUND_INTEGRAL(10,"订单退款,退回积分"),//订单已支付,用户退款申请通过,则退回商品项使用的积分
+    ORDER_REFUND_INTEGRAL(10,"退回退款订单项,消费者支付的积分"),//订单已支付,用户退款申请通过,则退回商品项使用的积分
     ORDER_INTEGRAL_UNFREEZE(11,"订单积分到账"),//购物收货7天后,冻结积分变为可用积分
-    ORDER_GET_FREEZE_INTEGRAL(12,"购物返积分"),//购物获得冻结积分
-    ORDER_CANCEL_BY_USER_REFUND_INTEGRAL(13,"取消订单,退回积分"),//用户手动取消未支付订单,退回购物使用的积分
-    ORDER_CANCEL_BY_SYSTEM_REFUND_INTEGRAL(14,"订单超时未支付,退回积分"),//订单超时未支付,退回购物使用的积分
-    ORDER_REFUND_CANCEL_INTEGRAL(15,"订单退款,减少冻结积分"),//订单已支付,用户退款申请通过,则减少之前给用户的冻结积分
+    AFTER_CRASH_CALC_PT_TOTAL_GROSS_QUOTA(12, "碰撞后计算平台收益"),
+    FREEZE_CHANGE_INTEGRAL(13, "冻结积分转化成可用积分"),
+    GROSS_PROFIT_BONUS_QUOTA_PERC_EXCEED_MAXIMUM_LIMIT(14, "合赢奖超额"),
+    GROSS_PROFIT_ANCESTOR_QUOTA_PERC_EXCEED_MAXIMUM_LIMIT(15, "直推奖超额"),
+    ORDER_CANCEL_BY_USER_REFUND_INTEGRAL(16,"取消订单,退回积分"),
+    ORDER_CANCEL_BY_SYSTEM_REFUND_INTEGRAL(17,"订单超时未支付,退回积分"),
+    ORDER_PAY_INTEGRAL_ANCESTER(18, "直推人购物,推荐人获得冻结积分"),//购物 上级直推人 获得积分
+    ORDER_REFUND_INTEGRAL_CONSUMER(19,"订单退款,收回消费者获得的冻结积分"),
+    ORDER_REFUND_INTEGRAL_ANCESTER(20,"订单退款,收回消费者的推荐人,获得的冻结积分")
+    ;
+
+//    ORDER_GET_FREEZE_INTEGRAL(12,"购物返积分"),//购物获得冻结积分
+//    ORDER_CANCEL_BY_USER_REFUND_INTEGRAL(13,"取消订单,退回积分"),//用户手动取消未支付订单,退回购物使用的积分
+//    ORDER_CANCEL_BY_SYSTEM_REFUND_INTEGRAL(14,"订单超时未支付,退回积分"),//订单超时未支付,退回购物使用的积分
+//    ORDER_REFUND_CANCEL_INTEGRAL(15,"订单退款,减少冻结积分"),//订单已支付,用户退款申请通过,则减少之前给用户的冻结积分
     ;
 
     /**

+ 4 - 0
feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/dal/dataobject/order/TradeOrderItemDO.java

@@ -43,6 +43,10 @@ public class TradeOrderItemDO extends BaseDO {
      * 用户付款后,获得的冻结积分
      */
     private Long increaseIntegral;
+    /**
+     * 直推人用户付款后,推荐人用户获得积分
+     */
+    private Long ancestorIncreaseIntegral;
     /**
      * 用户编号
      *

+ 5 - 0
feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/dal/mysql/order/TradeOrderMapper.java

@@ -9,6 +9,8 @@ import cn.newfeifan.mall.module.trade.controller.app.order.vo.AppTradeOrderPageR
 import cn.newfeifan.mall.module.trade.dal.dataobject.order.TradeOrderDO;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
 
 import java.time.LocalDateTime;
 import java.util.List;
@@ -17,6 +19,9 @@ import java.util.Set;
 
 @Mapper
 public interface TradeOrderMapper extends BaseMapperX<TradeOrderDO> {
+    //add by Ben 20240604
+    @Select("SELECT ancestor FROM `distri_share_path` where descendant = #{userId} and depth=1")
+    Long selectAncesterByMemberUserId(@Param("userId") Long userId);
 
     default int updateByIdAndStatus(Long id, Integer status, TradeOrderDO update) {
         return update(update, new LambdaUpdateWrapper<TradeOrderDO>()

+ 12 - 3
feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/service/aftersale/AfterSaleServiceImpl.java

@@ -403,13 +403,22 @@ public class AfterSaleServiceImpl implements AfterSaleService {
         toid.setId(tradeOrderItemDO.getId());
         toid.setRefundIntegral(payIntegral);
         tradeOrderItemMapper.updateById(toid);
-        //返回退款订单项对应的积分
+        //退回退款订单项,购物者支付的积分
         integralService.updateUserIntegral(orderUserId, CaclEnum.ORDER_REFUND_INTEGRAL, payIntegral,0l,tradeOrderId,tradeOrderNum);
 
 
         //2. 减少退货物品对应的冻结积分
-        Long increaseIntegral = tradeOrderItemDO.getIncreaseIntegral();
-        integralService.updateUserIntegral(orderUserId, CaclEnum.ORDER_REFUND_CANCEL_INTEGRAL, 0l,increaseIntegral*(-1),tradeOrderId,tradeOrderNum);
+        Long increaseIntegral = tradeOrderItemDO.getIncreaseIntegral();//消费者自得冻结积分
+        Long ancestorIncreaseIntegral = tradeOrderItemDO.getAncestorIncreaseIntegral();//消费者推荐人得冻结积分
+
+
+        //订单退款,收回消费者获得的冻结积分
+        integralService.updateUserIntegral(orderUserId, CaclEnum.ORDER_REFUND_INTEGRAL_CONSUMER, 0l,increaseIntegral*(-1),tradeOrderId,tradeOrderNum);
+
+        //20240604 推荐人(上级用户ID)
+        Long ancesterUserId = tradeOrderMapper.selectAncesterByMemberUserId(orderUserId);
+        //订单退款,收回消费者推荐人获得的冻结积分
+        integralService.updateUserIntegral(ancesterUserId, CaclEnum.ORDER_REFUND_INTEGRAL_ANCESTER, 0l,ancestorIncreaseIntegral*(-1),tradeOrderId,tradeOrderNum);
 
         // 发起退款单。注意,需要在事务提交后,再进行发起,避免重复发起
         createPayRefund(userIp, afterSale);