From e1a62ec62e7331d97af9302e90e1ce44af8235eb Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期三, 27 一月 2021 15:26:55 +0800
Subject: [PATCH] 拼多多授权绑定

---
 fanli/src/main/java/com/yeshi/fanli/controller/client/v2/InviteControllerV2.java |  103 ++++++++++++++++++++++++++++-----------------------
 1 files changed, 56 insertions(+), 47 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/client/v2/InviteControllerV2.java b/fanli/src/main/java/com/yeshi/fanli/controller/client/v2/InviteControllerV2.java
index a136c1c..608c29f 100644
--- a/fanli/src/main/java/com/yeshi/fanli/controller/client/v2/InviteControllerV2.java
+++ b/fanli/src/main/java/com/yeshi/fanli/controller/client/v2/InviteControllerV2.java
@@ -11,6 +11,7 @@
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
 
+import com.yeshi.fanli.entity.SystemEnum;
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
@@ -32,7 +33,6 @@
 import com.yeshi.fanli.entity.bus.user.UserInfoExtra;
 import com.yeshi.fanli.entity.bus.user.UserInviteValidNum;
 import com.yeshi.fanli.entity.bus.user.UserInviteValidRecord;
-import com.yeshi.fanli.entity.bus.user.WeiXinUser;
 import com.yeshi.fanli.entity.bus.user.invite.TeamDailyRecord;
 import com.yeshi.fanli.entity.bus.user.vip.TeamUserLevelStatistic;
 import com.yeshi.fanli.entity.bus.user.vip.TearcherInfo;
@@ -71,15 +71,16 @@
 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 org.yeshi.utils.TimeUtil;
 import com.yeshi.fanli.util.VersionUtil;
 import com.yeshi.fanli.util.annotation.RequestSerializableByKey;
 import com.yeshi.fanli.util.user.UserLevelUtil;
-import com.yeshi.fanli.util.wx.WXLoginUtil;
 import com.yeshi.fanli.vo.order.OrderRankingVO;
 
 import net.sf.json.JSONArray;
 import net.sf.json.JSONObject;
+import org.yeshi.utils.entity.wx.WeiXinUser;
+import org.yeshi.utils.wx.WXAppLoginUtil;
 
 @Controller
 @RequestMapping("api/v2/invite")
@@ -186,7 +187,7 @@
 		try {
 			WXAccountInfoDTO wxAccount = Constant.getWXAccount(acceptData.getPlatform(), acceptData.getVersion());
 			// 鑾峰彇寰俊淇℃伅
-			WeiXinUser weiXinUser = WXLoginUtil.getWeiXinUser(code, wxAccount.getAppId(), wxAccount.getAppSecret());
+			WeiXinUser weiXinUser = WXAppLoginUtil.getWeiXinUser(code, wxAccount.getAppId(), wxAccount.getAppSecret());
 			if (weiXinUser == null)
 				throw new UserInfoExtraException(1, "寰俊鎺堟潈澶辫触");
 
@@ -249,7 +250,6 @@
 	 * 鐢ㄦ埛闃熷憳鍒楄〃鏌ヨ
 	 * 
 	 * @param acceptData
-	 * @param id
 	 * @param out
 	 */
 	@RequestMapping(value = "getMyTeam", method = RequestMethod.POST)
@@ -299,7 +299,6 @@
 	/**
 	 * 缁勭粐鏁版嵁
 	 * 
-	 * @param count
 	 * @param list
 	 * @param uid
 	 * @param type
@@ -395,7 +394,6 @@
 	/**
 	 * 鍔犲伐鏁版嵁
 	 * 
-	 * @param count
 	 * @param list
 	 * @param uid
 	 * @param type  鏌ヨ绮変笣绫诲瀷 1鐩存帴 2闂存帴
@@ -544,7 +542,6 @@
 	 * 鐢ㄦ埛闃熷憳缁熻- IOS
 	 * 
 	 * @param acceptData
-	 * @param id
 	 * @param out
 	 */
 	@RequestMapping(value = "countMyTeam", method = RequestMethod.POST)
@@ -559,12 +556,12 @@
 		resultData.put("firstTeamTotal", firstTeam);
 		resultData.put("secondTeam", countSecond);
 		resultData.put("secondTeamTotal", countSecond);
-		resultData.put("helpLink", configService.get(ConfigKeyEnum.teamHelpUrl.getKey()));
+		resultData.put("helpLink", configService.getValue(ConfigKeyEnum.teamHelpUrl.getKey(),acceptData.getSystem()));
 
 		boolean hasTeam = true;
 		if (firstTeam <= 0) {
 			hasTeam = false;
-			resultData.put("invitelink", configService.get(ConfigKeyEnum.inviteActivationUrl.getKey()));
+			resultData.put("invitelink", configService.getValue(ConfigKeyEnum.inviteActivationUrl.getKey(),acceptData.getSystem()));
 		}
 		resultData.put("hasTeam", hasTeam);
 
@@ -583,7 +580,7 @@
 		resultData.put("hasCode", hasCode);
 		if (!hasCode) {
 			List<String> tipCode = new ArrayList<String>();
-			resultData.put("helpLinkActivate", configService.get(ConfigKeyEnum.teamHelpUrl.getKey()));
+			resultData.put("helpLinkActivate", configService.getValue(ConfigKeyEnum.teamHelpUrl.getKey(),acceptData.getSystem()));
 			tipCode.add("婵�娲婚個璇峰姛鑳藉悗鎵嶅彲浠ラ個璇风矇涓濓紝鐩存帴绮変笣鏄敱浣犵洿鎺ラ個璇凤紝闂存帴绮変笣鏄敱浣犵殑鐩存帴绮変笣閭�璇枫��");
 			tipCode.add("閭�璇锋縺娲诲姛鑳斤紝蹇呴』瑕佹湁閭�璇风爜锛岄個璇风爜鍙互閫氳繃閲戝竵鍏戞崲锛屼篃鍙互鍏ㄧ綉鎼滅储銆�");
 			resultData.put("tipCode", tipCode);
@@ -622,7 +619,6 @@
 	/**
 	 * 涓婄骇淇℃伅缁勭粐
 	 * 
-	 * @param acceptData
 	 * @param uid
 	 * @param threeSale
 	 * @return
@@ -655,8 +651,9 @@
 			}
 			bossData.put("inviteTime", "浣犱簬 " + sdf.format(inviteTime) + "鎺ュ彈浜員A鐨勯個璇�");
 		} else {
+			SystemEnum system= userInfoService.getUserSystem(uid);
 			bossData.put("hasBoss", false);
-			bossData.put("helpLink", configService.get(ConfigKeyEnum.inviteCodeHlepLink.getKey()));
+			bossData.put("helpLink", configService.getValue(ConfigKeyEnum.inviteCodeHlepLink.getKey(),system));
 			bossData.put("weiXinTip", "鎭枩浣狅紝鎴戜滑鐨勪紭璐ㄧ敤鎴凤紱\r\n浣犲苟娌℃湁閭�璇蜂汉锛屼絾浣犵殑閭�璇锋縺娲诲姛鑳芥槸琚粯璁ゅ紑鍚殑锛沑r\n浣犳嫢鏈夌嫭鐗圭殑鏃犻個璇蜂汉婵�娲荤爜銆�");
 		}
 		return bossData;
@@ -724,7 +721,7 @@
 		try {
 			List<String> listIOS = new ArrayList<String>();
 			List<String> listAndroid = new ArrayList<String>();
-			pushService.pushZNX(remindId, title, content, listIOS, listAndroid);
+			pushService.pushZNX(remindId, title, content, listIOS, listAndroid,acceptData.getSystem());
 
 			userSystemMsgService.addUserSystemMsg(remindId, UserSystemMsgTypeEnum.common, title, content,
 					UserSystemMsg.TIME_TAG_COMMON, null);
@@ -796,7 +793,7 @@
 			JSONObject data = new JSONObject();
 			data.put("count", spreadImgService.countAll());
 			data.put("inviteCode", inviteCode);
-			data.put("helpLink", configService.get(ConfigKeyEnum.inviteHelpLink.getKey()));
+			data.put("helpLink", configService.getValue(ConfigKeyEnum.inviteHelpLink.getKey(),acceptData.getSystem()));
 			data.put("inviteRules", values.getValue().replace("\n", "<br><br>"));
 			data.put("imgUrlList", JsonUtil.getSimpleGsonWithDate().toJson(imgList));
 			data.put("inviteLink", Constant.YINGYONGBAO_LINK);
@@ -812,7 +809,6 @@
 	 * 
 	 * @param acceptData
 	 * @param uid
-	 * @param inviteId
 	 * @param out
 	 */
 	@RequestMapping(value = "tailorCode")
@@ -839,7 +835,6 @@
 	 * 鐢ㄦ埛闃熷憳鍒楄〃鏌ヨ
 	 * 
 	 * @param acceptData
-	 * @param id
 	 * @param out
 	 */
 	@RequestMapping(value = "getMyTeamV2", method = RequestMethod.POST)
@@ -894,7 +889,7 @@
 
 		// 缁熻H5閾炬帴
 		if (page == 1) {
-			result.put("link", configService.get(ConfigKeyEnum.teamStatisticsLink.getKey()));
+			result.put("link", configService.getValue(ConfigKeyEnum.teamStatisticsLink.getKey(),acceptData.getSystem()));
 		}
 		out.print(JsonUtil.loadTrueResult(result));
 	}
@@ -920,7 +915,6 @@
 	 * 鐢ㄦ埛闃熷憳缁熻
 	 * 
 	 * @param acceptData
-	 * @param id
 	 * @param out
 	 */
 	@RequestMapping(value = "countMyTeamV2")
@@ -1040,7 +1034,6 @@
 			int darenMonth = 0;
 			int highVIPMonth = 0;
 			int superVIPMonth = 0;
-			Date date = new Date();
 			Date minTime = TimeUtil.parseYYYYMMDD(firstday);
 			Date maxTime = TimeUtil.parseYYYYMMDD_HHMMSS(lastday + " 23:59:59");
 			List<TeamDailyRecord> listMonth = teamDailyRecordService.sumGroupByYearMonth(uid, minTime, maxTime);
@@ -1202,14 +1195,24 @@
 		if (directNum > 0) {
 			indirectNum = threeSaleSerivce.countSecondTeam(workerId);
 		}
-
+		data.put("fansNum", "鐩存帴绮変笣锛� " + directNum + "浜篭n" + "闂存帴绮変笣锛� " + indirectNum + "浜�");
+		
 		// 璁㈠崟缁熻
 		long countTB = commonOrderCountService.countOrderBySourceAndNearDay(workerId, Constant.SOURCE_TYPE_TAOBAO, 60);
 		long countJD = commonOrderCountService.countOrderBySourceAndNearDay(workerId, Constant.SOURCE_TYPE_JD, 60);
 		long countPDD = commonOrderCountService.countOrderBySourceAndNearDay(workerId, Constant.SOURCE_TYPE_PDD, 60);
-
-		data.put("fansNum", "鐩存帴绮変笣锛� " + directNum + "浜篭n" + "闂存帴绮変笣锛� " + indirectNum + "浜�");
-		data.put("orderInfo", "娣樺疂 (" + countTB + "绗�)\n" + "浜笢 (" + countJD + "绗�)\n" + "鎷煎澶� (" + countPDD + "绗�)");
+		
+		StringBuilder builder = new StringBuilder();
+		builder.append("娣樺疂 (" + countTB + "绗�)");
+		builder.append("\n浜笢 (" + countJD + "绗�)");
+		builder.append("\n鎷煎澶� (" + countPDD + "绗�)");
+		if (VersionUtil.greaterThan_2_1_2(acceptData.getPlatform(), acceptData.getVersion())) {
+			long countVip = commonOrderCountService.countOrderBySourceAndNearDay(workerId, Constant.SOURCE_TYPE_VIP, 60);
+			long countSL = commonOrderCountService.countOrderBySourceAndNearDay(workerId, Constant.SOURCE_TYPE_SUNING, 60);
+			builder.append("\n鍞搧浼� (" + countVip + "绗�)");
+			builder.append("\n鑻忓畞 (" + countSL + "绗�)");
+		}
+		data.put("orderInfo", builder.toString());
 		out.print(JsonUtil.loadTrueResult(data));
 	}
 
@@ -1299,7 +1302,14 @@
 		if (activeTime == null) {
 			activeTime = new Date(user.getCreatetime());
 		}
-
+		
+		String inviteCode = "";
+		if (!StringUtil.isNullOrEmpty(userInfoExtra.getInviteCode()))
+			inviteCode = userInfoExtra.getInviteCode();
+		if (!StringUtil.isNullOrEmpty(userInfoExtra.getInviteCodeVip()))
+			inviteCode = userInfoExtra.getInviteCodeVip();
+		
+		data.put("inviteCode", inviteCode);
 		data.put("weixin", StringUtil.isNullOrEmpty(weixin) ? "" : weixin);
 		data.put("loginTime", TimeUtil.formatDate(activeTime));
 
@@ -1311,27 +1321,16 @@
 			data.put("taobao", false);
 		}
 
-		UserVIPPreInfo userVIPPreInfo = userVIPPreInfoService.getLatestProcessInfo(fansId);
-		if (userVIPPreInfo != null) {
-			String levelName = null;
-			Integer process = userVIPPreInfo.getProcess();
-			if (process == UserVIPPreInfo.PROCESS_2) {
-				levelName = "楂樼骇浼氬憳";
-			} else if (process == UserVIPPreInfo.PROCESS_3) {
-				levelName = "瓒呯骇浼氬憳";
-			} else if (process == UserVIPPreInfo.PROCESS_4) {
-				levelName = "璧勬繁瀵煎笀";
-			}
-
-			Integer sourceType = userVIPPreInfo.getSourceType();
-			if (sourceType != null && levelName != null) {
-				if (sourceType == UserVIPPreInfo.SOURCE_TYPE_ORDER) {
-					data.put("level", levelName += "(鑷喘鍒嗕韩鍨�)");
-				} else if (sourceType == UserVIPPreInfo.SOURCE_TYPE_TEAM) {
-					data.put("level", levelName += "(閭�璇峰洟闃熷瀷)");
-				}
-			}
+		// 褰撳墠绛夌骇
+		UserLevelEnum level = null;
+		UserVIPLevel vipLevel = userInviteService.getVIPLevelByUid(fansId);
+		if (vipLevel != null && vipLevel.getLevel() != null) {
+			level = UserLevelUtil.getByLevel(vipLevel.getLevel());
 		}
+		if (level == null) {
+			level = UserLevelEnum.daRen;
+		}
+		data.put("level", UserLevelUtil.getShowLevel(level));
 
 		// 绮変笣缁熻
 		long indirectNum = 0;
@@ -1339,14 +1338,24 @@
 		if (directNum > 0) {
 			indirectNum = threeSaleSerivce.countSecondTeam(fansId);
 		}
+		data.put("fansNum", "鐩存帴绮変笣锛� " + directNum + "浜篭n" + "闂存帴绮変笣锛� " + indirectNum + "浜�");
 
 		// 璁㈠崟缁熻
 		long countTB = commonOrderCountService.countOrderBySourceAndNearDay(fansId, Constant.SOURCE_TYPE_TAOBAO, 60);
 		long countJD = commonOrderCountService.countOrderBySourceAndNearDay(fansId, Constant.SOURCE_TYPE_JD, 60);
 		long countPDD = commonOrderCountService.countOrderBySourceAndNearDay(fansId, Constant.SOURCE_TYPE_PDD, 60);
 
-		data.put("fansNum", "鐩存帴绮変笣锛� " + directNum + "浜篭n" + "闂存帴绮変笣锛� " + indirectNum + "浜�");
-		data.put("orderInfo", "娣樺疂 (" + countTB + "绗�)\n" + "浜笢 (" + countJD + "绗�)\n" + "鎷煎澶� (" + countPDD + "绗�)");
+		StringBuilder builder = new StringBuilder();
+		builder.append("娣樺疂 (" + countTB + "绗�)");
+		builder.append("\n浜笢 (" + countJD + "绗�)");
+		builder.append("\n鎷煎澶� (" + countPDD + "绗�)");
+		if (VersionUtil.greaterThan_2_1_2(acceptData.getPlatform(), acceptData.getVersion())) {
+			long countVip = commonOrderCountService.countOrderBySourceAndNearDay(fansId, Constant.SOURCE_TYPE_VIP, 60);
+			long countSL = commonOrderCountService.countOrderBySourceAndNearDay(fansId, Constant.SOURCE_TYPE_SUNING, 60);
+			builder.append("\n鍞搧浼� (" + countVip + "绗�)");
+			builder.append("\n鑻忓畞 (" + countSL + "绗�)");
+		}
+		data.put("orderInfo", builder.toString());
 		JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
 	}
 

--
Gitblit v1.8.0