From 58d2a20d424c413e4aea4909e483f8e36dc1ac78 Mon Sep 17 00:00:00 2001
From: xiaoyong931011 <15274802129@163.com>
Date: Mon, 14 Aug 2023 15:44:13 +0800
Subject: [PATCH] 赠送积分更新状态

---
 src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallOrderInfoServiceImpl.java |   41 +++++++++++++----------------------------
 1 files changed, 13 insertions(+), 28 deletions(-)

diff --git a/src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallOrderInfoServiceImpl.java b/src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallOrderInfoServiceImpl.java
index f9861df..1656f38 100644
--- a/src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallOrderInfoServiceImpl.java
+++ b/src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallOrderInfoServiceImpl.java
@@ -647,34 +647,19 @@
         orderInfo.setReceivingTime(new Date());
         this.baseMapper.updateById(orderInfo);
 
-        //生成一条团长提成记录
-//        Long orderInfoId = orderInfo.getId();
-//        List<MallOrderItem> mallOrderItemList = mallOrderItemMapper.selectListByOrderId(orderInfoId);
-//        if(CollUtil.isNotEmpty(mallOrderItemList)){
-//
-//            MallTeamLeader mallTeamLeader = mallTeamLeaderMapper.selectLeaderByUniqueCode(orderInfo.getTakeUniqueCode());
-//            Integer profitSwitch = mallTeamLeader.getProfitSwitch()==null?2:mallTeamLeader.getProfitSwitch();
-//            BigDecimal bonusPercent =new BigDecimal(mallTeamLeader.getBonusPercent()==null?"0":mallTeamLeader.getBonusPercent());
-//
-//            if(1 == profitSwitch){
-//                for(MallOrderItem mallOrderItem : mallOrderItemList){
-//                    Integer state = mallOrderItem.getState() == null ? 1 : mallOrderItem.getState();
-//                    if(1 == state){
-//                        MallLeaderAchieve mallLeaderAchieve = new MallLeaderAchieve();
-//                        mallLeaderAchieve.setMemberId(orderInfo.getMemberId());
-//                        mallLeaderAchieve.setOrderNo(orderInfo.getOrderNo());
-//                        mallLeaderAchieve.setOrderItemId(mallOrderItem.getId());
-//                        BigDecimal itemAmount = mallOrderItem.getAmount();
-//                        mallLeaderAchieve.setAmount(itemAmount);
-//                        BigDecimal bigDecimal = bonusPercent.multiply(itemAmount).setScale(2, BigDecimal.ROUND_DOWN);
-//                        mallLeaderAchieve.setProfitAmount(bigDecimal);
-//                        mallLeaderAchieve.setUniqueCode(orderInfo.getTakeUniqueCode());
-//                        mallLeaderAchieve.setState(MallLeaderAchieve.STATE_ONE);
-//                        mallLeaderAchieveMapper.insert(mallLeaderAchieve);
-//                    }
-//                }
-//            }
-//        }
+        //是否返利
+        if(ObjectUtil.isNotEmpty(member.getReferrerId())){
+            String referrerId = member.getReferrerId();
+            MallMember mallMemberParent = memberMapper.selectInfoByInviteId(referrerId);
+            Long parentId = mallMemberParent.getId();
+            String orderNo = orderInfo.getOrderNo();
+            MallMoneyFlow mallMoneyFlow = mallMoneyFlowMapper.selectOneByOrderNoAndMemberIdAndRtMemberId(orderNo, member.getId(), parentId);
+            mallMoneyFlow.setStatus(2);
+            mallMoneyFlow.setIsReturn(1);
+            mallMoneyFlowMapper.updateById(mallMoneyFlow);
+            memberWalletService.add(mallMoneyFlow.getAmount(), parentId, "balance");
+        }
+
     }
 
     @Override

--
Gitblit v1.9.1