From 4114e871bcb3dce771b6aed64a1027d0bbb95ca6 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期四, 16 五月 2019 15:28:37 +0800
Subject: [PATCH] 增加动态用户

---
 fanli/src/main/java/com/yeshi/fanli/controller/client/UserInfoController.java |  341 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 333 insertions(+), 8 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..9cacef4 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
@@ -1,5 +1,6 @@
 package com.yeshi.fanli.controller.client;
 
+import java.io.IOException;
 import java.io.PrintWriter;
 import java.io.UnsupportedEncodingException;
 import java.lang.reflect.InvocationTargetException;
@@ -21,6 +22,7 @@
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.multipart.MultipartFile;
 import org.yeshi.utils.HttpUtil;
 import org.yeshi.utils.IPUtil;
 import org.yeshi.utils.JsonUtil;
@@ -66,6 +68,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;
@@ -85,6 +88,7 @@
 import com.yeshi.fanli.service.inter.user.BindingAccountService;
 import com.yeshi.fanli.service.inter.user.ExtractRecordService;
 import com.yeshi.fanli.service.inter.user.ExtractService;
+import com.yeshi.fanli.service.inter.user.MaskKeyService;
 import com.yeshi.fanli.service.inter.user.ShamUserService;
 import com.yeshi.fanli.service.inter.user.SpreadUserImgService;
 import com.yeshi.fanli.service.inter.user.UserAccountService;
@@ -201,6 +205,10 @@
 
 	@Resource
 	private AccountMessageService accountMessageService;
+	
+	@Resource
+	private MaskKeyService maskKeyService;
+	
 
 	private static final String PASSWORD_MAX_ERROR = "password_max_error";
 	private static final String EXTRACT_MIN_MONEY = "extract_min_money";
@@ -573,10 +581,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));
@@ -1040,7 +1058,6 @@
 		return;
 	}
 
-
 	/**
 	 * 鏂扮増鎻愮幇
 	 * 
@@ -1146,13 +1163,17 @@
 					} catch (UnsupportedEncodingException e) {
 						e.printStackTrace();
 					}
-					AdminUser adminUser = adminUserService.selectByPrimaryKey(4L);
+
+					long[] targetUids = new long[] { 3L, 4L };
 					Config config = configService.getConfig("extract_code_email_from");
 					String[] sts = config.getValue().split(",");
 					String account = sts[0];
 					String pwd = sts[1];
-					String msg = "鎻愮幇瀹℃牳閾炬帴:" + url;
-					boolean isS = MailSenderUtil.sendEmail(adminUser.getEmail(), account, pwd, "鏈夋柊鐨勬彁鐜板鏍�", msg);
+					for (long adminId : targetUids) {
+						AdminUser adminUser = adminUserService.selectByPrimaryKey(adminId);
+						String msg = "鎻愮幇瀹℃牳閾炬帴:" + url;
+						boolean isS = MailSenderUtil.sendEmail(adminUser.getEmail(), account, pwd, "鏈夋柊鐨勬彁鐜板鏍�", msg);
+					}
 				}
 			});
 			return;
@@ -1162,6 +1183,10 @@
 			out.print(JsonUtil.loadFalseResult("宸茶秴杩囧綋鏃ユ彁鐜伴噾棰�"));
 		} else if (etype == 3) {
 			out.print(JsonUtil.loadFalseResult("鎻愮幇閲戦澶т簬鎴戠殑绾㈠寘"));
+		} else if (etype == 111) {
+			out.print(JsonUtil.loadFalseResult("鏇存崲浜嗘墜鏈哄彿鍚�7澶╁唴涓嶅厑璁告彁鐜�"));
+		} else if (etype == 110) {
+			out.print(JsonUtil.loadFalseResult(Constant.znxConfig.getExtractWrongMsg()));
 		}
 
 	}
@@ -1576,9 +1601,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);
 			}
 
 			// 瀹夊崜绯荤粺杩斿洖鎵�鏈夋暟鎹�
@@ -1636,6 +1661,78 @@
 			e.printStackTrace();
 		}
 
+	}
+
+	/**
+	 * 鐢ㄦ埛闃熷憳鍒楄〃鏌ヨ 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();
+		}
 	}
 
 	/**
@@ -1909,4 +2006,232 @@
 			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));
+
+			// 鐣岄潰鐘舵��
+			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);
+		}
+	}
+
+	
+	/**
+	 * 鐢ㄦ埛鏇存崲澶村儚
+	 * @param acceptData
+	 * @param fileList
+	 * @param uid
+	 * @param request
+	 * @param out
+	 */
+	@RequestMapping(value = "uploadPortrait")
+	public void uploadPortrait(AcceptData acceptData, MultipartFile file, Long uid, HttpServletRequest request, PrintWriter out) {
+		try {
+			if (uid == null) {
+				out.print(JsonUtil.loadFalseResult("鐢ㄦ埛鏈櫥褰�"));
+				return;
+			}
+			if (file == null) {
+				out.print(JsonUtil.loadFalseResult("涓婁紶鏂囦欢涓嶈兘涓虹┖"));
+				return;
+			}
+			
+			long fileSize = file.getSize() / 1024 + 1;
+			if (fileSize > 200) {
+				out.print(JsonUtil.loadFalseResult("涓婁紶鏂囦欢涓嶈兘澶т簬200kb"));
+				return;
+			}
+			userInfoService.uploadPortrait(file, uid);
+			out.print(JsonUtil.loadTrueResult("淇濆瓨鎴愬姛"));
+		} catch (UserInfoException e) {
+			out.print(JsonUtil.loadFalseResult(e.getMsg()));
+			e.printStackTrace();
+		} catch (IOException e) {
+			out.print(JsonUtil.loadFalseResult("鍥剧墖涓婁紶澶辫触澶辫触"));
+			e.printStackTrace();
+		} catch (Exception e) {
+			out.print(JsonUtil.loadFalseResult("淇濆瓨澶辫触"));
+			e.printStackTrace();
+		}
+	}
+	
+	/**
+	 * 鏇存崲鏄电О
+	 * @param acceptData
+	 * @param nickName
+	 * @param uid
+	 * @param out
+	 */
+	@RequestMapping(value = "saveInfo")
+	public void saveInfo(AcceptData acceptData, String nickName, Long uid, PrintWriter out) {
+		try {
+			if (uid == null) {
+				out.print(JsonUtil.loadFalseResult("鐢ㄦ埛鏈櫥褰�"));
+				return;
+			}
+			if (StringUtil.isNullOrEmpty(nickName)) {
+				out.print(JsonUtil.loadFalseResult("鏄电О涓嶈兘涓虹┖"));
+				return;
+			}
+			if (nickName.length() > 200) {
+				out.print(JsonUtil.loadFalseResult("鏄电О杩囬暱"));
+				return;
+			}
+			
+			if(maskKeyService.examineContent(nickName)) {
+				out.print(JsonUtil.loadFalseResult("涓嶈兘鍖呭惈鏁忔劅璇嶆眹"));
+				return;
+			}
+			
+			userInfoService.saveUserInfo(nickName, uid);
+			
+			out.print(JsonUtil.loadTrueResult("淇濆瓨鎴愬姛"));
+		} catch (UserInfoException e) {
+			out.print(JsonUtil.loadFalseResult(e.getMsg()));
+			e.printStackTrace();
+		} catch (Exception e) {
+			out.print(JsonUtil.loadFalseResult("淇濆瓨澶辫触"));
+			e.printStackTrace();
+		}
+	}
 }

--
Gitblit v1.8.0