From 28cf328a098334b51a3e9d2d56f983fb8c862211 Mon Sep 17 00:00:00 2001 From: yujian <yujian@163.com> Date: 星期六, 23 五月 2020 09:54:38 +0800 Subject: [PATCH] 足迹、收藏订单兼容新需求 --- fanli/src/main/java/com/yeshi/fanli/controller/wxmp/v1/InviteController.java | 184 +++++++++++++++++++++++++++++++-------------- 1 files changed, 127 insertions(+), 57 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/wxmp/v1/InviteController.java b/fanli/src/main/java/com/yeshi/fanli/controller/wxmp/v1/InviteController.java index 358cbec..1ff6e9f 100644 --- a/fanli/src/main/java/com/yeshi/fanli/controller/wxmp/v1/InviteController.java +++ b/fanli/src/main/java/com/yeshi/fanli/controller/wxmp/v1/InviteController.java @@ -12,25 +12,26 @@ import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; -import org.yeshi.utils.DateUtil; import org.yeshi.utils.JsonUtil; import com.yeshi.fanli.dto.WXMPAcceptData; -import com.yeshi.fanli.entity.accept.AcceptData; +import com.yeshi.fanli.entity.bus.msg.UserSystemMsg; +import com.yeshi.fanli.entity.bus.msg.UserSystemMsgTypeEnum; import com.yeshi.fanli.entity.bus.user.ThreeSale; import com.yeshi.fanli.entity.bus.user.ThreeSaleExtraInfo; 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.system.ConfigKeyEnum; import com.yeshi.fanli.service.inter.config.ConfigService; +import com.yeshi.fanli.service.inter.msg.UserSystemMsgService; +import com.yeshi.fanli.service.inter.push.PushService; import com.yeshi.fanli.service.inter.user.UserInfoExtraService; -import com.yeshi.fanli.service.inter.user.UserInviteSeparateService; +import com.yeshi.fanli.service.inter.user.UserInfoService; 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.vip.UserVIPInfoService; import com.yeshi.fanli.util.Constant; import com.yeshi.fanli.util.StringUtil; -import com.yeshi.fanli.util.VersionUtil; import net.sf.json.JSONArray; import net.sf.json.JSONObject; @@ -52,10 +53,16 @@ private UserVIPInfoService userVIPInfoService; @Resource - private UserInviteSeparateService userInviteSeparateService; - - @Resource private ThreeSaleExtraInfoSerivce threeSaleExtraInfoSerivce; + + @Resource + private UserInfoService userInfoService; + + @Resource + private PushService pushService; + + @Resource + private UserSystemMsgService userSystemMsgService; /** * 涓撳睘閭�璇风爜鏉′欢 @@ -95,7 +102,7 @@ JSONObject data = new JSONObject(); data.put("desc", array); - data.put("num", threeSaleSerivce.countFirstTeam(uid, 1)); + data.put("num", threeSaleSerivce.countFirstTeam(uid)); data.put("limit", Constant.INVITE_CODRE_TAILOR_LIMIT); out.print(JsonUtil.loadTrueResult(data)); @@ -111,11 +118,8 @@ @RequestMapping(value = "countMyTeam", method = RequestMethod.POST) public void countMyTeam(WXMPAcceptData acceptData, long uid, PrintWriter out) { try { - long firstTeam = threeSaleSerivce.countFirstTeam(uid, 1); - long firstTeamTotal = threeSaleSerivce.countFirstTeam(uid, null); - - long secondTeam = threeSaleSerivce.countSecondTeam(uid, 1); - long secondTeamTotal = threeSaleSerivce.countSecondTeam(uid, null); + long firstTeam = threeSaleSerivce.countFirstTeam(uid); + long secondTeam = threeSaleSerivce.countSecondTeam(uid); JSONObject bossData = new JSONObject(); ThreeSale threeSale = threeSaleSerivce.getMyBoss(uid); if (threeSale != null) { @@ -133,15 +137,15 @@ JSONObject resultData = new JSONObject(); - String helpLink = configService.get("team_help_url"); + String helpLink = configService.get(ConfigKeyEnum.teamHelpUrl.getKey()); if (helpLink == null) { helpLink = ""; } resultData.put("helpLink", helpLink); resultData.put("firstTeam", firstTeam); - resultData.put("firstTeamTotal", firstTeamTotal); + resultData.put("firstTeamTotal", firstTeam); resultData.put("secondTeam", secondTeam); - resultData.put("secondTeamTotal", secondTeamTotal); + resultData.put("secondTeamTotal", secondTeam); resultData.put("boss", bossData); boolean hasCode = false; @@ -150,7 +154,7 @@ hasCode = true; // 宸叉湁閭�璇风爜 } else { // 閭�璇锋縺娲婚摼鎺� - resultData.put("activationlink", configService.get("invite_activation_url")); + resultData.put("activationlink", configService.get(ConfigKeyEnum.inviteActivationUrl.getKey())); } resultData.put("hasCode", hasCode); @@ -168,7 +172,7 @@ * @param id * @param out */ - @RequestMapping(value = "listMyTeam", method = RequestMethod.POST) + @RequestMapping(value = "listMyTeam") public void listMyTeam(WXMPAcceptData acceptData, int page, long uid, int type, PrintWriter out) { if (type != 1 && type != 2) { out.print(JsonUtil.loadFalseResult("绮変笣绫诲瀷涓嶆纭�")); @@ -178,16 +182,14 @@ long count = 0; List<ThreeSale> listTeam = null; if (type == 1) { - listTeam = threeSaleSerivce.listFirstTeam((page - 1) * Constant.PAGE_SIZE, Constant.PAGE_SIZE, uid, 1); - count = threeSaleSerivce.countFirstTeam(uid, 1); + listTeam = threeSaleSerivce.listFirstTeam((page - 1) * Constant.PAGE_SIZE, Constant.PAGE_SIZE, uid); + count = threeSaleSerivce.countFirstTeam(uid); } else if (type == 2) { - listTeam = threeSaleSerivce.listSecondTeam((page - 1) * Constant.PAGE_SIZE, Constant.PAGE_SIZE, uid, 1); - count = threeSaleSerivce.countSecondTeam(uid, 1); + listTeam = threeSaleSerivce.listSecondTeam((page - 1) * Constant.PAGE_SIZE, Constant.PAGE_SIZE, uid); + count = threeSaleSerivce.countSecondTeam(uid); } - boolean needVIPInfo = false; - if (VersionUtil.greaterThan_2_0_5(acceptData.getPlatform(), acceptData.getVersion())) - needVIPInfo = true; + boolean needVIPInfo = true; // 缁勭粐鏁版嵁 JSONObject resultData = organizeTeam(count, listTeam, uid, type, needVIPInfo); @@ -250,35 +252,6 @@ // 娣诲姞鏄惁涓篤IP if (vipMap != null && vipMap.get(worker.getId()) != null) { object.put("vip", vipMap.get(worker.getId())); - if (vipMap.get(worker.getId())) { - 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", "灏嗕簬"); - - JSONObject contentJson2 = new JSONObject(); - contentJson2.put("color", "#F14242"); - contentJson2.put("content", DateUtil.dateDiff4(new Date(), separate.getEndTime())); - - JSONObject contentJson3 = new JSONObject(); - contentJson3.put("color", "#888888"); - contentJson3.put("content", "鍚庤劚绂婚個璇峰叧绯�"); - - JSONArray array = new JSONArray(); - array.add(contentJson1); - array.add(contentJson2); - array.add(contentJson3); - object.put("vipBreakTime", array); - - } catch (Exception e) { - e.printStackTrace(); - } - } - } } String fontColor1 = "#888888"; JSONArray array = new JSONArray(); @@ -343,13 +316,110 @@ * @param out */ @RequestMapping(value = "getBossInfo", method = RequestMethod.POST) - public void getBossInfo(AcceptData acceptData, Long uid, PrintWriter out) { + public void getBossInfo(WXMPAcceptData acceptData, Long uid, PrintWriter out) { if (uid == null || uid <= 0) { out.print(JsonUtil.loadFalseResult("鐢ㄦ埛鏈櫥褰�")); return; } JSONObject bossData = getBossInfo(uid, threeSaleSerivce.getMyBoss(uid)); out.print(JsonUtil.loadTrueResult(bossData)); + } + + /** + * 绔欏唴淇℃彁閱掗槦鍛樻坊鍔犲井淇″彿 + * + * @param acceptData + * @param uid + * @param inviteId + * @param out + */ + @RequestMapping(value = "remindBossAddWX") + public void remindTeam(WXMPAcceptData acceptData, Long uid, PrintWriter out) { + if (uid == null) { + out.print(JsonUtil.loadFalseResult("浼犻�掑弬鏁扮己澶�")); + return; + } + + UserInfo userInfo = userInfoService.selectByPKey(uid); + if (userInfo == null) { + out.print(JsonUtil.loadFalseResult("鐢ㄦ埛淇℃伅涓嶅瓨鍦�")); + return; + } + + ThreeSale threeSale = threeSaleSerivce.getByWorkerId(uid); + if (threeSale == null) { + out.print(JsonUtil.loadFalseResult("娌℃湁閭�璇蜂汉")); + return; + } + + Long remindId = null; + boolean remindBoss = true; + if (uid.longValue() == threeSale.getWorker().getId().longValue()) { + remindId = threeSale.getBoss().getId(); // 鎻愰啋涓婄骇 + } else if (uid.longValue() == threeSale.getBoss().getId().longValue()) { + remindBoss = false; + remindId = threeSale.getWorker().getId(); // 鎻愰啋涓嬬骇 + } + + if (remindId == null) { + out.print(JsonUtil.loadFalseResult("淇℃伅楠岃瘉鏈�氳繃")); + return; + } + + Long bossId = null; + Long workerId = null; + String title = "绮変笣鎻愰啋娑堟伅"; + String content = ""; + if (remindBoss) { + // 鎻愮ず闃熼暱 + bossId = remindId; + workerId = uid; + content = "浣犵殑鐩存帴绮変笣" + userInfo.getNickName() + + "锛屾彁閱掍綘娣诲姞寰俊鍙凤紝浠ヤ究浜庡拰浣犲彇寰楄仈绯诲拰瀛︿範鐪侀挶鎶�宸э紝璧跺揩鍘绘坊鍔犲惂锛涙敞锛氳鍗囩骇鍒版湰杞欢鏈�鏂扮増鏈湪鈥滄垜鐨�-鎴戠殑淇℃伅鈥濅腑娣诲姞銆�"; + } else { + // 鎻愮ず闃熷憳 + bossId = uid; + workerId = remindId; + content = "浣犵殑閭�璇蜂汉" + userInfo.getNickName() + + "锛屾彁閱掍綘娣诲姞寰俊鍙凤紝浠ヤ究浜庡拰浣犲彇寰楄仈绯诲府鍔╀綘鏇村ソ鐨勭渷閽憋紝璧跺揩鍘绘坊鍔犲惂锛涙敞锛氳鍗囩骇鍒版湰杞欢鏈�鏂扮増鏈湪鈥滄垜鐨�-鎴戠殑淇℃伅鈥濅腑娣诲姞銆�"; + } + + try { + List<String> listIOS = new ArrayList<String>(); + List<String> listAndroid = new ArrayList<String>(); + pushService.pushZNX(remindId, title, content, listIOS, listAndroid); + + userSystemMsgService.addUserSystemMsg(remindId, UserSystemMsgTypeEnum.common, title, content, + UserSystemMsg.TIME_TAG_COMMON, null); + + ThreeSaleExtraInfo newInfo = new ThreeSaleExtraInfo(); + if (remindBoss) { + newInfo.setRemindBoss(1); + } else { + newInfo.setRemindWorker(1); + } + + ThreeSaleExtraInfo threeExtra = threeSaleExtraInfoSerivce.getbyBossIdAndWorkerId(bossId, workerId); + if (threeExtra != null) { + newInfo.setId(threeExtra.getId()); + newInfo.setUpdateTime(new Date()); + threeSaleExtraInfoSerivce.updateByPrimaryKeySelective(newInfo); + } else { + newInfo.setBoss(new UserInfo(bossId)); + newInfo.setWorker(new UserInfo(workerId)); + newInfo.setCreateTime(new Date()); + newInfo.setUpdateTime(new Date()); + threeSaleExtraInfoSerivce.insertSelective(newInfo); + } + + JSONObject data = new JSONObject(); + data.put("weiXinState", 2); + data.put("weiXinTip", "绯荤粺宸插彂閫佹彁閱掞紝閭�璇蜂汉娣诲姞寰俊鍚庝綘鍙鍒讹紝濡傚鏂硅繜杩熶笉娣诲姞锛屼綘鍙仈绯讳汉宸ュ鏈嶅姹傚府鍔�"); + out.print(JsonUtil.loadTrueResult(data)); + } catch (Exception e) { + e.printStackTrace(); + out.print(JsonUtil.loadFalseResult("鎻愰啋澶辫触")); + } } /** @@ -389,7 +459,7 @@ bossData.put("inviteTime", "浣犱簬 " + sdf.format(inviteTime) + "鎺ュ彈浜員A鐨勯個璇�"); } else { bossData.put("hasBoss", false); - bossData.put("helpLink", configService.get("invite_code_hlep_link")); + bossData.put("helpLink", configService.get(ConfigKeyEnum.inviteCodeHlepLink.getKey())); bossData.put("weiXinTip", "鎭枩浣狅紝鎴戜滑鐨勪紭璐ㄧ敤鎴凤紱\r\n浣犲苟娌℃湁閭�璇蜂汉锛屼絾浣犵殑閭�璇锋縺娲诲姛鑳芥槸琚粯璁ゅ紑鍚殑锛沑r\n浣犳嫢鏈夌嫭鐗圭殑鏃犻個璇蜂汉婵�娲荤爜銆�"); } return bossData; -- Gitblit v1.8.0