admin
2020-04-14 5b16b6d8c05f97845f864d0a36f5b7443533962e
fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserSystemCouponServiceImpl.java
@@ -43,6 +43,7 @@
import com.yeshi.fanli.entity.common.JumpDetailV2;
import com.yeshi.fanli.entity.money.UserMoneyDetail;
import com.yeshi.fanli.entity.order.CommonOrder;
import com.yeshi.fanli.entity.order.HongBaoOrder;
import com.yeshi.fanli.entity.system.ConfigKeyEnum;
import com.yeshi.fanli.entity.system.SystemCoupon;
import com.yeshi.fanli.entity.system.SystemCoupon.CouponTypeEnum;
@@ -227,11 +228,10 @@
      return userSystemCouponMapper.countUserCouponList(uid);
   }
   @Override
   @Transactional(rollbackFor=Exception.class)
   public UserSystemCoupon freeCouponWin(Long uid, CouponTypeEnum typeEnum, String source, int num, boolean notify) throws UserSystemCouponException, Exception{
   public UserSystemCoupon freeCouponWin(Long uid, CouponTypeEnum typeEnum, String source, int num, boolean notify)
         throws UserSystemCouponException, Exception {
      if (typeEnum == null || uid == null || StringUtil.isNullOrEmpty(source) || num < 1) {
         throw new UserSystemCouponException(1, "参数不正确");
      }
@@ -292,8 +292,8 @@
         public void run() { 
            if (notify) { // 消息推送
               try {
                  userOtherMsgNotificationService.freeCouponWinMsg(uid, typeEnum.getDesc(), source,
                        num, "成功获得", nowTime, endTime);
                  userOtherMsgNotificationService.freeCouponWinMsg(uid, typeEnum.getDesc(), source, num, "成功获得",
                        nowTime, endTime);
               } catch (Exception e) {
                   e.printStackTrace();
               }
@@ -317,12 +317,10 @@
      return userSystemCoupon;
   }
   
   @Override
   @Transactional(rollbackFor=Exception.class)
   public UserSystemCoupon rewardCouponWin(Long uid, String source, int num, boolean notify,
         BigDecimal percent) throws UserSystemCouponException, Exception{
   public UserSystemCoupon rewardCouponWin(Long uid, String source, int num, boolean notify, BigDecimal percent)
         throws UserSystemCouponException, Exception {
      if (uid == null || percent == null|| StringUtil.isNullOrEmpty(source) || num < 1) {
         throw new UserSystemCouponException(1, "参数不正确");
      }
@@ -389,10 +387,6 @@
      
      return userSystemCoupon;
   }
   @Transactional(rollbackFor=Exception.class)
   @Override
@@ -752,7 +746,6 @@
      return userSystemCouponMapper.countUsableByUid(uid, listCouponId);
   }
   
   @Override
   public long countGiveFreeCoupon(Long uid) {
      if (uid == null)
@@ -769,8 +762,6 @@
      return userSystemCouponMapper.countUsableByUid(uid, listCouponId);
   }
   @Override
   public long countUsableRewardCoupon(Long uid) {
@@ -919,10 +910,9 @@
         throw new UserSystemCouponException(1, "亲,很遗憾,售后维权订单不能使用返利奖励券~");
      }
      // 订单
      List<CommonOrderVO> listVo = commonOrderService.listGroupOrderNoByUid(0, 1, uid, 2, 1,1, orderNo, null,
            null, null, sourceType);
      List<CommonOrderVO> listVo = commonOrderService.listGroupOrderNoByUid(0, 1, uid, 2, 1, 1, orderNo, null, null,
            null, sourceType);
      if (listVo == null || listVo.size() == 0) 
         throw new UserSystemCouponException(1, "亲,很遗憾,该订单已不能使用返利奖励券~");
      
@@ -1032,9 +1022,19 @@
         // 2.插入关联
         orderHongBaoMapService.addOrderHongBaoMap(hongBaoV2, order);
         // 计算该订单原有返利
         List<HongBaoOrder> hongBaoOrderlist = hongBaoOrderService
               .listDetailByOrderIdAndSourceType(order.getOrderId(), order.getOrderType());
         BigDecimal originalMoney = new BigDecimal(0);
         if (hongBaoOrderlist != null)
            for (HongBaoOrder ho : hongBaoOrderlist) {
               if (ho.getHongBaoV2() != null && ho.getHongBaoV2().getState() == HongBaoV2.STATE_YILINGQU)
                  originalMoney = originalMoney.add(ho.getHongBaoV2().getMoney());
            }
         // 3.插入资金明细,用户余额
         UserMoneyDetail userMoneyDetail = UserMoneyDetailFactory.createOrderReward(order.getOrderId(),
               order.getOrderType(), money, new UserInfo(uid));
               order.getOrderType(), money, originalMoney, new UserInfo(uid));
         userMoneyDetailService.addUserMoneyDetail(userMoneyDetail);
         userInfoService.addMoney(new UserInfo(uid), money);
@@ -1357,7 +1357,6 @@
      return userRecordVO;
   }
   @Transactional(rollbackFor=Exception.class)
   @Override
   public void updateStateByDrawback(String orderNo) throws Exception {
@@ -1398,7 +1397,6 @@
      record.setState(UserSystemCouponRecord.STATE_SUCCESS);
      userSystemCouponRecordService.updateByPrimaryKeySelective(record);
   }
   
   @Override
   public List<UserSystemCoupon> getCounponNowInvalid(int count) {
@@ -1474,8 +1472,6 @@
      return isfree;
   }
   /**
    * 随机券比例
@@ -2014,15 +2010,16 @@
            continue;
         }
         try { // 消息推送
            Long uid = userCoupon.getUid();
            String source = userCoupon.getSource();
             if (baseCoupon.getType() == CouponTypeEnum.freeCoupon || baseCoupon.getType() == CouponTypeEnum.freeCouponBuy) {
            if (baseCoupon.getType() == CouponTypeEnum.freeCoupon
                  || baseCoupon.getType() == CouponTypeEnum.freeCouponBuy) {
                userOtherMsgNotificationService.freeCouponEndMsg(uid, "自购免单券", source, 1, "已过期");
             } else if (baseCoupon.getType() == CouponTypeEnum.freeCouponGive) {
                userOtherMsgNotificationService.freeCouponEndMsg(uid, "赠送免单券", source, 1, "已过期");
            } if (baseCoupon.getType() == CouponTypeEnum.rebatePercentCoupon) {
            }
            if (baseCoupon.getType() == CouponTypeEnum.rebatePercentCoupon) {
                userOtherMsgNotificationService.rewardCouponEndMsg(uid, source, 1, "已过期");
            }
         } catch (Exception e) {
@@ -2200,8 +2197,8 @@
         userOtherMsgNotificationService.freeCouponWinMsg(uid, type.getDesc(), source, 1, "使用退回", 
               userCoupon.getStartTime(), userCoupon.getEndTime());
      } else if (CouponTypeEnum.rebatePercentCoupon == systemCoupon.getType()) {
         userOtherMsgNotificationService.rewardCouponWinMsg(uid, source, 1, "使用退回",
               userCoupon.getStartTime(), userCoupon.getEndTime());
         userOtherMsgNotificationService.rewardCouponWinMsg(uid, source, 1, "使用退回", userCoupon.getStartTime(),
               userCoupon.getEndTime());
      }
   }
@@ -2275,8 +2272,8 @@
            userOtherMsgNotificationService.freeCouponWinMsg(uid, type.getDesc(), source, 1, "使用退回", 
                  userCoupon.getStartTime(), userCoupon.getEndTime());
         } else if (CouponTypeEnum.rebatePercentCoupon == systemCoupon.getType()) {
            userOtherMsgNotificationService.rewardCouponWinMsg(uid, source, 1, "使用退回",
                  userCoupon.getStartTime(), userCoupon.getEndTime());
            userOtherMsgNotificationService.rewardCouponWinMsg(uid, source, 1, "使用退回", userCoupon.getStartTime(),
                  userCoupon.getEndTime());
         }
      }
   }
@@ -2286,12 +2283,12 @@
      // 过期券
      updateInvalidSate(uid);
      
      List<UserSystemCouponVO> listCoupon = userSystemCouponMapper.getValidByUidAndType(uid, CouponTypeEnum.rebatePercentCoupon.name());
      List<UserSystemCouponVO> listCoupon = userSystemCouponMapper.getValidByUidAndType(uid,
            CouponTypeEnum.rebatePercentCoupon.name());
      if (listCoupon == null || listCoupon.size() == 0)
         return false;
      return true;
   }
   @Override
   public List<UserSystemCouponVO> listIncludeNotExchange(Long uid) throws Exception {
@@ -2301,8 +2298,8 @@
      // 退回券
      sendBackTimeOutCoupon(uid);
      List<UserSystemCouponVO> listCoupon = userSystemCouponMapper.getValidByUidAndType(uid, CouponTypeEnum.rebatePercentCoupon.name());
      List<UserSystemCouponVO> listCoupon = userSystemCouponMapper.getValidByUidAndType(uid,
            CouponTypeEnum.rebatePercentCoupon.name());
      if (listCoupon == null || listCoupon.size() == 0)
         return null;
@@ -2466,8 +2463,7 @@
            public void run() {
               Long uid = coupon.getUid();
               String source = coupon.getSource();
               userOtherMsgNotificationService.freeCouponWinMsg(uid, "自购免单券", source, 1,
                     "激活成功", nowDate, endTime);
               userOtherMsgNotificationService.freeCouponWinMsg(uid, "自购免单券", source, 1, "激活成功", nowDate, endTime);
            }
         });
      } catch (Exception e) {