| | |
| | | import org.yeshi.utils.DateUtil;
|
| | | import org.yeshi.utils.JsonUtil;
|
| | |
|
| | | import com.yeshi.fanli.dto.user.UserInviteLevelEnum;
|
| | | import com.yeshi.fanli.dto.vip.UserVIPLevel;
|
| | | import com.yeshi.fanli.dto.wx.WXAccountInfoDTO;
|
| | | import com.yeshi.fanli.entity.accept.AcceptData;
|
| | | import com.yeshi.fanli.entity.bus.msg.UserSystemMsg;
|
| | |
| | | import com.yeshi.fanli.entity.bus.user.UserInfo;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfoExtra;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInviteSeparate;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInviteValidRecord;
|
| | | import com.yeshi.fanli.entity.bus.user.WeiXinUser;
|
| | | import com.yeshi.fanli.entity.system.BusinessSystem;
|
| | | import com.yeshi.fanli.entity.system.ConfigKeyEnum;
|
| | |
| | | import com.yeshi.fanli.service.inter.user.UserInviteSeparateService;
|
| | | import com.yeshi.fanli.service.inter.user.invite.ThreeSaleExtraInfoSerivce;
|
| | | import com.yeshi.fanli.service.inter.user.invite.ThreeSaleSerivce;
|
| | | import com.yeshi.fanli.service.inter.user.invite.UserInviteService;
|
| | | import com.yeshi.fanli.service.inter.user.invite.UserInviteValidRecordService;
|
| | | import com.yeshi.fanli.service.inter.user.vip.UserVIPInfoService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.RedisKeyEnum;
|
| | | import com.yeshi.fanli.util.RedisManager;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.TimeUtil;
|
| | | import com.yeshi.fanli.util.VersionUtil;
|
| | | import com.yeshi.fanli.util.annotation.RequestSerializableByKey;
|
| | | import com.yeshi.fanli.util.wx.WXLoginUtil;
|
| | |
| | |
|
| | | @Resource
|
| | | private SystemClientParamsService systemClientParamsService;
|
| | | |
| | | @Resource
|
| | | private UserInviteService userInviteService;
|
| | | |
| | | @Resource
|
| | | private UserInviteValidRecordService userInviteValidRecordService;
|
| | |
|
| | |
|
| | |
|
| | |
| | | out.print(JsonUtil.loadFalseResult("粉丝类型不正确"));
|
| | | return;
|
| | | }
|
| | | |
| | | if (VersionUtil.greaterThan_2_1(acceptData.getPlatform(), acceptData.getVersion())) {
|
| | | getMyTeamNew(acceptData, page, uid, type, out);
|
| | | return;
|
| | | }
|
| | |
|
| | | long count = 0;
|
| | | List<ThreeSale> listTeam = null;
|
| | |
| | | UserInviteSeparate separate = userInviteSeparateService.selectByWorkerIdAndBossId(worker.getId(), uid);
|
| | | if (separate != null && separate.getEndTime() != null) {
|
| | | try {
|
| | | |
| | | |
| | | JSONObject contentJson1 = new JSONObject();
|
| | | contentJson1.put("color", "#888888");
|
| | | contentJson1.put("content", "将于");
|
| | |
| | | array.add(contentJson2);
|
| | | array.add(contentJson3);
|
| | | object.put("vipBreakTime",array);
|
| | | |
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
| | | return result;
|
| | | }
|
| | |
|
| | | |
| | | private void getMyTeamNew(AcceptData acceptData, long page, long uid, int type, PrintWriter out) {
|
| | | if (type != 1 && type != 2) {
|
| | | out.print(JsonUtil.loadFalseResult("粉丝类型不正确"));
|
| | | return;
|
| | | }
|
| | |
|
| | | long count = 0;
|
| | | List<ThreeSale> listTeam = null;
|
| | | if (type == 1) {
|
| | | listTeam = threeSaleSerivce.listFirstTeamByUndeleted((page - 1) * Constant.PAGE_SIZE, Constant.PAGE_SIZE, uid);
|
| | | count = threeSaleSerivce.countFirstTeamByUndeleted(uid);
|
| | | } else if (type == 2) {
|
| | | listTeam = threeSaleSerivce.listSecondTeamByUndeleted((page - 1) * Constant.PAGE_SIZE, Constant.PAGE_SIZE, uid);
|
| | | count = threeSaleSerivce.countSecondTeamByUndeleted(uid);
|
| | | }
|
| | |
|
| | | JSONObject result = new JSONObject();
|
| | | result.put("count", count);
|
| | | result.put("list", organizeTeamNew(count, listTeam, uid, type, true));
|
| | | |
| | | // 第一页判断是否激活 是否有队员
|
| | | if (type == 1 && page == 1) {
|
| | | boolean hasCode = false;
|
| | | UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid);
|
| | | if (userInfoExtra != null) {
|
| | | if (!StringUtil.isNullOrEmpty(userInfoExtra.getInviteCode()))
|
| | | hasCode = true;
|
| | | }
|
| | | result.put("hasCode", hasCode);
|
| | | result.put("hasTeam", count > 0 ? true : false);
|
| | | }
|
| | | out.print(JsonUtil.loadTrueResult(result));
|
| | | }
|
| | | |
| | | /**
|
| | | * 加工数据
|
| | | * @param count
|
| | | * @param list
|
| | | * @param uid
|
| | | * @param type 查询粉丝类型 1直接 2间接
|
| | | * @param wxtip 是需要微信提示
|
| | | * @return
|
| | | */
|
| | | private JSONArray organizeTeamNew(long count, List<ThreeSale> list, Long uid, int type, boolean wxtip) {
|
| | | JSONArray resultArray = new JSONArray();
|
| | | if (list == null || list.size() == 0) {
|
| | | return resultArray;
|
| | | }
|
| | |
|
| | | Date todayTime = new Date();
|
| | | SimpleDateFormat sdf = new SimpleDateFormat("MM.dd HH:mm");
|
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy.MM.dd HH:mm");
|
| | | SimpleDateFormat formatYears = new SimpleDateFormat("yyyy");
|
| | |
|
| | | List<Long> listWid = new ArrayList<>();
|
| | | for (ThreeSale threeSale : list) {
|
| | | listWid.add(threeSale.getWorker().getId());
|
| | | }
|
| | | |
| | | // 查询有效粉丝id
|
| | | int validType = UserInviteValidRecord.TYPE_TWO;
|
| | | if (type == 1) {
|
| | | validType = UserInviteValidRecord.TYPE_ONE;
|
| | | }
|
| | | List<Long> listVid = userInviteValidRecordService.getValidWorkerIdsByUid(uid, listWid, validType);
|
| | | |
| | | for (ThreeSale threeSale : list) {
|
| | | UserInfo worker = threeSale.getWorker();
|
| | | Long workerId = worker.getId();
|
| | |
|
| | | // 邀请状态
|
| | | Boolean state = threeSale.getState();
|
| | | if (type == 2) {
|
| | | if (state && threeSale.getStateSuper()) {
|
| | | state = true;
|
| | | } else {
|
| | | state = false;
|
| | | }
|
| | | }
|
| | | |
| | | |
| | | // 邀请成功时间
|
| | | Long succeedTime = threeSale.getSucceedTime(); |
| | | if (succeedTime == null) {
|
| | | succeedTime = threeSale.getCreateTime();
|
| | | }
|
| | | |
| | | // 有效粉丝
|
| | | boolean validFans = false; |
| | | if (state && listVid != null && listVid.size() > 0 && listVid.contains(workerId)) {
|
| | | validFans = true;
|
| | | }
|
| | | |
| | | // 最近登录时间
|
| | | Date lastLoginTime = new Date(threeSale.getCreateTime());
|
| | | UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(workerId);
|
| | | if (userInfoExtra != null && userInfoExtra.getActiveTime() != null) {
|
| | | lastLoginTime = userInfoExtra.getActiveTime();
|
| | | } |
| | | JSONObject loginJson = new JSONObject();
|
| | | if (formatYears.format(todayTime).equals(formatYears.format(lastLoginTime))) {
|
| | | loginJson.put("content", "最近登录 " + sdf.format(lastLoginTime)); // 本年
|
| | | } else {
|
| | | loginJson.put("content", "最近登录 " + format.format(lastLoginTime)); // 往年
|
| | | }
|
| | | loginJson.put("color", "#888888");
|
| | | |
| | | JSONArray array = new JSONArray();
|
| | | array.add(loginJson);
|
| | |
|
| | | // 等级
|
| | | UserInviteLevelEnum level = null;
|
| | | UserVIPLevel vipLevel = userInviteService.getVIPLevelByUid(uid);
|
| | | if (vipLevel != null) {
|
| | | if (vipLevel.getLevel() == UserVIPLevel.LEVEL_3) {
|
| | | level = UserInviteLevelEnum.actived;
|
| | | } else if (vipLevel.getLevel() == UserVIPLevel.LEVEL_7) {
|
| | | level = UserInviteLevelEnum.actived;
|
| | | } else if (vipLevel.getLevel() == UserVIPLevel.LEVEL_10) {
|
| | | level = UserInviteLevelEnum.actived;
|
| | | }
|
| | | }
|
| | | |
| | | if(level == null) {
|
| | | if (userInfoExtra == null || StringUtil.isNullOrEmpty(userInfoExtra.getInviteCode())) {
|
| | | level = UserInviteLevelEnum.noActive;
|
| | | } else {
|
| | | level = UserInviteLevelEnum.actived;
|
| | | }
|
| | | }
|
| | | |
| | | |
| | | JSONObject object = new JSONObject();
|
| | | object.put("workerId", workerId);
|
| | | object.put("nickName", worker.getNickName());
|
| | | object.put("portrait", worker.getPortrait());
|
| | | object.put("inviteId", threeSale.getId());
|
| | | object.put("inviteTime", format.format(new Date(succeedTime)) + " 加入");
|
| | | object.put("state", state? 1 : 2);
|
| | | object.put("recentMsg", array);
|
| | | object.put("level", level.name());
|
| | | object.put("validFans", validFans);
|
| | | |
| | | |
| | | // 判断是否存在脱离关系队员
|
| | | if (vipLevel != null) {
|
| | | UserInviteSeparate separate = userInviteSeparateService.selectByWorkerIdAndBossId(workerId, uid);
|
| | | if (separate != null && separate.getEndTime() != null) {
|
| | | try {
|
| | | JSONObject contentJson1 = new JSONObject();
|
| | | contentJson1.put("color", "#888888");
|
| | | contentJson1.put("content", "将于");
|
| | |
|
| | | String dateDiff = DateUtil.dateDiff4(new Date(), separate.getEndTime());
|
| | | JSONObject contentJson2 = new JSONObject();
|
| | | contentJson2.put("color", "#F14242");
|
| | | contentJson2.put("content", dateDiff);
|
| | |
|
| | | JSONObject contentJson3 = new JSONObject();
|
| | | contentJson3.put("color", "#888888");
|
| | | contentJson3.put("content", "后脱离邀请关系");
|
| | | |
| | | JSONArray vipBreak = new JSONArray();
|
| | | vipBreak.add(contentJson1);
|
| | | vipBreak.add(contentJson2);
|
| | | vipBreak.add(contentJson3);
|
| | | object.put("vipBreakTime",vipBreak);
|
| | | |
| | | List<String> tips = new ArrayList<String>();
|
| | | tips.add("于"+ TimeUtil.formatDateDot(vipLevel.getSuccessTime()) + "升级为" + level.getName());
|
| | | if (type == 1) {
|
| | | tips.add("你需要在"+ dateDiff +"内升级为会员,否则按照邀请规则TA将与你脱离邀请关系。");
|
| | | tips.add("赶快加油升级为会员吧!");
|
| | | } else {
|
| | | tips.add("你需要辅助TA的邀请人"+ threeSale.getBoss().getNickName()+ "在"+dateDiff+"内升级为会员,否则这位间接粉丝" +worker.getNickName()+"将与你脱离邀请关系。");
|
| | | tips.add("赶快帮助TA升级为会员吧!");
|
| | | }
|
| | | object.put("vipBreakTip",tips);
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | }
|
| | | |
| | | |
| | | if (wxtip && type == 1 && threeSale.getState() != null && threeSale.getState()) {
|
| | | // 一级队员 查询昵称备注
|
| | | String memoName = null;
|
| | | ThreeSaleExtraInfo threeSaleExtraInfo = threeSale.getThreeSaleExtraInfo();
|
| | | if (threeSaleExtraInfo != null) {
|
| | | if (!StringUtil.isNullOrEmpty(threeSaleExtraInfo.getNickname())) {
|
| | | memoName = threeSaleExtraInfo.getNickname();
|
| | | }
|
| | | }
|
| | | object.put("memoName", memoName);
|
| | | |
| | | // 添加微信信息
|
| | | if (userInfoExtra != null && !StringUtil.isNullOrEmpty(userInfoExtra.getWeiXin())) {
|
| | | object.put("weiXin", userInfoExtra.getWeiXin());
|
| | | object.put("weiXinState", 3);
|
| | | object.put("weiXinTip", "添加TA的微信,你可教授TA如何通过板栗快省赚钱技巧。");
|
| | | } else {
|
| | | if (!threeSaleExtraInfoSerivce.isRemindWorker(uid, workerId)) {
|
| | | object.put("weiXinState", 1);
|
| | | object.put("weiXinTip", "点击提醒TA,系统会发送一封站内信,提醒其添加微信号。");
|
| | | } else {
|
| | | object.put("weiXinState", 2);
|
| | | object.put("weiXinTip", "系统已发送提醒,邀请人添加微信后你可复制,如对方迟迟不添加,你可联系人工客服寻求帮助");
|
| | | }
|
| | | }
|
| | | }
|
| | | |
| | | resultArray.add(object);
|
| | | }
|
| | | return resultArray;
|
| | | }
|
| | | |
| | | |
| | | /**
|
| | | * 查看下级的直接粉丝
|
| | | * @param acceptData
|
| | | * @param page
|
| | | * @param uid 当前UId
|
| | | * @param tid 下级UId
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getOthersTeam", method = RequestMethod.POST)
|
| | | public void getOthersTeam(AcceptData acceptData, long page, Long uid, Long tid, PrintWriter out) {
|
| | | if (tid == null) {
|
| | | out.print(JsonUtil.loadFalseResult("传递参数不正确"));
|
| | | return;
|
| | | }
|
| | | |
| | | List<ThreeSale> listTeam = threeSaleSerivce.listFirstTeam((page - 1) * Constant.PAGE_SIZE, Constant.PAGE_SIZE, tid, 1);
|
| | | long count = threeSaleSerivce.countFirstTeam(tid, 1);
|
| | |
|
| | | JSONObject result = new JSONObject();
|
| | | result.put("count", count);
|
| | | result.put("list", organizeTeamNew(count, listTeam, tid, 1, false));
|
| | | out.print(JsonUtil.loadTrueResult(result));
|
| | | }
|
| | | |
| | | |
| | | /**
|
| | | * 用户队员统计- IOS
|
| | | *
|
| | |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "用户未登录"));
|
| | | return;
|
| | | }
|
| | |
|
| | | UserInfo userInfo = userInfoService.selectByPKey(uid);
|
| | | if (userInfo == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "该用户不存在"));
|
| | | return;
|
| | | }
|
| | |
|
| | | // 省钱 -自购产生返利
|
| | |
|
| | | List<Integer> list = new ArrayList<Integer>();
|
| | | list.add(BanLiShopOrder.STATE_SUCCESS);
|
| | | BigDecimal payMoney = new BigDecimal(userVipConfigService.getValueByKey("require_order_pay"));
|
| | |
|
| | | BigDecimal finishGoldCoin = integralDetailService.getCumulativeMoney(uid);
|
| | |
|
| | | // long finishTeam = hongBaoV2CountService.countValidOrderTeamUserByUid(uid,
|
| | | // TimeUtil.convertDateToTemp(Constant.VIP_ONLINE_TIME), payMoney);
|
| | | // |
| | | long finishTeam = 0L;
|
| | | long vipBegin = TimeUtil.convertDateToTemp(Constant.VIP_ONLINE_TIME);
|
| | | List<ThreeSale> listThreeSale = threeSaleSerivce.getValidWorkerIdsByTime(uid, vipBegin);
|
| | | if (listThreeSale != null && listThreeSale.size() > 0) {
|
| | | for (ThreeSale three: listThreeSale) {
|
| | | UserInfo worker = three.getWorker();
|
| | | if (worker == null || worker.getId() == null) {
|
| | | continue;
|
| | | }
|
| | | // 1、邀请关系成功后;2、单(分享 + 自购)实付款大于1元
|
| | | long countValid = hongBaoV2CountService.countValidOrderByUidAndTime(worker.getId(), three.getSucceedTime(), payMoney);
|
| | | if (countValid > 0) {
|
| | | finishTeam ++;
|
| | | }
|
| | | }
|
| | | }
|
| | | |
| | | long finishHongBao = banLiShopOrderService.countByUidAndState(uid, list);
|
| | | BigDecimal finishMoney = hongBaoV2CountService.getRewardMoneyBySelf(uid);
|
| | |
|
| | | long limitTeam = 0;
|
| | |
|
| | | // 区分老用户和新用户
|
| | | String limtDate = userVipConfigService.getValueByKey("vip_execute_time");
|
| | | Date executeDate = null;
|
| | | try {
|
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy-mm-dd");
|
| | | executeDate = format.parse(limtDate);
|
| | | } catch (ParseException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | UserInfoExtra extra = userInfoExtraService.getUserInfoExtra(uid);
|
| | | if (extra != null
|
| | | && (extra.getFirstLoginTime() == null || extra.getFirstLoginTime().getTime() < executeDate.getTime())) {
|
| | | limitTeam = (Long.parseLong(userVipConfigService.getValueByKey("require_invite_num_old_user")));
|
| | | } else {
|
| | | limitTeam = (Long.parseLong(userVipConfigService.getValueByKey("require_invite_num_new_user")));
|
| | | }
|
| | | long limitHongBao = (Long.parseLong(userVipConfigService.getValueByKey("require_shop_buy")));
|
| | | BigDecimal limitMoney = (new BigDecimal(userVipConfigService.getValueByKey("require_fan_money")));
|
| | | BigDecimal limitgoldCoin = (new BigDecimal(userVipConfigService.getValueByKey("require_gold_coin")));
|
| | |
|
| | | if (finishGoldCoin.compareTo(limitgoldCoin) >= 0 && finishTeam >= limitTeam && finishHongBao >= limitHongBao
|
| | | && finishMoney.compareTo(limitMoney) >= 0) {// 条件符合
|
| | | ;
|
| | | } else {
|
| | | if (!StringUtil.isNullOrEmpty(callback)) {
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("未达到开通条件")));
|
| | | } else {
|
| | | out.print(JsonUtil.loadFalseResult("未达到开通条件"));
|
| | | }
|
| | | return;
|
| | | }
|
| | | // 开通
|
| | | try {
|
| | | userVIPInfoService.applyVIP(uid);
|
| | | } catch (UserVIPInfoException e) {
|
| | |
| | | }
|
| | |
|
| | | if (!StringUtil.isNullOrEmpty(callback)) {
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult("")));
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult("申请成功,正在受理中")));
|
| | | } else {
|
| | | out.print(JsonUtil.loadTrueResult(""));
|
| | | out.print(JsonUtil.loadTrueResult("申请成功,正在受理中"));
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | long limitShare = 0;
|
| | | long limitFirst = 0;
|
| | | long limitSecond = 0;
|
| | | String school = "板栗学院";
|
| | | String platformSubsidy = "补贴返佣 ";
|
| | | String teamSubsidy = "会员专属";
|
| | | String teamReward = "超级会员专属";
|
| | | if (level == UserInviteLevelEnum.actived || level == UserInviteLevelEnum.noActive) {
|
| | | // TODO 比例
|
| | | school += "达人班";
|
| | | platformSubsidy += "<label style=\"color:#E5005C;\">52.5%</label>";
|
| | | |
| | | |
| | | String zigou = userVipConfigService.getValueByKey("vip_pre_3_zigou_order_count");
|
| | | if (!StringUtil.isNullOrEmpty(zigou)) {
|
| | | limitZiGou = Long.parseLong(zigou);
|
| | |
| | | limitSecond = Long.parseLong(second);
|
| | | }
|
| | | } else if (level == UserInviteLevelEnum.vipPre1) {
|
| | | |
| | | // TODO 比例
|
| | | school += "普通班";
|
| | | platformSubsidy += "<label style=\"color:#E5005C;\">60%</label>";
|
| | | teamSubsidy = "会员专属最高<label style=\"color:#E5005C;\">7.5%</label>";
|
| | | |
| | | |
| | | String zigou = userVipConfigService.getValueByKey("vip_pre_7_zigou_order_count");
|
| | | if (!StringUtil.isNullOrEmpty(zigou)) {
|
| | | limitZiGou = Long.parseLong(zigou);
|
| | |
| | | limitSecond = Long.parseLong(second);
|
| | | }
|
| | | } else if (level == UserInviteLevelEnum.vipPre2 || level == UserInviteLevelEnum.vipApply) {
|
| | | school += "高级班";
|
| | | platformSubsidy += "<label style=\"color:#E5005C;\">70%</label>";
|
| | | teamSubsidy = "会员专属最高<label style=\"color:#E5005C;\">15%</label>";
|
| | | |
| | | String zigou = userVipConfigService.getValueByKey("vip_pre_10_zigou_order_count");
|
| | | if (!StringUtil.isNullOrEmpty(zigou)) {
|
| | | limitZiGou = Long.parseLong(zigou);
|
| | |
| | | }
|
| | | } else if (level == UserInviteLevelEnum.vip || level == UserInviteLevelEnum.tearcherApply) {
|
| | | // TODO 比例
|
| | | school += "超级班";
|
| | | platformSubsidy += "<label style=\"color:#E5005C;\">115%</label>";
|
| | | teamSubsidy = "会员专属最高<label style=\"color:#E5005C;\">22.5%</label>";
|
| | | teamReward = "超级会员专属最高<label style=\"color:#E5005C;\">40%</label>";
|
| | |
|
| | | } else if (level == UserInviteLevelEnum.tearcher) {
|
| | | // TODO
|
| | | }
|
| | |
|
| | | // 邀请订单
|
| | | // 自购订单
|
| | | long doneZiGou = hongBaoV2CountService.counOrderByUidAndOrderType(uid, Constant.VIP_ORDER_PAY,
|
| | | HongBaoV2.TYPE_ZIGOU);
|
| | | // 邀请订单
|
| | | // 分享订单
|
| | | long doneShare = hongBaoV2CountService.counOrderByUidAndOrderType(uid, Constant.VIP_ORDER_PAY,
|
| | | HongBaoV2.TYPE_SHARE_GOODS);
|
| | |
|
| | |
| | | typeList.add(UserMoneyDetailTypeEnum.systemEqualize);
|
| | | typeList.add(UserMoneyDetailTypeEnum.subsidy);
|
| | | BigDecimal earnMoney = userMoneyDetailService.statisticUserTypeMoneyWithDate(uid, typeList, start, now).abs();
|
| | | |
| | | if (level != UserInviteLevelEnum.vip) {
|
| | | BigDecimal rate = new BigDecimal("0.409");
|
| | | saveMoney = MoneyBigDecimalUtil.mul2(saveMoney, rate);
|
| | | earnMoney = MoneyBigDecimalUtil.mul2(earnMoney, rate);
|
| | | }
|
| | | |
| | | String school = "板栗学院";
|
| | | String platformSubsidy = "补贴返佣 ";
|
| | | String teamSubsidy = "会员专属";
|
| | | String teamReward = "超级会员专属";
|
| | | |
| | | // 达人版
|
| | | JSONObject jsonrRed1 = new JSONObject();
|
| | | jsonrRed1.put("platformSubsidy", platformSubsidy + "<label style=\"color:#E5005C;\">52.5%</label>");
|
| | | jsonrRed1.put("school", school + "<label style=\"color:#E5005C;\">达人班</label>");
|
| | | jsonrRed1.put("teamSubsidy", teamSubsidy);
|
| | | jsonrRed1.put("teamReward", teamReward);
|
| | | |
| | | |
| | | JSONObject jsonrRed2 = new JSONObject();
|
| | | jsonrRed2.put("platformSubsidy", platformSubsidy + "<label style=\"color:#E5005C;\">60%</label>");
|
| | | jsonrRed2.put("school", school + "<label style=\"color:#E5005C;\">普通班</label>");
|
| | | jsonrRed2.put("teamSubsidy", teamSubsidy + "最高<label style=\"color:#E5005C;\">7.5%</label>");
|
| | | jsonrRed2.put("teamReward", teamReward);
|
| | | |
| | |
|
| | | JSONObject jsonrRed3 = new JSONObject();
|
| | | jsonrRed3.put("platformSubsidy", platformSubsidy + "<label style=\"color:#E5005C;\">70%</label>");
|
| | | jsonrRed3.put("school", school + "<label style=\"color:#E5005C;\">高级班</label>");
|
| | | jsonrRed3.put("teamSubsidy", teamSubsidy + "最高<label style=\"color:#E5005C;\">15%</label>");
|
| | | jsonrRed3.put("teamReward", teamReward);
|
| | | |
| | |
|
| | | JSONObject jsonrRed4 = new JSONObject();
|
| | | jsonrRed4.put("platformSubsidy", platformSubsidy + "<label style=\"color:#E5005C;\">115%</label>");
|
| | | jsonrRed4.put("school", school + "<label style=\"color:#E5005C;\">超级班</label>");
|
| | | jsonrRed4.put("teamSubsidy", teamSubsidy + "最高<label style=\"color:#E5005C;\">22.5%</label>");
|
| | | jsonrRed4.put("teamReward", teamReward + "最高<label style=\"color:#E5005C;\">40%</label>");
|
| | |
|
| | |
|
| | | JSONObject json = new JSONObject();
|
| | |
| | | json.put("limitFirst", limitFirst);
|
| | | json.put("limitSecond", limitSecond);
|
| | |
|
| | | // 文字内容
|
| | | json.put("platformSubsidy", platformSubsidy);
|
| | | json.put("school", school);
|
| | | json.put("teamSubsidy", teamSubsidy);
|
| | | json.put("teamReward", teamReward);
|
| | |
|
| | | // 已完成
|
| | | json.put("master", jsonrRed1);
|
| | | json.put("vip1", jsonrRed2);
|
| | | json.put("vip2", jsonrRed3);
|
| | | json.put("vip3", jsonrRed4);
|
| | | |
| | | // 人工客服链接
|
| | | json.put("csdLink", configService.get(ConfigKeyEnum.customerServiceLink.getKey()));
|
| | |
|
| | |
| | | query.addCriteria(Criteria.where("startTime").lte(now)); |
| | | query.addCriteria(Criteria.where("endTime").gte(now)); |
| | | query.skip(start).limit(count); |
| | | query.with(new Sort(Sort.Direction.DESC,"weight")).with(new Sort(Sort.Direction.DESC,"createTime")); |
| | | query.with(new Sort(Sort.Direction.DESC,"weight")).with(new Sort(Sort.Direction.DESC,"startTime")); |
| | | return mongoTemplate.find(query, GoodsEvaluate.class); |
| | | } |
| | | |
| | |
| | | * @return
|
| | | */
|
| | | long countFirstTeam(@Param("uid") Long uid, @Param("state") Integer state);
|
| | | |
| | | |
| | | /**
|
| | | * 查询一级队员-未删除版
|
| | | * |
| | | * @param paramLong
|
| | | * @param paramInt
|
| | | * @param paramLong1
|
| | | * @return
|
| | | */
|
| | | List<ThreeSale> listFirstTeamByUndeleted(@Param("start") long start, @Param("count") int count, @Param("uid") Long uid);
|
| | |
|
| | | /**
|
| | | * 统计一级队员 -未删除版
|
| | | * |
| | | * @param uid
|
| | | * @param state
|
| | | * @return
|
| | | */
|
| | | long countFirstTeamByUndeleted(@Param("uid") Long uid);
|
| | |
|
| | | |
| | | |
| | | /**
|
| | | * 查询二级队员
|
| | | * |
| | | * @param start
|
| | | * @param count
|
| | | * @param uid
|
| | | * @return
|
| | | */
|
| | | List<ThreeSale> listSecondTeamByUndeleted(@Param("start") long start, @Param("count") int count,
|
| | | @Param("uid") Long uid);
|
| | |
|
| | | /**
|
| | | * 统计二级队员
|
| | | * |
| | | * @param uid
|
| | | * @param state
|
| | | * @return
|
| | | */
|
| | | long countSecondTeamByUndeleted(@Param("uid") Long uid);
|
| | | |
| | | |
| | | |
| | |
|
| | | /**
|
| | | * 查询二级队员
|
| | |
| | | * @return |
| | | */ |
| | | long countSearchOrderByUid(@Param("uid") Long uid, @Param("list")List<ESOrder> list); |
| | | |
| | | |
| | | |
| | | /** |
| | | * 查询最小结算时间 |
| | | * @return |
| | | */ |
| | | List<CommonOrder> getMinSettleTimeAndUid(); |
| | | |
| | | |
| | | |
| | | } |
| | |
| | | package com.yeshi.fanli.dao.mybatis.user; |
| | | |
| | | import java.util.List; |
| | | |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import com.yeshi.fanli.dao.BaseMapper; |
| | |
| | | * @return |
| | | */ |
| | | UserInviteValidRecord selectByUniqueKey(@Param("uniqueKey")String uniqueKey); |
| | | |
| | | |
| | | /** |
| | | * 查询用户下的有效粉丝 |
| | | * @param uid |
| | | * @param list |
| | | * @return |
| | | */ |
| | | List<Long> getValidWorkerIdsByUid(@Param("uid")Long uid,@Param("list") List<Long> list,@Param("type")Integer type); |
| | | |
| | | } |
New file |
| | |
| | | package com.yeshi.fanli.dao.mybatis.user.vip;
|
| | |
|
| | | import org.apache.ibatis.annotations.Param;
|
| | |
|
| | | import com.yeshi.fanli.dto.vip.UserVIPLevel;
|
| | |
|
| | | public interface UserVIPLevelMapper{
|
| | |
|
| | | |
| | | /**
|
| | | * 根据用户ID检索
|
| | | * |
| | | * @param uid
|
| | | * @return
|
| | | */
|
| | | UserVIPLevel getLevelByUid(@Param("uid") Long uid);
|
| | |
|
| | | } |
New file |
| | |
| | | package com.yeshi.fanli.dto.vip;
|
| | |
|
| | | import java.util.Date;
|
| | |
|
| | | import com.yeshi.fanli.dto.user.UserInviteLevelEnum;
|
| | |
|
| | | public class UserVIPLevel {
|
| | | |
| | | public static int LEVEL_3 = 3;// 超级会员第一阶段 -普通会员
|
| | | public static int LEVEL_7 = 7;// 超级会员第二阶段 -高级会员
|
| | | public static int LEVEL_10 = 7;// 超级会员 |
| | | |
| | | private Integer level;
|
| | | private Date successTime;
|
| | | private UserInviteLevelEnum LevelEnum;
|
| | | |
| | | public Integer getLevel() {
|
| | | return level;
|
| | | }
|
| | |
|
| | | public void setLevel(Integer level) {
|
| | | this.level = level;
|
| | | }
|
| | |
|
| | | public Date getSuccessTime() {
|
| | | return successTime;
|
| | | }
|
| | |
|
| | | public void setSuccessTime(Date successTime) {
|
| | | this.successTime = successTime;
|
| | | }
|
| | |
|
| | | public UserInviteLevelEnum getLevelEnum() {
|
| | | return LevelEnum;
|
| | | }
|
| | |
|
| | | public void setLevelEnum(UserInviteLevelEnum levelEnum) {
|
| | | LevelEnum = levelEnum;
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | @Table(name = "yeshi_ec_threeSale")
|
| | | @org.yeshi.utils.mybatis.Table("yeshi_ec_threeSale")
|
| | | public class ThreeSale {
|
| | |
|
| | | public static int EXPIRE_NORMAL = 0;// 正常状态
|
| | | public static int EXPIRE_OUTOFDATE = 1;// 邀请关系脱离
|
| | |
|
| | | // 邀请状态
|
| | | public static int STATE_SUCCESS = 1;// 成功
|
| | | public static int STATE_NOT_SUCCESS = 0;// 尚未成功
|
| | |
|
| | | // 脱离状态
|
| | | public static int EXPIRE_NORMAL = 0;// 正常状态
|
| | | public static int EXPIRE_BREAK = 1;// 邀请关系脱离
|
| | | public static int EXPIRE_BREAK_VIP = 2; // vip脱离关系
|
| | | public static int EXPIRE_BREAK_VIP_DEL3 = 3; // 直接脱离关系删除
|
| | | public static int EXPIRE_BREAK_VIP_DEL4 = 4; // 间接脱离关系删除
|
| | | public static int EXPIRE_BREAK_VIP_DEL34 = 34; // 直接、间接脱离关系删除
|
| | |
|
| | | @Id
|
| | | @GeneratedValue(strategy = GenerationType.AUTO)
|
| | |
| | |
|
| | | @Transient
|
| | | private ThreeSaleExtraInfo threeSaleExtraInfo;
|
| | |
|
| | | // 上上级关系状态
|
| | | @Transient
|
| | | private Boolean stateSuper;
|
| | |
|
| | | public Long getId() {
|
| | | return id;
|
| | |
| | | this.threeSaleExtraInfo = threeSaleExtraInfo;
|
| | | }
|
| | |
|
| | | public Boolean getStateSuper() {
|
| | | return stateSuper;
|
| | | }
|
| | |
|
| | | public void setStateSuper(Boolean stateSuper) {
|
| | | this.stateSuper = stateSuper;
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | <result column="createTime" property="createTime" jdbcType="BIGINT" />
|
| | | <result column="updateTime" property="updateTime" jdbcType="BIGINT" />
|
| | | <result column="expire" property="expire" jdbcType="INTEGER" />
|
| | | <result column="stateSuper" property="stateSuper" jdbcType="BOOLEAN" />
|
| | |
|
| | |
|
| | | <association property="boss" column="boss_id"
|
| | | select="com.yeshi.fanli.dao.mybatis.UserInfoMapper.selectByPrimaryKey" />
|
| | |
| | | </if>
|
| | | )A
|
| | | </select>
|
| | | |
| | | |
| | | <select id="listFirstTeamByUndeleted" resultMap="AllResultMap">
|
| | | SELECT * FROM `yeshi_ec_threesale` ts
|
| | | LEFT JOIN `yeshi_ec_threesale_extra_info` ff ON (ts.`boss_id` = ff.`tf_boss_id` AND ts.`worker_id`=ff.`tf_worker_id`)
|
| | | WHERE ts.`boss_id` = #{uid} AND (ts.`expire` = 0 OR ts.`expire` = 2 OR ts.`expire` = 4)
|
| | | ORDER BY ts.state DESC, ts.createTime DESC
|
| | | LIMIT ${start},${count}
|
| | | </select>
|
| | |
|
| | | <select id="countFirstTeamByUndeleted" resultType="java.lang.Long">
|
| | | SELECT IFNULL(count(ts.id),0) FROM `yeshi_ec_threesale` ts
|
| | | WHERE ts.`boss_id` = #{uid} AND (ts.`expire` = 0 OR ts.`expire` = 2 OR ts.`expire` = 4)
|
| | | </select>
|
| | | |
| | | |
| | | <select id="listSecondTeamByUndeleted" resultMap="AllResultMap">
|
| | | SELECT yet.*,stateSuper FROM (
|
| | | SELECT DISTINCT(ts.`id`) AS id, tf.state AS stateSuper FROM `yeshi_ec_threesale` ts
|
| | | LEFT JOIN yeshi_ec_threesale tf ON ts.`boss_id`=tf.`worker_id`
|
| | | WHERE tf.`boss_id` = #{uid} AND (tf.`expire` = 0 OR tf.`expire` = 2))A
|
| | | LEFT JOIN yeshi_ec_threesale yet ON yet.id = A.id
|
| | | WHERE yet.`expire` = 0 OR yet.`expire` = 2 OR yet.`expire` = 3
|
| | | ORDER BY yet.state DESC, yet.createTime DESC
|
| | | LIMIT ${start},${count}
|
| | | </select>
|
| | |
|
| | | <select id="countSecondTeamByUndeleted" resultType="java.lang.Long">
|
| | | SELECT COUNT(DISTINCT yet.id) FROM (SELECT DISTINCT(ts.`id`) AS id FROM `yeshi_ec_threesale` ts
|
| | | LEFT JOIN yeshi_ec_threesale tf ON ts.`boss_id`=tf.`worker_id`
|
| | | WHERE tf.`boss_id` = #{uid} AND (tf.`expire` = 0 OR tf.`expire` = 2))A
|
| | | LEFT JOIN yeshi_ec_threesale yet ON yet.id = A.id
|
| | | WHERE yet.`expire` = 0 OR yet.`expire` = 2 OR yet.`expire` = 3
|
| | | </select>
|
| | | |
| | | |
| | |
|
| | | <select id="getMyBoss" resultMap="AllResultMap">
|
| | | select
|
| | |
| | | </foreach> |
| | | GROUP BY co.`co_order_no`, co.`co_source_type` )A |
| | | </select> |
| | | |
| | | <select id="getMinSettleTimeAndUid" resultMap="BaseResultMap"> |
| | | SELECT d.`co_uid`,MAX(d.`co_settle_time`) AS co_settle_time FROM `yeshi_ec_common_order` d |
| | | WHERE d.`co_settle_time` IS NOT NULL AND d.`co_payment` > 1 |
| | | GROUP BY d.`co_uid`;` |
| | | </select> |
| | | </mapper> |
| | |
| | | limit 1 |
| | | </select> |
| | | |
| | | <select id="getValidWorkerIdsByUid" resultType="Long"> |
| | | select DISTINCT tvr_worker_id from yeshi_ec_user_invite_valid_record |
| | | where tvr_uid = #{uid} and tvr_type = #{type} |
| | | and tvr_worker_id in <foreach collection="list" item="item" open="(" separator="," close=")">#{item}</foreach> |
| | | </select> |
| | | |
| | | </mapper> |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | |
| | | <mapper namespace="com.yeshi.fanli.dao.mybatis.user.vip.UserVIPLevelMapper"> |
| | | <resultMap id="BaseResultMap" type="com.yeshi.fanli.dto.vip.UserVIPLevel"> |
| | | <id column="level" property="level" jdbcType="INTEGER" /> |
| | | <result column="success_time" property="successTime" jdbcType="TIMESTAMP" /> |
| | | </resultMap> |
| | | |
| | | <select id="getLevelByUid" resultMap="BaseResultMap"> |
| | | SELECT IFNULL(A.grade,B.vpi_process) AS 'level',IF(A.grade IS NULL,B.vpi_create_time,A.uvi_success_time) AS 'success_time' |
| | | FROM (SELECT p.`vpi_process`,p.`vpi_uid`,p.`vpi_create_time` FROM `yeshi_ec_user_vip_pre_info` p |
| | | WHERE p.`vpi_uid` = #{uid} ORDER BY p.`vpi_process` DESC LIMIT 1)B |
| | | LEFT JOIN (SELECT 10 AS grade,d.`uvi_uid`,d.`uvi_success_time` FROM `yeshi_ec_user_vip_info` d |
| | | WHERE d.`uvi_uid` = #{uid} AND d.`uvi_state` = 2 LIMIT 1)A ON A.uvi_uid = B.vpi_uid |
| | | </select> |
| | | |
| | | </mapper> |
| | |
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.apache.ibatis.annotations.Param;
|
| | | import org.springframework.stereotype.Service;
|
| | | import org.yeshi.utils.DateUtil;
|
| | |
|
| | |
| | | e.printStackTrace(); |
| | | continue; |
| | | } |
| | | |
| | | // 按照发布显示时间段起始时间为准。 |
| | | goodsEvaluate.setPublishTime(goodsEvaluate.getStartTime()); |
| | | |
| | | |
| | | List<CommentInfo> comments = evaluateNew.getComments(); |
| | | if (comments != null && comments.size() > 0) { |
| | |
| | | import com.yeshi.fanli.service.inter.user.UserInfoService; |
| | | import com.yeshi.fanli.service.inter.user.UserSystemCouponRecordService; |
| | | import com.yeshi.fanli.service.inter.user.UserSystemCouponService; |
| | | import com.yeshi.fanli.service.inter.user.invite.UserInviteService; |
| | | import com.yeshi.fanli.service.inter.user.vip.UserVIPInfoService; |
| | | import com.yeshi.fanli.util.Constant; |
| | | import com.yeshi.fanli.util.MoneyBigDecimalUtil; |
| | |
| | | |
| | | @Resource |
| | | private UserInfoService userInfoService; |
| | | |
| | | @Resource |
| | | private UserInviteService userInviteService; |
| | | |
| | | @Resource(name = "producer") |
| | | private Producer orderProducer; |
| | |
| | | return commonOrderMapper.countSearchOrderByUid(uid, list); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public List<CommonOrder> getMinSettleTimeAndUid() { |
| | | return commonOrderMapper.getMinSettleTimeAndUid(); |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public List<CommonOrderVO> searchOrderByUid(AcceptData acceptData, int page, int size, Long uid, List<ESOrder> list) |
| | | throws Exception { |
| | |
| | | // 2019.8.1开始返回维权信息 |
| | | Date august = TimeUtil.parse("2019-08-01"); |
| | | |
| | | // 当前用户是否VIP |
| | | boolean vip = userVIPInfoService.isVIP(uid); |
| | | // 当前用户是否可以使用奖励券 |
| | | boolean isvip = userInviteService.verifyVIP(uid); |
| | | // 是否存在奖励券 |
| | | boolean hasRewardCoupon = userSystemCouponService.getValidRebateCoupon(uid); |
| | | |
| | |
| | | if (HongBaoV2.TYPE_ZIGOU == hongBaoType) { |
| | | // 奖励订单、免单 使用记录 |
| | | if (sourceType == null) { |
| | | couponFactoryNew(order, hasRewardCoupon, hongBaoState, hongBaoType, null, uid, vip); |
| | | couponFactoryNew(order, hasRewardCoupon, hongBaoState, hongBaoType, null, uid, isvip); |
| | | } else if (sourceType == Constant.SOURCE_TYPE_TAOBAO) { |
| | | couponFactoryNew(order, hasRewardCoupon, hongBaoState, hongBaoType, listRecordTB, uid, vip); |
| | | couponFactoryNew(order, hasRewardCoupon, hongBaoState, hongBaoType, listRecordTB, uid, isvip); |
| | | } else if (sourceType == Constant.SOURCE_TYPE_JD) { |
| | | couponFactoryNew(order, hasRewardCoupon, hongBaoState, hongBaoType, listRecordJD, uid, vip); |
| | | couponFactoryNew(order, hasRewardCoupon, hongBaoState, hongBaoType, listRecordJD, uid, isvip); |
| | | } else if (sourceType == Constant.SOURCE_TYPE_PDD) { |
| | | couponFactoryNew(order, hasRewardCoupon, hongBaoState, hongBaoType, listRecordPDD, uid, vip); |
| | | couponFactoryNew(order, hasRewardCoupon, hongBaoState, hongBaoType, listRecordPDD, uid, isvip); |
| | | } |
| | | } |
| | | |
| | |
| | | import com.yeshi.fanli.service.inter.user.UserSystemCouponRecordService;
|
| | | import com.yeshi.fanli.service.inter.user.UserSystemCouponService;
|
| | | import com.yeshi.fanli.service.inter.user.invite.ThreeSaleSerivce;
|
| | | import com.yeshi.fanli.service.inter.user.vip.UserVIPInfoService;
|
| | | import com.yeshi.fanli.service.inter.user.invite.UserInviteService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.MoneyBigDecimalUtil;
|
| | | import com.yeshi.fanli.util.RedisManager;
|
| | |
| | | @Resource
|
| | | private SystemCouponService systemCouponService;
|
| | |
|
| | | @Lazy
|
| | | @Resource
|
| | | private CommonOrderService commonOrderService;
|
| | |
|
| | |
| | | private Producer producer;
|
| | |
|
| | | @Resource
|
| | | private UserVIPInfoService userVIPInfoService;
|
| | | private UserInviteService userInviteService;
|
| | |
|
| | | @Override
|
| | | public int insertSelective(UserSystemCoupon record) {
|
| | |
| | | jumpBtn.put("params", jumpLink);
|
| | | jumpBtn.put("jumpDetail", jumpDetailV2Service.getByTypeCache("web"));
|
| | | } else if (CouponTypeEnum.rebatePercentCoupon == type) {
|
| | | if (userVIPInfoService.isVIP(uid)) { // 会员只可赠送
|
| | | if (userInviteService.verifyVIP(uid)) { // 会员只可赠送
|
| | | userCouponVO.setState(UserSystemCoupon.STATE_GIVE_ONLY);
|
| | | } else {// 可使用 可赠送
|
| | | userCouponVO.setState(UserSystemCoupon.STATE_USE_GIVE);
|
| | |
| | | List<ThreeSale> list = listByWorkerId(worker.getId());
|
| | | if (list != null && list.size() > 0) {
|
| | | for (ThreeSale ts : list) {
|
| | | if (!ts.getState() && ts.getExpire() == ThreeSale.EXPIRE_OUTOFDATE) {
|
| | | if (!ts.getState() && ts.getExpire() == ThreeSale.EXPIRE_BREAK) {
|
| | | outOfDateCount++;
|
| | | }
|
| | | }
|
| | |
| | | if (list != null)
|
| | | for (int i = 0; i < list.size(); i++) {
|
| | | if (list.get(i).getState() != null && list.get(i).getState() == false
|
| | | && list.get(i).getExpire() == ThreeSale.EXPIRE_OUTOFDATE) {// 过期的
|
| | | && list.get(i).getExpire() == ThreeSale.EXPIRE_BREAK) {// 过期的
|
| | | list.remove(i);
|
| | | i--;
|
| | | }
|
| | |
| | | }
|
| | |
|
| | | @Override
|
| | | public List<ThreeSale> listFirstTeamByUndeleted(long start, int count, Long uid) {
|
| | | return threeSaleMapper.listFirstTeamByUndeleted(start, count, uid);
|
| | | }
|
| | | |
| | | @Override
|
| | | public long countFirstTeamByUndeleted(Long uid) {
|
| | | return threeSaleMapper.countFirstTeamByUndeleted(uid);
|
| | | }
|
| | | |
| | | @Override
|
| | | public List<ThreeSale> listSecondTeamByUndeleted(long start, int count, Long uid) {
|
| | | return threeSaleMapper.listSecondTeamByUndeleted(start, count, uid);
|
| | | }
|
| | | |
| | | @Override
|
| | | public long countSecondTeamByUndeleted(Long uid) {
|
| | | return threeSaleMapper.countSecondTeamByUndeleted(uid);
|
| | | }
|
| | | |
| | | |
| | | @Override
|
| | | public List<ThreeSale> listSecondTeam(long start, int count, Long uid, Integer state) {
|
| | | return threeSaleMapper.listSecondTeam(start, count, uid, state);
|
| | | }
|
| | |
| | | package com.yeshi.fanli.service.impl.user.invite;
|
| | |
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.stereotype.Service;
|
| | | import org.springframework.transaction.annotation.Transactional;
|
| | | import org.yeshi.utils.DateUtil;
|
| | |
|
| | | import com.yeshi.fanli.dao.mybatis.user.UserInviteSeparateMapper;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInviteSeparate;
|
| | | import com.yeshi.fanli.service.inter.user.UserInviteSeparateService;
|
| | | import com.yeshi.fanli.service.inter.user.vip.UserVipConfigService;
|
| | |
|
| | | @Service
|
| | | public class UserInviteSeparateServiceImpl implements UserInviteSeparateService {
|
| | |
| | | @Resource
|
| | | private UserInviteSeparateMapper userInviteSeparateMapper;
|
| | |
|
| | | @Resource
|
| | | private UserVipConfigService userVipConfigService;
|
| | | |
| | | |
| | |
|
| | | @Override
|
| | | public void insertSelective(UserInviteSeparate record) {
|
| | | userInviteSeparateMapper.insertSelective(record);
|
| | | }
|
| | | |
| | | |
| | | @Override
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | public void addPreSeparateRecord(Long workerId, Long bossId) {
|
| | | // 更新之前状态失效
|
| | | userInviteSeparateMapper.updateStateByWorkerIdAndBossId(workerId, bossId, UserInviteSeparate.STATE_INVALID);
|
| | | |
| | | // 限制天数
|
| | | int limitDays = Integer.parseInt(userVipConfigService.getValueByKey("invite_separate_limit_days"));
|
| | | |
| | | // 保存记录
|
| | | UserInviteSeparate inviteSeparate = new UserInviteSeparate();
|
| | | inviteSeparate.setBossId(bossId);
|
| | | inviteSeparate.setWorkerId(workerId);
|
| | | inviteSeparate.setState(UserInviteSeparate.STATE_INIT);
|
| | | inviteSeparate.setEndTime(DateUtil.plusDayDate(limitDays, new Date()));
|
| | | inviteSeparate.setCreateTime(new Date());
|
| | | inviteSeparate.setUpdateTime(new Date());
|
| | | userInviteSeparateMapper.insertSelective(inviteSeparate);
|
| | | }
|
| | | |
| | | |
| | |
|
| | | @Override
|
| | | public void updateInvalidByBossId(Long uid) {
|
| | |
| | | return userInviteSeparateMapper.getHandleOverdue(start, count);
|
| | | }
|
| | |
|
| | | |
| | | |
| | | |
| | | }
|
| | |
| | |
|
| | | import org.springframework.stereotype.Service;
|
| | |
|
| | | import com.yeshi.fanli.dao.mybatis.user.vip.UserVIPLevelMapper;
|
| | | import com.yeshi.fanli.dto.user.UserInviteLevelEnum;
|
| | | import com.yeshi.fanli.dto.vip.UserVIPLevel;
|
| | | import com.yeshi.fanli.entity.bus.user.vip.UserVIPInfo;
|
| | | import com.yeshi.fanli.entity.bus.user.vip.UserVIPPreInfo;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoExtraService;
|
| | |
| | |
|
| | | @Resource
|
| | | private UserVIPPreInfoService userVIPPreInfoService;
|
| | | |
| | | @Resource
|
| | | private UserVIPLevelMapper userVIPLevelMapper;
|
| | | |
| | | |
| | |
|
| | | @Override
|
| | | public UserInviteLevelEnum getUserInviteLevel(Long uid) {
|
| | |
| | | return UserInviteLevelEnum.actived;
|
| | | }
|
| | |
|
| | | |
| | | @Override
|
| | | public boolean verifyVIP(Long uid) {
|
| | | String inviteCode = userInfoExtraService.getInviteCodeByUid(uid);
|
| | | if (StringUtil.isNullOrEmpty(inviteCode)) {
|
| | | return false;
|
| | | }
|
| | | |
| | | UserVIPInfo info = userVIPInfoService.selectByUid(uid);
|
| | | if (info != null && info.getState() == UserVIPInfo.STATE_SUCCESS) {
|
| | | return true;
|
| | | }
|
| | | |
| | | UserVIPPreInfo userVIPPreInfo = userVIPPreInfoService.getLatestProcessInfo(uid);
|
| | | if (userVIPPreInfo != null) {
|
| | | return true;
|
| | | }
|
| | | |
| | | return false;
|
| | | }
|
| | | |
| | | |
| | | |
| | | @Override
|
| | | public UserVIPLevel getVIPLevelByUid(Long uid) {
|
| | | return userVIPLevelMapper.getLevelByUid(uid);
|
| | | }
|
| | | }
|
| | |
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.context.annotation.Lazy;
|
| | | import org.springframework.stereotype.Service;
|
| | |
|
| | | import com.yeshi.fanli.dao.mybatis.user.UserInviteValidNumMapper;
|
| | |
| | | import com.yeshi.fanli.entity.bus.user.UserInviteValidNum;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInviteValidRecord;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.order.CommonOrderService;
|
| | | import com.yeshi.fanli.service.inter.user.invite.ThreeSaleSerivce;
|
| | | import com.yeshi.fanli.service.inter.user.invite.UserInviteValidNumService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | |
| | |
|
| | | @Resource
|
| | | private ThreeSaleSerivce threeSaleSerivce;
|
| | | |
| | |
|
| | |
|
| | | @Override
|
New file |
| | |
| | | package com.yeshi.fanli.service.impl.user.invite;
|
| | |
|
| | | import java.util.List;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.stereotype.Service;
|
| | |
|
| | | import com.yeshi.fanli.dao.mybatis.user.UserInviteValidRecordMapper;
|
| | | import com.yeshi.fanli.service.inter.user.invite.UserInviteValidRecordService;
|
| | |
|
| | | @Service
|
| | | public class UserInviteValidRecordServiceImpl implements UserInviteValidRecordService {
|
| | |
|
| | | @Resource
|
| | | private UserInviteValidRecordMapper userInviteValidRecordMapper;
|
| | | |
| | | @Override
|
| | | public List<Long> getValidWorkerIdsByUid(Long uid, List<Long> list,Integer type){
|
| | | return userInviteValidRecordMapper.getValidWorkerIdsByUid(uid, list, type);
|
| | | }
|
| | | |
| | | }
|
| | |
| | | package com.yeshi.fanli.service.impl.user.vip;
|
| | |
|
| | | import java.math.BigDecimal;
|
| | | import java.text.ParseException;
|
| | | import java.text.SimpleDateFormat;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Date;
|
| | | import java.util.HashMap;
|
| | | import java.util.List;
|
| | |
| | | import org.springframework.context.annotation.Lazy;
|
| | | import org.springframework.stereotype.Service;
|
| | | import org.springframework.transaction.annotation.Transactional;
|
| | | import org.yeshi.utils.DateUtil;
|
| | |
|
| | | import com.yeshi.fanli.dao.mybatis.user.vip.UserVIPInfoMapper;
|
| | | import com.yeshi.fanli.dto.msg.MsgAccountVipDTO;
|
| | |
| | | import com.yeshi.fanli.entity.bus.user.UserInfo;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfoExtra;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInviteSeparate;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInviteValidNum;
|
| | | import com.yeshi.fanli.entity.bus.user.UserSystemCoupon;
|
| | | import com.yeshi.fanli.entity.bus.user.vip.UserVIPInfo;
|
| | | import com.yeshi.fanli.entity.bus.user.vip.UserVIPPreInfo;
|
| | | import com.yeshi.fanli.entity.integral.IntegralDetail;
|
| | | import com.yeshi.fanli.entity.shop.BanLiShopOrder;
|
| | | import com.yeshi.fanli.entity.system.ConfigKeyEnum;
|
| | | import com.yeshi.fanli.entity.system.SystemCoupon.CouponTypeEnum;
|
| | | import com.yeshi.fanli.exception.msg.MsgAccountDetailException;
|
| | | import com.yeshi.fanli.exception.user.vip.UserVIPInfoException;
|
| | |
| | | import com.yeshi.fanli.service.inter.user.UserSystemCouponService;
|
| | | import com.yeshi.fanli.service.inter.user.integral.IntegralDetailService;
|
| | | import com.yeshi.fanli.service.inter.user.invite.ThreeSaleSerivce;
|
| | | import com.yeshi.fanli.service.inter.user.invite.UserInviteValidNumService;
|
| | | import com.yeshi.fanli.service.inter.user.msg.MsgAccountDetailService;
|
| | | import com.yeshi.fanli.service.inter.user.vip.UserVIPInfoService;
|
| | | import com.yeshi.fanli.service.inter.user.vip.UserVIPPreInfoService;
|
| | |
| | |
|
| | | @Resource
|
| | | private MsgAccountDetailService msgAccountDetailService;
|
| | | |
| | | @Resource
|
| | | private UserInviteValidNumService userInviteValidNumService;
|
| | |
|
| | | @Override
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | |
| | | userVIPInfoMapper.insert(info);
|
| | | }
|
| | |
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | @Override
|
| | | public void passVIPApply(Long uid) throws UserVIPInfoException {
|
| | | UserVIPInfo userVIPInfo = userVIPInfoMapper.selectByPrimaryKeyForUpdate(uid);
|
| | | if (userVIPInfo == null) {
|
| | | throw new UserVIPInfoException(1, "用户信息不存在");
|
| | | }
|
| | | if (userVIPInfo.getState() != UserVIPInfo.STATE_VERIFING) {
|
| | | throw new UserVIPInfoException(2, "申请未处于审核状态");
|
| | | }
|
| | |
|
| | | if (!verifyConform(uid))
|
| | | throw new UserVIPInfoException(1, "系统验证:不满足升级条件");
|
| | |
|
| | | UserVIPInfo info = new UserVIPInfo();
|
| | | info.setId(userVIPInfo.getId());
|
| | | info.setSuccessTime(new Date());
|
| | | info.setState(UserVIPInfo.STATE_SUCCESS);
|
| | | info.setUpdateTime(new Date());
|
| | | userVIPInfoMapper.updateByPrimaryKeySelective(info);
|
| | |
|
| | | // 下级的超级会员 不脱离
|
| | | userInviteSeparateService.updateInvalidByBossId(uid);
|
| | |
|
| | | // 额外信息
|
| | | UserInfoExtra userInfoExtra = userInfoExtraService.getByUidForUpdate(uid);
|
| | | if (userInfoExtra == null)
|
| | | throw new UserVIPInfoException(1, "用户信息不存在");
|
| | |
|
| | | // 添加金币
|
| | | IntegralDetail detail = new IntegralDetail();
|
| | | detail.setTitle("升级VIP福利");
|
| | | detail.setUid(uid);
|
| | | detail.setMoney(Constant.VIP_COLDCOIN_NUM);
|
| | | detail.setCreateTime(new Date());
|
| | | detail.setUniqueKey("VIP-" + uid);
|
| | | integralDetailService.insertSelective(detail);
|
| | | userInfoExtraService.addGoldCoinByUid(uid, Constant.VIP_COLDCOIN_NUM);
|
| | |
|
| | | try {
|
| | | // 奖励券
|
| | | BigDecimal percent = new BigDecimal(configService.get(ConfigKeyEnum.exchangeRebatePercent.getKey()));
|
| | | for (int i = 0; i < Constant.VIP_COUPON_REWARD_NUM; i++) {
|
| | | userSystemCouponService.insertUserCoupon(uid, CouponTypeEnum.rebatePercentCoupon.name(),
|
| | | UserSystemCoupon.SOURCE_SYSTEM_PUSH, percent, false);
|
| | | }
|
| | |
|
| | | // 赠送免单券
|
| | | for (int i = 0; i < Constant.VIP_COUPON_GIVEFREE_NUM; i++) {
|
| | | userSystemCouponService.insertUserCoupon(uid, CouponTypeEnum.freeCouponGive.name(),
|
| | | UserSystemCoupon.SOURCE_SYSTEM_PUSH, null, false);
|
| | | }
|
| | | } catch (Exception e) {
|
| | | throw new UserVIPInfoException(1, "券赠送失败");
|
| | | }
|
| | |
|
| | | // 消息
|
| | | MsgOtherVIPDTO msgOther = new MsgOtherVIPDTO();
|
| | | msgOther.setContent1("恭喜你,已成为超级会员");
|
| | | msgOther.setContent2("满足升级条件");
|
| | | msgOther.setContent3(TimeUtil.formatDateDot(new Date()));
|
| | | userOtherMsgNotificationService.passVIPApplyMsg(uid, "返利奖励券和、赠送免单券和金币请到我的-福利中心中查看", msgOther);
|
| | |
|
| | | // 通知上级
|
| | | callBoss(uid);
|
| | | }
|
| | |
|
| | | /**
|
| | | * 通知上级脱离关系
|
| | | * |
| | | * @param uid
|
| | | */
|
| | | @Transactional
|
| | | private void callBoss(Long uid) {
|
| | | // 是否存在上级
|
| | | ThreeSale threeSale = threeSaleSerivce.getMyBoss(uid);
|
| | | if (threeSale == null)
|
| | | return;
|
| | | // 上级是否为会员
|
| | | Long bossId = threeSale.getBoss().getId();
|
| | | UserVIPInfo bossVIP = userVIPInfoMapper.selectByPrimaryKeyForUpdate(bossId);
|
| | | if (bossVIP != null && bossVIP.getState() != null && bossVIP.getState() == UserVIPInfo.STATE_SUCCESS)
|
| | | return;
|
| | |
|
| | | // 之前插入记录失效
|
| | | userInviteSeparateService.updateStateByWorkerIdAndBossId(uid, bossId, UserInviteSeparate.STATE_INVALID);
|
| | |
|
| | | // 限制时间
|
| | | int limitDays = Integer.parseInt(userVipConfigService.getValueByKey("invite_separate_limit_days"));
|
| | | UserInviteSeparate inviteSeparate = new UserInviteSeparate();
|
| | | inviteSeparate.setBossId(bossId);
|
| | | inviteSeparate.setWorkerId(uid);
|
| | | inviteSeparate.setState(UserInviteSeparate.STATE_INIT);
|
| | | inviteSeparate.setEndTime(DateUtil.plusDayDate(limitDays, new Date()));
|
| | | inviteSeparate.setCreateTime(new Date());
|
| | | inviteSeparate.setUpdateTime(new Date());
|
| | | userInviteSeparateService.insertSelective(inviteSeparate);
|
| | |
|
| | | UserInfo userInfo = userInfoService.selectByPKey(uid);
|
| | | // 消息
|
| | | MsgOtherVIPDTO msgboss = new MsgOtherVIPDTO();
|
| | | msgboss.setContent1(userInfo.getNickName() + " " + uid);
|
| | | msgboss.setContent2("于" + TimeUtil.formatDateDot(new Date()) + "成功升级成为超级会员");
|
| | | msgboss.setContent3("今日起" + limitDays + "天内,你未能成为超级会员将会与其脱离邀请关系 ");
|
| | | userOtherMsgNotificationService.teamVIPCallBoss(bossId, "如有疑问请联系我的-人工客服", msgboss);
|
| | | }
|
| | |
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | @Override
|
| | | public void rejectVIPApply(Long uid, String reason) throws UserVIPInfoException {
|
| | | UserVIPInfo userInfo = userVIPInfoMapper.selectByPrimaryKeyForUpdate(uid);
|
| | | if (userInfo == null) {
|
| | | throw new UserVIPInfoException(1, "用户信息不存在");
|
| | | }
|
| | | if (userInfo.getState() != UserVIPInfo.STATE_VERIFING) {
|
| | | throw new UserVIPInfoException(2, "申请未处于审核状态");
|
| | | }
|
| | |
|
| | | UserVIPInfo info = new UserVIPInfo();
|
| | | info.setId(userInfo.getId());
|
| | | info.setState(UserVIPInfo.STATE_INVALID);
|
| | | info.setUpdateTime(new Date());
|
| | | userVIPInfoMapper.updateByPrimaryKeySelective(info);
|
| | |
|
| | | // 消息
|
| | | MsgOtherVIPDTO msgOther = new MsgOtherVIPDTO();
|
| | | msgOther.setContent1("很抱歉,未通过超级会员申请");
|
| | | msgOther.setContent2("未满足超级会员升级条件或疑似出现违规 ");
|
| | | userOtherMsgNotificationService.rejectVIPApply(uid, "如有疑问请联系我的-人工客服", msgOther);
|
| | | }
|
| | |
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | @Override
|
| | | public void applyVIP(Long uid) throws UserVIPInfoException {
|
| | | UserVIPInfo userInfo = userVIPInfoMapper.selectByPrimaryKeyForUpdate(uid);
|
| | | if (userInfo == null) {
|
| | | userInfo = new UserVIPInfo();
|
| | | userInfo.setId(uid);
|
| | | addUserVIPInfo(userInfo);
|
| | | }
|
| | |
|
| | | if (userInfo.getState() != UserVIPInfo.STATE_INVALID)
|
| | | throw new UserVIPInfoException(2, "已经申请过");
|
| | |
|
| | | UserVIPInfo info = new UserVIPInfo();
|
| | | info.setId(userInfo.getId());
|
| | | info.setApplyTime(new Date());
|
| | | info.setState(UserVIPInfo.STATE_VERIFING);
|
| | | info.setUpdateTime(new Date());
|
| | | userVIPInfoMapper.updateByPrimaryKeySelective(info);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public boolean isVIP(Long uid) {
|
| | |
| | | return map;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public boolean verifyConform(Long uid) {
|
| | | if (uid == null || uid <= 0)
|
| | | return false;
|
| | |
|
| | | UserInfoExtra extra = userInfoExtraService.getUserInfoExtra(uid);
|
| | | if (extra == null)
|
| | | return false;
|
| | |
|
| | | // 1、直接粉丝(从 2020 年 1 月 1 日起直接粉丝产生有效订单)
|
| | | BigDecimal payMoney = new BigDecimal(userVipConfigService.getValueByKey("require_order_pay"));
|
| | | // long teamNum =
|
| | | // hongBaoV2CountService.countValidOrderTeamUserByUid(uid,
|
| | | // TimeUtil.convertDateToTemp(Constant.VIP_ONLINE_TIME), payMoney);
|
| | | long teamNum = 0L;
|
| | | long vipBegin = TimeUtil.convertDateToTemp(Constant.VIP_ONLINE_TIME);
|
| | | List<ThreeSale> listThreeSale = threeSaleSerivce.getValidWorkerIdsByTime(uid, vipBegin);
|
| | | if (listThreeSale != null && listThreeSale.size() > 0) {
|
| | | for (ThreeSale three : listThreeSale) {
|
| | | UserInfo worker = three.getWorker();
|
| | | if (worker == null || worker.getId() == null) {
|
| | | continue;
|
| | | }
|
| | | // 1、邀请关系成功后;2、单(分享 + 自购)实付款大于1元
|
| | | long countValid = hongBaoV2CountService.countValidOrderByUidAndTime(worker.getId(),
|
| | | three.getSucceedTime(), payMoney);
|
| | | if (countValid > 0) {
|
| | | teamNum++;
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | // 区分老用户和新用户
|
| | | String limtDate = userVipConfigService.getValueByKey("vip_execute_time");
|
| | | Date executeDate = null;
|
| | | try {
|
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy-mm-dd");
|
| | | executeDate = format.parse(limtDate);
|
| | | } catch (ParseException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | if (executeDate == null)
|
| | | return false;
|
| | |
|
| | | if (extra.getFirstLoginTime() == null || extra.getFirstLoginTime().getTime() < executeDate.getTime()) {
|
| | | long limitNum = Long.parseLong(userVipConfigService.getValueByKey("require_invite_num_old_user"));
|
| | | if (teamNum < limitNum)
|
| | | return false;
|
| | | } else {
|
| | | long limitNum = Long.parseLong(userVipConfigService.getValueByKey("require_invite_num_new_user"));
|
| | | if (teamNum < limitNum)
|
| | | return false;
|
| | | }
|
| | |
|
| | | // 2、累计自购返利≥100 元(从注册板栗快省起);
|
| | | BigDecimal fanMoney = new BigDecimal(userVipConfigService.getValueByKey("require_fan_money"));
|
| | | BigDecimal purchase = hongBaoV2CountService.getRewardMoneyBySelf(uid);
|
| | | if (purchase.compareTo(fanMoney) < 0)
|
| | | return false;
|
| | |
|
| | | // 3、累计金币≥10000 枚(从注册板栗快省起);
|
| | | BigDecimal goldCoin = integralDetailService.getCumulativeMoney(uid);
|
| | | BigDecimal limitGoldCoin = new BigDecimal(userVipConfigService.getValueByKey("require_gold_coin"));
|
| | | if (goldCoin.compareTo(limitGoldCoin) < 0)
|
| | | return false;
|
| | |
|
| | | // 4、使用红包≥1 次
|
| | | List<Integer> list = new ArrayList<Integer>();
|
| | | list.add(BanLiShopOrder.STATE_SUCCESS);
|
| | | long useHongBao = banLiShopOrderService.countByUidAndState(uid, list);
|
| | | long limitHongBao = Long.parseLong(userVipConfigService.getValueByKey("require_shop_buy"));
|
| | | if (useHongBao < limitHongBao)
|
| | | return false;
|
| | |
|
| | | // 符合条件
|
| | | return true;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<UserVIPInfo> listQuery(int page, int count, String key, Integer state) {
|
| | |
| | |
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | @Override
|
| | | public void applyVIPNew(Long uid) throws UserVIPInfoException {
|
| | | public void applyVIP(Long uid) throws UserVIPInfoException {
|
| | | UserVIPPreInfo latestProcess = userVIPPreInfoService.getLatestProcessInfo(uid);
|
| | | if (latestProcess == null || latestProcess.getProcess() != UserVIPPreInfo.PROCESS_2) {
|
| | | throw new UserVIPInfoException(1, "该用户还不是高级会员");
|
| | | }
|
| | |
|
| | | if (!verifyVipNew(uid))
|
| | | if (!verifyVip(uid))
|
| | | throw new UserVIPInfoException(1, "系统验证:不满足升级条件");
|
| | |
|
| | | UserVIPInfo userInfo = userVIPInfoMapper.selectByPrimaryKeyForUpdate(uid);
|
| | |
| | |
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | @Override
|
| | | public void passVIPApplyNew(Long uid) throws UserVIPInfoException {
|
| | | public void passVIPApply(Long uid) throws UserVIPInfoException {
|
| | | UserVIPInfo userVIPInfo = userVIPInfoMapper.selectByPrimaryKeyForUpdate(uid);
|
| | | if (userVIPInfo == null) {
|
| | | throw new UserVIPInfoException(1, "用户信息不存在");
|
| | |
| | | throw new UserVIPInfoException(1, "该用户还不是高级会员");
|
| | | }
|
| | |
|
| | | if (!verifyVipNew(uid))
|
| | | if (!verifyVip(uid))
|
| | | throw new UserVIPInfoException(1, "系统验证:不满足升级条件");
|
| | |
|
| | | // 额外信息
|
| | |
| | | info.setUpdateTime(new Date());
|
| | | userVIPInfoMapper.updateByPrimaryKeySelective(info);
|
| | |
|
| | | // 添加金币
|
| | | userInfoExtraService.addGoldCoinByUid(uid, Constant.VIP_COLDCOIN_NUM);
|
| | | // 添加金币明细
|
| | | IntegralDetail detail = new IntegralDetail();
|
| | | detail.setTitle("升级VIP福利");
|
| | | detail.setUid(uid);
|
| | | detail.setMoney(Constant.VIP_COLDCOIN_NUM);
|
| | | detail.setCreateTime(new Date());
|
| | | detail.setUniqueKey("VIP-" + uid);
|
| | | integralDetailService.insertSelective(detail);
|
| | |
|
| | | try {
|
| | | // 奖励券
|
| | | BigDecimal percent = new BigDecimal(configService.get(ConfigKeyEnum.exchangeRebatePercent.getKey()));
|
| | | for (int i = 0; i < Constant.VIP_COUPON_REWARD_NUM; i++) {
|
| | | userSystemCouponService.insertUserCoupon(uid, CouponTypeEnum.rebatePercentCoupon.name(),
|
| | | UserSystemCoupon.SOURCE_SYSTEM_PUSH, percent, false);
|
| | | }
|
| | |
|
| | | // 赠送免单券
|
| | | for (int i = 0; i < Constant.VIP_COUPON_GIVEFREE_NUM; i++) {
|
| | | userSystemCouponService.insertUserCoupon(uid, CouponTypeEnum.freeCouponGive.name(),
|
| | | UserSystemCoupon.SOURCE_SYSTEM_PUSH, null, false);
|
| | | String giveCoupon = userVipConfigService.getValueByKey("vip_pre_10_gift_givefree_coupon");
|
| | | if (!StringUtil.isNullOrEmpty(giveCoupon)) {
|
| | | int num = Integer.parseInt(giveCoupon);
|
| | | for (int i = 0; i < num; i++) {
|
| | | userSystemCouponService.insertUserCoupon(uid, CouponTypeEnum.freeCouponGive.name(),
|
| | | UserSystemCoupon.SOURCE_SYSTEM_PUSH, null, false);
|
| | | }
|
| | | }
|
| | | } catch (Exception e) {
|
| | | throw new UserVIPInfoException(1, "券赠送失败");
|
| | | }
|
| | |
|
| | | |
| | | // 消息
|
| | | MsgAccountVipDTO msgDto = new MsgAccountVipDTO();
|
| | | msgDto.setStatus("已将你的账户由高级会员升级为超级会员");
|
| | |
| | | * @param uid
|
| | | * @return
|
| | | */
|
| | | private boolean verifyVipNew(Long uid) {
|
| | | // 邀请订单
|
| | | long countZiGou = hongBaoV2CountService.counOrderByUidAndOrderType(uid, Constant.VIP_ORDER_PAY,
|
| | | private boolean verifyVip(Long uid) {
|
| | | // 自购订单
|
| | | long doneZiGou = hongBaoV2CountService.counOrderByUidAndOrderType(uid, Constant.VIP_ORDER_PAY,
|
| | | HongBaoV2.TYPE_ZIGOU);
|
| | | // 邀请订单
|
| | | long countShare = hongBaoV2CountService.counOrderByUidAndOrderType(uid, Constant.VIP_ORDER_PAY,
|
| | | // 分享订单
|
| | | long doneShare = hongBaoV2CountService.counOrderByUidAndOrderType(uid, Constant.VIP_ORDER_PAY,
|
| | | HongBaoV2.TYPE_SHARE_GOODS);
|
| | | // 队员
|
| | | long firstTeam = threeSaleSerivce.countFirstTeam(uid, 1);
|
| | | long secondTeam = threeSaleSerivce.countSecondTeam(uid, 1);
|
| | | |
| | | // 有效粉丝
|
| | | int doneFirst = 0;
|
| | | int doneSecond = 0;
|
| | | UserInviteValidNum userInviteValidNum = userInviteValidNumService.selectByPrimaryKey(uid);
|
| | | if (userInviteValidNum != null) {
|
| | | doneFirst = userInviteValidNum.getNumFirst() == null ? 0 : userInviteValidNum.getNumFirst();
|
| | | doneSecond = userInviteValidNum.getNumSecond() == null ? 0 : userInviteValidNum.getNumSecond();
|
| | | }
|
| | |
|
| | | long limitZiGou = 0;
|
| | | String zigou = userVipConfigService.getValueByKey("vip_pre_10_zigou_order_count");
|
| | |
| | | limitSecond = Long.parseLong(second);
|
| | | }
|
| | |
|
| | | if (countZiGou >= limitZiGou || countShare >= limitShare || (firstTeam >= limitFirst && secondTeam >= limitSecond)) {
|
| | | if (doneZiGou >= limitZiGou || doneShare >= limitShare || (doneFirst >= limitFirst && doneSecond >= limitSecond)) {
|
| | | return true;
|
| | | }
|
| | | return false;
|
| | |
| | |
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | @Override
|
| | | public void rejectVIPApplyNew(Long uid, String reason) throws UserVIPInfoException {
|
| | | public void rejectVIPApply(Long uid, String reason) throws UserVIPInfoException {
|
| | | UserVIPInfo userInfo = userVIPInfoMapper.selectByPrimaryKeyForUpdate(uid);
|
| | | if (userInfo == null) {
|
| | | throw new UserVIPInfoException(1, "用户信息不存在");
|
| | |
| | | package com.yeshi.fanli.service.impl.user.vip;
|
| | |
|
| | | import java.math.BigDecimal;
|
| | | import java.util.Collections;
|
| | | import java.util.Comparator;
|
| | | import java.util.Date;
|
| | |
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.context.annotation.Lazy;
|
| | | import org.springframework.stereotype.Service;
|
| | | import org.springframework.transaction.annotation.Transactional;
|
| | |
|
| | | import com.yeshi.fanli.dao.mybatis.user.vip.UserVIPPreInfoMapper;
|
| | | import com.yeshi.fanli.dto.msg.MsgAccountVipDTO;
|
| | | import com.yeshi.fanli.entity.bus.user.HongBaoV2;
|
| | | import com.yeshi.fanli.entity.bus.user.ThreeSale;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfo;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInviteValidNum;
|
| | | import com.yeshi.fanli.entity.bus.user.UserSystemCoupon;
|
| | | import com.yeshi.fanli.entity.bus.user.vip.UserVIPPreInfo;
|
| | | import com.yeshi.fanli.entity.integral.IntegralDetail;
|
| | | import com.yeshi.fanli.entity.system.ConfigKeyEnum;
|
| | | import com.yeshi.fanli.entity.system.SystemCoupon.CouponTypeEnum;
|
| | | import com.yeshi.fanli.exception.user.vip.UserVIPPreInfoException;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.config.ConfigService;
|
| | | import com.yeshi.fanli.service.inter.count.HongBaoV2CountService;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoExtraService;
|
| | | import com.yeshi.fanli.service.inter.user.UserInviteSeparateService;
|
| | | import com.yeshi.fanli.service.inter.user.UserSystemCouponService;
|
| | | import com.yeshi.fanli.service.inter.user.integral.IntegralDetailService;
|
| | | import com.yeshi.fanli.service.inter.user.invite.ThreeSaleSerivce;
|
| | | import com.yeshi.fanli.service.inter.user.invite.UserInviteValidNumService;
|
| | | import com.yeshi.fanli.service.inter.user.msg.MsgAccountDetailService;
|
| | | import com.yeshi.fanli.service.inter.user.vip.UserVIPPreInfoService;
|
| | | import com.yeshi.fanli.service.inter.user.vip.UserVipConfigService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.TimeUtil;
|
| | | import com.yeshi.fanli.util.annotation.RequestSerializableByKeyService;
|
| | |
|
| | | @Service
|
| | |
| | |
|
| | | @Resource
|
| | | private UserVipConfigService userVipConfigService;
|
| | | |
| | | @Resource
|
| | | private UserInviteValidNumService userInviteValidNumService;
|
| | | |
| | | @Resource
|
| | | private UserInfoExtraService userInfoExtraService;
|
| | | |
| | | @Resource
|
| | | private IntegralDetailService integralDetailService;
|
| | | |
| | | @Resource
|
| | | private ConfigService configService;
|
| | | |
| | | @Lazy
|
| | | @Resource
|
| | | private UserSystemCouponService userSystemCouponService;
|
| | | |
| | | @Resource
|
| | | private UserInviteSeparateService userInviteSeparateService;
|
| | |
|
| | |
|
| | | @Override
|
| | |
| | | if (oldInfo != null) {
|
| | | return;
|
| | | }
|
| | |
|
| | | // 邀请订单
|
| | | long countZiGou = hongBaoV2CountService.counOrderByUidAndOrderType(uid, Constant.VIP_ORDER_PAY,
|
| | | |
| | | // 自购订单
|
| | | long doneZiGou = hongBaoV2CountService.counOrderByUidAndOrderType(uid, Constant.VIP_ORDER_PAY,
|
| | | HongBaoV2.TYPE_ZIGOU);
|
| | | // 邀请订单
|
| | | long countShare = hongBaoV2CountService.counOrderByUidAndOrderType(uid, Constant.VIP_ORDER_PAY,
|
| | | // 分享订单
|
| | | long doneShare = hongBaoV2CountService.counOrderByUidAndOrderType(uid, Constant.VIP_ORDER_PAY,
|
| | | HongBaoV2.TYPE_SHARE_GOODS);
|
| | | // 队员
|
| | | long firstTeam = threeSaleSerivce.countFirstTeam(uid, 1);
|
| | | long secondTeam = threeSaleSerivce.countSecondTeam(uid, 1);
|
| | | |
| | | // 有效粉丝
|
| | | int doneFirst = 0;
|
| | | int doneSecond = 0;
|
| | | UserInviteValidNum userInviteValidNum = userInviteValidNumService.selectByPrimaryKey(uid);
|
| | | if (userInviteValidNum != null) {
|
| | | doneFirst = userInviteValidNum.getNumFirst() == null ? 0 : userInviteValidNum.getNumFirst();
|
| | | doneSecond = userInviteValidNum.getNumSecond() == null ? 0 : userInviteValidNum.getNumSecond();
|
| | | }
|
| | |
|
| | | // 一阶段
|
| | | boolean process1 = oneProcess(uid, countZiGou, countShare, firstTeam, secondTeam);
|
| | | boolean process1 = oneProcess(uid, doneZiGou, doneShare, doneFirst, doneSecond);
|
| | | if (!process1) {
|
| | | return;
|
| | | }
|
| | |
|
| | | // 二阶段
|
| | | twoProcess(uid, countZiGou, countShare, firstTeam, secondTeam);
|
| | | twoProcess(uid, doneZiGou, doneShare, doneFirst, doneSecond);
|
| | | } catch (Exception e) {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | }
|
| | |
| | | * @param firstTeam
|
| | | * @param secondTeam
|
| | | */
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | private boolean oneProcess(Long uid, long countZiGou, long countShare, long firstTeam, long secondTeam) {
|
| | | boolean process = false;
|
| | | String msg = "";
|
| | |
| | | msgDto.setStatus("系统已将你的账户由快省达人升级为普通会员");
|
| | | msgDto.setEquity("从收到本消息起,你将获得全部普通会员权益");
|
| | | msgAccountDetailService.addMsgVIP(uid, msg, "如有疑问请联系我的-人工客服", msgDto);
|
| | | |
| | | |
| | | // 赠送金币
|
| | | String goldcoin = userVipConfigService.getValueByKey("vip_pre_3_gift_goldcoin");
|
| | | if (!StringUtil.isNullOrEmpty(goldcoin)) {
|
| | | // 添加金币明细
|
| | | IntegralDetail detail = new IntegralDetail();
|
| | | detail.setTitle("升级VIP福利");
|
| | | detail.setUid(uid);
|
| | | detail.setMoney(Constant.VIP_COLDCOIN_NUM);
|
| | | detail.setCreateTime(new Date());
|
| | | detail.setUniqueKey("VIP-3-" + uid);
|
| | | integralDetailService.insertSelective(detail);
|
| | | |
| | | // 添加金币
|
| | | userInfoExtraService.addGoldCoinByUid(uid, Integer.parseInt(goldcoin));
|
| | | }
|
| | | |
| | | // 是否存在下级脱离期限 -更新不脱离
|
| | | userInviteSeparateService.updateInvalidByBossId(uid);
|
| | | |
| | | // 上级脱离关系
|
| | | remindBoss(uid);
|
| | | |
| | | } catch (UserVIPPreInfoException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
| | | return process;
|
| | | }
|
| | |
|
| | | |
| | | private void remindBoss(Long uid) {
|
| | | // 是否存在上级
|
| | | ThreeSale threeSale = threeSaleSerivce.getMyBoss(uid);
|
| | | if (threeSale == null)
|
| | | return;
|
| | | |
| | | Long bossId = threeSale.getBoss().getId();
|
| | | // 验证上级是否已是会员
|
| | | UserVIPPreInfo oldInfo = userVIPPreInfoMapper.selectByUidAndProcess(bossId, UserVIPPreInfo.PROCESS_1);
|
| | | if (oldInfo != null) {
|
| | | return;
|
| | | }
|
| | | |
| | | // 添加脱离关系倒计时
|
| | | userInviteSeparateService.addPreSeparateRecord(uid, bossId);
|
| | | |
| | | // TODO 消息
|
| | | |
| | | }
|
| | | |
| | | |
| | | |
| | | /**
|
| | | * 二阶段
|
| | | *
|
| | |
| | | * @param firstTeam
|
| | | * @param secondTeam
|
| | | */
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | private boolean twoProcess(Long uid, long countZiGou, long countShare, long firstTeam, long secondTeam) {
|
| | | boolean process = false;
|
| | | String msg = "";
|
| | |
| | | msgDto.setStatus("系统已将你的账户由普通会员升级为高级会员");
|
| | | msgDto.setEquity("从收到本消息起,你将获得全部高级会员权益");
|
| | | msgAccountDetailService.addMsgVIP(uid, msg, "如有疑问请联系我的-人工客服", msgDto);
|
| | | } catch (UserVIPPreInfoException e) {
|
| | | |
| | | // 赠送奖励券
|
| | | String rewardCoupon = userVipConfigService.getValueByKey("vip_pre_7_gift_reward_coupon");
|
| | | if (!StringUtil.isNullOrEmpty(rewardCoupon)) {
|
| | | int num = Integer.parseInt(rewardCoupon);
|
| | | BigDecimal percent = new BigDecimal(configService.get(ConfigKeyEnum.exchangeRebatePercent.getKey()));
|
| | | for (int i = 0; i < num; i++) {
|
| | | userSystemCouponService.insertUserCoupon(uid, CouponTypeEnum.rebatePercentCoupon.name(),
|
| | | UserSystemCoupon.SOURCE_SYSTEM_PUSH, percent, false);
|
| | | }
|
| | | }
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | LogHelper.error(e);
|
| | | }
|
| | | }
|
| | | return process;
|
| | |
| | | */ |
| | | public Date getThirdCreateTime(String orderId,int sourceType); |
| | | |
| | | |
| | | public List<CommonOrder> getMinSettleTimeAndUid(); |
| | | |
| | | } |
| | |
| | | */
|
| | | public List<UserInviteSeparate> getHandleOverdue(int start, int count);
|
| | |
|
| | |
|
| | | public void addPreSeparateRecord(Long workerId, Long bossId);
|
| | |
|
| | | }
|
| | |
| | | */
|
| | | public List<ThreeSale> getMyBossDeepList(Long uid,int deep);
|
| | |
|
| | | /**
|
| | | * 查询未删除版-粉丝一级
|
| | | * @param start
|
| | | * @param count
|
| | | * @param uid
|
| | | * @return
|
| | | */
|
| | | public List<ThreeSale> listFirstTeamByUndeleted(long start, int count, Long uid);
|
| | |
|
| | | /**
|
| | | * 统计粉丝一级
|
| | | * @param uid
|
| | | * @return
|
| | | */
|
| | | public long countFirstTeamByUndeleted(Long uid);
|
| | |
|
| | | /**
|
| | | * 查询未删除版-粉丝二级
|
| | | * @param start
|
| | | * @param count
|
| | | * @param uid
|
| | | * @return
|
| | | */
|
| | | public List<ThreeSale> listSecondTeamByUndeleted(long start, int count, Long uid);
|
| | |
|
| | | /**
|
| | | * 统计粉丝二级
|
| | | * @param uid
|
| | | * @return
|
| | | */
|
| | | public long countSecondTeamByUndeleted(Long uid);
|
| | |
|
| | | }
|
| | |
| | | package com.yeshi.fanli.service.inter.user.invite;
|
| | |
|
| | | import com.yeshi.fanli.dto.user.UserInviteLevelEnum;
|
| | | import com.yeshi.fanli.dto.vip.UserVIPLevel;
|
| | |
|
| | | public interface UserInviteService {
|
| | | /**
|
| | |
| | | * @return
|
| | | */
|
| | | public UserInviteLevelEnum getUserInviteLevelNew(Long uid);
|
| | |
|
| | |
|
| | | public boolean verifyVIP(Long uid);
|
| | |
|
| | |
|
| | | /**
|
| | | * 查询会员当前VIP等级
|
| | | * @param uid
|
| | | * @return
|
| | | */
|
| | | public UserVIPLevel getVIPLevelByUid(Long uid);
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.service.inter.user.invite;
|
| | |
|
| | | import java.util.List;
|
| | |
|
| | | public interface UserInviteValidRecordService {
|
| | |
|
| | | /**
|
| | | * 查询有效粉丝的粉丝id
|
| | | * @param uid
|
| | | * @param list
|
| | | * @param type
|
| | | * @return
|
| | | */
|
| | | public List<Long> getValidWorkerIdsByUid(Long uid, List<Long> list, Integer type);
|
| | |
|
| | |
|
| | | |
| | | }
|
| | |
| | | */
|
| | | public void addUserVIPInfo(UserVIPInfo info) throws UserVIPInfoException;
|
| | |
|
| | | /**
|
| | | * 申请VIP
|
| | | * |
| | | * @param uid
|
| | | * @throws UserVIPInfoException
|
| | | */
|
| | | public void applyVIP(Long uid) throws UserVIPInfoException;
|
| | |
|
| | | /**
|
| | | * 通过vip申请
|
| | | * |
| | | * @param uid
|
| | | */
|
| | | public void passVIPApply(Long uid) throws UserVIPInfoException;
|
| | |
|
| | | /**
|
| | | * 拒绝申请
|
| | | * |
| | | * @param uid
|
| | | * @param reason
|
| | | */
|
| | | public void rejectVIPApply(Long uid, String reason) throws UserVIPInfoException;
|
| | |
|
| | | /**
|
| | | * 是否为VIP
|
| | |
| | | */
|
| | | public Map<Long,Boolean> listByUids(List<Long> uid);
|
| | |
|
| | | /**
|
| | | * 验证是否满足会员条件
|
| | | * @param uid
|
| | | * @return
|
| | | */
|
| | | public boolean verifyConform(Long uid);
|
| | |
|
| | | /**
|
| | | * 待审核列表
|
| | |
| | | * @param uid
|
| | | * @throws UserVIPInfoException
|
| | | */
|
| | | public void passVIPApplyNew(Long uid) throws UserVIPInfoException;
|
| | | public void passVIPApply(Long uid) throws UserVIPInfoException;
|
| | |
|
| | | /**
|
| | | * 超级会员未通过
|
| | |
| | | * @param reason
|
| | | * @throws UserVIPInfoException
|
| | | */
|
| | | public void rejectVIPApplyNew(Long uid, String reason) throws UserVIPInfoException;
|
| | | public void rejectVIPApply(Long uid, String reason) throws UserVIPInfoException;
|
| | |
|
| | | /**
|
| | | * 超级会员申请
|
| | | * @param uid
|
| | | * @throws UserVIPInfoException
|
| | | */
|
| | | public void applyVIPNew(Long uid) throws UserVIPInfoException;
|
| | | public void applyVIP(Long uid) throws UserVIPInfoException;
|
| | |
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.util.rocketmq.consumer.user;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.stereotype.Component;
|
| | |
|
| | | import com.aliyun.openservices.ons.api.Action;
|
| | | import com.aliyun.openservices.ons.api.ConsumeContext;
|
| | | import com.aliyun.openservices.ons.api.Message;
|
| | | import com.aliyun.openservices.ons.api.MessageListener;
|
| | | import com.google.gson.Gson;
|
| | | import com.yeshi.fanli.dto.mq.order.OrderTopicTagEnum;
|
| | | import com.yeshi.fanli.dto.mq.order.body.OrderConfirmMQMsg;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.user.invite.UserInviteValidNumService;
|
| | |
|
| | | /**
|
| | | * 有效队员
|
| | | * |
| | | * @author Administrator
|
| | | *
|
| | | */
|
| | | @Component |
| | | public class InviteValidTeamMessageListener implements MessageListener {
|
| | |
|
| | | @Resource
|
| | | private UserInviteValidNumService userInviteValidNumService;
|
| | |
|
| | | @Override
|
| | | public Action consume(Message message, ConsumeContext context) {
|
| | | |
| | | LogHelper.mqInfo("consumer-InviteValidTeamMessageListener", message.getMsgID(), message.getTopic(),
|
| | | message.getTag(), new String(message.getBody()));
|
| | | String tag = message.getTag();
|
| | | if (tag == null)
|
| | | tag = "";
|
| | |
|
| | | // 订单到账相关
|
| | | if (tag.equalsIgnoreCase(OrderTopicTagEnum.orderConfirm.name())) {
|
| | | OrderConfirmMQMsg dto = new Gson().fromJson(new String(message.getBody()),OrderConfirmMQMsg.class);
|
| | | if (dto != null) {
|
| | | userInviteValidNumService.addValidTeamNum(dto.getSourceUid(), dto.getSettleMent(), dto.getPlaceOrderTime());
|
| | | }
|
| | | }
|
| | | return Action.CommitMessage;
|
| | | }
|
| | | }
|