admin
2020-11-28 dc5be7d38446f70e6ff86df311119c32b41fe7f8
fanli/src/main/java/com/yeshi/fanli/service/impl/order/OrderRepairServiceImpl.java
@@ -13,9 +13,8 @@
import javax.annotation.Resource;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import com.yeshi.fanli.entity.SystemEnum;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import com.yeshi.fanli.dao.mybatis.HongBaoV2Mapper;
@@ -39,7 +38,7 @@
import com.yeshi.fanli.entity.order.ShareGoodsActivityOrder;
import com.yeshi.fanli.entity.push.PushInfo;
import com.yeshi.fanli.entity.push.PushInfo.PushTypeEnum;
import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
import com.yeshi.goods.facade.entity.taobao.TaoBaoGoodsBrief;
import com.yeshi.fanli.entity.taobao.TaoBaoOrder;
import com.yeshi.fanli.entity.taobao.TaoBaoWeiQuanOrder;
import com.yeshi.fanli.exception.money.UserMoneyDetailException;
@@ -65,9 +64,9 @@
import com.yeshi.fanli.service.inter.user.UserSystemCouponRecordService;
import com.yeshi.fanli.service.inter.user.UserSystemCouponService;
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.MoneyBigDecimalUtil;
import org.yeshi.utils.MoneyBigDecimalUtil;
import com.yeshi.fanli.util.StringUtil;
import com.yeshi.fanli.util.TimeUtil;
import org.yeshi.utils.TimeUtil;
import com.yeshi.fanli.util.factory.CommonOrderGoodsFactory;
import com.yeshi.fanli.util.factory.UserMoneyDetailFactory;
import com.yeshi.fanli.util.factory.goods.CommonOrderFactory;
@@ -131,9 +130,6 @@
   private OrderRepairHistoryService orderRepairHistoryService;
   @Resource
   private DataSourceTransactionManager dataSourceTransactionManager;
   @Resource
   private TaoBaoWeiQuanOrderService taoBaoWeiQuanOrderService;
   @Resource
@@ -191,7 +187,6 @@
   }
   @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
   private void processLessFanOrder(String orderId) throws Exception {
      List<CommonOrder> commonOrderList = commonOrderMapper.listBySourceTypeAndOrderNo(Constant.SOURCE_TYPE_TAOBAO,
@@ -392,10 +387,12 @@
   }
   // 修改订单信息
   @Transactional(rollbackFor = Exception.class)
   private void updateOrderInfo(TaoBaoOrder taoBaoOrder, Long commonOrderId) throws Exception {
      HongBaoOrder hongBaoOrder = hongBaoOrderService.selectDetailByCommonOrderId(commonOrderId);
      CommonOrder newCommonOrder = CommonOrderFactory.create(taoBaoOrder);
      SystemEnum system=userInfoService.getUserSystem(newCommonOrder.getUserInfo().getId());
      List<CommonOrderGoods> commonGoodsList = commonOrderGoodsMapper
            .listByGoodsIdAndGoodsType(taoBaoOrder.getAuctionId() + "", newCommonOrder.getSourceType());
      CommonOrderGoods cog = null;
@@ -434,7 +431,7 @@
      if (hongBaoOrder.getHongBaoV2().getType() == HongBaoV2.TYPE_ZIGOU) {
         BigDecimal fanliRate = hongBaoManageService.getFanLiRate(UserLevelEnum.daRen,
               commonOrder.getCreateTime().getTime());
               commonOrder.getCreateTime().getTime(),system);
         // 免单处理
         boolean mianDan = false;
         List<CommonOrder> orderList = commonOrderService.listBySourceTypeAndOrderId(Constant.SOURCE_TYPE_TAOBAO,
@@ -492,10 +489,10 @@
               BigDecimal rate = null;
               if (child.getType() == HongBaoV2.TYPE_YIJI) {// 一级分享赚
                  rate = hongBaoManageService.getFirstInviteRate(child.getUrank(),
                        commonOrder.getCreateTime().getTime());
                        commonOrder.getCreateTime().getTime(),system);
               } else if (child.getType() == HongBaoV2.TYPE_ERJI) {// 二级分享赚
                  rate = hongBaoManageService.getSecondInviteRate(child.getUrank(),
                        commonOrder.getCreateTime().getTime());
                        commonOrder.getCreateTime().getTime(),system);
               }
               // 以实际收入为准计算预估收益
@@ -523,7 +520,7 @@
      } else if (hongBaoOrder.getHongBaoV2().getType() == HongBaoV2.TYPE_SHARE_GOODS) {
         BigDecimal fanliRate = hongBaoManageService.getShareRate(UserLevelEnum.daRen,
               commonOrder.getCreateTime().getTime());
               commonOrder.getCreateTime().getTime(),system);
         List<ShareGoodsActivityOrder> list = shareGoodsActivityOrderService
               .listByOrderIdAndUid(commonOrder.getUserInfo().getId(), commonOrder.getOrderNo());
         if (list != null && list.size() > 0) {
@@ -564,9 +561,9 @@
               childUpdate.setUpdateTime(new Date());
               BigDecimal rate = null;
               if (child.getType() == HongBaoV2.TYPE_SHARE_YIJI) {// 一级分享赚
                  rate = hongBaoManageService.getFirstShareRate(1, commonOrder.getCreateTime().getTime());
                  rate = hongBaoManageService.getFirstShareRate(1, commonOrder.getCreateTime().getTime(),system);
               } else if (child.getType() == HongBaoV2.TYPE_SHARE_ERJI) {// 二级分享赚
                  rate = hongBaoManageService.getSecondShareRate(1, commonOrder.getCreateTime().getTime());
                  rate = hongBaoManageService.getSecondShareRate(1, commonOrder.getCreateTime().getTime(),system);
               }
               // 以实际收入为准计算预估收益
@@ -624,6 +621,8 @@
         commonOrder.setCommonOrderGoods(goods);
      }
      SystemEnum system=userInfoService.getUserSystem(commonOrder.getUserInfo().getId());
      CommonOrder oldCommonOrder = commonOrderMapper.selectBySourceTypeAndTradeId(commonOrder.getSourceType(),
            commonOrder.getTradeId());
      if (oldCommonOrder == null)// 新增
@@ -642,7 +641,7 @@
      // 添加红包
      if (type == HongBaoV2.TYPE_ZIGOU) {// 获取自购的返利比例
         BigDecimal fanliRate = hongBaoManageService.getFanLiRate(UserLevelEnum.daRen,
               commonOrder.getCreateTime().getTime());
               commonOrder.getCreateTime().getTime(),system);
         // 查询是否有免单计划
         BigDecimal mianDanMoney = null;
         if (commonOrder.getState() == CommonOrder.STATE_JS || commonOrder.getState() == CommonOrder.STATE_FK) {
@@ -724,7 +723,7 @@
            // 插入一级子红包
            BigDecimal firstRate = hongBaoManageService
                  .getFirstInviteRate(boss.getRank() == null ? 0 : boss.getRank());
                  .getFirstInviteRate(boss.getRank() == null ? 0 : boss.getRank(),system);
            if (firstRate.compareTo(new BigDecimal(0)) <= 0)
               return;
            HongBaoV2 firstHongbao = new HongBaoV2();
@@ -771,7 +770,7 @@
            if (boss != null) {// 二级BOSS存在
               BigDecimal secondRate = hongBaoManageService
                     .getSecondInviteRate(boss.getRank() == null ? 0 : boss.getRank());
                     .getSecondInviteRate(boss.getRank() == null ? 0 : boss.getRank(),system);
               if (secondRate.compareTo(new BigDecimal(0)) <= 0)
                  return;
               HongBaoV2 secondHongbao = new HongBaoV2();
@@ -819,7 +818,7 @@
            return;
         // 分享赚
         BigDecimal shareRate = hongBaoManageService.getShareRate(UserLevelEnum.daRen,
               commonOrder.getCreateTime().getTime());
               commonOrder.getCreateTime().getTime(),system);
         HongBaoV2 hongBao = new HongBaoV2();
         hongBao.setBeizhu("2019年7月批量修改");
@@ -862,7 +861,7 @@
               boss = userInfoService.selectByPKey(firstUid);
            if (boss != null) {
               BigDecimal firstLevelRate = hongBaoManageService.getFirstShareRate(1,
                     commonOrder.getThirdCreateTime().getTime());
                     commonOrder.getThirdCreateTime().getTime(),system);
               HongBaoV2 child = new HongBaoV2();
               child.setBeizhu("2019年7月批量修改");
               child.setParent(hongBao);
@@ -903,7 +902,6 @@
   }
   @Transactional(propagation = Propagation.REQUIRED)
   private void deleteByCommonOrderId(Long commonOrderId) {
      commonOrderMapper.deleteByPrimaryKey(commonOrderId);
      HongBaoOrder hongBaoOrder = hongBaoOrderMapper.selectByCommonOrderId(commonOrderId);
@@ -992,7 +990,10 @@
               return;
         }
         for (CommonOrder commonOrder : list) {
                SystemEnum system=userInfoService.getUserSystem(commonOrder.getUserInfo().getId());
            HongBaoOrder hongBaoOrder = hongBaoOrderMapper.selectByCommonOrderId(commonOrder.getId());
            if (hongBaoOrder == null)
               continue;
@@ -1007,7 +1008,7 @@
            if (boss != null && hongBao.getState() != HongBaoV2.STATE_SHIXIAO) {// 1级BOSS存在且红包未失效,免单不支持多级分销
               // 插入一级子红包
               BigDecimal firstRate = hongBaoManageService
                     .getFirstInviteRate(boss.getRank() == null ? 0 : boss.getRank());
                     .getFirstInviteRate(boss.getRank() == null ? 0 : boss.getRank(),system);
               if (firstRate.compareTo(new BigDecimal(0)) <= 0)
                  return;
               HongBaoV2 firstHongbao = new HongBaoV2();
@@ -1052,7 +1053,7 @@
               if (boss != null) {// 二级BOSS存在
                  BigDecimal secondRate = hongBaoManageService
                        .getSecondInviteRate(boss.getRank() == null ? 0 : boss.getRank());
                        .getSecondInviteRate(boss.getRank() == null ? 0 : boss.getRank(),system);
                  if (secondRate.compareTo(new BigDecimal(0)) <= 0)
                     return;
                  HongBaoV2 secondHongbao = new HongBaoV2();
@@ -1161,6 +1162,8 @@
            if (hongBaoOrder == null)
               continue;
            SystemEnum system=userInfoService.getUserSystem(commonOrder.getUserInfo().getId());
            HongBaoV2 hongBao = hongBaoOrder.getHongBaoV2();
            // 4月17日后才有一级分享赚
            if (commonOrder.getThirdCreateTime().getTime() > TimeUtil.convertToTimeTemp("2019-04-17",
@@ -1170,7 +1173,7 @@
                  boss = userInfoService.selectByPKey(firstUid);
               if (boss != null) {
                  BigDecimal firstLevelRate = hongBaoManageService.getFirstShareRate(1,
                        commonOrder.getThirdCreateTime().getTime());
                        commonOrder.getThirdCreateTime().getTime(),system);
                  HongBaoV2 child = new HongBaoV2();
                  child.setBeizhu("2019年7月批量修改");
                  child.setParent(hongBao);