admin
2019-09-29 6f14a131b39c8fc44b29b6130c4e2002bbf2d3ca
fanli/src/main/java/com/yeshi/fanli/service/impl/user/integral/IntegralExchangeServiceImpl.java
@@ -86,6 +86,10 @@
   @Resource
   private IntegralDetailService integralDetailService;
   
   @Override
   public IntegralExchange selectByPrimaryKey(Long id) {
      return integralExchangeMapper.selectByPrimaryKey(id);
   }
   @Override
   public List<IntegralExchange> listValidCache(long start, int count){
@@ -96,7 +100,6 @@
   public Long countValid(){
      return integralExchangeMapper.countValid();
   }
   
   @Override
   public ExchangeTipVO verifyExchange(Long uid, Long id) throws IntegralExchangeException{
@@ -117,7 +120,6 @@
      Integer state = exchange.getState();
      if (state == null || state != 1)
         throw new IntegralExchangeException(1, "兑换活动未开启");
      
      Integer goldCoin = exchange.getGoldCoin();
      
@@ -230,25 +232,29 @@
      boolean once = false; // 兑换一次是否消失
      try {
         if (ExchangeTypeEnum.freeCouponBuy == type) {
            List<UserSystemCoupon> listCoupon = userSystemCouponService.getFreeCouponByType(uid, CouponTypeEnum.freeCouponBuy.name());
            List<UserSystemCoupon> listCoupon = userSystemCouponService.getFreeCouponByType(uid,
                  CouponTypeEnum.freeCouponBuy.name());
            if (listCoupon != null && listCoupon.size() > 0)
               throw new IntegralExchangeException(1, "自购免单券,仅能兑换一次");
            
            thing = "自购免单券";
            thingNum = "1张";
            userSystemCouponService.exchangeCoupon(uid, CouponTypeEnum.freeCouponBuy.name(), UserSystemCoupon.SOURCE_EXCHANGE, null);
            userSystemCouponService.exchangeCoupon(uid, CouponTypeEnum.freeCouponBuy.name(),
                  UserSystemCoupon.SOURCE_EXCHANGE, null);
            once = true; 
            couponNews = 1;
         } else if (ExchangeTypeEnum.freeCouponGive == type) {
            thing = "赠送免单券";
            thingNum = "1张";
            userSystemCouponService.exchangeCoupon(uid, CouponTypeEnum.freeCouponGive.name(), UserSystemCoupon.SOURCE_EXCHANGE, null);
            userSystemCouponService.exchangeCoupon(uid, CouponTypeEnum.freeCouponGive.name(),
                  UserSystemCoupon.SOURCE_EXCHANGE, null);
            couponNews = 1;
         } else if (ExchangeTypeEnum.rebatePercentCoupon == type) {
            thing = "返利奖励券";
            thingNum = "1张";
            String percent = configService.get("exchange_rebate_percent");
            userSystemCouponService.exchangeCoupon(uid, CouponTypeEnum.rebatePercentCoupon.name(), UserSystemCoupon.SOURCE_EXCHANGE, new BigDecimal(percent));
            userSystemCouponService.exchangeCoupon(uid, CouponTypeEnum.rebatePercentCoupon.name(),
                  UserSystemCoupon.SOURCE_EXCHANGE, new BigDecimal(percent));
            couponNews = 1;
         } else if (ExchangeTypeEnum.inviteCodePublish == type) {
            thing = "邀请码发布卡";
@@ -292,7 +298,8 @@
         exchangeCount ++;
         String progress = exchange.getProgress();
         if (!StringUtil.isNullOrEmpty(progress))
            progress = progress.replace("{已兑换}",exchangeCount + "").replace("{上限数}", exchange.getUpperLimit() + "");
            progress = progress.replace("{已兑换}", exchangeCount + "").replace("{上限数}",
                  exchange.getUpperLimit() + "");
         exchange.setProgress(progress);
         
         // 剩余金币
@@ -346,7 +353,6 @@
      }
   }
   
   @Override
   public ExchangeTipVO verifyInviteCode(Long uid, Long id) throws IntegralExchangeException{
      if (uid == null || uid <= 0)
@@ -387,7 +393,6 @@
      return exchangeTip;
   }
   
   @Override
   public String exchangeInviteCode(Long uid, Long id) throws IntegralExchangeException {
      if (uid == null || uid <= 0)
@@ -415,7 +420,6 @@
      Integer goldCoinHas = extraVO.getGoldCoin();
      if (goldCoin.intValue() > goldCoinHas.intValue())
         throw new IntegralExchangeException(1, "当前账户中可用金币不足,无法兑换该奖品!");
      
      try {
         UserInfoExtraVO inviteExtra = userInfoExtraService.getInfoExtraVOByUid(record.getUid());
@@ -470,4 +474,5 @@
         throw new IntegralExchangeException(1, "兑换失败");
      }
   }
}