From 155913b57ad50126240bc3d5c1aef6ebfe12e3cf Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期四, 12 九月 2019 16:43:15 +0800
Subject: [PATCH] 微信开放平台修改

---
 fanli/src/main/java/com/yeshi/fanli/controller/client/v2/InviteControllerV2.java |  116 ++++++++++++++++++++++++++++-----------------------------
 1 files changed, 57 insertions(+), 59 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 00287fe..144762e 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
@@ -34,37 +34,34 @@
 import net.sf.json.JSONArray;
 import net.sf.json.JSONObject;
 
-
 @Controller
 @RequestMapping("api/v2/invite")
 public class InviteControllerV2 {
 
 	@Resource
 	private ConfigService configService;
-	
+
 	@Resource
 	private PushService pushService;
 
 	@Resource
 	private UserSystemMsgService userSystemMsgService;
-	
+
 	@Resource
 	private ThreeSaleSerivce threeSaleSerivce;
-	
+
 	@Resource
 	private UserInfoService userInfoService;
-	
+
 	@Resource
 	private UserInfoExtraService userInfoExtraService;
-	
+
 	@Resource
 	private ThreeSaleExtraInfoSerivce threeSaleExtraInfoSerivce;
 
-	
-	
-	
 	/**
 	 * 閭�璇风爜楠岃瘉
+	 * 
 	 * @param out
 	 */
 	@RequestMapping(value = "verifyCode")
@@ -80,16 +77,17 @@
 			out.print(JsonUtil.loadFalseResult(e.getMsg()));
 		}
 	}
-	
-	
+
 	/**
 	 * 閭�璇风爜寰俊
+	 * 
 	 * @param out
 	 */
 	@RequestMapping(value = "verifyWX")
 	public void verifyWX(AcceptData acceptData, Long uid, String code, PrintWriter out) {
 		try {
-			UserInfo userInfo = userInfoExtraService.getInviterInfo(uid, code);
+			UserInfo userInfo = userInfoExtraService.getInviterInfo(
+					Constant.getWXAccount(acceptData.getPlatform(), acceptData.getVersion()), uid, code);
 			JSONObject data = new JSONObject();
 			data.put("nickName", userInfo.getNickName());
 			data.put("portrait", userInfo.getPortrait());
@@ -99,7 +97,7 @@
 			out.print(JsonUtil.loadFalseResult(e.getMsg()));
 		}
 	}
-	
+
 	/**
 	 * 鐢ㄦ埛闃熷憳鍒楄〃鏌ヨ 1.5.3鏌ヨ鏈夋晥闃熷憳
 	 * 
@@ -123,10 +121,10 @@
 			listTeam = threeSaleSerivce.listSecondTeam((page - 1) * Constant.PAGE_SIZE, Constant.PAGE_SIZE, uid, 1);
 			count = threeSaleSerivce.countSecondTeam(uid, 1);
 		}
-		
+
 		// 缁勭粐鏁版嵁
 		JSONObject resultData = organizeTeam(count, listTeam, uid, type);
-		
+
 		// 绗竴椤靛垽鏂槸鍚︽縺娲� 鏄惁鏈夐槦鍛�
 		if (type == 1 && page == 1) {
 			boolean hasCode = false;
@@ -136,15 +134,14 @@
 					hasCode = true;
 			}
 			resultData.put("hasCode", hasCode);
-			resultData.put("hasTeam", count > 0? true:false);
+			resultData.put("hasTeam", count > 0 ? true : false);
 		}
 		out.print(JsonUtil.loadTrueResult(resultData));
 	}
-	
-	
-	
+
 	/**
 	 * 缁勭粐鏁版嵁
+	 * 
 	 * @param count
 	 * @param list
 	 * @param uid
@@ -154,28 +151,28 @@
 	private JSONObject organizeTeam(long count, List<ThreeSale> list, Long uid, int type) {
 		JSONObject result = new JSONObject();
 		JSONArray resultArray = new JSONArray();
-		
+
 		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");
-		
+
 		for (ThreeSale threeSale : list) {
 			UserInfo worker = threeSale.getWorker();
 			if (worker == null) {
 				continue;
 			}
 			Long workerId = worker.getId();
-			
+
 			JSONObject object = new JSONObject();
 			object.put("workerId", worker.getId());
 			object.put("nickName", worker.getNickName());
 			object.put("portrait", worker.getPortrait());
 			object.put("inviteId", threeSale.getId());
-			
+
 			Date inviteTime = new Date(threeSale.getCreateTime());
 			object.put("inviteTime", format.format(inviteTime) + " 鍔犲叆");
-			
+
 			String fontColor1 = "#888888";
 			JSONArray array = new JSONArray();
 			if (threeSale.getState()) {
@@ -194,9 +191,9 @@
 					contentJson.put("content", "鏈�杩戠櫥褰� " + format.format(lastLoginTime));
 				}
 				array.add(contentJson);
-				
+
 				// 涓�绾ч槦鍛� 鏌ヨ
-				if(type == 1) {
+				if (type == 1) {
 					String memoName = null;
 					ThreeSaleExtraInfo threeSaleExtraInfo = threeSale.getThreeSaleExtraInfo();
 					if (threeSaleExtraInfo != null) {
@@ -205,7 +202,7 @@
 						}
 					}
 					object.put("memoName", memoName);
-					
+
 					UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(workerId);
 					if (userInfoExtra != null && !StringUtil.isNullOrEmpty(userInfoExtra.getWeiXin())) {
 						object.put("weiXin", userInfoExtra.getWeiXin());
@@ -221,7 +218,7 @@
 						}
 					}
 				}
-			} 
+			}
 			object.put("state", 1);
 			object.put("recentMsg", array);
 			resultArray.add(object);
@@ -232,7 +229,6 @@
 		return result;
 	}
 
-	
 	/**
 	 * 鐢ㄦ埛闃熷憳缁熻- IOS
 	 * 
@@ -244,7 +240,7 @@
 	public void countMyTeam(AcceptData acceptData, long uid, PrintWriter out) {
 		JSONObject bossData = getBossInfo(acceptData, uid, threeSaleSerivce.getMyBoss(uid));
 		JSONObject resultData = new JSONObject();
-		
+
 		long firstTeam = threeSaleSerivce.countFirstTeam(uid, 1);
 		resultData.put("boss", bossData);
 		resultData.put("helpLink", configService.get("team_help_url"));
@@ -252,25 +248,25 @@
 		resultData.put("firstTeamTotal", threeSaleSerivce.countFirstTeam(uid, null));
 		resultData.put("secondTeam", threeSaleSerivce.countSecondTeam(uid, 1));
 		resultData.put("secondTeamTotal", threeSaleSerivce.countSecondTeam(uid, null));
-		
+
 		boolean hasTeam = true;
 		if (firstTeam <= 0) {
 			hasTeam = false;
 			resultData.put("invitelink", configService.get("invite_activation_url"));
 		}
 		resultData.put("hasTeam", hasTeam);
-		
+
 		boolean hasCode = false;
 		boolean bdWeiXin = false;
 		UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid);
 		if (userInfoExtra != null) {
 			if (!StringUtil.isNullOrEmpty(userInfoExtra.getInviteCode()))
 				hasCode = true;
-			
+
 			if (!StringUtil.isNullOrEmpty(userInfoExtra.getWeiXin()))
 				bdWeiXin = true;
 		}
-		
+
 		// 鏈縺娲婚個璇风爜
 		resultData.put("hasCode", hasCode);
 		if (!hasCode) {
@@ -280,7 +276,7 @@
 			tipCode.add("閭�璇锋縺娲诲姛鑳斤紝蹇呴』瑕佹湁閭�璇风爜锛岄個璇风爜鍙互閫氳繃閲戝竵鍏戞崲锛屼篃鍙互鍏ㄧ綉鎼滅储銆�");
 			resultData.put("tipCode", tipCode);
 		}
-		
+
 		// 鏈坊鍔犲井淇″彿
 		List<String> tipWeiXin = new ArrayList<String>();
 		if (!bdWeiXin) {
@@ -290,12 +286,13 @@
 		resultData.put("tipWeiXin", tipWeiXin);
 		resultData.put("tipWeiXinAdd", "娣诲姞寰俊鍙峰悗锛屼綘鐨勯個璇蜂汉鍜屼竴绾ч槦鍛樺彲浠ラ�氳繃寰俊涓庝綘寤虹珛鑱旂郴銆�");
 		resultData.put("bdWeiXin", bdWeiXin);
-		
+
 		out.print(JsonUtil.loadTrueResult(resultData));
 	}
-	
+
 	/**
 	 * 涓婄骇淇℃伅缁勭粐
+	 * 
 	 * @param acceptData
 	 * @param uid
 	 * @param threeSale
@@ -312,7 +309,7 @@
 			SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd");
 			Long createTime = threeSale.getCreateTime();
 			Date inviteTime = new Date(createTime);
-			
+
 			UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(boss.getId());
 			if (userInfoExtra != null && !StringUtil.isNullOrEmpty(userInfoExtra.getWeiXin())) {
 				bossData.put("weiXin", userInfoExtra.getWeiXin());
@@ -331,15 +328,14 @@
 		} else {
 			bossData.put("hasBoss", false);
 			bossData.put("helpLink", configService.get("invite_code_hlep_link"));
-			bossData.put("weiXinTip", "鎭枩浣狅紝鎴戜滑鐨勪紭璐ㄧ敤鎴凤紱\r\n浣犲苟娌℃湁閭�璇蜂汉锛屼絾浣犵殑閭�璇锋縺娲诲姛鑳芥槸琚粯璁ゅ紑鍚殑锛沑r\n浣犳嫢鏈夌嫭鐗圭殑鏃犻個璇蜂汉婵�娲荤爜銆�");	
+			bossData.put("weiXinTip", "鎭枩浣狅紝鎴戜滑鐨勪紭璐ㄧ敤鎴凤紱\r\n浣犲苟娌℃湁閭�璇蜂汉锛屼絾浣犵殑閭�璇锋縺娲诲姛鑳芥槸琚粯璁ゅ紑鍚殑锛沑r\n浣犳嫢鏈夌嫭鐗圭殑鏃犻個璇蜂汉婵�娲荤爜銆�");
 		}
 		return bossData;
-	} 
-	
-	
-	
+	}
+
 	/**
 	 * 绔欏唴淇℃彁閱掗槦鍛樻坊鍔犲井淇″彿
+	 * 
 	 * @param acceptData
 	 * @param uid
 	 * @param inviteId
@@ -351,19 +347,19 @@
 			out.print(JsonUtil.loadFalseResult("浼犻�掑弬鏁扮己澶�"));
 			return;
 		}
-		
+
 		UserInfo userInfo = userInfoService.selectByPKey(uid);
 		if (userInfo == null) {
 			out.print(JsonUtil.loadFalseResult("鐢ㄦ埛淇℃伅涓嶅瓨鍦�"));
 			return;
 		}
-		
+
 		ThreeSale threeSale = threeSaleSerivce.selectByPrimaryKey(inviteId);
 		if (threeSale == null) {
 			out.print(JsonUtil.loadFalseResult("鍏崇郴id涓嶅瓨鍦�"));
 			return;
-		} 
-		
+		}
+
 		Long remindId = null;
 		boolean remindBoss = true;
 		if (uid.longValue() == threeSale.getWorker().getId().longValue()) {
@@ -371,13 +367,13 @@
 		} 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 = "闃熷憳鎻愰啋娑堟伅";
@@ -386,29 +382,31 @@
 			// 鎻愮ず闃熼暱
 			bossId = remindId;
 			workerId = uid;
-			content = "浣犵殑涓�绾ч槦鍛�"+ userInfo.getNickName() +"锛屾彁閱掍綘娣诲姞寰俊鍙凤紝浠ヤ究浜庡拰浣犲彇寰楄仈绯诲拰瀛︿範鐪侀挶鎶�宸э紝璧跺揩鍘绘坊鍔犲惂锛涙敞锛氳鍗囩骇鍒版湰杞欢鏈�鏂扮増鏈湪鈥滄垜鐨�-鎴戠殑淇℃伅鈥濅腑娣诲姞銆�";
+			content = "浣犵殑涓�绾ч槦鍛�" + userInfo.getNickName()
+					+ "锛屾彁閱掍綘娣诲姞寰俊鍙凤紝浠ヤ究浜庡拰浣犲彇寰楄仈绯诲拰瀛︿範鐪侀挶鎶�宸э紝璧跺揩鍘绘坊鍔犲惂锛涙敞锛氳鍗囩骇鍒版湰杞欢鏈�鏂扮増鏈湪鈥滄垜鐨�-鎴戠殑淇℃伅鈥濅腑娣诲姞銆�";
 		} else {
 			// 鎻愮ず闃熷憳
 			bossId = uid;
 			workerId = remindId;
-			content = "浣犵殑閭�璇蜂汉"+ userInfo.getNickName() +"锛屾彁閱掍綘娣诲姞寰俊鍙凤紝浠ヤ究浜庡拰浣犲彇寰楄仈绯诲府鍔╀綘鏇村ソ鐨勭渷閽憋紝璧跺揩鍘绘坊鍔犲惂锛涙敞锛氳鍗囩骇鍒版湰杞欢鏈�鏂扮増鏈湪鈥滄垜鐨�-鎴戠殑淇℃伅鈥濅腑娣诲姞銆�";
+			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);
-			
+
+			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());
@@ -421,7 +419,7 @@
 				newInfo.setUpdateTime(new Date());
 				threeSaleExtraInfoSerivce.insertSelective(newInfo);
 			}
-			
+
 			JSONObject data = new JSONObject();
 			data.put("weiXinState", 2);
 			data.put("weiXinTip", "绯荤粺宸插彂閫佹彁閱掞紝閭�璇蜂汉娣诲姞寰俊鍚庝綘鍙鍒讹紝濡傚鏂硅繜杩熶笉娣诲姞锛屼綘鍙仈绯讳汉宸ュ鏈嶅姹傚府鍔�");

--
Gitblit v1.8.0