yujian
2019-09-17 2a99c607e5c7dc640d3608b35a20b451e42922c3
fanli/src/main/java/com/yeshi/fanli/service/impl/integral/IntegralExchangeServiceImpl.java
@@ -20,6 +20,7 @@
import com.yeshi.fanli.entity.integral.IntegralExchange;
import com.yeshi.fanli.entity.integral.IntegralExchange.ExchangeTypeEnum;
import com.yeshi.fanli.entity.money.UserMoneyDetail;
import com.yeshi.fanli.entity.system.SystemCoupon.CouponTypeEnum;
import com.yeshi.fanli.exception.integral.IntegralExchangeException;
import com.yeshi.fanli.log.LogHelper;
import com.yeshi.fanli.service.inter.config.ConfigService;
@@ -229,21 +230,25 @@
      boolean once = false; // 兑换一次是否消失
      try {
         if (ExchangeTypeEnum.freeCouponBuy == type) {
            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, type.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, type.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, type.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 = "邀请码发布卡";
@@ -333,6 +338,8 @@
            exchange = null;
         
         return exchange;
      } catch (IntegralExchangeException e) {
         throw new IntegralExchangeException(1, e.getMsg());
      } catch (Exception e) {
         LogHelper.errorDetailInfo(e);
         throw new IntegralExchangeException(1, "兑换异常");