| | |
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.context.annotation.Lazy;
|
| | | import org.springframework.core.task.TaskExecutor;
|
| | | import org.springframework.stereotype.Service;
|
| | |
|
| | |
| | | import com.yeshi.fanli.entity.bus.user.UserSystemCoupon;
|
| | | import com.yeshi.fanli.entity.bus.user.UserSystemCouponGiveRecord;
|
| | | import com.yeshi.fanli.entity.bus.user.UserSystemCouponRecord;
|
| | | import com.yeshi.fanli.entity.system.SystemCoupon;
|
| | | import com.yeshi.fanli.entity.system.SystemCoupon.CouponTypeEnum;
|
| | | import com.yeshi.fanli.exception.tlj.UserTaoLiJinOriginException;
|
| | | import com.yeshi.fanli.exception.user.TokenRecordException;
|
| | | import com.yeshi.fanli.exception.user.UserInfoExtraException;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.config.SystemCouponService;
|
| | | import com.yeshi.fanli.service.inter.hongbao.ThreeSaleSerivce;
|
| | | import com.yeshi.fanli.service.inter.integral.IntegralGetService;
|
| | | import com.yeshi.fanli.service.inter.msg.UserOtherMsgNotificationService;
|
| | | import com.yeshi.fanli.service.inter.tlj.UserTaoLiJinGiveRecordService;
|
| | | import com.yeshi.fanli.service.inter.tlj.UserTaoLiJinOriginService;
|
| | |
| | |
|
| | | @Resource
|
| | | private UserOtherMsgNotificationService userOtherMsgNotificationService;
|
| | | |
| | | @Lazy
|
| | | @Resource
|
| | | private IntegralGetService integralGetService;
|
| | | |
| | | @Resource
|
| | | private SystemCouponService systemCouponService;
|
| | | |
| | |
|
| | | @Override
|
| | | public void insertSelective(TokenRecord record) {
|
| | |
| | | if (StringUtil.isNullOrEmpty(parseToken))
|
| | | throw new TokenRecordException(1, "未发现口令");
|
| | |
|
| | | TokenRecord rokenRecord = tokenRecordMapper.getByToken(token);
|
| | | TokenRecord rokenRecord = tokenRecordMapper.getByToken(parseToken);
|
| | | if (rokenRecord == null)
|
| | | throw new TokenRecordException(1, "口令不存在");
|
| | |
|
| | | Long uidToken = rokenRecord.getUid();
|
| | | if (uid != null && uidToken != null && uid.longValue() == uidToken.longValue())
|
| | | throw new TokenRecordException(1, "不能自己赠送给自己");
|
| | | |
| | | Date now = new Date();
|
| | | Date endTimeToken = rokenRecord.getEndTime();
|
| | | Integer stateTtoken = rokenRecord.getState();
|
| | |
| | |
|
| | | TokenVO tokenVO = new TokenVO();
|
| | | tokenVO.setAmount(num);
|
| | | tokenVO.setToken(token);
|
| | | tokenVO.setToken(parseToken);
|
| | | tokenVO.setNickName(nickName + "赠送");
|
| | | tokenVO.setPortrait(portrait);
|
| | | tokenVO.setTips(tips);
|
| | |
| | | TokenRecord rokenRecord = tokenRecordMapper.getByToken(token);
|
| | | if (rokenRecord == null)
|
| | | throw new TokenRecordException(1, "口令已失效");
|
| | |
|
| | | |
| | | Long uidToken = rokenRecord.getUid();
|
| | | if (uidToken != null && uid.longValue() == uidToken.longValue())
|
| | | throw new TokenRecordException(1, "不能自己赠送给自己");
|
| | | |
| | | Date now = new Date();
|
| | | Date endTimeToken = rokenRecord.getEndTime();
|
| | | if (endTimeToken != null && endTimeToken.getTime() < now.getTime())
|
| | |
| | | || userCoupon.getState() != UserSystemCoupon.STATE_IN_USE)
|
| | | throw new TokenRecordException(1, "该券不存在或非赠送");
|
| | |
|
| | | |
| | | |
| | | try {
|
| | | userSystemCouponService.insertUserCoupon(uid, CouponTypeEnum.freeCoupon.name(),
|
| | | UserSystemCoupon.SOURCE_GIVE);
|
| | | UserSystemCoupon.SOURCE_GIVE, null);
|
| | | } catch (Exception e) {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | throw new TokenRecordException(1, "领取失败");
|
| | |
| | | updateGiveRecord.setState(UserSystemCouponGiveRecord.STATE_RECEIVE);
|
| | | userSystemCouponGiveRecordService.updateByPrimaryKeySelective(updateGiveRecord);
|
| | |
|
| | | integralGetService.addGiveFreeCoupon(giveUid);
|
| | | |
| | | msg = "领取成功[免单券]成功,请到[我的-福利中心]中查看";
|
| | | // 消息 + 队员
|
| | | executor.execute(new Runnable() {
|
| | | @Override
|
| | | public void run() {
|
| | | SimpleDateFormat sd = new SimpleDateFormat("yyyy.MM.dd HH.mm");
|
| | | SimpleDateFormat sd = new SimpleDateFormat("yyyy.MM.dd HH:mm");
|
| | | boolean addTeam = addInviteTeam(uid, giveUid, userInfoExtra);
|
| | | String beiZhu = "无";
|
| | | if (addTeam)
|
| | |
| | | msgOther.setType(MsgOtherGiveContentDTO.TYEP_COUPON);
|
| | | msgOther.setTitle("赠送免单券");
|
| | | msgOther.setGiveType("你赠送的免单券被成功领取");
|
| | | msgOther.setReceiveInfo("昵称: " + userName + " ID:" + uid);
|
| | | msgOther.setReceiveInfo("昵称: :" + userName + " ID:" + uid);
|
| | | msgOther.setGiveTime(sd.format(giveRecord.getGiveTime()));
|
| | | msgOther.setReceiveTime(sd.format(new Date()));
|
| | | userOtherMsgNotificationService.tokenGiveMsg(giveUid, beiZhu, msgOther);
|
| | |
| | | || userCoupon.getState() != UserSystemCoupon.STATE_IN_USE)
|
| | | throw new TokenRecordException(1, "该券不存在或非赠送");
|
| | |
|
| | | SystemCoupon systemCoupon = userCoupon.getSystemCoupon();
|
| | | if (systemCoupon == null)
|
| | | throw new TokenRecordException(1, "该券不存在");
|
| | | |
| | | systemCoupon = systemCouponService.selectByPrimaryKey(systemCoupon.getId());
|
| | | if (systemCoupon == null)
|
| | | throw new TokenRecordException(1, "该券不存在");
|
| | | |
| | | try {
|
| | | userSystemCouponService.insertUserCoupon(uid, CouponTypeEnum.freeCoupon.name(),
|
| | | UserSystemCoupon.SOURCE_GIVE);
|
| | | userSystemCouponService.insertUserCoupon(uid, CouponTypeEnum.rebatePercentCoupon.name(),
|
| | | UserSystemCoupon.SOURCE_GIVE, systemCoupon.getPercent());
|
| | | } catch (Exception e) {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | throw new TokenRecordException(1, "领取失败");
|
| | |
| | | updateGiveRecord.setState(UserSystemCouponGiveRecord.STATE_RECEIVE);
|
| | | userSystemCouponGiveRecordService.updateByPrimaryKeySelective(updateGiveRecord);
|
| | |
|
| | | integralGetService.addGiveRebateCoupon(giveUid);
|
| | | |
| | | msg = "领取成功[返利奖励券]成功,请到[我的-福利中心]中查看";
|
| | | // 消息 + 队员
|
| | | executor.execute(new Runnable() {
|
| | | @Override
|
| | | public void run() {
|
| | | SimpleDateFormat sd = new SimpleDateFormat("yyyy.MM.dd HH.mm");
|
| | | SimpleDateFormat sd = new SimpleDateFormat("yyyy.MM.dd HH:mm");
|
| | | boolean addTeam = addInviteTeam(uid, giveUid, userInfoExtra);
|
| | | String beiZhu = "无";
|
| | | if (addTeam)
|
| | |
| | | updateRecord.setState(UserTaoLiJinGiveRecord.STATE_RECEIVE);
|
| | | userTaoLiJinGiveRecordService.updateByPrimaryKeySelective(updateRecord);
|
| | |
|
| | | integralGetService.addGiveTaoLiJin(giveUid);
|
| | | |
| | | msg = "领取成功[推广红包]成功,请到[我的-推广红包]中查看";
|
| | |
|
| | | // 消息 + 队员
|
| | | executor.execute(new Runnable() {
|
| | | @Override
|
| | | public void run() {
|
| | | SimpleDateFormat sd = new SimpleDateFormat("yyyy.MM.dd HH.mm");
|
| | | SimpleDateFormat sd = new SimpleDateFormat("yyyy.MM.dd HH:mm");
|
| | | boolean addTeam = addInviteTeam(uid, giveUid, userInfoExtra);
|
| | | String beiZhu = "无";
|
| | | if (addTeam)
|
| | |
| | | userName = user.getNickName();
|
| | |
|
| | | MsgOtherGiveContentDTO msgOther = new MsgOtherGiveContentDTO();
|
| | | msgOther.setType(MsgOtherGiveContentDTO.TYEP_COUPON);
|
| | | msgOther.setType(MsgOtherGiveContentDTO.TYEP_TLJ);
|
| | | msgOther.setTitle("赠送推广红包");
|
| | | msgOther.setGiveType("你赠送的推广红包被成功领取");
|
| | | msgOther.setReceiveInfo("昵称: " + userName + " ID:" + uid);
|