From 1da17d215d48e3e3aa9e8d7a3ef526904764f408 Mon Sep 17 00:00:00 2001
From: yujian <yujian>
Date: 星期一, 08 四月 2019 14:06:12 +0800
Subject: [PATCH] 1.5.3部分需求 提交

---
 fanli/src/main/java/com/yeshi/fanli/controller/client/UserInfoController.java |  254 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 250 insertions(+), 4 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/client/UserInfoController.java b/fanli/src/main/java/com/yeshi/fanli/controller/client/UserInfoController.java
index a85d7f9..9bfbae8 100644
--- a/fanli/src/main/java/com/yeshi/fanli/controller/client/UserInfoController.java
+++ b/fanli/src/main/java/com/yeshi/fanli/controller/client/UserInfoController.java
@@ -66,6 +66,7 @@
 import com.yeshi.fanli.exception.taobao.TaoKeApiException;
 import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException;
 import com.yeshi.fanli.exception.user.UserCustomSettingsException;
+import com.yeshi.fanli.exception.user.UserInfoException;
 import com.yeshi.fanli.exception.user.UserInfoExtraException;
 import com.yeshi.fanli.log.LogHelper;
 import com.yeshi.fanli.service.AdminUserService;
@@ -517,6 +518,7 @@
 				}
 			}
 		}
+		
 
 		GsonBuilder gsonBuilder = new GsonBuilder().excludeFieldsWithoutExposeAnnotation();
 
@@ -573,10 +575,20 @@
 		data.put("moduleState", mySettings);
 
 		int welfareCenterNews = 0;
+		String invitCode = null;
 		UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(user.getId());
-		if (userInfoExtra != null && userInfoExtra.getCouponNews() != null) {
-			welfareCenterNews = userInfoExtra.getCouponNews();
+		if (userInfoExtra != null  ) {
+			if(userInfoExtra.getCouponNews() != null) {
+				welfareCenterNews = userInfoExtra.getCouponNews();
+			}
+			
+			if(userInfoExtra.getInviteCode() != null && userInfoExtra.getInviteCode().trim().length() > 0) {
+				invitCode = userInfoExtra.getInviteCode();
+			}
 		}
+		// 閭�璇风爜
+		data.put("invitCode", invitCode);
+		// 绂忓埄涓績娑堟伅
 		data.put("welfareCenterNews", welfareCenterNews);
 
 		out.print(JsonUtil.loadTrueResult(data));
@@ -1576,9 +1588,9 @@
 
 			JSONObject resultData = new JSONObject();
 			if (type == 1) {
-				resultData = threeSaleSerivce.getMyFirstTeam((page - 1) * pageSize, pageSize, uid);
+				resultData = threeSaleSerivce.getMyFirstTeam((page - 1) * pageSize, pageSize, uid, null);
 			} else if (type == 2) {
-				resultData = threeSaleSerivce.getMySecondTeam((page - 1) * pageSize, pageSize, uid);
+				resultData = threeSaleSerivce.getMySecondTeam((page - 1) * pageSize, pageSize, uid, null);
 			}
 
 			// 瀹夊崜绯荤粺杩斿洖鎵�鏈夋暟鎹�
@@ -1638,6 +1650,81 @@
 
 	}
 
+	
+	/**
+	 * 鐢ㄦ埛闃熷憳鍒楄〃鏌ヨ 1.5.3鏌ヨ鏈夋晥闃熷憳
+	 * 
+	 * @param acceptData
+	 * @param id
+	 * @param out
+	 */
+	@RequestMapping(value = "getMyTeamNew", method = RequestMethod.POST)
+	public void getMyTeamNew(AcceptData acceptData, long page, long uid, long type, PrintWriter out) {
+
+		try {
+			int pageSize = Constant.PAGE_SIZE;
+
+			JSONObject resultData = new JSONObject();
+			if (type == 1) {
+				resultData = threeSaleSerivce.getMyFirstTeam((page - 1) * pageSize, pageSize, uid, 1);
+			} else if (type == 2) {
+				resultData = threeSaleSerivce.getMySecondTeam((page - 1) * pageSize, pageSize, uid, 1);
+			}
+
+			// 瀹夊崜绯荤粺杩斿洖鎵�鏈夋暟鎹�
+			String platform = acceptData.getPlatform();
+			if ("android".equalsIgnoreCase(platform)) {
+				long firstTeam = threeSaleSerivce.countFirstTeam(uid, 1);
+
+				long secondTeam = threeSaleSerivce.countSecondTeam(uid, 1);
+
+				JSONObject bossData = null;
+				ThreeSale threeSale = threeSaleSerivce.getMyBoss(uid);
+				if (threeSale != null) {
+					bossData = new JSONObject();
+					UserInfo boss = threeSale.getBoss();
+					if (boss != null) {
+						bossData.put("nickName", boss.getNickName());
+						bossData.put("portrait", boss.getPortrait());
+					}
+
+					SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd");
+					Long createTime = threeSale.getCreateTime();
+					Date inviteTime = new Date(createTime);
+					bossData.put("inviteTime", "閭�璇锋椂闂�: " + sdf.format(inviteTime));
+				}
+
+				String helpLink = configService.get("team_help_url");
+				if (helpLink == null) {
+					helpLink = "";
+				}
+
+				boolean hasCode = false;
+				String inviteCode = userInfoExtraService.getUserInviteCode(uid);
+				if (inviteCode != null && inviteCode.trim().length() > 0) {
+					hasCode = true; // 宸叉湁閭�璇风爜
+				} else {
+					// 閭�璇锋縺娲婚摼鎺�
+					resultData.put("activationlink", configService.get("invite_activation_url"));
+				}
+				resultData.put("hasCode", hasCode);
+
+				resultData.put("helpLink", helpLink);
+				resultData.put("firstTeam", firstTeam);
+				resultData.put("secondTeam", secondTeam);
+				resultData.put("boss", bossData);
+			}
+			out.print(JsonUtil.loadTrueResult(resultData));
+		} catch (UserInfoExtraException e) {
+			out.print(JsonUtil.loadFalseResult(e.getMsg()));
+		} catch (Exception e) {
+			out.print(JsonUtil.loadFalseResult("缁熻澶辫触"));
+			e.printStackTrace();
+		}
+	}
+	
+	
+	
 	/**
 	 * 鐢ㄦ埛闃熷憳缁熻 1.4.1
 	 * 
@@ -1909,4 +1996,163 @@
 			e.printStackTrace();
 		}
 	}
+	
+	/**
+	 * 鑾峰彇鐢ㄦ埛淇℃伅
+	 * 
+	 * @param acceptData
+	 * @param form
+	 * @param requst
+	 * @param out
+	 */
+	@RequestMapping(value = "getuserinfoNew", method = RequestMethod.POST)
+	public void getuserinfoNew(AcceptData acceptData, Long uid, HttpServletRequest requst, PrintWriter out) {
+		try {
+			BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
+					acceptData.getPackages());
+			if (system == null) {
+				out.print(JsonUtil.loadFalseResult("绯荤粺涓嶅瓨鍦�"));
+				return;
+			}
+			
+			if (uid == null) {
+				out.print(JsonUtil.loadFalseResult("璇锋眰鍙傛暟涓虹┖"));
+				return;
+			}
+			
+			UserInfo userInfo = userInfoService.getUserInfo(uid);
+			
+			// 娣诲姞鐢ㄦ埛娲昏穬璁板綍
+			UserActiveLog userActiveLog = new UserActiveLog();
+			userActiveLog.setChannel(acceptData.getChannel());
+			userActiveLog.setIp(requst.getRemoteHost());
+			userActiveLog.setUid(userInfo.getId());
+			userActiveLog.setVersionCode(acceptData.getVersion());
+			userActiveLog.setOsVersion(acceptData.getOsVersion());
+			userActiveLog.setDeviceType(acceptData.getDeviceType());
+			userActiveLogService.addUserActiveLog(userActiveLog);
+			
+			// 澶勭悊鐢ㄦ埛淇℃伅
+			outUserInfoHandle(userInfo);
+			
+			GsonBuilder gsonBuilder = new GsonBuilder().excludeFieldsWithoutExposeAnnotation();
+			JSONObject data = new JSONObject();
+			data.put("user", JsonUtil.getConvertBigDecimalToStringBuilder(gsonBuilder).create().toJson(userInfo));
+			
+
+//			if ("ios".equalsIgnoreCase(acceptData.getPlatform())
+//					&& configService.iosOnLining(Integer.parseInt(acceptData.getVersion()))) {
+//				data.put("inviteList", String.format("http://%s/%s/client/share/friends_new_online.html",
+//						Constant.systemCommonConfig.getProjectHost(), Constant.systemCommonConfig.getProjectName()));
+//			} else {
+//				data.put("inviteList", configService.get("team_list"));
+//			}
+//			
+			// 鐣岄潰鐘舵��
+			UserSettingsVO mySettings = null;
+			try {
+				mySettings = userCustomSettingsService.getMySettings(uid);
+			} catch (UserCustomSettingsException e) {
+				mySettings = new UserSettingsVO();
+				e.printStackTrace();
+			}
+
+			if (mySettings.getCancelNotice() == null) {
+				mySettings.setCancelNotice(0);
+			}
+			if (mySettings.getNoBonusCount() == null) {
+				mySettings.setNoBonusCount(0);
+			}
+			if (mySettings.getNoNewsRedDot() == null) {
+				mySettings.setNoNewsRedDot(0);
+			}
+			if (mySettings.getNoShareRecordAndStorage() == null) {
+				mySettings.setNoShareRecordAndStorage(0);
+			}
+			if (mySettings.getNoInvitationBonus() == null) {
+				mySettings.setNoInvitationBonus(0);
+			}
+			data.put("moduleState", mySettings);
+
+			
+			int welfareCenterNews = 0;
+			String invitCode = null;
+			UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid);
+			if (userInfoExtra != null  ) {
+				if(userInfoExtra.getCouponNews() != null) {
+					welfareCenterNews = userInfoExtra.getCouponNews();
+				}
+				
+				if(userInfoExtra.getInviteCode() != null && userInfoExtra.getInviteCode().trim().length() > 0) {
+					invitCode = userInfoExtra.getInviteCode();
+				}
+				
+				if (userInfoExtra.getUserRank() != null) {
+					String picture = userInfoExtra.getUserRank().getPicture();
+					String icon = userInfoExtra.getUserRank().getIcon();
+					userInfo.setRankNamePicture(picture);
+					userInfo.setRankIcon(icon);
+				} else {
+					userInfo.setRankNamePicture(null);
+					userInfo.setRankIcon(null);
+				}
+			}
+			
+			data.put("invitCode", invitCode); // 閭�璇风爜
+			data.put("welfareCenterNews", welfareCenterNews);// 绂忓埄涓績娑堟伅
+			out.print(JsonUtil.loadTrueResult(data));
+
+			final UserInfo uuser = userInfo;
+			ThreadUtil.run(new Runnable() {
+				public void run() {
+					try {
+						// 鑾峰彇閭�璇风爜锛氳嫢鏃犻個璇风爜涓斿瓨鍦ㄦ湁鏁堢殑闃熷憳鍏崇郴 鍒欒嚜鍔ㄧ敓鎴愰個璇风爜
+						userInfoExtraService.getUserInviteCode(uuser.getId());
+					} catch (UserInfoExtraException e) {
+						e.printStackTrace();
+					}
+
+					// 鏇存柊鐢ㄦ埛闄勫姞淇℃伅锛岃�佺敤鎴蜂笉瀛樺湪鐨勯渶瑕佹坊鍔�
+					try {
+						userInfoExtraService.updateUserRankByUid(uuser.getId());
+					} catch (UserInfoExtraException e) {
+						e.printStackTrace();
+					}
+				}
+			});
+			
+		} catch (UserInfoException e) {
+			out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMsg()));
+		} catch (Exception e) {
+			out.print(JsonUtil.loadFalseResult("鑾峰彇澶辫触"));
+			e.printStackTrace();
+		}
+	}
+	
+	private void outUserInfoHandle(UserInfo user) {
+		
+		// 绾㈠寘澶勭悊
+		user.setTotalHongBao(new BigDecimal(0));
+		user.setNoOpenHongBao(new BigDecimal(0));
+		user.setCanOpenHongBao(new BigDecimal(0));
+
+		// 鐢佃瘽鍙风爜澶勭悊
+		if (!StringUtil.isNullOrEmpty(user.getPhone())) {
+			if (user.getPhone().length() > 5) {
+				String phone = user.getPhone().substring(0, 3);
+				phone += "******";
+				phone += user.getPhone().substring(user.getPhone().length() - 2, user.getPhone().length());
+				user.setPhone(phone);
+			}
+		}
+		
+		UserInfoExtraVO userInfoExtra = userInfoExtraService.getInfoExtraVOByUid(user.getId());
+		if (userInfoExtra != null && userInfoExtra.getUserRank() != null) {
+			String picture = userInfoExtra.getUserRank().getPicture();
+			String icon = userInfoExtra.getUserRank().getIcon();
+			user.setRankNamePicture(picture);
+			user.setRankIcon(icon);
+		}
+	}
+	
 }

--
Gitblit v1.8.0