| | |
| | | import com.yeshi.fanli.exception.user.UserInfoExtraException;
|
| | | import com.yeshi.fanli.exception.user.UserLotteryRecordException;
|
| | | import com.yeshi.fanli.exception.user.UserSystemCouponException;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.config.ConfigService;
|
| | | import com.yeshi.fanli.service.inter.config.SystemCouponService;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoExtraService;
|
| | | import com.yeshi.fanli.service.inter.user.UserLotteryRecordService;
|
| | | import com.yeshi.fanli.service.inter.user.UserSystemCouponService;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | |
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | |
| | | record = new UserLotteryRecord();
|
| | | record.setUid(uid);
|
| | | record.setType(type);
|
| | | record.setCount(num);
|
| | | } else {
|
| | | record.setCount(num);
|
| | | }
|
| | | return record;
|
| | |
| | | throw new UserLotteryRecordException(2, "抽奖次数不足");
|
| | | }
|
| | |
|
| | | String prize = null;
|
| | | String couponType = null;
|
| | | // 新人抽奖 -已抽中奖品
|
| | | List<UserSystemCoupon> list = userSystemCouponService.getUserCouponBySource(uid, UserSystemCoupon.SOURCE_NEWBIES);
|
| | | |
| | | String prize = null;
|
| | | |
| | | if (list == null || list.size() == 0) {
|
| | | prize = getLotteryPrizeNewbies(count, 0, null);
|
| | | } else if (list.size() == 1) {
|
| | | String couponType = null;
|
| | | |
| | | UserSystemCoupon userSystemCoupon = list.get(0);
|
| | | SystemCoupon systemCoupon = userSystemCoupon.getSystemCoupon();
|
| | | if (systemCoupon != null) {
|
| | |
| | | }
|
| | |
|
| | | if (prize == null || prize.trim().length() == 0) {
|
| | | prize = "NoPrize";
|
| | | } else if (prize.equals(couponType)) {
|
| | | // 已存在此券
|
| | | prize = "NoPrize";
|
| | | } else {
|
| | | try {
|
| | |
| | | throw new UserLotteryRecordException(2, "抽奖次数不足");
|
| | | }
|
| | |
|
| | | String prize = "";
|
| | | String prize = null;
|
| | | // 今日天天抽奖-已抽中拥有券数量
|
| | | int todayHas = userSystemCouponService.countTodatyUserCouponBySource(uid, UserSystemCoupon.SOURCE_DAILY_REBATE);
|
| | |
|
| | | if (todayHas == 0) {
|
| | | // 抽奖
|
| | | prize = getLotteryPrizeDaily(count);
|
| | | LogHelper.test(uid + "中奖结果:" + prize);
|
| | | try {
|
| | | int num = 0;
|
| | | if ("rebateCoupon".equals(prize)) {
|
| | |
| | | } else if ("doubleCoupon".equals(prize)) {
|
| | | num = 2;
|
| | | }
|
| | | |
| | | // 插入奖励券
|
| | | userSystemCouponService.randomRewardCoupon(num, uid, UserSystemCoupon.SOURCE_DAILY_REBATE);
|
| | | if (num > 0) {
|
| | | userSystemCouponService.randomRewardCoupon(num, uid, UserSystemCoupon.SOURCE_DAILY_REBATE);
|
| | | }
|
| | |
|
| | | } catch (UserSystemCouponException e) {
|
| | | throw new UserLotteryRecordException(1, "抽奖失败");
|
| | |
| | | updateRecord.setUpdateTime(new Date());
|
| | | userLotteryRecordMapper.updateByPrimaryKeySelective(updateRecord);
|
| | |
|
| | | if (prize == null || prize.trim().length() == 0) {
|
| | | LogHelper.test(uid + "返回H5中奖结果:" + prize);
|
| | | if (StringUtil.isNullOrEmpty(prize)) {
|
| | | prize = "NoPrize";
|
| | | }
|
| | | LogHelper.test(uid + "返回H5中奖结果处理空值:" + prize);
|
| | |
|
| | | Map<String,Object> map = new HashMap<String, Object>();
|
| | | map.put("count", count);
|
| | |
| | | String rebateCoupon = "rebateCoupon"; // 一张奖励券
|
| | | String doubleCoupon = "doubleCoupon"; // 两张奖励券
|
| | |
|
| | | if (count== 1) {
|
| | | if (count == 1) {
|
| | | // 剩余最后一次必中
|
| | | long result = (1 + Math.round(Math.random() * (9)));
|
| | | if (result <= 7) {
|
| | |
| | | }
|
| | | } else {
|
| | | long result = (1 + Math.round(Math.random() * (9)));
|
| | | if (result <= 2) {
|
| | | if (result <= 3) {
|
| | | prize = rebateCoupon;
|
| | | } else if (result <= 5) {
|
| | | prize = doubleCoupon;
|