Pārlūkot izejas kodu

Merge branch 'dev/2024/0624/update-app-Y' of feifan/mall-backend-app into master

修改订单支付没有判断余额的问题
Yangzw 9 mēneši atpakaļ
vecāks
revīzija
1d218c03a7

+ 2 - 3
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/dal/mysql/ptprofit/PtProfitMapper.java

@@ -4,9 +4,7 @@ import cn.newfeifan.mall.framework.common.pojo.PageResult;
 import cn.newfeifan.mall.framework.mybatis.core.mapper.BaseMapperX;
 import cn.newfeifan.mall.framework.mybatis.core.query.LambdaQueryWrapperX;
 import cn.newfeifan.mall.module.distri.controller.admin.ptprofit.vo.PtProfitPageReqVO;
-import cn.newfeifan.mall.module.distri.dal.dataobject.integral.IntegralDO;
 import cn.newfeifan.mall.module.distri.dal.dataobject.ptprofit.PtProfitDO;
-import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Select;
@@ -31,7 +29,8 @@ public interface PtProfitMapper extends BaseMapperX<PtProfitDO> {
                 .orderByDesc(PtProfitDO::getId));
     }
 
-    @Update("UPDATE distri_integral SET current_quota = current_quota + #{amount},freeze_quota = freeze_quota + #{freeze_mount} WHERE (current_quota + #{amount2})>=0 and user_id=#{userId} and (freeze_quota + #{freeze_mount2})>=0 ")
+    @Update("UPDATE distri_integral SET current_quota = current_quota + #{amount},freeze_quota = freeze_quota + #{freeze_mount} " +
+            "WHERE (current_quota + #{amount2})>=0 and user_id=#{userId} and (freeze_quota + #{freeze_mount2})>=0 ")
     int updateUserIntegral(@Param("amount") Long amount,
                            @Param("amount2") Long amount2,
                            @Param("freeze_mount") Long freezeAmount,

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

@@ -160,7 +160,7 @@ public class SharePathServiceImpl implements SharePathService {
                 .eq(SharePathDO::getDescendant, userId)
                 .eq(SharePathDO::getDepth, 1));
         SharePathRespVO ancestor = BeanUtils.toBean(sharePathDO, SharePathRespVO.class);
-        if(ancestor != null) {
+        if (ancestor != null) {
             ancestor.setAvatar(getAvatar(ancestor.getAncestor()));
             getSocialStatus(ancestor, ancestor.getAncestor());
             //获取最大可用额度
@@ -171,17 +171,18 @@ public class SharePathServiceImpl implements SharePathService {
                     .eq(SharePathDO::getAncestor, ancestor.getAncestor())
             );
             ancestor.setDescendantsCount(descendantsCount);
-            ancestor.setResidueSocial(getResidueSocial(ancestor.getAncestor()));
+            //里面放的是本人的兄弟分区额度
+            ancestor.setResidueSocial(getBrotherSocial(userId));
             //获取用户名
             ancestor.setUsername(memberUserService.getUser(ancestor.getAncestor()).getUsername());
         }
 
         //获取团队成员
         PageResult<SharePathDO> descendants = sharePathMapper.selectPage(pageParam, new LambdaQueryWrapperX<SharePathDO>()
-                        .eq(SharePathDO::getAncestor, userId)
-                        .eq(SharePathDO::getDepth, 1)
-                        .orderByAsc(SharePathDO::getDepth)
-                );
+                .eq(SharePathDO::getAncestor, userId)
+                .eq(SharePathDO::getDepth, 1)
+                .orderByAsc(SharePathDO::getDepth)
+        );
         PageResult<SharePathRespVO> result = BeanUtils.toBean(descendants, SharePathRespVO.class);
         result.getList().forEach(item -> {
             item.setAvatar(getAvatar(item.getDescendant()));
@@ -196,7 +197,7 @@ public class SharePathServiceImpl implements SharePathService {
 //            setHighQuota(item, item.getDescendant());
 
             //获取剩余碰撞额度 + 待确权直推奖
-            item.setResidueSocial(getResidueSocial(item.getDescendant()));
+            item.setResidueSocial(getSonSocial(item.getDescendant()));
             //获取用户名
             item.setUsername(memberUserService.getUser(item.getDescendant()).getUsername());
         });
@@ -208,36 +209,58 @@ public class SharePathServiceImpl implements SharePathService {
                 .descendants(result).build();
     }
 
-    private Long getResidueSocial(Long userId){
-//        if(!userId.equals(PT_ID)){
-//            Long ancestorIncreaseIntegral = sharePathMapper.getAncestorIncreaseIntegralByUserId(userId);
-//            if(ancestorIncreaseIntegral == null) ancestorIncreaseIntegral = 0L;
-//            Long residueSocial = partitionCrashService.getResidueSocial(userId);
-//            return ancestorIncreaseIntegral + residueSocial;
-//        }
+    /**
+     * 获取本用户兄弟分区的剩余额度值
+     *
+     * @param userId 用户编号
+     * @return 剩余额度值
+     */
+    private Long getBrotherSocial(Long userId) {
+        return getYesterdayCrash(userId, 1).getBrotherPrice();
+    }
 
+    /**
+     * 获取昨日分区信息
+     *
+     * @param userId 用户编号
+     * @return 分区信息
+     */
+    private PartitionCrashDO getYesterdayCrash(Long userId, int today) {
         LocalDateTime todayStart = LocalDateTime.of(LocalDate.now(), LocalTime.MIDNIGHT); // 今天的开始时间,即午夜12点
-        LocalDateTime localDateTime = todayStart.minusDays(1);
+        LocalDateTime localDateTime = todayStart.minusDays(today);
         String yesterdayNo = "CRASH:" + userId + ":" + localDateTime.toString();
-        PartitionCrashDO yesterdayCrash = partitionCrashMapper.selectOne(new LambdaQueryWrapperX<PartitionCrashDO>().eqIfPresent(PartitionCrashDO::getPartNo, yesterdayNo));
+        PartitionCrashDO partitionCrashDO = partitionCrashMapper.selectOne(new LambdaQueryWrapperX<PartitionCrashDO>().eqIfPresent(PartitionCrashDO::getPartNo, yesterdayNo));
+        if(partitionCrashDO == null){
+            return getYesterdayCrash(userId, ++today);
+        }
+        return partitionCrashDO;
+    }
 
-        return yesterdayCrash.getAfterHitQuota();
+    /**
+     * 获取直推人后代分区的剩余额度值
+     *
+     * @param userId 用户编号
+     * @return 剩余额度值
+     */
+    private Long getSonSocial(Long userId) {
+        return getYesterdayCrash(userId, 1).getSonPrice();
     }
 
     /**
      * 获取最高可获取积分
+     *
      * @param sharePath 对象
-     * @param userId 用户编号
+     * @param userId    用户编号
      */
-    private void setHighQuota(SharePathRespVO sharePath,Long userId){
+    private void setHighQuota(SharePathRespVO sharePath, Long userId) {
         IntegralDO integralDO = integralService.selectByUser(userId);
-        if(integralDO != null){
+        if (integralDO != null) {
             sharePath.setHigh_quota(integralDO.getHighQuota());
         }
     }
 
-    private void getSocialStatus(SharePathRespVO sharePathRespVO,Long userId){
-        if(Objects.equals(userId, PT_ID)) return;
+    private void getSocialStatus(SharePathRespVO sharePathRespVO, Long userId) {
+        if (Objects.equals(userId, PT_ID)) return;
         DuserDO duser = duserService.getDuserByUser(userId);
         SocialStatusDO socialStatus = socialStatusService.getSocialStatus(duser.getSocialStatusId());
         sharePathRespVO.setSocialStatusLevel(socialStatus.getLevel());

+ 1 - 0
feifan-module-mall/feifan-module-trade-api/src/main/java/cn/newfeifan/mall/module/trade/enums/ErrorCodeConstants.java

@@ -94,5 +94,6 @@ public interface ErrorCodeConstants {
     ErrorCode BROKERAGE_WITHDRAW_USER_BALANCE_NOT_ENOUGH = new ErrorCode(1_011_008_003, "您当前最多可提现 {} 元");
 
     ErrorCode MESSAGE_LOG_NOT_EXISTS = new ErrorCode(1_011_008_004, "微信模板消息日志不存在");
+    ErrorCode ORDER_PAY_ERROR = new ErrorCode(1_011_008_005, "钱包积分不够支付");
 
 }

+ 4 - 1
feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/service/order/TradeOrderUpdateServiceImpl.java

@@ -782,7 +782,10 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
                 Long tradeOrderId = order.getId();
                 String OrderNum = order.getNo();
                 Long payIntegral = order.getPayIntegral().longValue();//每个订单使用的积分
-                integralService.updateUserIntegral(userId, userId, CaclEnum.ORDER_PAY_INTEGRAL, payIntegral * (-1), 0L, tradeOrderId, OrderNum);
+                Boolean flag = integralService.updateUserIntegral(userId, userId, CaclEnum.ORDER_PAY_INTEGRAL, payIntegral * (-1), 0L, tradeOrderId, OrderNum);
+                if(!flag){
+                    throw exception(ORDER_PAY_ERROR);
+                }
             }
         }