From 30d8e227e8d823b6c38c3b9c90ac2df03b63befe Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期二, 25 二月 2025 16:41:22 +0800
Subject: [PATCH] 淘宝转链接口更新

---
 fanli/src/main/java/com/yeshi/fanli/controller/client/v2/InviteControllerV2.java | 2245 +++++++++++++++++++++++++++++++++++++++++-----------------
 1 files changed, 1,591 insertions(+), 654 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 063fd5e..189dc1a 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
@@ -1,654 +1,1591 @@
-package com.yeshi.fanli.controller.client.v2;
-
-import java.io.PrintWriter;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-
-import javax.annotation.Resource;
-import javax.servlet.http.HttpServletRequest;
-
-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.wx.WXAccountInfoDTO;
-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.bus.user.WeiXinUser;
-import com.yeshi.fanli.entity.system.BusinessSystem;
-import com.yeshi.fanli.entity.system.ConfigKeyEnum;
-import com.yeshi.fanli.entity.system.SystemClientParams;
-import com.yeshi.fanli.exception.user.UserAccountException;
-import com.yeshi.fanli.exception.user.UserInfoExtraException;
-import com.yeshi.fanli.log.LogHelper;
-import com.yeshi.fanli.service.inter.config.ConfigService;
-import com.yeshi.fanli.service.inter.config.SpreadImgService;
-import com.yeshi.fanli.service.inter.config.SystemClientParamsService;
-import com.yeshi.fanli.service.inter.msg.UserSystemMsgService;
-import com.yeshi.fanli.service.inter.push.PushService;
-import com.yeshi.fanli.service.inter.user.SpreadUserImgService;
-import com.yeshi.fanli.service.inter.user.UserInfoExtraService;
-import com.yeshi.fanli.service.inter.user.UserInfoService;
-import com.yeshi.fanli.service.inter.user.UserInviteSeparateService;
-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.RedisKeyEnum;
-import com.yeshi.fanli.util.RedisManager;
-import com.yeshi.fanli.util.StringUtil;
-import com.yeshi.fanli.util.VersionUtil;
-import com.yeshi.fanli.util.annotation.RequestSerializableByKey;
-import com.yeshi.fanli.util.wx.WXLoginUtil;
-
-import net.sf.json.JSONArray;
-import net.sf.json.JSONObject;
-
-@Controller
-@RequestMapping("api/v2/invite")
-public class InviteControllerV2 {
-
-	@Resource
-	private RedisManager redisManager;
-
-	@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;
-
-	@Resource
-	private UserVIPInfoService userVIPInfoService;
-	
-	@Resource
-	private UserInviteSeparateService userInviteSeparateService;
-
-	@Resource
-	private SpreadImgService spreadImgService;
-	
-	@Resource
-	private SpreadUserImgService spreadUserImgService;
-	
-	@Resource
-	private SystemClientParamsService systemClientParamsService;
-	
-	
-	
-	/**
-	 * 閭�璇风爜楠岃瘉
-	 * 
-	 * @param out
-	 */
-	@RequestMapping(value = "verifyCode")
-	public void verifyCode(AcceptData acceptData, Long uid, String inviteCode, PrintWriter out) {
-		try {
-			UserInfo userInfo = userInfoExtraService.getUserByInviteCode(inviteCode);
-			JSONObject data = new JSONObject();
-			data.put("nickName", userInfo.getNickName());
-			data.put("portrait", userInfo.getPortrait());
-			data.put("tips", "纭瑕佹垚涓篢A鐨勭洿鎺ョ矇涓濆悧锛熼個璇峰叧绯讳竴鏃﹀缓绔嬩笉鍙洿鏀广��");
-			out.print(JsonUtil.loadTrueResult(data));
-		} catch (UserInfoExtraException e) {
-			out.print(JsonUtil.loadFalseResult(e.getMsg()));
-		}
-	}
-
-	/**
-	 * 閭�璇风爜寰俊楠岃瘉
-	 * 
-	 * @param out
-	 */
-	@RequestMapping(value = "verifyWX")
-	public void verifyWX(AcceptData acceptData, Long uid, String code, PrintWriter out) {
-		try {
-			WXAccountInfoDTO wxAccount = Constant.getWXAccount(acceptData.getPlatform(), acceptData.getVersion());
-			// 鑾峰彇寰俊淇℃伅
-			WeiXinUser weiXinUser = WXLoginUtil.getWeiXinUser(code, wxAccount.getAppId(), wxAccount.getAppSecret());
-			if (weiXinUser == null)
-				throw new UserInfoExtraException(1, "寰俊鎺堟潈澶辫触");
-
-			String wxUnionId = weiXinUser.getUnionid();
-			if (wxUnionId == null || wxUnionId.trim().length() == 0)
-				throw new UserInfoExtraException(1, "寰俊鎺堟潈澶辫触");
-
-			String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.emptyKey, StringUtil.Md5("activeWX:" + weiXinUser.getUnionid()));
-			redisManager.cacheCommonString(key, JsonUtil.getSimpleGson().toJson(weiXinUser), 60 * 20);
-
-			// 閭�璇峰叧绯荤敤鎴蜂俊鎭�
-			UserInfo userInfo = userInfoExtraService.getInviterInfo(uid, wxUnionId);
-
-			JSONObject data = new JSONObject();
-			data.put("nickName", userInfo.getNickName());
-			data.put("portrait", userInfo.getPortrait());
-			data.put("tips", "纭瑕佹垚涓篢A鐨勭洿鎺ョ矇涓濆悧锛熼個璇峰叧绯讳竴鏃﹀缓绔嬩笉鍙洿鏀广��");
-			data.put("key", key);
-			out.print(JsonUtil.loadTrueResult(data));
-		} catch (UserInfoExtraException e) {
-			out.print(JsonUtil.loadFalseResult(e.getMsg()));
-		}
-	}
-
-	/**
-	 * 寰俊婵�娲�
-	 * 
-	 * @param acceptData
-	 * @param uid
-	 * @param key
-	 *            楠岃瘉杩斿洖鐨刱ey
-	 * @param out
-	 */
-	@RequestSerializableByKey(key = "'activeInviteWX-'+#uid")
-	@RequestMapping(value = "activeInviteWX")
-	public void activeInviteWX(AcceptData acceptData, Long uid, String key, PrintWriter out) {
-		try {
-			String value = redisManager.getCommonString(key);
-			if (StringUtil.isNullOrEmpty(value))
-				throw new UserAccountException(1, "寰俊鎺堟潈澶辨晥");
-
-			WeiXinUser weiXinUser = JsonUtil.getSimpleGson().fromJson(value, WeiXinUser.class);
-			if (weiXinUser == null)
-				throw new UserAccountException(1, "寰俊鎺堟潈澶辨晥");
-
-			userInfoExtraService.activeInviteWX(uid, weiXinUser);
-			// 鍒犻櫎缂撳瓨
-			redisManager.removeCommonString(key);
-
-			out.print(JsonUtil.loadTrueResult("閭�璇风爜婵�娲绘垚鍔�"));
-		} catch (UserInfoExtraException e) {
-			out.print(JsonUtil.loadFalseResult(e.getMsg()));
-		} catch (Exception e) {
-			out.print(JsonUtil.loadFalseResult("閭�璇风爜婵�娲诲け璐�"));
-			e.printStackTrace();
-		}
-	}
-
-	/**
-	 * 鐢ㄦ埛闃熷憳鍒楄〃鏌ヨ 1.5.3鏌ヨ鏈夋晥闃熷憳
-	 * 
-	 * @param acceptData
-	 * @param id
-	 * @param out
-	 */
-	@RequestMapping(value = "getMyTeam", method = RequestMethod.POST)
-	public void getMyTeam(AcceptData acceptData, long page, long uid, int type, PrintWriter out) {
-		if (type != 1 && type != 2) {
-			out.print(JsonUtil.loadFalseResult("绮変笣绫诲瀷涓嶆纭�"));
-			return;
-		}
-
-		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);
-		} else if (type == 2) {
-			listTeam = threeSaleSerivce.listSecondTeam((page - 1) * Constant.PAGE_SIZE, Constant.PAGE_SIZE, uid, 1);
-			count = threeSaleSerivce.countSecondTeam(uid, 1);
-		}
-
-		boolean needVIPInfo = false;
-		if (VersionUtil.greaterThan_2_0_5(acceptData.getPlatform(), acceptData.getVersion()))
-			needVIPInfo = true;
-
-		// 缁勭粐鏁版嵁
-		JSONObject resultData = organizeTeam(count, listTeam, uid, type,needVIPInfo);
-
-		// 绗竴椤靛垽鏂槸鍚︽縺娲� 鏄惁鏈夐槦鍛�
-		if (type == 1 && page == 1) {
-			boolean hasCode = false;
-			UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid);
-			if (userInfoExtra != null) {
-				if (!StringUtil.isNullOrEmpty(userInfoExtra.getInviteCode()))
-					hasCode = true;
-			}
-			resultData.put("hasCode", hasCode);
-			resultData.put("hasTeam", count > 0 ? true : false);
-		}
-		out.print(JsonUtil.loadTrueResult(resultData));
-	}
-
-	/**
-	 * 缁勭粐鏁版嵁
-	 * 
-	 * @param count
-	 * @param list
-	 * @param uid
-	 * @param type
-	 * @return
-	 */
-	private JSONObject organizeTeam(long count, List<ThreeSale> list, Long uid, int type, boolean needVipInfo) {
-		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");
-
-		List<Long> workerIdList = new ArrayList<>();
-		Map<Long, Boolean> vipMap = null;
-		if (needVipInfo) {
-			for (ThreeSale threeSale : list)
-				workerIdList.add(threeSale.getWorker().getId());
-			if (workerIdList.size() > 0)
-				vipMap = userVIPInfoService.listByUids(workerIdList);
-		}
-		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) + " 鍔犲叆");
-			// 娣诲姞鏄惁涓篤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();
-			if (threeSale.getState()) {
-				Long lastLoginTime = worker.getLastLoginTime();
-				if (lastLoginTime == null) {
-					lastLoginTime = threeSale.getCreateTime();
-				}
-
-				JSONObject contentJson = new JSONObject();
-				contentJson.put("color", fontColor1);
-				if (formatYears.format(todayTime).equals(formatYears.format(lastLoginTime))) {
-					// 鏈勾
-					contentJson.put("content", "鏈�杩戠櫥褰� " + sdf.format(lastLoginTime));
-				} else {
-					// 寰�骞�
-					contentJson.put("content", "鏈�杩戠櫥褰� " + format.format(lastLoginTime));
-				}
-				array.add(contentJson);
-
-				// 涓�绾ч槦鍛� 鏌ヨ
-				if (type == 1) {
-					String memoName = null;
-					ThreeSaleExtraInfo threeSaleExtraInfo = threeSale.getThreeSaleExtraInfo();
-					if (threeSaleExtraInfo != null) {
-						if (!StringUtil.isNullOrEmpty(threeSaleExtraInfo.getNickname())) {
-							memoName = threeSaleExtraInfo.getNickname();
-						}
-					}
-					object.put("memoName", memoName);
-
-					UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(workerId);
-					if (userInfoExtra != null && !StringUtil.isNullOrEmpty(userInfoExtra.getWeiXin())) {
-						object.put("weiXin", userInfoExtra.getWeiXin());
-						object.put("weiXinState", 3);
-						object.put("weiXinTip", "娣诲姞TA鐨勫井淇★紝浣犲彲鏁欐巿TA濡備綍閫氳繃鏉挎牀蹇渷璧氶挶鎶�宸с��");
-					} else {
-						if (!threeSaleExtraInfoSerivce.isRemindWorker(uid, workerId)) {
-							object.put("weiXinState", 1);
-							object.put("weiXinTip", "鐐瑰嚮鎻愰啋TA锛岀郴缁熶細鍙戦�佷竴灏佺珯鍐呬俊锛屾彁閱掑叾娣诲姞寰俊鍙枫��");
-						} else {
-							object.put("weiXinState", 2);
-							object.put("weiXinTip", "绯荤粺宸插彂閫佹彁閱掞紝閭�璇蜂汉娣诲姞寰俊鍚庝綘鍙鍒讹紝濡傚鏂硅繜杩熶笉娣诲姞锛屼綘鍙仈绯讳汉宸ュ鏈嶅姹傚府鍔�");
-						}
-					}
-				}
-			}
-			object.put("state", 1);
-			object.put("recentMsg", array);
-			resultArray.add(object);
-		}
-
-		result.put("count", count);
-		result.put("list", resultArray);
-		return result;
-	}
-
-	/**
-	 * 鐢ㄦ埛闃熷憳缁熻- IOS
-	 * 
-	 * @param acceptData
-	 * @param id
-	 * @param out
-	 */
-	@RequestMapping(value = "countMyTeam", method = RequestMethod.POST)
-	public void countMyTeam(AcceptData acceptData, long uid, PrintWriter out) {
-		JSONObject bossData = getBossInfo(uid, threeSaleSerivce.getMyBoss(uid));
-		JSONObject resultData = new JSONObject();
-
-		long firstTeam = threeSaleSerivce.countFirstTeam(uid, 1);
-		resultData.put("boss", bossData);
-		resultData.put("helpLink", configService.get(ConfigKeyEnum.teamHelpUrl.getKey()));
-		resultData.put("firstTeam", firstTeam);
-		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(ConfigKeyEnum.inviteActivationUrl.getKey()));
-		}
-		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) {
-			List<String> tipCode = new ArrayList<String>();
-			resultData.put("helpLinkActivate", configService.get(ConfigKeyEnum.teamHelpUrl.getKey()));
-			tipCode.add("婵�娲婚個璇峰姛鑳藉悗鎵嶅彲浠ラ個璇风矇涓濓紝鐩存帴绮変笣鏄敱浣犵洿鎺ラ個璇凤紝闂存帴绮変笣鏄敱浣犵殑鐩存帴绮変笣閭�璇枫��");
-			tipCode.add("閭�璇锋縺娲诲姛鑳斤紝蹇呴』瑕佹湁閭�璇风爜锛岄個璇风爜鍙互閫氳繃閲戝竵鍏戞崲锛屼篃鍙互鍏ㄧ綉鎼滅储銆�");
-			resultData.put("tipCode", tipCode);
-		}
-
-		// 鏈坊鍔犲井淇″彿
-		List<String> tipWeiXin = new ArrayList<String>();
-		if (!bdWeiXin) {
-			tipWeiXin.add("娣诲姞寰俊鍙峰悗锛屼綘鐨勯個璇蜂汉鍜岀洿鎺ョ矇涓濆彲閫氳繃寰俊鍙蜂笌浣犲缓绔嬭仈绯伙紱");
-			tipWeiXin.add("浣犱篃鍙互鍚戦個璇蜂汉瀛︿範鎴栧悜鐩存帴绮変笣鏁欐巿璧氶挶鎶�宸с��");
-		}
-		resultData.put("tipWeiXin", tipWeiXin);
-		resultData.put("tipWeiXinAdd", "娣诲姞寰俊鍙峰悗锛屼綘鐨勯個璇蜂汉鍜岀洿鎺ョ矇涓濆彲浠ラ�氳繃寰俊涓庝綘寤虹珛鑱旂郴銆�");
-		resultData.put("bdWeiXin", bdWeiXin);
-
-		out.print(JsonUtil.loadTrueResult(resultData));
-	}
-
-	/**
-	 * 鑾峰彇鐢ㄦ埛淇℃伅
-	 * @param acceptData
-	 * @param uid
-	 * @param out
-	 */
-	@RequestMapping(value = "getBossInfo", method = RequestMethod.POST)
-	public void getBossInfo(AcceptData 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 threeSale
-	 * @return
-	 */
-	private JSONObject getBossInfo(long uid, ThreeSale threeSale) {
-		JSONObject bossData = new JSONObject();
-		if (threeSale != null && threeSale.getBoss() != null) {
-			UserInfo boss = threeSale.getBoss();
-			bossData.put("hasBoss", true);
-			bossData.put("inviteId", threeSale.getId());
-			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);
-
-			UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(boss.getId());
-			if (userInfoExtra != null && !StringUtil.isNullOrEmpty(userInfoExtra.getWeiXin())) {
-				bossData.put("weiXin", userInfoExtra.getWeiXin());
-				bossData.put("weiXinState", 3);
-				bossData.put("weiXinTip", "娣诲姞TA鐨勫井淇★紝浣犲彲鍚慣A瀛︿範濡備綍閫氳繃鏉挎牀蹇渷璧氶挶銆�");
-			} else {
-				if (!threeSaleExtraInfoSerivce.isRemindBoss(boss.getId(), uid)) {
-					bossData.put("weiXinState", 1);
-					bossData.put("weiXinTip", "鐐瑰嚮鎻愰啋TA锛岀郴缁熶細鍙戦�佷竴灏佺珯鍐呬俊锛屾彁閱掑叾娣诲姞寰俊鍙枫��");
-				} else {
-					bossData.put("weiXinState", 2);
-					bossData.put("weiXinTip", "绯荤粺宸插彂閫佹彁閱掞紝閭�璇蜂汉娣诲姞寰俊鍚庝綘鍙鍒讹紝濡傚鏂硅繜杩熶笉娣诲姞锛屼綘鍙仈绯讳汉宸ュ鏈嶅姹傚府鍔�");
-				}
-			}
-			bossData.put("inviteTime", "浣犱簬 " + sdf.format(inviteTime) + "鎺ュ彈浜員A鐨勯個璇�");
-		} else {
-			bossData.put("hasBoss", false);
-			bossData.put("helpLink", configService.get(ConfigKeyEnum.inviteCodeHlepLink.getKey()));
-			bossData.put("weiXinTip", "鎭枩浣狅紝鎴戜滑鐨勪紭璐ㄧ敤鎴凤紱\r\n浣犲苟娌℃湁閭�璇蜂汉锛屼絾浣犵殑閭�璇锋縺娲诲姛鑳芥槸琚粯璁ゅ紑鍚殑锛沑r\n浣犳嫢鏈夌嫭鐗圭殑鏃犻個璇蜂汉婵�娲荤爜銆�");
-		}
-		return bossData;
-	}
-
-	/**
-	 * 绔欏唴淇℃彁閱掗槦鍛樻坊鍔犲井淇″彿
-	 * 
-	 * @param acceptData
-	 * @param uid
-	 * @param inviteId
-	 * @param out
-	 */
-	@RequestMapping(value = "remindTeam")
-	public void remindTeam(AcceptData acceptData, Long uid, Long inviteId, PrintWriter out) {
-		if (uid == null || inviteId == null) {
-			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()) {
-			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("鎻愰啋澶辫触"));
-		}
-	}
-	
-	
-	@RequestSerializableByKey(key = "'getInviteImgs-'+#uid")
-	@RequestMapping(value = "/getInviteImgs", method = RequestMethod.POST)
-	public void getInviteImgs(AcceptData acceptData, Long uid, Integer page, PrintWriter out, HttpServletRequest request) {
-		if (uid == null || uid <= 0) {
-			out.print(JsonUtil.loadFalseResult("鐢ㄦ埛鏈櫥褰�"));
-			return;
-		}
-
-		if (page == null || page < 1)
-			page = 1;
-		
-		try {
-			String inviteCode = userInfoExtraService.getInviteCodeByUid(uid);
-			if (StringUtil.isNullOrEmpty(inviteCode)) {
-				out.print(JsonUtil.loadFalseResult("閭�璇风爜鏈縺娲�"));
-				return;
-			}
-			
-			int count = 3;
-			if (page > 1) 
-				count = Integer.MAX_VALUE;
-			
-			// 閭�璇峰浘
-			List<String> imgList = spreadUserImgService.getUserSpreadImgToPage(uid, page, count, request);
-		
-			// 閭�璇疯鍒�
-			BusinessSystem system = new BusinessSystem();
-			system.setId(4L);
-			system.setPlatform(1);
-			system.setCreatetime(java.lang.System.currentTimeMillis());
-			SystemClientParams values = systemClientParamsService.getSystemClientParamsBySystemAndKey(system, "inviteRules");
-			
-			JSONObject data = new JSONObject();
-			data.put("count", spreadImgService.countAll());
-			data.put("inviteCode", inviteCode);
-			data.put("helpLink", configService.get(ConfigKeyEnum.inviteHelpLink.getKey()));
-			data.put("inviteRules",  values.getValue().replace("\n", "<br><br>"));
-			data.put("imgUrlList", JsonUtil.getSimpleGsonWithDate().toJson(imgList));
-			data.put("inviteLink", Constant.YINGYONGBAO_LINK);
-			out.print(JsonUtil.loadTrue(0, JsonUtil.getSimpleGson().toJson(data), "鎴愬姛"));
-		} catch (Exception e) {
-			LogHelper.errorDetailInfo(e);
-			out.print(JsonUtil.loadFalseResult("閭�璇蜂俊鎭幏鍙栧け璐�"));
-		}
-	}
-	
-	/**
-	 * 绔欏唴淇℃彁閱掗槦鍛樻坊鍔犲井淇″彿
-	 * 
-	 * @param acceptData
-	 * @param uid
-	 * @param inviteId
-	 * @param out
-	 */
-	@RequestMapping(value = "tailorCode")
-	public void tailorCode(AcceptData acceptData, String callback, Long uid, PrintWriter out) {
-		if (uid == null) {
-			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鐢ㄦ埛id缂哄け"));
-			return;
-		}
-
-		JSONObject data = new JSONObject();
-		data.put("num", threeSaleSerivce.countFirstTeam(uid, 1));
-		data.put("limit", Constant.INVITE_CODRE_TAILOR_LIMIT);
-		JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
-	}
-	
-	
-	
-}
+package com.yeshi.fanli.controller.client.v2;
+
+import java.io.PrintWriter;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+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;
+import org.yeshi.utils.DateUtil;
+import org.yeshi.utils.JsonUtil;
+
+import com.yeshi.fanli.dto.user.ThreeSaleFocusDTO;
+import com.yeshi.fanli.dto.vip.UserVIPLevel;
+import com.yeshi.fanli.dto.wx.WXAccountInfoDTO;
+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.TeamFansInfo;
+import com.yeshi.fanli.entity.bus.user.ThreeSale;
+import com.yeshi.fanli.entity.bus.user.ThreeSaleDetail;
+import com.yeshi.fanli.entity.bus.user.ThreeSaleExtraInfo;
+import com.yeshi.fanli.entity.bus.user.UserExtraTaoBaoInfo;
+import com.yeshi.fanli.entity.bus.user.UserInfo;
+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.invite.TeamDailyRecord;
+import com.yeshi.fanli.entity.bus.user.vip.TeamUserLevelStatistic;
+import com.yeshi.fanli.entity.bus.user.vip.TearcherInfo;
+import com.yeshi.fanli.entity.bus.user.vip.UserLevelEnum;
+import com.yeshi.fanli.entity.bus.user.vip.UserVIPPreInfo;
+import com.yeshi.fanli.entity.system.BusinessSystem;
+import com.yeshi.fanli.entity.system.ConfigKeyEnum;
+import com.yeshi.fanli.entity.system.SystemClientParams;
+import com.yeshi.fanli.exception.user.UserAccountException;
+import com.yeshi.fanli.exception.user.UserInfoExtraException;
+import com.yeshi.fanli.log.LogHelper;
+import com.yeshi.fanli.service.inter.config.ConfigService;
+import com.yeshi.fanli.service.inter.config.SpreadImgService;
+import com.yeshi.fanli.service.inter.config.SystemClientParamsService;
+import com.yeshi.fanli.service.inter.msg.UserSystemMsgService;
+import com.yeshi.fanli.service.inter.order.CommonOrderCountService;
+import com.yeshi.fanli.service.inter.push.PushService;
+import com.yeshi.fanli.service.inter.user.SpreadUserImgService;
+import com.yeshi.fanli.service.inter.user.UserCustomSettingsService;
+import com.yeshi.fanli.service.inter.user.UserInfoExtraService;
+import com.yeshi.fanli.service.inter.user.UserInfoService;
+import com.yeshi.fanli.service.inter.user.invite.TeamDailyRecordService;
+import com.yeshi.fanli.service.inter.user.invite.TeamFansInfoService;
+import com.yeshi.fanli.service.inter.user.invite.ThreeSaleDetailService;
+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.invite.UserInviteService;
+import com.yeshi.fanli.service.inter.user.invite.UserInviteValidNumService;
+import com.yeshi.fanli.service.inter.user.invite.UserInviteValidRecordService;
+import com.yeshi.fanli.service.inter.user.tb.UserExtraTaoBaoInfoService;
+import com.yeshi.fanli.service.inter.user.vip.TeamUserLevelStatisticService;
+import com.yeshi.fanli.service.inter.user.vip.TearcherService;
+import com.yeshi.fanli.service.inter.user.vip.UserVIPInfoService;
+import com.yeshi.fanli.service.inter.user.vip.UserVIPPreInfoService;
+import com.yeshi.fanli.util.Constant;
+import com.yeshi.fanli.util.RedisKeyEnum;
+import com.yeshi.fanli.util.RedisManager;
+import com.yeshi.fanli.util.StringUtil;
+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.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")
+public class InviteControllerV2 {
+
+	@Resource
+	private RedisManager redisManager;
+
+	@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;
+
+	@Resource
+	private UserVIPInfoService userVIPInfoService;
+
+	@Resource
+	private SpreadImgService spreadImgService;
+
+	@Resource
+	private SpreadUserImgService spreadUserImgService;
+
+	@Resource
+	private SystemClientParamsService systemClientParamsService;
+
+	@Resource
+	private UserInviteService userInviteService;
+
+	@Resource
+	private UserInviteValidRecordService userInviteValidRecordService;
+
+	@Resource
+	private UserInviteValidNumService userInviteValidNumService;
+
+	@Resource
+	private UserExtraTaoBaoInfoService userExtraTaoBaoInfoService;
+
+	@Resource
+	private CommonOrderCountService commonOrderCountService;
+
+	@Resource
+	private TeamFansInfoService teamFansInfoService;
+
+	@Resource
+	private UserCustomSettingsService userCustomSettingsService;
+
+	@Resource
+	private TearcherService tearcherService;
+
+	@Resource
+	private TeamUserLevelStatisticService teamUserLevelStatisticService;
+
+	@Resource
+	private UserVIPPreInfoService userVIPPreInfoService;
+
+	@Resource
+	private TeamDailyRecordService teamDailyRecordService;
+
+	@Resource
+	private ThreeSaleDetailService threeSaleDetailService;
+
+	/**
+	 * 閭�璇风爜楠岃瘉
+	 * 
+	 * @param out
+	 */
+	@RequestMapping(value = "verifyCode")
+	public void verifyCode(AcceptData acceptData, Long uid, String inviteCode, PrintWriter out) {
+		try {
+			UserInfo userInfo = userInfoExtraService.getUserByInviteCode(inviteCode);
+			JSONObject data = new JSONObject();
+			data.put("nickName", userInfo.getNickName());
+			data.put("portrait", userInfo.getPortrait());
+			data.put("tips", "纭瑕佹垚涓篢A鐨勭洿鎺ョ矇涓濆悧锛熼個璇峰叧绯讳竴鏃﹀缓绔嬩笉鍙洿鏀广��");
+			out.print(JsonUtil.loadTrueResult(data));
+		} catch (UserInfoExtraException e) {
+			out.print(JsonUtil.loadFalseResult(e.getMsg()));
+		}
+	}
+
+	/**
+	 * 閭�璇风爜寰俊楠岃瘉
+	 * 
+	 * @param out
+	 */
+	@RequestMapping(value = "verifyWX")
+	public void verifyWX(AcceptData acceptData, Long uid, String code, PrintWriter out) {
+		try {
+			WXAccountInfoDTO wxAccount = Constant.getWXAccount(acceptData.getPlatform(), acceptData.getVersion());
+			// 鑾峰彇寰俊淇℃伅
+			WeiXinUser weiXinUser = WXAppLoginUtil.getWeiXinUser(code, wxAccount.getAppId(), wxAccount.getAppSecret());
+			if (weiXinUser == null)
+				throw new UserInfoExtraException(1, "寰俊鎺堟潈澶辫触");
+
+			String wxUnionId = weiXinUser.getUnionid();
+			if (wxUnionId == null || wxUnionId.trim().length() == 0)
+				throw new UserInfoExtraException(1, "寰俊鎺堟潈澶辫触");
+
+			String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.emptyKey,
+					StringUtil.Md5("activeWX:" + weiXinUser.getUnionid()));
+			redisManager.cacheCommonString(key, JsonUtil.getSimpleGson().toJson(weiXinUser), 60 * 20);
+
+			// 閭�璇峰叧绯荤敤鎴蜂俊鎭�
+			UserInfo userInfo = userInfoExtraService.getInviterInfo(uid, wxUnionId);
+
+			JSONObject data = new JSONObject();
+			data.put("nickName", userInfo.getNickName());
+			data.put("portrait", userInfo.getPortrait());
+			data.put("tips", "纭瑕佹垚涓篢A鐨勭洿鎺ョ矇涓濆悧锛熼個璇峰叧绯讳竴鏃﹀缓绔嬩笉鍙洿鏀广��");
+			data.put("key", key);
+			out.print(JsonUtil.loadTrueResult(data));
+		} catch (UserInfoExtraException e) {
+			out.print(JsonUtil.loadFalseResult(e.getMsg()));
+		}
+	}
+
+	/**
+	 * 寰俊婵�娲�
+	 * 
+	 * @param acceptData
+	 * @param uid
+	 * @param key        楠岃瘉杩斿洖鐨刱ey
+	 * @param out
+	 */
+	@RequestSerializableByKey(key = "'activeInviteWX-'+#uid")
+	@RequestMapping(value = "activeInviteWX")
+	public void activeInviteWX(AcceptData acceptData, Long uid, String key, PrintWriter out) {
+		try {
+			String value = redisManager.getCommonString(key);
+			if (StringUtil.isNullOrEmpty(value))
+				throw new UserAccountException(1, "寰俊鎺堟潈澶辨晥");
+
+			WeiXinUser weiXinUser = JsonUtil.getSimpleGson().fromJson(value, WeiXinUser.class);
+			if (weiXinUser == null)
+				throw new UserAccountException(1, "寰俊鎺堟潈澶辨晥");
+
+			userInfoExtraService.activeInviteWX(uid, weiXinUser);
+			// 鍒犻櫎缂撳瓨
+			redisManager.removeCommonString(key);
+
+			out.print(JsonUtil.loadTrueResult("閭�璇风爜婵�娲绘垚鍔�"));
+		} catch (UserInfoExtraException e) {
+			out.print(JsonUtil.loadFalseResult(e.getMsg()));
+		} catch (Exception e) {
+			out.print(JsonUtil.loadFalseResult("閭�璇风爜婵�娲诲け璐�"));
+			e.printStackTrace();
+		}
+	}
+
+	/**
+	 * 鐢ㄦ埛闃熷憳鍒楄〃鏌ヨ
+	 * 
+	 * @param acceptData
+	 * @param out
+	 */
+	@RequestMapping(value = "getMyTeam", method = RequestMethod.POST)
+	public void getMyTeam(AcceptData acceptData, long page, long uid, int type, PrintWriter out) {
+		if (type != 1 && type != 2) {
+			out.print(JsonUtil.loadFalseResult("绮変笣绫诲瀷涓嶆纭�"));
+			return;
+		}
+		long count = 0;
+		List<ThreeSale> listTeam = null;
+		if (type == 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);
+			count = threeSaleSerivce.countSecondTeam(uid);
+		}
+
+		// 鏁版嵁鍔犲伐
+		JSONArray array = null;
+		if (VersionUtil.greaterThan_2_1(acceptData.getPlatform(), acceptData.getVersion())) {
+			array = organizeTeamNew(acceptData, listTeam, uid, type, true);
+		} else {
+			boolean needVIPInfo = false;
+			if (VersionUtil.greaterThan_2_0_5(acceptData.getPlatform(), acceptData.getVersion()))
+				needVIPInfo = true;
+			array = organizeTeam(listTeam, uid, type, needVIPInfo);
+		}
+
+		JSONObject result = new JSONObject();
+		result.put("count", count);
+		result.put("list", array);
+
+		if (type == 1 && page == 1) {
+			boolean hasCode = false;
+			UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid);
+			if (userInfoExtra != null) {
+				if (!StringUtil.isNullOrEmpty(userInfoExtra.getInviteCode()))
+					hasCode = true;
+			}
+			result.put("hasCode", hasCode);
+			result.put("hasTeam", count > 0 ? true : false);
+		}
+		out.print(JsonUtil.loadTrueResult(result));
+	}
+
+	/**
+	 * 缁勭粐鏁版嵁
+	 * 
+	 * @param list
+	 * @param uid
+	 * @param type
+	 * @return
+	 */
+	private JSONArray organizeTeam(List<ThreeSale> list, Long uid, int type, boolean needVipInfo) {
+		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");
+
+		List<Long> workerIdList = new ArrayList<>();
+		Map<Long, Boolean> vipMap = null;
+		if (needVipInfo) {
+			for (ThreeSale threeSale : list)
+				workerIdList.add(threeSale.getWorker().getId());
+			if (workerIdList.size() > 0)
+				vipMap = userVIPInfoService.listByUids(workerIdList);
+		}
+		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) + " 鍔犲叆");
+			// 娣诲姞鏄惁涓篤IP
+			if (vipMap != null && vipMap.get(worker.getId()) != null) {
+				object.put("vip", vipMap.get(worker.getId()));
+			}
+			String fontColor1 = "#888888";
+			JSONArray array = new JSONArray();
+			if (threeSale.getState()) {
+				Long lastLoginTime = worker.getLastLoginTime();
+				if (lastLoginTime == null) {
+					lastLoginTime = threeSale.getCreateTime();
+				}
+
+				JSONObject contentJson = new JSONObject();
+				contentJson.put("color", fontColor1);
+				if (formatYears.format(todayTime).equals(formatYears.format(lastLoginTime))) {
+					// 鏈勾
+					contentJson.put("content", "鏈�杩戠櫥褰� " + sdf.format(lastLoginTime));
+				} else {
+					// 寰�骞�
+					contentJson.put("content", "鏈�杩戠櫥褰� " + format.format(lastLoginTime));
+				}
+				array.add(contentJson);
+
+				// 涓�绾ч槦鍛� 鏌ヨ
+				if (type == 1) {
+					String memoName = null;
+					ThreeSaleExtraInfo threeSaleExtraInfo = threeSale.getThreeSaleExtraInfo();
+					if (threeSaleExtraInfo != null) {
+						if (!StringUtil.isNullOrEmpty(threeSaleExtraInfo.getNickname())) {
+							memoName = threeSaleExtraInfo.getNickname();
+						}
+					}
+					object.put("memoName", memoName);
+
+					UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(workerId);
+					if (userInfoExtra != null && !StringUtil.isNullOrEmpty(userInfoExtra.getWeiXin())) {
+						object.put("weiXin", userInfoExtra.getWeiXin());
+						object.put("weiXinState", 3);
+						object.put("weiXinTip", "娣诲姞TA鐨勫井淇★紝浣犲彲鏁欐巿TA濡備綍閫氳繃鏉挎牀蹇渷璧氶挶鎶�宸с��");
+					} else {
+						if (!threeSaleExtraInfoSerivce.isRemindWorker(uid, workerId)) {
+							object.put("weiXinState", 1);
+							object.put("weiXinTip", "鐐瑰嚮鎻愰啋锛岀郴缁熶細鍙戦�佷竴灏佺珯鍐呬俊锛屾彁閱掑叾娣诲姞寰俊鍙枫��");
+						} else {
+							object.put("weiXinState", 2);
+							object.put("weiXinTip", "绯荤粺宸插彂閫佹彁閱掞紝閭�璇蜂汉娣诲姞寰俊鍚庝綘鍙鍒讹紝濡傚鏂硅繜杩熶笉娣诲姞锛屼綘鍙仈绯讳汉宸ュ鏈嶅姹傚府鍔�");
+						}
+					}
+				}
+			}
+			object.put("state", 1);
+			object.put("recentMsg", array);
+			resultArray.add(object);
+		}
+		return resultArray;
+	}
+
+	/**
+	 * 鍔犲伐鏁版嵁
+	 * 
+	 * @param list
+	 * @param uid
+	 * @param type  鏌ヨ绮変笣绫诲瀷 1鐩存帴 2闂存帴
+	 * @param wxtip 鏄渶瑕佸井淇℃彁绀�
+	 * @return
+	 */
+	private JSONArray organizeTeamNew(AcceptData acceptData, List<ThreeSale> list, Long uid, int type, boolean wxtip) {
+		JSONArray resultArray = new JSONArray();
+		if (list == null || list.size() == 0) {
+			return resultArray;
+		}
+
+		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");
+
+		List<Long> listWid = new ArrayList<>();
+		for (ThreeSale threeSale : list) {
+			listWid.add(threeSale.getWorker().getId());
+		}
+
+		// 鏌ヨ鏈夋晥绮変笣id
+		int validType = UserInviteValidRecord.TYPE_TWO;
+		if (type == 1) {
+			validType = UserInviteValidRecord.TYPE_ONE;
+		}
+
+		List<Long> listVid = userInviteValidRecordService.getValidWorkerIdsByUid(uid, listWid, validType);
+
+		for (ThreeSale threeSale : list) {
+			UserInfo worker = threeSale.getWorker();
+			Long workerId = worker.getId();
+
+			// 閭�璇锋垚鍔熸椂闂�
+			Long succeedTime = threeSale.getSucceedTime();
+			if (succeedTime == null) {
+				succeedTime = threeSale.getCreateTime();
+			}
+
+			// 鏈夋晥绮変笣
+			boolean validFans = false;
+			if (listVid != null && listVid.size() > 0 && listVid.contains(workerId)) {
+				validFans = true;
+			}
+
+			// 鏈�杩戠矇涓濈櫥褰曟椂闂�
+			Date lastLoginTime = new Date(threeSale.getCreateTime());
+			UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(workerId);
+			if (userInfoExtra != null && userInfoExtra.getActiveTime() != null) {
+				lastLoginTime = userInfoExtra.getActiveTime();
+			}
+			JSONObject loginJson = new JSONObject();
+			if (formatYears.format(todayTime).equals(formatYears.format(lastLoginTime))) {
+				loginJson.put("content", "鏈�杩戠櫥褰� " + sdf.format(lastLoginTime)); // 鏈勾
+			} else {
+				loginJson.put("content", "鏈�杩戠櫥褰� " + format.format(lastLoginTime)); // 寰�骞�
+			}
+			loginJson.put("color", "#888888");
+
+			JSONArray array = new JSONArray();
+			array.add(loginJson);
+
+			// 鏌ヨ绮変笣绛夌骇
+			UserLevelEnum level = null;
+			UserVIPLevel vipLevel = userInviteService.getVIPLevelByUid(workerId);
+			if (vipLevel != null && vipLevel.getLevel() != null) {
+				level = UserLevelUtil.getByLevel(vipLevel.getLevel());
+			}
+			if (level == null) {
+				level = UserLevelEnum.daRen;
+			}
+			level = UserLevelUtil.getShowLevel(level);
+
+			JSONObject object = new JSONObject();
+			object.put("workerId", workerId);
+			object.put("nickName", worker.getNickName());
+			object.put("portrait", worker.getPortrait());
+			object.put("inviteId", threeSale.getId());
+			object.put("inviteTime", format.format(new Date(succeedTime)) + " 鍔犲叆");
+			object.put("state", 1);
+			object.put("recentMsg", array);
+			object.put("level", level.name());
+			object.put("validFans", validFans);
+
+			if (wxtip) {
+				// 涓�绾ч槦鍛� 鏌ヨ鏄电О澶囨敞
+				String memoName = null;
+				ThreeSaleExtraInfo threeSaleExtraInfo = threeSale.getThreeSaleExtraInfo();
+				if (threeSaleExtraInfo != null) {
+					if (!StringUtil.isNullOrEmpty(threeSaleExtraInfo.getNickname())) {
+						memoName = threeSaleExtraInfo.getNickname();
+					}
+				}
+				object.put("memoName", memoName);
+
+				if (type == 1 && !VersionUtil.greaterThan_2_1_1(acceptData.getPlatform(), acceptData.getVersion())) {
+					// 娣诲姞寰俊淇℃伅
+					if (userInfoExtra != null && !StringUtil.isNullOrEmpty(userInfoExtra.getWeiXin())) {
+						object.put("weiXin", userInfoExtra.getWeiXin());
+						object.put("weiXinState", 3);
+						object.put("weiXinTip", "娣诲姞TA鐨勫井淇★紝浣犲彲鏁欐巿TA濡備綍閫氳繃鏉挎牀蹇渷璧氶挶鎶�宸с��");
+					} else {
+						if (!threeSaleExtraInfoSerivce.isRemindWorker(uid, workerId)) {
+							object.put("weiXinState", 1);
+							object.put("weiXinTip", "鐐瑰嚮鎻愰啋锛岀郴缁熶細鍙戦�佷竴灏佺珯鍐呬俊锛屾彁閱掑叾娣诲姞寰俊鍙枫��");
+						} else {
+							object.put("weiXinState", 2);
+							object.put("weiXinTip", "绯荤粺宸插彂閫佹彁閱掞紝閭�璇蜂汉娣诲姞寰俊鍚庝綘鍙鍒讹紝濡傚鏂硅繜杩熶笉娣诲姞锛屼綘鍙仈绯讳汉宸ュ鏈嶅姹傚府鍔�");
+						}
+					}
+				}
+			}
+			resultArray.add(object);
+		}
+		return resultArray;
+	}
+
+	/**
+	 * 鏌ョ湅涓嬬骇鐨勭洿鎺ョ矇涓�
+	 * 
+	 * @param acceptData
+	 * @param page
+	 * @param uid        褰撳墠UId
+	 * @param tid        涓嬬骇UId
+	 * @param out
+	 */
+	@RequestMapping(value = "getOthersTeam", method = RequestMethod.POST)
+	public void getOthersTeam(AcceptData acceptData, long page, Long uid, Long tid, PrintWriter out) {
+		if (tid == null) {
+			out.print(JsonUtil.loadFalseResult("浼犻�掑弬鏁颁笉姝g‘"));
+			return;
+		}
+
+		List<ThreeSale> listTeam = threeSaleSerivce.listFirstTeam((page - 1) * Constant.PAGE_SIZE, Constant.PAGE_SIZE,
+				tid);
+		long count = threeSaleSerivce.countFirstTeam(tid);
+
+		JSONObject result = new JSONObject();
+		result.put("count", count);
+		result.put("list", organizeTeamNew(acceptData, listTeam, tid, 1, false));
+		out.print(JsonUtil.loadTrueResult(result));
+	}
+
+	/**
+	 * 鐢ㄦ埛闃熷憳缁熻- IOS
+	 * 
+	 * @param acceptData
+	 * @param out
+	 */
+	@RequestMapping(value = "countMyTeam", method = RequestMethod.POST)
+	public void countMyTeam(AcceptData acceptData, long uid, PrintWriter out) {
+		JSONObject bossData = getBossInfo(uid, threeSaleSerivce.getMyBoss(uid));
+		JSONObject resultData = new JSONObject();
+
+		long firstTeam = threeSaleSerivce.countFirstTeam(uid);
+		long countSecond = threeSaleSerivce.countSecondTeam(uid);
+		resultData.put("boss", bossData);
+		resultData.put("firstTeam", firstTeam);
+		resultData.put("firstTeamTotal", firstTeam);
+		resultData.put("secondTeam", countSecond);
+		resultData.put("secondTeamTotal", countSecond);
+		resultData.put("helpLink", configService.getValue(ConfigKeyEnum.teamHelpUrl.getKey(),acceptData.getSystem()));
+
+		boolean hasTeam = true;
+		if (firstTeam <= 0) {
+			hasTeam = false;
+			resultData.put("invitelink", configService.getValue(ConfigKeyEnum.inviteActivationUrl.getKey(),acceptData.getSystem()));
+		}
+		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) {
+			List<String> tipCode = new ArrayList<String>();
+			resultData.put("helpLinkActivate", configService.getValue(ConfigKeyEnum.teamHelpUrl.getKey(),acceptData.getSystem()));
+			tipCode.add("婵�娲婚個璇峰姛鑳藉悗鎵嶅彲浠ラ個璇风矇涓濓紝鐩存帴绮変笣鏄敱浣犵洿鎺ラ個璇凤紝闂存帴绮変笣鏄敱浣犵殑鐩存帴绮変笣閭�璇枫��");
+			tipCode.add("閭�璇锋縺娲诲姛鑳斤紝蹇呴』瑕佹湁閭�璇风爜锛岄個璇风爜鍙互閫氳繃閲戝竵鍏戞崲锛屼篃鍙互鍏ㄧ綉鎼滅储銆�");
+			resultData.put("tipCode", tipCode);
+		}
+
+		// 鏈坊鍔犲井淇″彿
+		List<String> tipWeiXin = new ArrayList<String>();
+		if (!bdWeiXin) {
+			tipWeiXin.add("娣诲姞寰俊鍙峰悗锛屼綘鐨勯個璇蜂汉鍜岀洿鎺ョ矇涓濆彲閫氳繃寰俊鍙蜂笌浣犲缓绔嬭仈绯伙紱");
+			tipWeiXin.add("浣犱篃鍙互鍚戦個璇蜂汉瀛︿範鎴栧悜鐩存帴绮変笣鏁欐巿璧氶挶鎶�宸с��");
+		}
+		resultData.put("tipWeiXin", tipWeiXin);
+		resultData.put("tipWeiXinAdd", "娣诲姞寰俊鍙峰悗锛屼綘鐨勯個璇蜂汉鍜岀洿鎺ョ矇涓濆彲浠ラ�氳繃寰俊涓庝綘寤虹珛鑱旂郴銆�");
+		resultData.put("bdWeiXin", bdWeiXin);
+
+		out.print(JsonUtil.loadTrueResult(resultData));
+	}
+
+	/**
+	 * 鑾峰彇鐢ㄦ埛淇℃伅
+	 * 
+	 * @param acceptData
+	 * @param uid
+	 * @param out
+	 */
+	@RequestMapping(value = "getBossInfo", method = RequestMethod.POST)
+	public void getBossInfo(AcceptData 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 uid
+	 * @param threeSale
+	 * @return
+	 */
+	private JSONObject getBossInfo(long uid, ThreeSale threeSale) {
+		JSONObject bossData = new JSONObject();
+		if (threeSale != null && threeSale.getBoss() != null) {
+			UserInfo boss = threeSale.getBoss();
+			bossData.put("hasBoss", true);
+			bossData.put("inviteId", threeSale.getId());
+			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);
+
+			UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(boss.getId());
+			if (userInfoExtra != null && !StringUtil.isNullOrEmpty(userInfoExtra.getWeiXin())) {
+				bossData.put("weiXin", userInfoExtra.getWeiXin());
+				bossData.put("weiXinState", 3);
+				bossData.put("weiXinTip", "娣诲姞TA鐨勫井淇★紝浣犲彲鍚慣A瀛︿範濡備綍閫氳繃鏉挎牀蹇渷璧氶挶銆�");
+			} else {
+				if (!threeSaleExtraInfoSerivce.isRemindBoss(boss.getId(), uid)) {
+					bossData.put("weiXinState", 1);
+					bossData.put("weiXinTip", "鐐瑰嚮鎻愰啋锛岀郴缁熶細鍙戦�佷竴灏佺珯鍐呬俊锛屾彁閱掑叾娣诲姞寰俊鍙枫��");
+				} else {
+					bossData.put("weiXinState", 2);
+					bossData.put("weiXinTip", "绯荤粺宸插彂閫佹彁閱掞紝閭�璇蜂汉娣诲姞寰俊鍚庝綘鍙鍒讹紝濡傚鏂硅繜杩熶笉娣诲姞锛屼綘鍙仈绯讳汉宸ュ鏈嶅姹傚府鍔�");
+				}
+			}
+			bossData.put("inviteTime", "浣犱簬 " + sdf.format(inviteTime) + "鎺ュ彈浜員A鐨勯個璇�");
+		} else {
+			SystemEnum system= userInfoService.getUserSystem(uid);
+			bossData.put("hasBoss", false);
+			bossData.put("helpLink", configService.getValue(ConfigKeyEnum.inviteCodeHlepLink.getKey(),system));
+			bossData.put("weiXinTip", "鎭枩浣狅紝鎴戜滑鐨勪紭璐ㄧ敤鎴凤紱\r\n浣犲苟娌℃湁閭�璇蜂汉锛屼絾浣犵殑閭�璇锋縺娲诲姛鑳芥槸琚粯璁ゅ紑鍚殑锛沑r\n浣犳嫢鏈夌嫭鐗圭殑鏃犻個璇蜂汉婵�娲荤爜銆�");
+		}
+		return bossData;
+	}
+
+	/**
+	 * 绔欏唴淇℃彁閱掗槦鍛樻坊鍔犲井淇″彿
+	 * 
+	 * @param acceptData
+	 * @param uid
+	 * @param inviteId
+	 * @param out
+	 */
+	@RequestMapping(value = "remindTeam")
+	public void remindTeam(AcceptData acceptData, Long uid, Long inviteId, PrintWriter out) {
+		if (uid == null || inviteId == null) {
+			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()) {
+			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,acceptData.getSystem());
+
+			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("鎻愰啋澶辫触"));
+		}
+	}
+
+	@RequestSerializableByKey(key = "'getInviteImgs-'+#uid")
+	@RequestMapping(value = "/getInviteImgs", method = RequestMethod.POST)
+	public void getInviteImgs(AcceptData acceptData, Long uid, Integer page, PrintWriter out,
+			HttpServletRequest request) {
+		if (uid == null || uid <= 0) {
+			out.print(JsonUtil.loadFalseResult("鐢ㄦ埛鏈櫥褰�"));
+			return;
+		}
+
+		if (page == null || page < 1)
+			page = 1;
+
+		try {
+			String inviteCode = userInfoExtraService.getInviteCodeByUid(uid);
+			if (StringUtil.isNullOrEmpty(inviteCode)) {
+				out.print(JsonUtil.loadFalseResult("閭�璇风爜鏈縺娲�"));
+				return;
+			}
+
+			int count = 3;
+			if (page > 1)
+				count = Integer.MAX_VALUE;
+
+			// 閭�璇峰浘
+			List<String> imgList = spreadUserImgService.getUserSpreadImgToPage(uid, page, count, request);
+
+			// 閭�璇疯鍒�
+			BusinessSystem system = new BusinessSystem();
+			system.setId(4L);
+			system.setPlatform(1);
+			system.setCreatetime(java.lang.System.currentTimeMillis());
+			SystemClientParams values = systemClientParamsService.getSystemClientParamsBySystemAndKey(system,
+					"inviteRules");
+
+			JSONObject data = new JSONObject();
+			data.put("count", spreadImgService.countAll());
+			data.put("inviteCode", inviteCode);
+			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);
+			out.print(JsonUtil.loadTrue(0, JsonUtil.getSimpleGson().toJson(data), "鎴愬姛"));
+		} catch (Exception e) {
+			LogHelper.errorDetailInfo(e);
+			out.print(JsonUtil.loadFalseResult("閭�璇蜂俊鎭幏鍙栧け璐�"));
+		}
+	}
+
+	/**
+	 * 绔欏唴淇℃彁閱掗槦鍛樻坊鍔犲井淇″彿
+	 * 
+	 * @param acceptData
+	 * @param uid
+	 * @param out
+	 */
+	@RequestMapping(value = "tailorCode")
+	public void tailorCode(AcceptData acceptData, String callback, Long uid, PrintWriter out) {
+		if (uid == null) {
+			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鐢ㄦ埛id缂哄け"));
+			return;
+		}
+
+		// 鏈夋晥绮変笣
+		int doneFirst = 0;
+		UserInviteValidNum userInviteValidNum = userInviteValidNumService.selectByPrimaryKey(uid);
+		if (userInviteValidNum != null) {
+			doneFirst = userInviteValidNum.getNumFirst() == null ? 0 : userInviteValidNum.getNumFirst();
+		}
+
+		JSONObject data = new JSONObject();
+		data.put("num", doneFirst);
+		data.put("limit", Constant.INVITE_CODRE_TAILOR_LIMIT);
+		JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
+	}
+
+	/**
+	 * 鐢ㄦ埛闃熷憳鍒楄〃鏌ヨ
+	 * 
+	 * @param acceptData
+	 * @param out
+	 */
+	@RequestMapping(value = "getMyTeamV2", method = RequestMethod.POST)
+	public void getMyTeamV2(AcceptData acceptData, int page, long uid, int type, ThreeSaleFocusDTO focus,
+			PrintWriter out) {
+		if (type != 1 && type != 2) {
+			out.print(JsonUtil.loadFalseResult("绮変笣绫诲瀷涓嶆纭�"));
+			return;
+		}
+
+		long firstTeam = 0;
+		long countSecond = 0;
+		List<ThreeSale> listTeam = null;
+		if (!existScreen(focus)) { // 鏅�氭煡璇�
+			if (type == 1) {
+				listTeam = threeSaleSerivce.listFirstTeam((page - 1) * Constant.PAGE_SIZE, Constant.PAGE_SIZE, uid);
+			} else if (type == 2) {
+				listTeam = threeSaleSerivce.listSecondTeam((page - 1) * Constant.PAGE_SIZE, Constant.PAGE_SIZE, uid);
+			}
+			firstTeam = threeSaleSerivce.countFirstTeam(uid);
+			countSecond = threeSaleSerivce.countSecondTeam(uid);
+		} else { // 绛涢�夋潯浠�
+			List<Long> listId = null;
+			List<TeamFansInfo> listfocus = teamFansInfoService.query((page - 1) * Constant.PAGE_SIZE,
+					Constant.PAGE_SIZE, type, uid, focus);
+			if (listfocus != null && listfocus.size() > 0) {
+				listId = new ArrayList<Long>();
+				for (TeamFansInfo focusInfo : listfocus) {
+					listId.add(focusInfo.getWorkerId());
+				}
+			}
+
+			if (listId != null && listId.size() > 0) {
+				if (type == 1) {
+					listTeam = threeSaleSerivce.listFirstTeam(0, Constant.PAGE_SIZE, uid, listId);
+				} else if (type == 2) {
+					listTeam = threeSaleSerivce.listSecondTeam(0, Constant.PAGE_SIZE, uid, listId);
+				}
+			}
+			firstTeam = teamFansInfoService.count(1, uid, focus);
+			countSecond = teamFansInfoService.count(2, uid, focus);
+		}
+		JSONArray array = organizeTeamNew(acceptData, listTeam, uid, type, true);
+
+		long count = (type == 1) ? firstTeam : countSecond;
+
+		JSONObject result = new JSONObject();
+		result.put("firstTeam", firstTeam);
+		result.put("secondTeam", countSecond);
+		result.put("count", count);
+		result.put("list", array);
+
+		// 缁熻H5閾炬帴
+		if (page == 1) {
+			result.put("link", configService.getValue(ConfigKeyEnum.teamStatisticsLink.getKey(),acceptData.getSystem()));
+		}
+		out.print(JsonUtil.loadTrueResult(result));
+	}
+
+	/**
+	 * 楠岃瘉鏄惁瀛樺湪绛涢�夋潯浠�
+	 * 
+	 * @param focus
+	 * @return
+	 */
+	private boolean existScreen(ThreeSaleFocusDTO focus) {
+		if (focus.getStateValid() != null || focus.getTaobaoBind() != null || focus.getWeixinBind() != null
+				|| focus.getMinFansNum() != null || focus.getMinFansNum() != null || focus.getMinActiveTime() != null
+				|| focus.getMaxActiveTime() != null || focus.getMinIncome() != null || focus.getMaxIncome() != null
+				|| focus.getMinJoinTime() != null || focus.getMaxJoinTime() != null
+				|| !StringUtil.isNullOrEmpty(focus.getKey()) || !StringUtil.isNullOrEmpty(focus.getLevel()))
+			return true;
+
+		return false;
+	}
+
+	/**
+	 * 鐢ㄦ埛闃熷憳缁熻
+	 * 
+	 * @param acceptData
+	 * @param out
+	 */
+	@RequestMapping(value = "countMyTeamV2")
+	public void countMyTeamV2(String callback, AcceptData acceptData, Long uid, PrintWriter out) {
+		try {
+			JSONObject bossObject = new JSONObject();
+			ThreeSale threeSale = threeSaleSerivce.getByWorkerId(uid);
+			if (threeSale == null) {
+				bossObject.put("exist", false);
+				bossObject.put("desc", "鎭枩浣狅紒鏉挎牀蹇渷浼樿川鐢ㄦ埛锛沑r\n\r\n浣犲苟娌℃湁閭�璇蜂汉锛屼絾浣犵殑閭�璇疯兘鍔涢粯璁ゆ槸寮�鍚殑锛沑r\n浣犳嫢鏈夌嫭鐗圭殑鏃犻個璇蜂汉婵�娲荤爜銆�");
+			} else {
+				// 涓婄骇鍩烘湰淇℃伅
+				Long bossId = threeSale.getBoss().getId();
+				UserInfo userInfo = userInfoService.selectByPKey(bossId);
+				boolean phoneCopy = true;
+				String phone = userInfo.getPhone();
+				if (StringUtil.isNullOrEmpty(phone)) {
+					phone = "";
+				} else {
+					if (!userCustomSettingsService.validateDisplayPhoneByUid(bossId)) {
+						phoneCopy = false;
+						phone = phone.substring(0, 7) + "****";
+					}
+				}
+
+				// 寰俊鍙�
+				UserInfoExtra extra = userInfoExtraService.getUserInfoExtra(bossId);
+				if (extra != null) {
+					bossObject.put("weixin", StringUtil.isNullOrEmpty(extra.getWeiXin()) ? "" : extra.getWeiXin());
+				}
+
+				// 褰撳墠绛夌骇
+				UserLevelEnum level = null;
+				UserVIPLevel vipLevel = userInviteService.getVIPLevelByUid(bossId);
+				if (vipLevel != null && vipLevel.getLevel() != null) {
+					level = UserLevelUtil.getByLevel(vipLevel.getLevel());
+				}
+				if (level == null) {
+					level = UserLevelEnum.daRen;
+				}
+				level = UserLevelUtil.getShowLevel(level);
+
+				bossObject.put("exist", true);
+				bossObject.put("nickName", userInfo.getNickName());
+				bossObject.put("portrait", userInfo.getPortrait());
+				bossObject.put("phone", phone);
+				bossObject.put("phoneCopy", phoneCopy);
+				bossObject.put("level", level.name());
+			}
+
+			JSONObject json = new JSONObject();
+			json.put("boss", bossObject);
+
+			TearcherInfo tearcherInfo = tearcherService.selectByUid(uid);
+			if (tearcherInfo != null) {
+				JSONObject tearcherObject = new JSONObject();
+				tearcherObject.put("nickName", tearcherInfo.getNickName());
+				tearcherObject.put("portrait", tearcherInfo.getPortrait());
+				tearcherObject.put("phone", tearcherInfo.getPhone());
+				tearcherObject.put("weixin", tearcherInfo.getWxID());
+				tearcherObject.put("level", UserLevelEnum.tearcher);
+				json.put("tearcher", tearcherObject);
+			}
+
+			JSONObject daren = new JSONObject();
+			JSONObject highVIP = new JSONObject();
+			JSONObject superVIP = new JSONObject();
+
+			TeamUserLevelStatistic statistic = teamUserLevelStatisticService.selectByUid(uid);
+			if (statistic == null) {
+				daren.put("total", 0);
+				highVIP.put("total", 0);
+				superVIP.put("total", 0);
+			} else {
+				int totalDaren = statistic.getDaRenFirstCount() + statistic.getDaRenSecondCount()
+						+ statistic.getNormalFirstCount() + statistic.getNormalSecondCount();
+				daren.put("total", totalDaren);
+				highVIP.put("total", statistic.getHighFirstCount() + statistic.getHighSecondCount());
+				superVIP.put("total", statistic.getSuperFirstCount() + statistic.getSuperSecondCount());
+			}
+
+			int darenToday = 0;
+			int highVIPToday = 0;
+			int superVIPToday = 0;
+			String createId = teamDailyRecordService.createId(uid, new Date());
+			TeamDailyRecord record = teamDailyRecordService.getById(createId);
+			if (record != null) {
+				if (record.getFirstDaRen() != null)
+					darenToday += record.getFirstDaRen();
+				if (record.getSecondDaRen() != null)
+					darenToday += record.getSecondDaRen();
+				if (record.getFirstHighVIP() != null)
+					highVIPToday += record.getFirstHighVIP();
+				if (record.getSecondHighVIP() != null)
+					highVIPToday += record.getSecondHighVIP();
+				if (record.getFirstSuperVIP() != null)
+					superVIPToday += record.getFirstSuperVIP();
+				if (record.getSecondSuperVIP() != null)
+					superVIPToday += record.getSecondSuperVIP();
+			}
+
+			// 鑾峰彇褰撴湀绗竴澶╁拰鏈�鍚庝竴澶�
+			Calendar cale = Calendar.getInstance();
+			SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
+			String firstday, lastday;
+			// 鑾峰彇鍓嶆湀鐨勭涓�澶�
+			cale = Calendar.getInstance();
+			cale.add(Calendar.MONTH, 0);
+			cale.set(Calendar.DAY_OF_MONTH, 1);
+			firstday = format.format(cale.getTime());
+			// 鑾峰彇鍓嶆湀鐨勬渶鍚庝竴澶�
+			cale = Calendar.getInstance();
+			cale.add(Calendar.MONTH, 1);
+			cale.set(Calendar.DAY_OF_MONTH, 0);
+			lastday = format.format(cale.getTime());
+
+			int darenMonth = 0;
+			int highVIPMonth = 0;
+			int superVIPMonth = 0;
+			Date minTime = TimeUtil.parseYYYYMMDD(firstday);
+			Date maxTime = TimeUtil.parseYYYYMMDD_HHMMSS(lastday + " 23:59:59");
+			List<TeamDailyRecord> listMonth = teamDailyRecordService.sumGroupByYearMonth(uid, minTime, maxTime);
+			if (listMonth != null && listMonth.size() > 0) {
+				TeamDailyRecord teamRecord = listMonth.get(0);
+				if (teamRecord.getFirstDaRen() != null)
+					darenMonth += teamRecord.getFirstDaRen();
+				if (teamRecord.getSecondDaRen() != null)
+					darenMonth += teamRecord.getSecondDaRen();
+				if (teamRecord.getFirstHighVIP() != null)
+					highVIPMonth += teamRecord.getFirstHighVIP();
+				if (teamRecord.getSecondHighVIP() != null)
+					highVIPMonth += teamRecord.getSecondHighVIP();
+				if (teamRecord.getFirstSuperVIP() != null)
+					superVIPMonth += teamRecord.getFirstSuperVIP();
+				if (teamRecord.getSecondSuperVIP() != null)
+					superVIPMonth += teamRecord.getSecondSuperVIP();
+			}
+			// 杈句汉
+			daren.put("today", darenToday);
+			daren.put("month", darenMonth);
+			// 楂樼骇浼氫細鍛�
+			highVIP.put("today", highVIPToday);
+			highVIP.put("month", highVIPMonth);
+			// 缁熻瓒呯骇浼氬憳鏁伴噺
+			superVIP.put("today", superVIPToday);
+			superVIP.put("month", superVIPMonth);
+
+			json.put("daren", daren);
+			json.put("highVIP", highVIP);
+			json.put("superVIP", superVIP);
+			JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(json));
+		} catch (Exception e) {
+			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("缁熻澶辫触"));
+			e.printStackTrace();
+		}
+
+	}
+
+	/**
+	 * 鑾峰彇绮変笣淇℃伅
+	 * 
+	 * @param acceptData
+	 * @param uid
+	 * @param workerId
+	 * @param out
+	 */
+	@RequestMapping(value = "getFansInfo")
+	public void getFansInfo(AcceptData acceptData, Long uid, Long workerId, PrintWriter out) {
+		if (uid == null || workerId == null) {
+			out.print(JsonUtil.loadFalseResult("鐢ㄦ埛id缂哄け"));
+			return;
+		}
+
+		ThreeSale threeSale = threeSaleSerivce.getByWorkerId(workerId);
+		if (threeSale == null) {
+			out.print(JsonUtil.loadFalseResult("閭�璇峰叧绯讳笉瀛樺湪"));
+			return;
+		}
+
+		UserInfo user = userInfoService.selectByPKey(workerId);
+		if (user == null) {
+			out.print(JsonUtil.loadFalseResult("鐢ㄦ埛涓嶅瓨鍦�"));
+			return;
+		}
+
+		// 闈炵洿鎺ラ個璇峰叧绯�
+		String bossNickName = null;
+		if (uid.longValue() != threeSale.getBoss().getId().longValue()) {
+			UserInfo boss = userInfoService.selectByPKey(threeSale.getBoss().getId());
+			if (boss != null) {
+				bossNickName = boss.getNickName();
+			}
+		}
+
+		JSONArray tagArray = new JSONArray();
+		String memoName = user.getNickName();
+		Long succeedTime = threeSale.getSucceedTime();
+
+		JSONObject data = new JSONObject();
+		String phone = user.getPhone();
+		boolean phoneCopy = true;
+		if (StringUtil.isNullOrEmpty(phone)) {
+			phone = "";
+		} else {
+			if (!userCustomSettingsService.validateDisplayPhoneByUid(workerId)) {
+				phoneCopy = false;
+				phone = phone.substring(0, 7) + "****";
+			}
+		}
+
+		data.put("bossNickName", bossNickName);
+		data.put("nickName", user.getNickName());
+		data.put("phone", phone);
+		data.put("phoneCopy", phoneCopy);
+		data.put("joinTime", TimeUtil.formatDate(succeedTime == null ? threeSale.getCreateTime() : succeedTime));
+
+		ThreeSaleExtraInfo saleExtraInfo = threeSaleExtraInfoSerivce.getbyBossIdAndWorkerId(uid, workerId);
+		if (saleExtraInfo != null) {
+			if (!StringUtil.isNullOrEmpty(saleExtraInfo.getNickname())) {
+				memoName = saleExtraInfo.getNickname();
+			}
+			String tags = saleExtraInfo.getTags();
+			if (!StringUtil.isNullOrEmpty(tags)) {
+				tagArray = JSONArray.fromObject(tags);
+			}
+		}
+		data.put("memoName", memoName);
+		data.put("tags", tagArray);
+
+		Date activeTime = null;
+		String weixin = null;
+		UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(workerId);
+		if (userInfoExtra != null) {
+			weixin = userInfoExtra.getWeiXin();
+			activeTime = userInfoExtra.getActiveTime();
+		}
+
+		if (activeTime == null) {
+			activeTime = new Date(user.getCreatetime());
+		}
+
+		data.put("weixin", StringUtil.isNullOrEmpty(weixin) ? "" : weixin);
+		data.put("loginTime", TimeUtil.formatDate(activeTime));
+
+		UserExtraTaoBaoInfo userExtraTaoBaoInfo = userExtraTaoBaoInfoService.getByUid(workerId);
+		if (userExtraTaoBaoInfo != null && !StringUtil.isNullOrEmpty(userExtraTaoBaoInfo.getRelationId())
+				&& !StringUtil.isNullOrEmpty(userExtraTaoBaoInfo.getSpecialId())) {
+			data.put("taobao", true);
+		} else {
+			data.put("taobao", false);
+		}
+
+		UserVIPPreInfo userVIPPreInfo = userVIPPreInfoService.getLatestProcessInfo(workerId);
+		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 += "(閭�璇峰洟闃熷瀷)");
+				}
+			}
+		}
+
+		// 绮変笣缁熻
+		long indirectNum = 0;
+		long directNum = threeSaleSerivce.countFirstTeam(workerId);
+		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);
+		
+		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));
+	}
+
+	/**
+	 * 鑾峰彇绮変笣淇℃伅
+	 * 
+	 * @param acceptData
+	 * @param uid
+	 * @param workerId
+	 * @param out
+	 */
+	@RequestMapping(value = "fansSearch")
+	public void fansSearch(String callback, AcceptData acceptData, Long uid, String key, PrintWriter out) {
+		if (uid == null) {
+			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鐢ㄦ埛鏈櫥褰�"));
+			return;
+		}
+
+		if (StringUtil.isNullOrEmpty(key)) {
+			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璇疯緭鍏ョ瓫閫変俊鎭�"));
+			return;
+		}
+
+		List<TeamFansInfo> listfocus = teamFansInfoService.queryByUserInfo(key);
+		if (listfocus == null || listfocus.size() == 0) {
+			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(2, "鏆傛棤鐩稿叧淇℃伅"));
+			return;
+		}
+
+		Long fansId = null;
+		for (TeamFansInfo teamFansInfo : listfocus) {
+			Long workerId = teamFansInfo.getWorkerId();
+			ThreeSaleDetail threeDetail = threeSaleDetailService.getByBossUidAndWorkerUid(uid, workerId);
+			if (threeDetail != null) {
+				fansId = workerId;
+				break;
+			}
+		}
+
+		if (fansId == null) {
+			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(2, "鏆傛棤鐩稿叧淇℃伅"));
+			return;
+		}
+
+		ThreeSale threeSale = threeSaleSerivce.getByWorkerId(fansId);
+		if (threeSale == null) {
+			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(2, "鏆傛棤鐩稿叧淇℃伅"));
+			return;
+		}
+		
+		UserInfo user = userInfoService.selectByPKey(fansId);
+		if (user == null) {
+			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(2, "鏆傛棤鐩稿叧淇℃伅"));
+			return;
+		}
+
+		JSONObject data = new JSONObject();
+		JSONObject inviteBoss = getInviteBoss(threeSale.getBoss().getId());
+		data.put("boss", inviteBoss);
+
+		String phone = user.getPhone();
+		boolean phoneCopy = true;
+		if (StringUtil.isNullOrEmpty(phone)) {
+			phone = "";
+		} else {
+			if (!userCustomSettingsService.validateDisplayPhoneByUid(fansId)) {
+				phoneCopy = false;
+				phone = phone.substring(0, 7) + "****";
+			}
+		}
+
+		data.put("fansId", fansId);
+		data.put("nickName", user.getNickName());
+		data.put("portrait", user.getPortrait());
+		data.put("phone", phone);
+		data.put("phoneCopy", phoneCopy);
+		data.put("joinTime", TimeUtil.formatDate(threeSale.getSucceedTime() == null ? threeSale.getCreateTime() : threeSale.getSucceedTime()));
+
+		Date activeTime = null;
+		String weixin = null;
+		UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(fansId);
+		if (userInfoExtra != null) {
+			weixin = userInfoExtra.getWeiXin();
+			activeTime = userInfoExtra.getActiveTime();
+		}
+
+		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));
+
+		UserExtraTaoBaoInfo userExtraTaoBaoInfo = userExtraTaoBaoInfoService.getByUid(fansId);
+		if (userExtraTaoBaoInfo != null && !StringUtil.isNullOrEmpty(userExtraTaoBaoInfo.getRelationId())
+				&& !StringUtil.isNullOrEmpty(userExtraTaoBaoInfo.getSpecialId())) {
+			data.put("taobao", true);
+		} else {
+			data.put("taobao", false);
+		}
+
+		// 褰撳墠绛夌骇
+		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;
+		long directNum = threeSaleSerivce.countFirstTeam(fansId);
+		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);
+
+		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));
+	}
+
+	private JSONObject getInviteBoss(Long bossId) {
+		UserInfo userInfo = userInfoService.selectByPKey(bossId);
+		boolean phoneCopy = true;
+		String phone = userInfo.getPhone();
+		if (StringUtil.isNullOrEmpty(phone)) {
+			phone = "";
+		} else {
+			if (!userCustomSettingsService.validateDisplayPhoneByUid(bossId)) {
+				phoneCopy = false;
+				phone = phone.substring(0, 7) + "****";
+			}
+		}
+
+		// 寰俊鍙�
+		String weixin = "";
+		UserInfoExtra extra = userInfoExtraService.getUserInfoExtra(bossId);
+		if (extra != null) {
+			weixin = StringUtil.isNullOrEmpty(extra.getWeiXin()) ? "" : extra.getWeiXin();
+		}
+
+		// 褰撳墠绛夌骇
+		UserLevelEnum level = null;
+		UserVIPLevel vipLevel = userInviteService.getVIPLevelByUid(bossId);
+		if (vipLevel != null && vipLevel.getLevel() != null) {
+			level = UserLevelUtil.getByLevel(vipLevel.getLevel());
+		}
+		if (level == null) {
+			level = UserLevelEnum.daRen;
+		}
+		level = UserLevelUtil.getShowLevel(level);
+
+		JSONObject bossObject = new JSONObject();
+		bossObject.put("nickName", userInfo.getNickName());
+		bossObject.put("portrait", userInfo.getPortrait());
+		bossObject.put("phone", phone);
+		bossObject.put("phoneCopy", phoneCopy);
+		bossObject.put("weixin", weixin);
+		bossObject.put("level", level.name());
+		return bossObject;
+	}
+
+	/**
+	 * 淇濆瓨绮変笣淇℃伅
+	 * 
+	 * @param acceptData
+	 * @param uid
+	 * @param workerId
+	 * @param out
+	 */
+	@RequestMapping(value = "saveTags")
+	public void saveTags(AcceptData acceptData, Long uid, Long workerId, String tags, PrintWriter out) {
+		if (uid == null || workerId == null) {
+			out.print(JsonUtil.loadFalseResult("鐢ㄦ埛id缂哄け"));
+			return;
+		}
+
+		int type = 1;
+		ThreeSale threeSale = threeSaleSerivce.getByWorkerId(workerId);
+		if (threeSale != null && threeSale.getBoss().getId() != uid) {
+			type = 2;
+		}
+
+		ThreeSaleExtraInfo saleExtraInfo = threeSaleExtraInfoSerivce.getbyBossIdAndWorkerId(uid, workerId);
+		if (saleExtraInfo != null) {
+			ThreeSaleExtraInfo upObject = new ThreeSaleExtraInfo();
+			upObject.setTags(tags);
+			upObject.setId(saleExtraInfo.getId());
+			upObject.setUpdateTime(new Date());
+			threeSaleExtraInfoSerivce.updateByPrimaryKeySelective(upObject);
+		} else {
+			saleExtraInfo = new ThreeSaleExtraInfo();
+			saleExtraInfo.setBoss(new UserInfo(uid));
+			saleExtraInfo.setWorker(new UserInfo(workerId));
+			saleExtraInfo.setTags(tags);
+			saleExtraInfo.setType(type);
+			saleExtraInfo.setCreateTime(new Date());
+			threeSaleExtraInfoSerivce.insertSelective(saleExtraInfo);
+		}
+
+		// 鏇存柊绮変笣璁板綍淇℃伅
+		teamFansInfoService.updateTags(workerId, type, tags);
+		out.print(JsonUtil.loadTrueResult("淇濆瓨鎴愬姛"));
+	}
+
+	/**
+	 * 闃熷憳鏁伴噺缁熻
+	 * 
+	 * @param acceptData
+	 * @param id
+	 * @param out
+	 */
+	@RequestMapping(value = "countTeamNum")
+	public void countTeamNum(String callback, AcceptData acceptData, Long uid, PrintWriter out) {
+		try {
+			Date minDate = null;
+			Date maxDate = null;
+			long timeStamp = System.currentTimeMillis();
+
+			Calendar calendar = Calendar.getInstance();
+			calendar.setTimeInMillis(timeStamp);
+
+			// 浠婃棩棰勪及
+			calendar.add(Calendar.DAY_OF_YEAR, -1);
+			minDate = new Date(TimeUtil.convertDateToTemp(TimeUtil.getGernalTime(timeStamp)));
+			TeamDailyRecord todayRecord = createVO(
+					teamDailyRecordService.sumTeamNumGroupByCountDay(uid, minDate, null));
+
+			// 鏄ㄦ棩棰勪及
+			calendar.add(Calendar.DAY_OF_YEAR, -1);
+			maxDate = new Date(TimeUtil.convertDateToTemp(TimeUtil.getGernalTime(timeStamp)));
+			minDate = DateUtil.reduceDay(1, maxDate);
+			TeamDailyRecord yesterdayRecord = createVO(
+					teamDailyRecordService.sumTeamNumGroupByCountDay(uid, minDate, maxDate));
+
+			// 鏈湀棰勪及
+			maxDate = new Date(timeStamp);
+			calendar = Calendar.getInstance();
+			minDate = new Date(TimeUtil.convertToTimeTemp(
+					calendar.get(Calendar.YEAR) + "-" + (calendar.get(Calendar.MONTH) + 1), "yyyy-M"));
+			calendar.add(Calendar.MONTH, -1);
+			TeamDailyRecord monthRecord = createVO(
+					teamDailyRecordService.sumTeamNumGroupByYearMonth(uid, minDate, maxDate));
+
+			// 绱
+			TeamDailyRecord totalityRecord = createVO(teamDailyRecordService.sumTeamNumGroupByUid(uid, null, null));
+
+			JSONObject today = new JSONObject();
+			today.put("direct", todayRecord.getFirstNum());
+			today.put("indirect", todayRecord.getSecondNum());
+			today.put("beyond", todayRecord.getBeyondNum());
+
+			JSONObject yesterday = new JSONObject();
+			yesterday.put("direct", yesterdayRecord.getFirstNum());
+			yesterday.put("indirect", yesterdayRecord.getSecondNum());
+			yesterday.put("beyond", yesterdayRecord.getBeyondNum());
+
+			JSONObject month = new JSONObject();
+			month.put("direct", monthRecord.getFirstNum());
+			month.put("indirect", monthRecord.getSecondNum());
+			month.put("beyond", monthRecord.getBeyondNum());
+
+			JSONObject totality = new JSONObject();
+			totality.put("direct", totalityRecord.getFirstNum());
+			totality.put("indirect", totalityRecord.getSecondNum());
+			totality.put("beyond", totalityRecord.getBeyondNum());
+
+			JSONObject json = new JSONObject();
+			json.put("today", today);
+			json.put("yesterday", yesterday);
+			json.put("month", month);
+			json.put("totality", totality);
+			JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(json));
+		} catch (Exception e) {
+			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("缁熻澶辫触"));
+			e.printStackTrace();
+		}
+	}
+
+	private TeamDailyRecord createVO(List<TeamDailyRecord> list) {
+		TeamDailyRecord totalityRecord = new TeamDailyRecord(0, 0, 0);
+		if (list != null && list.size() > 0) {
+			for (TeamDailyRecord record : list) {
+				totalityRecord.setFirstNum(totalityRecord.getFirstNum() + record.getFirstNum());
+				totalityRecord.setSecondNum(totalityRecord.getSecondNum() + record.getSecondNum());
+				totalityRecord.setBeyondNum(totalityRecord.getBeyondNum() + record.getBeyondNum());
+			}
+		}
+		return totalityRecord;
+	}
+
+	/**
+	 * 閭�璇锋帓琛屾
+	 * 
+	 * @param callback
+	 * @param acceptData
+	 * @param uid
+	 * @param dateType
+	 * @param out
+	 */
+	@RequestMapping(value = "getRanking")
+	public void getRanking(String callback, AcceptData acceptData, Long uid, Integer dateType, PrintWriter out) {
+		if (uid == null || dateType == null) {
+			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鍙傛暟缂哄け"));
+			return;
+		}
+
+		try {
+			Date minDate = null;
+			Date maxDate = null;
+			long timeStamp = System.currentTimeMillis();
+			Calendar calendar = Calendar.getInstance();
+			calendar.setTimeInMillis(timeStamp);
+
+			if (dateType == 1) {
+				// 浠婃棩
+				calendar.add(Calendar.DAY_OF_YEAR, -1);
+				minDate = new Date(TimeUtil.convertDateToTemp(TimeUtil.getGernalTime(timeStamp)));
+			} else if (dateType == 2) {
+				// 鏄ㄦ棩
+				calendar.add(Calendar.DAY_OF_YEAR, -1);
+				maxDate = new Date(TimeUtil.convertDateToTemp(TimeUtil.getGernalTime(timeStamp)));
+				minDate = DateUtil.reduceDay(1, maxDate);
+			} else {
+				// 鏈湀
+				maxDate = new Date(timeStamp);
+				calendar = Calendar.getInstance();
+				minDate = new Date(TimeUtil.convertToTimeTemp(
+						calendar.get(Calendar.YEAR) + "-" + (calendar.get(Calendar.MONTH) + 1), "yyyy-M"));
+				calendar.add(Calendar.MONTH, -1);
+			}
+
+			List<OrderRankingVO> list = teamDailyRecordService.getRankingByFirstNum(uid, minDate, maxDate);
+			if (list.size() > 0) {
+				for (OrderRankingVO vo : list) {
+					UserInfo user = userInfoService.getUserByIdWithMybatis(vo.getUid());
+					vo.setNickName(user.getNickName());
+					vo.setPortrait(user.getPortrait());
+				}
+			}
+
+			JSONObject json = new JSONObject();
+			json.put("list", list);
+			JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(json));
+		} catch (Exception e) {
+			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("缁熻澶辫触"));
+			e.printStackTrace();
+		}
+	}
+
+}

--
Gitblit v1.8.0