From fe879975a3e8a0a1aa280fb839e02d159bfbcff8 Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期二, 27 八月 2019 18:04:38 +0800 Subject: [PATCH] 金币任务多次获取bug修改 --- fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserLotteryRecordServiceImpl.java | 32 +++++++++++++++++++++++--------- 1 files changed, 23 insertions(+), 9 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserLotteryRecordServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserLotteryRecordServiceImpl.java index 5e942ae..ef9aec2 100644 --- a/fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserLotteryRecordServiceImpl.java +++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserLotteryRecordServiceImpl.java @@ -19,11 +19,13 @@ 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; @@ -91,6 +93,8 @@ record = new UserLotteryRecord(); record.setUid(uid); record.setType(type); + record.setCount(num); + } else { record.setCount(num); } return record; @@ -164,14 +168,15 @@ 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) { @@ -186,9 +191,12 @@ if (prize == null || prize.trim().length() == 0) { prize = "NoPrize"; + } else if (prize.equals(couponType)) { + // 宸插瓨鍦ㄦ鍒� + prize = "NoPrize"; } else { try { - userSystemCouponService.insertUserCoupon(uid, prize, UserSystemCoupon.SOURCE_NEWBIES); + userSystemCouponService.insertUserCoupon(uid, prize, UserSystemCoupon.SOURCE_NEWBIES, null); } catch (UserSystemCouponException e) { e.printStackTrace(); } catch (Exception e) { @@ -307,13 +315,14 @@ 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)) { @@ -321,8 +330,11 @@ } 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, "鎶藉澶辫触"); @@ -339,9 +351,11 @@ 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); @@ -363,7 +377,7 @@ String rebateCoupon = "rebateCoupon"; // 涓�寮犲鍔卞埜 String doubleCoupon = "doubleCoupon"; // 涓ゅ紶濂栧姳鍒� - if (count== 1) { + if (count == 1) { // 鍓╀綑鏈�鍚庝竴娆″繀涓� long result = (1 + Math.round(Math.random() * (9))); if (result <= 7) { @@ -373,7 +387,7 @@ } } else { long result = (1 + Math.round(Math.random() * (9))); - if (result <= 2) { + if (result <= 3) { prize = rebateCoupon; } else if (result <= 5) { prize = doubleCoupon; -- Gitblit v1.8.0