| | |
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.stereotype.Service;
|
| | | import org.yeshi.utils.JsonUtil;
|
| | |
|
| | | import com.yeshi.fanli.dao.mybatis.user.TokenRecordMapper;
|
| | | import com.yeshi.fanli.entity.bus.tlj.UserTaoLiJinGiveRecord;
|
| | | import com.yeshi.fanli.entity.bus.user.ThreeSale;
|
| | | import com.yeshi.fanli.entity.bus.user.TokenRecord;
|
| | | import com.yeshi.fanli.entity.bus.user.TokenRecord.TokenTypeEnum;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfo;
|
| | |
| | | import com.yeshi.fanli.entity.bus.user.UserSystemCoupon;
|
| | | import com.yeshi.fanli.entity.system.SystemCoupon.CouponTypeEnum;
|
| | | import com.yeshi.fanli.exception.user.TokenRecordException;
|
| | | import com.yeshi.fanli.exception.user.UserSystemCouponException;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.hongbao.ThreeSaleSerivce;
|
| | | import com.yeshi.fanli.service.inter.tlj.UserTaoLiJinGiveRecordService;
|
| | | import com.yeshi.fanli.service.inter.user.TokenRecordService;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoExtraService;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoService;
|
| | | import com.yeshi.fanli.service.inter.user.UserSystemCouponGiveRecordService;
|
| | | import com.yeshi.fanli.service.inter.user.UserSystemCouponService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | |
| | |
|
| | | @Resource
|
| | | private UserInfoExtraService userInfoExtraService;
|
| | |
|
| | | @Resource
|
| | | private UserSystemCouponGiveRecordService userSystemCouponGiveRecordService;
|
| | |
|
| | | @Override
|
| | | public void insertSelective(TokenRecord record) {
|
| | |
| | | if (StringUtil.isNullOrEmpty(identify))
|
| | | throw new TokenRecordException(1, "口令标识不存在");
|
| | |
|
| | | boolean receive = false;
|
| | | Long giveUid = rokenRecord.getUid();
|
| | |
|
| | | UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid);
|
| | | if (userInfoExtra == null) |
| | | throw new TokenRecordException(1, "用户信息缺失");
|
| | | |
| | | boolean receive = false;
|
| | | TokenTypeEnum tokenType = rokenRecord.getType();
|
| | | if (tokenType == TokenTypeEnum.freeCoupon) {
|
| | | UserSystemCoupon userCoupon = userSystemCouponService.selectByPrimaryKey(Long.parseLong(identify));
|
| | |
| | | userSystemCouponService.insertUserCoupon(uid, CouponTypeEnum.freeCoupon.name(), UserSystemCoupon.SOURCE_GIVE);
|
| | | } catch (Exception e) {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | throw new TokenRecordException(1, "领取失败");
|
| | | }
|
| | |
|
| | | // 更新记录
|
| | | userSystemCouponGiveRecordService.updateRecord(uid, giveUid, Long.parseLong(identify));
|
| | | // 领取成功
|
| | | receive = true;
|
| | | } else {
|
| | |
| | | userSystemCouponService.insertUserCoupon(uid, CouponTypeEnum.rebatePercentCoupon.name(), UserSystemCoupon.SOURCE_GIVE);
|
| | | } catch (Exception e) {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | throw new TokenRecordException(1, "领取失败");
|
| | | }
|
| | | // 领取成功
|
| | | receive = true;
|
| | |
| | | throw new TokenRecordException(1, "哎呀,推广红包已被领取了!");
|
| | | } else {
|
| | |
|
| | | |
| | | |
| | | |
| | | }
|
| | | } else {
|
| | | throw new TokenRecordException(1, "无对应类型");
|
| | |
| | | if (receive)
|
| | | throw new TokenRecordException(1, "领取失败啦");
|
| | |
|
| | | UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid);
|
| | | if (StringUtil.isNullOrEmpty(userInfoExtra.getInviteCode())) {
|
| | | // 成为下级
|
| | | |
| | | |
| | | }
|
| | |
|
| | |
|
| | | }
|
| | | }
|