| | |
| | | @Resource
|
| | | private IntegralDetailService integralDetailService;
|
| | |
|
| | | @Override
|
| | | public IntegralExchange selectByPrimaryKey(Long id) {
|
| | | return integralExchangeMapper.selectByPrimaryKey(id);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<IntegralExchange> listValidCache(long start, int count){
|
| | |
| | | public Long countValid(){
|
| | | return integralExchangeMapper.countValid();
|
| | | }
|
| | | |
| | |
|
| | | @Override
|
| | | public ExchangeTipVO verifyExchange(Long uid, Long id) throws IntegralExchangeException{
|
| | |
| | | Integer state = exchange.getState();
|
| | | if (state == null || state != 1)
|
| | | throw new IntegralExchangeException(1, "兑换活动未开启");
|
| | | |
| | |
|
| | | Integer goldCoin = exchange.getGoldCoin();
|
| | |
|
| | |
| | | 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 = "邀请码发布卡";
|
| | |
| | | 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);
|
| | |
|
| | | // 剩余金币
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | |
| | | @Override
|
| | | public ExchangeTipVO verifyInviteCode(Long uid, Long id) throws IntegralExchangeException{
|
| | | if (uid == null || uid <= 0)
|
| | |
| | | return exchangeTip;
|
| | | }
|
| | |
|
| | | |
| | | @Override
|
| | | public String exchangeInviteCode(Long uid, Long id) throws IntegralExchangeException {
|
| | | if (uid == null || uid <= 0)
|
| | |
| | | Integer goldCoinHas = extraVO.getGoldCoin();
|
| | | if (goldCoin.intValue() > goldCoinHas.intValue())
|
| | | throw new IntegralExchangeException(1, "当前账户中可用金币不足,无法兑换该奖品!");
|
| | | |
| | |
|
| | | try {
|
| | | UserInfoExtraVO inviteExtra = userInfoExtraService.getInfoExtraVOByUid(record.getUid());
|
| | |
| | | throw new IntegralExchangeException(1, "兑换失败");
|
| | | }
|
| | | }
|
| | |
|
| | | }
|