fanli/src/main/java/com/yeshi/fanli/controller/apph5/AppH5QualityGoodsController.java
@@ -27,6 +27,7 @@ import com.yeshi.fanli.exception.taobao.TaoKeApiException; import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException; import com.yeshi.fanli.log.LogHelper; import com.yeshi.fanli.service.inter.config.ConfigService; import com.yeshi.fanli.service.inter.config.SystemService; import com.yeshi.fanli.service.inter.goods.CollectionGoodsV2Service; import com.yeshi.fanli.service.inter.goods.GoodsClassService; @@ -89,6 +90,10 @@ @Resource private HongBaoManageService hongBaoManageService; @Resource private ConfigService configService; /** * 9.9商品 @@ -1222,10 +1227,18 @@ long count = qualityGoodsService.countFreeGoods(tkRate, lableName); JSONObject data = new JSONObject(); if (page == 1) { // 抽奖规则 String rules = configService.get("free_goods_rule"); data.put("ruleLink", rules); } data.put("count", count); data.put("result_list", array); JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); } catch (Exception e) { fanli/src/main/java/com/yeshi/fanli/controller/client/UserAccountController.java
@@ -53,10 +53,12 @@ import com.yeshi.fanli.service.inter.user.UserAccountService; import com.yeshi.fanli.service.inter.user.UserInfoService; import com.yeshi.fanli.service.inter.user.UserShareGoodsRecordService; import com.yeshi.fanli.service.inter.user.UserSystemCouponService; import com.yeshi.fanli.util.Constant; import com.yeshi.fanli.util.GsonUtil; import com.yeshi.fanli.util.RedisManager; import com.yeshi.fanli.util.StringUtil; import com.yeshi.fanli.util.ThreadUtil; import com.yeshi.fanli.util.account.UserUtil; import com.yeshi.fanli.util.wx.WXLoginUtil; @@ -143,6 +145,9 @@ @Resource private ForbiddenUserIdentifyCodeService forbiddenUserIdentifyCodeService; @Resource private UserSystemCouponService userSystemCouponService; private static final String PASSWORD_MAX_ERROR = "password_max_error"; private static final String EXTRACT_MIN_MONEY = "extract_min_money"; @@ -226,6 +231,25 @@ root.put("type", result.getType()); root.put("data", data); out.print(JsonUtil.loadTrueResult(root)); final UserInfo uuser = result.getUser(); ThreadUtil.run(new Runnable() { public void run() { try { int platformType = 0; String platform = acceptData.getPlatform(); if ("android".equals(platform)) { platformType = 1; } else if ("ios".equals(platform)) { platformType = 2; } userSystemCouponService.copyLotteryPrize(uuser.getId(), platformType, acceptData.getDevice()); } catch (Exception e) { e.printStackTrace(); } } }); } catch (UserAccountException e) { try { LogHelper.cookieLog("登录出错:" + e.getCode() + "-" + e.getMessage()); @@ -234,6 +258,7 @@ } out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMsg())); } } /** fanli/src/main/java/com/yeshi/fanli/controller/client/UserCouponController.java
@@ -80,8 +80,6 @@ @Resource private ThreeSaleSerivce threeSaleSerivce; // 最大抽奖次数 private static int MAX_COUNT = 5; /** * 用户券列表查询 @@ -462,10 +460,10 @@ List<DeviceLotteryRecord> list = deviceLotteryRecordService.listByPlatformAndDevice(platformType, device); if (list != null && list.size() == MAX_COUNT) { // 无抽奖机会 if (list != null && list.size() == Constant.MAX_COUNT_LOTTERY_NEWBIES) { // 无抽奖机会 JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(2, "抽奖次数不足")); return; } else if (list != null && list.size() < MAX_COUNT) { // 拥有抽奖机会 } else if (list != null && list.size() < Constant.MAX_COUNT_LOTTERY_NEWBIES) { // 拥有抽奖机会 for (DeviceLotteryRecord deviceLotteryRecord : list) { Long systemCouponId = deviceLotteryRecord.getSystemCouponId(); @@ -481,14 +479,14 @@ hasPrize = coupon.getType().name(); } count = MAX_COUNT - 1 - list.size(); count = Constant.MAX_COUNT_LOTTERY_NEWBIES - 1 - list.size(); } else { count = MAX_COUNT - 1; count = Constant.MAX_COUNT_LOTTERY_NEWBIES - 1; } // 奖品 prize = getLotteryPrize(MAX_COUNT, countPrize, list.size(), couponId); prize = getLotteryPrize(Constant.MAX_COUNT_LOTTERY_NEWBIES, countPrize, list.size(), couponId); // 抽中 Long newCouponId = null; if (prize != null && prize.trim().length() > 0) { @@ -533,7 +531,7 @@ } // 奖品 prize = getLotteryPrize(MAX_COUNT, list.size(), MAX_COUNT - lotteryNewbies, couponId); prize = getLotteryPrize(Constant.MAX_COUNT_LOTTERY_NEWBIES, list.size(), Constant.MAX_COUNT_LOTTERY_NEWBIES - lotteryNewbies, couponId); // 抽中 if (prize != null && prize.trim().length() > 0) { fanli/src/main/java/com/yeshi/fanli/service/impl/hongbao/ThreeSaleSerivceImpl.java
@@ -665,6 +665,9 @@ threeSaleMapper.deleteExpireRecord(inviter.getId(), invitee.getId()); } //添加到队列 ThreeSaleCMQManager.getInstance().addThreeSaleMsg(threeSale); // 邀请消息 userInviteMsgNotificationService.inviteSuccess(inviter.getId(), threeSale); } fanli/src/main/java/com/yeshi/fanli/service/impl/user/DeviceLotteryRecordServiceImpl.java
@@ -18,6 +18,11 @@ @Override public int deleteByPrimaryKey(Long id) { return reviceLotteryRecordMapper.deleteByPrimaryKey(id); } @Override public int insertSelective(DeviceLotteryRecord record) { return reviceLotteryRecordMapper.insertSelective(record); } fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserSystemCouponServiceImpl.java
@@ -15,8 +15,10 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.yeshi.utils.DateUtil; import org.yeshi.utils.JsonUtil; import com.yeshi.fanli.dao.mybatis.user.UserSystemCouponMapper; import com.yeshi.fanli.entity.bus.user.DeviceLotteryRecord; import com.yeshi.fanli.entity.bus.user.HongBaoV2; import com.yeshi.fanli.entity.bus.user.Order; import com.yeshi.fanli.entity.bus.user.UserInfo; @@ -39,10 +41,12 @@ import com.yeshi.fanli.service.inter.hongbao.ThreeSaleSerivce; import com.yeshi.fanli.service.inter.msg.UserMoneyMsgNotificationService; import com.yeshi.fanli.service.inter.msg.UserOtherMsgNotificationService; import com.yeshi.fanli.service.inter.order.CommonOrderCountService; import com.yeshi.fanli.service.inter.order.CommonOrderService; 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.DeviceLotteryRecordService; import com.yeshi.fanli.service.inter.user.UserInfoExtraService; import com.yeshi.fanli.service.inter.user.UserInfoService; import com.yeshi.fanli.service.inter.user.UserMoneyDetailService; @@ -117,6 +121,11 @@ @Resource private UserOtherMsgNotificationService userOtherMsgNotificationService; @Resource private DeviceLotteryRecordService deviceLotteryRecordService; @Resource private CommonOrderCountService commonOrderCountService; @Override public int insertSelective(UserSystemCoupon record) { @@ -154,7 +163,8 @@ } @Override public void insertUserCoupon(Long uid, String couponType,String source)throws UserSystemCouponException,Exception{ @Transactional public void insertUserCoupon(Long uid, String couponType, String source)throws UserSystemCouponException,Exception{ if (couponType == null || uid == null) { throw new UserSystemCouponException(1, "参数不正确"); @@ -1044,6 +1054,9 @@ return; } // 验证是否失效 updateCounponInvalid(uid); // 待活福利免单券 List<UserSystemCoupon> list = userSystemCouponMapper.getCouponByTypeAndNotActivated(uid, systemCoupon.getId()); if (list == null || list.size() == 0) { @@ -1056,9 +1069,14 @@ userSystemCoupon.setUpdateTime(new Date()); userSystemCouponMapper.updateByPrimaryKeySelective(userSystemCoupon); Integer state = userSystemCoupon.getState(); if (UserSystemCoupon.STATE_OVERDUE == state) { continue; // 已失效不做消息推送 } // 消息推送 try { userOtherMsgNotificationService.welfareCouponGet(userSystemCoupon); userOtherMsgNotificationService.welfareCouponActive(userSystemCoupon, new UserInfo(uid)); } catch(Exception e) { try { LogHelper.errorDetailInfo(e); @@ -1325,5 +1343,114 @@ } @Override @Transactional public void copyLotteryPrize(Long uid, int platform, String device) throws Exception { if (uid == null || device == null) { return; } // 未登陆之前抽奖记录 List<DeviceLotteryRecord> list = deviceLotteryRecordService.listByPlatformAndDevice(platform, device); if (list == null || list.size() == 0) { return; } // 获取额外信息 UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid); if (userInfoExtra != null && userInfoExtra.getLotteryNewbies() != null) { return; } // 是否有过订单:返利、分享订单 boolean hasOrder = commonOrderCountService.hasRebateAndShareOrder(uid); if (hasOrder) { return; } int coupon = 0; for (DeviceLotteryRecord reviceLotteryRecord: list) { // 删除记录 deviceLotteryRecordService.deleteByPrimaryKey(reviceLotteryRecord.getId()); Long systemCouponId = reviceLotteryRecord.getSystemCouponId(); if (systemCouponId == null) { continue; } SystemCoupon systemCoupon = systemCouponService.selectByPrimaryKey(systemCouponId); if (systemCoupon == null) { continue; } int stateActivated = 1; if (systemCoupon.getType() == CouponTypeEnum.welfareFreeCoupon) { // 福利券状态 long countSuccess = threeSaleSerivce.countSuccessFirstTeam(uid); // 没有下级队员 --待激活 if (countSuccess == 0) { stateActivated = 0; } } // 结束日期 String endDay = DateUtil.plusDay(systemCoupon.getExpiryDay(), new Date()); SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); Date endTime = format.parse(endDay); UserSystemCoupon userCoupon = new UserSystemCoupon(); userCoupon.setUid(uid); userCoupon.setSource(UserSystemCoupon.SOURCE_CHOUJIANG); userCoupon.setSystemCoupon(systemCoupon); userCoupon.setState(UserSystemCoupon.STATE_CAN_USE); userCoupon.setStateActivated(stateActivated); userCoupon.setStartTime(new Date()); userCoupon.setEndTime(endTime); userCoupon.setCreateTime(new Date()); userCoupon.setUpdateTime(new Date()); // 插入数据库 insertSelective(userCoupon); // 券数量 coupon ++; // 消息推送 try { if (systemCoupon.getType() == CouponTypeEnum.welfareFreeCoupon) { userOtherMsgNotificationService.welfareCouponGet(userCoupon); } else if (systemCoupon.getType() == CouponTypeEnum.freeCoupon) { userOtherMsgNotificationService.freeSheetCouponGet(userCoupon); } else if (systemCoupon.getType() == CouponTypeEnum.rebatePercentCoupon) { userOtherMsgNotificationService.rewardCouponGet(userCoupon,systemCoupon.getPercent().intValue()); } } catch(Exception e) { try { LogHelper.errorDetailInfo(e); } catch (Exception e1) { e1.printStackTrace(); } } } if(userInfoExtra == null) { userInfoExtra = new UserInfoExtra(); userInfoExtra.setUserInfo(new UserInfo(uid)); } userInfoExtra.setLotteryNewbies(Constant.MAX_COUNT_LOTTERY_NEWBIES-list.size()); Integer couponNews = userInfoExtra.getCouponNews(); if (couponNews == null) { userInfoExtra.setCouponNews(coupon); } else { userInfoExtra.setCouponNews(couponNews + coupon); } userInfoExtraService.saveUserInfoExtra(userInfoExtra); } } fanli/src/main/java/com/yeshi/fanli/service/inter/user/DeviceLotteryRecordService.java
@@ -15,5 +15,7 @@ public int updateByPrimaryKey(DeviceLotteryRecord record); public List<DeviceLotteryRecord> listByPlatformAndDevice(int platform, String device); public int deleteByPrimaryKey(Long id); } fanli/src/main/java/com/yeshi/fanli/service/inter/user/UserSystemCouponService.java
@@ -176,5 +176,14 @@ * @throws Exception */ public void updateStateByArrivalAccount(String orderNo) throws Exception; /** * 领取未登录时已抽奖的礼品 * @param uid * @param platform * @param device * @throws Exception */ public void copyLotteryPrize(Long uid, int platform, String device) throws Exception; } fanli/src/main/java/com/yeshi/fanli/util/Constant.java
@@ -161,6 +161,10 @@ // public static final String TAOKE_ANDROID_APPKEY = "24587154"; // public static final String TAOKE_IOS_APPKEY = "24838852"; // 新人抽奖-最大次数 public static final int MAX_COUNT_LOTTERY_NEWBIES = 5; static { if (smsConfig == null) {