| | |
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.hongbao.HongBaoV2Service;
|
| | | import com.yeshi.fanli.service.inter.integral.CodePublishRecordService;
|
| | | import com.yeshi.fanli.service.inter.integral.IntegralExchangeRecordService;
|
| | | import com.yeshi.fanli.service.inter.integral.IntegralExchangeService;
|
| | | import com.yeshi.fanli.service.inter.tlj.UserTaoLiJinOriginService;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoExtraService;
|
| | |
| | |
|
| | | @Resource
|
| | | private CodePublishRecordService codePublishRecordService;
|
| | | |
| | | @Resource
|
| | | private IntegralExchangeRecordService integralExchangeRecordService;
|
| | |
|
| | |
|
| | |
|
| | |
| | | exchangeTip.setType(type.name());
|
| | | return exchangeTip;
|
| | | }
|
| | | |
| | | int upperLimit = exchange.getUpperLimit();
|
| | | // 今日兑换情况
|
| | | long exchangeCount = integralExchangeRecordService.countRecordByUid(id, uid);
|
| | | if (exchangeCount >= upperLimit) {
|
| | | throw new IntegralExchangeException(1, "今日兑换已达上限");
|
| | | }
|
| | | |
| | |
|
| | | Integer goldCoinHas = extraVO.getGoldCoin();
|
| | | if (goldCoin.intValue() > goldCoinHas.intValue()) {
|
| | |
| | | if (exchange == null)
|
| | | throw new IntegralExchangeException(1, "兑换方式不存在");
|
| | |
|
| | | int upperLimit = exchange.getUpperLimit();
|
| | | // 今日兑换情况
|
| | | long exchangeCount = integralExchangeRecordService.countRecordByUid(id, uid);
|
| | | if (exchangeCount >= upperLimit) {
|
| | | throw new IntegralExchangeException(1, "今日兑换已达上限");
|
| | | }
|
| | | |
| | | Integer goldCoin = exchange.getGoldCoin();
|
| | | Integer goldCoinHas = extraVO.getGoldCoin();
|
| | | if (goldCoin.intValue() > goldCoinHas.intValue()) {
|
| | |
| | |
|
| | | try {
|
| | | ExchangeTypeEnum type = exchange.getType();
|
| | | if (ExchangeTypeEnum.freeCouponBuy == type) {
|
| | | // 自购免单券
|
| | | userSystemCouponService.exchangeCoupon(uid, type.name(), UserSystemCoupon.SOURCE_EXCHANGE, false, null);
|
| | | } else if (ExchangeTypeEnum.freeCouponGive == type) {
|
| | | // 赠送免单券
|
| | | userSystemCouponService.exchangeCoupon(uid, type.name(), UserSystemCoupon.SOURCE_EXCHANGE, true, null);
|
| | | if (ExchangeTypeEnum.freeCouponBuy == type || ExchangeTypeEnum.freeCouponGive == type) {
|
| | | // 自购免单券、赠送免单券
|
| | | userSystemCouponService.exchangeCoupon(uid, type.name(), UserSystemCoupon.SOURCE_EXCHANGE, null);
|
| | | } else if (ExchangeTypeEnum.rebatePercentCoupon == type) {
|
| | | // 奖励免单券
|
| | | userSystemCouponService.exchangeCoupon(uid, type.name(), UserSystemCoupon.SOURCE_EXCHANGE, true,
|
| | | new BigDecimal(10));
|
| | | userSystemCouponService.exchangeCoupon(uid, type.name(), UserSystemCoupon.SOURCE_EXCHANGE, new BigDecimal(10));
|
| | | } else if (ExchangeTypeEnum.inviteCodePublish == type) {
|
| | | // 邀请码发布
|
| | | if(codePublishRecordService.countValidRecord(uid) > 0)
|
| | |
| | | throw new IntegralExchangeException(1, "兑换方式不存在");
|
| | | }
|
| | |
|
| | | exchangeCount ++;
|
| | | String progress = exchange.getProgress();
|
| | | if (!StringUtil.isNullOrEmpty(progress))
|
| | | progress = progress.replace("{已兑换}", 1 + "").replace("{上限数}", exchange.getUpperLimit() + "");
|
| | | progress = progress.replace("{已兑换}",exchangeCount + "").replace("{上限数}", exchange.getUpperLimit() + "");
|
| | | exchange.setProgress(progress);
|
| | |
|
| | | // 更新金币
|
| | |
| | | extraUpdate.setId(extraVO.getId());
|
| | | extraUpdate.setGoldCoin(goldCoinHas.intValue() - goldCoin.intValue());
|
| | | userInfoExtraService.saveUserInfoExtra(extraUpdate);
|
| | | |
| | | exchange.setUserGoldCoin(extraUpdate.getGoldCoin() + "枚");
|
| | | |
| | | return exchange;
|
| | | } catch (Exception e) {
|
| | | LogHelper.errorDetailInfo(e);
|