fanli/src/main/java/com/yeshi/fanli/controller/client/RecommendController.java
@@ -46,6 +46,7 @@ import com.yeshi.fanli.entity.bus.user.Order; import com.yeshi.fanli.entity.bus.user.ShamUser; import com.yeshi.fanli.entity.bus.user.UserInfo; import com.yeshi.fanli.entity.bus.user.UserInfoExtra; import com.yeshi.fanli.entity.common.ImageInfo; import com.yeshi.fanli.entity.common.JumpDetail; import com.yeshi.fanli.entity.common.JumpDetailV2; @@ -102,6 +103,7 @@ import com.yeshi.fanli.service.inter.user.TBPidService; import com.yeshi.fanli.service.inter.user.UserCustomSettingsService; import com.yeshi.fanli.service.inter.user.UserGoodsStorageService; import com.yeshi.fanli.service.inter.user.UserInfoExtraService; import com.yeshi.fanli.service.inter.user.UserInfoService; import com.yeshi.fanli.util.Constant; import com.yeshi.fanli.util.RedisManager; @@ -233,6 +235,10 @@ @Resource private ShareGoodsActivityOrderService shareGoodsActivityOrderService; @Resource private UserInfoExtraService userInfoExtraService; @RequestMapping(value = "getrecommendsection") public void getRecommendSection(AcceptData acceptData, int index, PrintWriter out) { @@ -2222,7 +2228,7 @@ * @param out */ @RequestMapping(value = "getSpecialActivities") public void getSpecialActivities(AcceptData acceptData, PrintWriter out) { public void getSpecialActivities(AcceptData acceptData, Long uid, PrintWriter out) { System system = systemService.getSystemCache(acceptData.getPlatform(), acceptData.getPackages()); if (system == null) { @@ -2251,6 +2257,20 @@ jumpDetail.setId(null); jumpDetail.setName(null); } // 邀请登陆验证 if(jumpDetail.getType().equals("invite_web") && jumpDetail.getNeedLogin() && uid != null) { UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid); if (userInfoExtra != null && userInfoExtra.getInviteCode() != null && userInfoExtra.getInviteCode().trim().length() > 0) { JSONObject params = new JSONObject(); params.put("url", configService.get("invite_activation_success_url")); special.setParams(params.toString()); } } } } fanli/src/main/java/com/yeshi/fanli/controller/client/UserCouponController.java
@@ -368,6 +368,7 @@ // 奖品 int count = 0; String prize = ""; String hasPrize = ""; Long couponId = null; if (uid == null) { // 未登录 @@ -387,7 +388,7 @@ JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("设备不存在")); return; } int hasPrize = 0; int countPrize = 0; List<DeviceLotteryRecord> list = deviceLotteryRecordService.listByPlatformAndDevice(platformType, device); @@ -395,25 +396,40 @@ JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(2, "抽奖次数不足")); return; } else if (list != null && list.size() < MAX_COUNT) { // 拥有抽奖机会 for (DeviceLotteryRecord deviceLotteryRecord : list) { Long systemCouponId = deviceLotteryRecord.getSystemCouponId(); if (systemCouponId != null) { hasPrize++; countPrize++; couponId = systemCouponId; } if (countPrize == 1) { SystemCoupon coupon = systemCouponService.selectByPrimaryKey(systemCouponId); hasPrize = coupon.getType().name(); } } count = MAX_COUNT - 1 - list.size(); } else { count = MAX_COUNT - 1; } // 奖品 prize = getLotteryPrize(MAX_COUNT, hasPrize, list.size(), couponId); prize = getLotteryPrize(MAX_COUNT, countPrize, list.size(), couponId); // 抽中 Long newCouponId = null; if (prize != null && prize.trim().length() > 0) { SystemCoupon coupon= systemCouponService.getCouponByType(prize); newCouponId =coupon.getId(); // 已存在此券 if (hasPrize.equals(prize)) { prize = null; } else { SystemCoupon coupon= systemCouponService.getCouponByType(prize); newCouponId = coupon.getId(); } } // 插入记录 @@ -442,34 +458,42 @@ List<UserSystemCoupon> list = userSystemCouponService.getUserCouponBySource(uid, UserSystemCoupon.SOURCE_CHOUJIANG); if (list != null && list.size() == 1) { couponId = list.get(0).getSystemCoupon().getId(); SystemCoupon coupon = systemCouponService.selectByPrimaryKey(couponId); hasPrize = coupon.getType().name(); } // 奖品 prize = getLotteryPrize(MAX_COUNT, list.size(), MAX_COUNT- lotteryNewbies, couponId); // 抽中 if (prize != null && prize.trim().length() > 0) { SystemCoupon coupon= systemCouponService.getCouponByType(prize); String endDay = DateUtil.plusDay(coupon.getExpiryDay(), new Date()); SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); Date endTime = format.parse(endDay); if (hasPrize.equals(prize)) { prize = null; } else { int stateActivated = 1; if (coupon.getType() == CouponTypeEnum.welfareFreeCoupon) { stateActivated = 0; SystemCoupon coupon= systemCouponService.getCouponByType(prize); String endDay = DateUtil.plusDay(coupon.getExpiryDay(), new Date()); SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); Date endTime = format.parse(endDay); int stateActivated = 1; if (coupon.getType() == CouponTypeEnum.welfareFreeCoupon) { stateActivated = 0; } UserSystemCoupon userCoupon = new UserSystemCoupon(); userCoupon.setUid(uid); userCoupon.setSource(UserSystemCoupon.SOURCE_CHOUJIANG); userCoupon.setSystemCoupon(coupon); userCoupon.setState(UserSystemCoupon.STATE_CAN_USE); userCoupon.setStateActivated(stateActivated); userCoupon.setStartTime(new Date()); userCoupon.setEndTime(endTime); userCoupon.setCreateTime(new Date()); userCoupon.setUpdateTime(new Date()); userSystemCouponService.insertSelective(userCoupon); } UserSystemCoupon userCoupon = new UserSystemCoupon(); userCoupon.setUid(uid); userCoupon.setSource(UserSystemCoupon.SOURCE_CHOUJIANG); userCoupon.setSystemCoupon(coupon); userCoupon.setState(UserSystemCoupon.STATE_CAN_USE); userCoupon.setStateActivated(stateActivated); userCoupon.setStartTime(new Date()); userCoupon.setEndTime(endTime); userCoupon.setCreateTime(new Date()); userCoupon.setUpdateTime(new Date()); userSystemCouponService.insertSelective(userCoupon); } // 剩余次数 @@ -501,13 +525,13 @@ * @param couponId 券id * @return */ public String getLotteryPrize(int maxCount, int hasPrize, int record, Long couponId) { public String getLotteryPrize(int maxCount, int countPrize, int record, Long couponId) { String prize = null; String freeCoupon = CouponTypeEnum.welfareFreeCoupon.name(); // 福利免费券 String rebateCoupon = CouponTypeEnum.rebatePercentCoupon.name(); // 奖励券 if (hasPrize == 1 && record == maxCount - 1) { if (countPrize == 1 && record == maxCount - 1) { // 最后一次: 只收到一个奖品 SystemCoupon systemCoupon = systemCouponService.selectByPrimaryKey(couponId); if (systemCoupon != null) { @@ -521,7 +545,7 @@ prize = rebateCoupon; // 奖励券 } } else if (hasPrize == 0 && record == maxCount - 2) { } else if (countPrize == 0 && record == maxCount - 2) { // 前3次没有奖励时、后面两次必中 long result = (1 + Math.round(Math.random() * (9))); if (result <= 5) { @@ -532,7 +556,7 @@ } else { // 大于3次机会 if (hasPrize < 2) { // 不足两个奖品 if (countPrize < 2) { // 不足两个奖品 long result = (1 + Math.round(Math.random() * (9))); if (result <= 3) { prize = freeCoupon; // 福利免费券 @@ -545,6 +569,12 @@ return prize; } public static void main(String[] args) { long result = (1 + Math.round(Math.random() * (9))); System.out.println(result); } /** fanli/src/main/java/com/yeshi/fanli/mapping/user/UserSystemCouponMapper.xml
@@ -121,7 +121,7 @@ AND uc.usc_coupon_id in <foreach collection="list" item="item" open="(" close=")" separator=",">#{item}</foreach> ORDER BY uc.`usc_create_time` ORDER BY uc.usc_state_activate, uc.`usc_create_time` </select> </mapper> fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserInfoExtraServiceImpl.java
@@ -392,4 +392,12 @@ return inviteCode; } public void countUserRank() { } } fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserSystemCouponServiceImpl.java
@@ -18,6 +18,7 @@ import com.yeshi.fanli.entity.bus.user.HongBaoV2; import com.yeshi.fanli.entity.bus.user.Order; import com.yeshi.fanli.entity.bus.user.UserInfo; import com.yeshi.fanli.entity.bus.user.UserInfoExtra; import com.yeshi.fanli.entity.bus.user.UserSystemCoupon; import com.yeshi.fanli.entity.bus.user.UserSystemCouponRecord; import com.yeshi.fanli.entity.common.JumpDetailV2; @@ -35,6 +36,7 @@ import com.yeshi.fanli.service.inter.order.HongBaoOrderService; import com.yeshi.fanli.service.inter.order.OrderHongBaoMapService; import com.yeshi.fanli.service.inter.order.OrderService; import com.yeshi.fanli.service.inter.user.UserInfoExtraService; import com.yeshi.fanli.service.inter.user.UserInfoService; import com.yeshi.fanli.service.inter.user.UserMoneyDetailService; import com.yeshi.fanli.service.inter.user.UserSystemCouponRecordService; @@ -90,6 +92,9 @@ @Resource private UserMoneyMsgNotificationService userMoneyMsgNotificationService; @Resource private UserInfoExtraService userInfoExtraService; // 券失效图片 public final static String PIC_INVALID = "http://192.168.1.200/icon/mian_invalid.png"; @@ -143,7 +148,7 @@ } // 数据组织 listDataFactory(listVO); listDataFactory(listVO, uid); return listVO; } @@ -153,7 +158,7 @@ * * @param listVO */ public void listDataFactory(List<UserSystemCouponVO> listVO) throws Exception{ public void listDataFactory(List<UserSystemCouponVO> listVO, Long uid) throws Exception{ for (UserSystemCouponVO userCouponVO : listVO) { @@ -174,21 +179,18 @@ userCouponVO.setCouponEffect(systemCoupon.getEffect()); userCouponVO.setCouponRule(systemCoupon.getRule()); // 使用中状态 改变为已使用 // 使用状态 Integer state = userCouponVO.getState(); if (UserSystemCoupon.STATE_IN_USE == state) { state = UserSystemCoupon.STATE_END_USE; userCouponVO.setState(state); } // 按钮跳转 Map<String, Object> jumpBtn = null; Integer stateActivated = userCouponVO.getStateActivated(); if (stateActivated == null || stateActivated == 0) { // 显示规则 userCouponVO.setCouponRule(systemCoupon.getRemark()); systemCoupon.setEffect("待激活"); userCouponVO.setCouponEffect("待激活"); // 状态未激活 -且未被使用 if (UserSystemCoupon.STATE_CAN_USE == state) { @@ -197,7 +199,17 @@ jumpBtn = new HashMap<String, Object>(); Map<String, Object> jumpLink = new HashMap<String, Object>(); jumpLink.put("url", configService.get("invite_activation_url")); UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid); if (userInfoExtra != null && userInfoExtra.getInviteCode() != null && userInfoExtra.getInviteCode().trim().length() > 0) { jumpLink.put("url", configService.get("invite_activation_success_url" +"?alert=ture")); } else { jumpLink.put("url", configService.get("invite_activation_url")); } jumpBtn.put("params", jumpLink); jumpBtn.put("jumpDetail", jumpDetailV2Service.getByTypeCache("invite")); @@ -220,21 +232,26 @@ jumpBtn.put("jumpDetail", jumpDetailV2Service.getByTypeCache("web")); } else if (CouponTypeEnum.rebatePercentCoupon == type) { // 返利奖励券 // 返利奖励券- 跳转至订单到账界面 jumpLink.put("state", 2); jumpBtn = new HashMap<String, Object>(); jumpBtn.put("params", jumpLink); // 跳转订单列表 jumpBtn.put("jumpDetail", jumpDetailV2Service.getByTypeCache("orderList")); } } else if (UserSystemCoupon.STATE_END_USE == state || UserSystemCoupon.STATE_OVERDUE == state) { userCouponVO.setCouponPicture(PIC_INVALID); } else if (UserSystemCoupon.STATE_IN_USE == state) { // 使用中 userCouponVO.setInUseExplain(configService.get("free_coupon_using-help")); } } // 券失效图片替换 if (UserSystemCoupon.STATE_END_USE == state || UserSystemCoupon.STATE_OVERDUE == state) { userCouponVO.setCouponPicture(PIC_INVALID); } userCouponVO.setJumpBtn(jumpBtn); String couponTerm = "有效期:"; @@ -822,4 +839,6 @@ return userRecordVO; } } fanli/src/main/java/com/yeshi/fanli/vo/user/UserSystemCouponVO.java
@@ -29,11 +29,10 @@ // 有效期 @Expose private String couponTerm; // 有效期 // 使用中说明 @Expose private String couponState; private String inUseExplain; // 跳转按钮 @Expose private Map<String, Object> jumpBtn; @@ -105,5 +104,13 @@ public void setJumpBtn(Map<String, Object> jumpBtn) { this.jumpBtn = jumpBtn; } public String getInUseExplain() { return inUseExplain; } public void setInUseExplain(String inUseExplain) { this.inUseExplain = inUseExplain; } }