| | |
| | | import com.yeshi.fanli.entity.bus.user.UserInfoExtra;
|
| | | import com.yeshi.fanli.entity.bus.user.UserSystemCoupon;
|
| | | import com.yeshi.fanli.entity.integral.CodePublishRecord;
|
| | | import com.yeshi.fanli.entity.integral.IntegralDetail;
|
| | | 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.service.inter.config.ConfigService;
|
| | | import com.yeshi.fanli.service.inter.hongbao.HongBaoV2Service;
|
| | | import com.yeshi.fanli.service.inter.integral.CodePublishRecordService;
|
| | | import com.yeshi.fanli.service.inter.integral.IntegralDetailService;
|
| | | import com.yeshi.fanli.service.inter.integral.IntegralExchangeRecordService;
|
| | | import com.yeshi.fanli.service.inter.integral.IntegralExchangeService;
|
| | | import com.yeshi.fanli.service.inter.msg.MsgInviteDetailService;
|
| | |
| | | @Resource
|
| | | private MsgInviteDetailService msgInviteDetailService;
|
| | |
|
| | | @Resource
|
| | | private IntegralDetailService integralDetailService;
|
| | |
|
| | |
|
| | | @Override
|
| | |
| | | }
|
| | |
|
| | | String thing = "";
|
| | | String thingNum = "";
|
| | | int couponNews = 0;
|
| | | boolean once = false; // 兑换一次是否消失
|
| | | try {
|
| | | if (ExchangeTypeEnum.freeCouponBuy == type) {
|
| | | thing = "自购免单券";
|
| | | thingNum = "1张";
|
| | | userSystemCouponService.exchangeCoupon(uid, type.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);
|
| | | couponNews = 1;
|
| | | } else if (ExchangeTypeEnum.rebatePercentCoupon == type) {
|
| | | thing = "奖励免单券";
|
| | | thingNum = "3天";
|
| | | String percent = configService.get("exchange_rebate_percent");
|
| | | userSystemCouponService.exchangeCoupon(uid, type.name(), UserSystemCoupon.SOURCE_EXCHANGE, new BigDecimal(percent));
|
| | | couponNews = 1;
|
| | | } else if (ExchangeTypeEnum.inviteCodePublish == type) {
|
| | | thing = "邀请码发布卡";
|
| | | thingNum = "1组";
|
| | | if(codePublishRecordService.countValidRecord(uid) > 0)
|
| | | throw new IntegralExchangeException(1, "三天之内不可重复兑换");
|
| | | codePublishRecordService.publishInviteCode(uid);
|
| | | |
| | | exchange.setNeedJump(true);
|
| | | exchange.setBtnName("去查看");
|
| | | } else if (ExchangeTypeEnum.taoLiJin == type) {
|
| | | thing = "推广红包";
|
| | | thingNum = exchange.getAmount() + "元";
|
| | | userTaoLiJinOriginService.exchangeMoney(uid, exchange.getAmount());
|
| | | } else if (ExchangeTypeEnum.cash == type) {
|
| | | thing = "现金红包";
|
| | | BigDecimal money = exchange.getAmount();
|
| | | thingNum = money + "元";
|
| | | |
| | | // 1、插入红包数据
|
| | | HongBaoV2 hongBaoV2 = new HongBaoV2();
|
| | | hongBaoV2.setMoney(money);
|
| | |
| | | // 添加兑换记录
|
| | | integralExchangeRecordService.addExchangeRecord(id, uid);
|
| | |
|
| | | // 加入明细
|
| | | IntegralDetail detail = new IntegralDetail();
|
| | | detail.setUid(uid);
|
| | | detail.setTitle("金币兑换-" + thing + "-" + thingNum);
|
| | | detail.setMoney(-goldCoin);
|
| | | detail.setCreateTime(new Date());
|
| | | integralDetailService.insertSelective(detail);
|
| | | |
| | | // 消息
|
| | | final String things = thing;
|
| | | executor.execute(new Runnable() {
|
| | |
| | | userOtherMsgNotificationService.exchangeMsg(uid, "", msgOther);
|
| | | }
|
| | | });
|
| | | |
| | | if (once) // 兑换之后消失
|
| | | exchange = null;
|
| | |
|
| | | return exchange;
|
| | | } catch (Exception e) {
|
| | |
| | |
|
| | |
|
| | | @Override
|
| | | public void exchangeInviteCode(Long uid, Long id) throws IntegralExchangeException {
|
| | | public String exchangeInviteCode(Long uid, Long id) throws IntegralExchangeException {
|
| | | if (uid == null || uid <= 0)
|
| | | throw new IntegralExchangeException(1, "用户未登录");
|
| | |
|
| | |
| | | throw new IntegralExchangeException(1, "兑换失败,该用户邀请码不存在");
|
| | |
|
| | | String inviteCode = inviteExtra.getInviteCode();
|
| | | userInfoExtraService.activateInviteCode(uid, inviteExtra.getInviteCode());
|
| | |
|
| | | // 剩余金币
|
| | | int surplus = goldCoinHas.intValue() - goldCoin.intValue();
|
| | |
| | | extraUpdate.setGoldCoin(surplus);
|
| | | userInfoExtraService.saveUserInfoExtra(extraUpdate);
|
| | |
|
| | | |
| | | // 加入明细
|
| | | IntegralDetail detail = new IntegralDetail();
|
| | | detail.setUid(uid);
|
| | | detail.setTitle("金币兑换-邀请码激活卡-1组");
|
| | | detail.setMoney(-goldCoin);
|
| | | detail.setCreateTime(new Date());
|
| | | integralDetailService.insertSelective(detail);
|
| | | |
| | | // 添加兑换记录
|
| | | integralExchangeRecordService.addExchangeRecord(id, uid);
|
| | |
|
| | |
| | | userOtherMsgNotificationService.exchangeMsg(uid, beizu, msgOther);
|
| | | }
|
| | | });
|
| | | |
| | | return inviteCode;
|
| | | } catch (Exception e) {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | throw new IntegralExchangeException(1, "兑换失败");
|
| | | }
|
| | | |
| | | |
| | | }
|
| | | }
|