From c51190b423317c39e16a10ed08578621e3296c07 Mon Sep 17 00:00:00 2001
From: admin <2780501319@qq.com>
Date: 星期六, 29 二月 2020 10:51:17 +0800
Subject: [PATCH] 转链bug修复
---
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/InviteControllerV2.java | 228 +++++++++++++++++++++++++++++++++++++++++++++++++--------
1 files changed, 196 insertions(+), 32 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 0416440..063fd5e 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
@@ -5,12 +5,15 @@
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;
@@ -21,19 +24,31 @@
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;
@@ -46,7 +61,7 @@
@Resource
private RedisManager redisManager;
-
+
@Resource
private ConfigService configService;
@@ -68,6 +83,23 @@
@Resource
private ThreeSaleExtraInfoSerivce threeSaleExtraInfoSerivce;
+ @Resource
+ private UserVIPInfoService userVIPInfoService;
+
+ @Resource
+ private UserInviteSeparateService userInviteSeparateService;
+
+ @Resource
+ private SpreadImgService spreadImgService;
+
+ @Resource
+ private SpreadUserImgService spreadUserImgService;
+
+ @Resource
+ private SystemClientParamsService systemClientParamsService;
+
+
+
/**
* 閭�璇风爜楠岃瘉
*
@@ -80,7 +112,7 @@
JSONObject data = new JSONObject();
data.put("nickName", userInfo.getNickName());
data.put("portrait", userInfo.getPortrait());
- data.put("tips", "纭瑕佹垚涓篢A鐨勪竴绾ч槦鍛樺悧锛熼個璇峰叧绯讳竴鏃﹀缓绔嬩笉鍙洿鏀广��");
+ data.put("tips", "纭瑕佹垚涓篢A鐨勭洿鎺ョ矇涓濆悧锛熼個璇峰叧绯讳竴鏃﹀缓绔嬩笉鍙洿鏀广��");
out.print(JsonUtil.loadTrueResult(data));
} catch (UserInfoExtraException e) {
out.print(JsonUtil.loadFalseResult(e.getMsg()));
@@ -100,22 +132,22 @@
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 activeWX = StringUtil.Md5("activeWX:" + weiXinUser.getUnionid());
- redisManager.cacheCommonString(activeWX, JsonUtil.getSimpleGson().toJson(weiXinUser), 60 * 20);
-
+
+ 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", activeWX);
+ data.put("tips", "纭瑕佹垚涓篢A鐨勭洿鎺ョ矇涓濆悧锛熼個璇峰叧绯讳竴鏃﹀缓绔嬩笉鍙洿鏀广��");
+ data.put("key", key);
out.print(JsonUtil.loadTrueResult(data));
} catch (UserInfoExtraException e) {
out.print(JsonUtil.loadFalseResult(e.getMsg()));
@@ -124,9 +156,11 @@
/**
* 寰俊婵�娲�
+ *
* @param acceptData
* @param uid
- * @param key 楠岃瘉杩斿洖鐨刱ey
+ * @param key
+ * 楠岃瘉杩斿洖鐨刱ey
* @param out
*/
@RequestSerializableByKey(key = "'activeInviteWX-'+#uid")
@@ -136,15 +170,15 @@
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()));
@@ -153,9 +187,7 @@
e.printStackTrace();
}
}
-
-
-
+
/**
* 鐢ㄦ埛闃熷憳鍒楄〃鏌ヨ 1.5.3鏌ヨ鏈夋晥闃熷憳
*
@@ -166,7 +198,7 @@
@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("闃熷憳绫诲瀷涓嶆纭�"));
+ out.print(JsonUtil.loadFalseResult("绮変笣绫诲瀷涓嶆纭�"));
return;
}
@@ -180,8 +212,12 @@
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);
+ JSONObject resultData = organizeTeam(count, listTeam, uid, type,needVIPInfo);
// 绗竴椤靛垽鏂槸鍚︽縺娲� 鏄惁鏈夐槦鍛�
if (type == 1 && page == 1) {
@@ -206,7 +242,7 @@
* @param type
* @return
*/
- private JSONObject organizeTeam(long count, List<ThreeSale> list, Long uid, int type) {
+ private JSONObject organizeTeam(long count, List<ThreeSale> list, Long uid, int type, boolean needVipInfo) {
JSONObject result = new JSONObject();
JSONArray resultArray = new JSONArray();
@@ -215,6 +251,14 @@
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) {
@@ -230,7 +274,39 @@
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()) {
@@ -296,12 +372,12 @@
*/
@RequestMapping(value = "countMyTeam", method = RequestMethod.POST)
public void countMyTeam(AcceptData acceptData, long uid, PrintWriter out) {
- JSONObject bossData = getBossInfo(acceptData, uid, threeSaleSerivce.getMyBoss(uid));
+ 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("team_help_url"));
+ 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));
@@ -310,7 +386,7 @@
boolean hasTeam = true;
if (firstTeam <= 0) {
hasTeam = false;
- resultData.put("invitelink", configService.get("invite_activation_url"));
+ resultData.put("invitelink", configService.get(ConfigKeyEnum.inviteActivationUrl.getKey()));
}
resultData.put("hasTeam", hasTeam);
@@ -329,8 +405,8 @@
resultData.put("hasCode", hasCode);
if (!hasCode) {
List<String> tipCode = new ArrayList<String>();
- resultData.put("helpLinkActivate", configService.get("team_help_url"));
- tipCode.add("婵�娲婚個璇峰姛鑳藉悗鎵嶅彲浠ラ個璇烽槦鍛橈紝涓�绾ч槦鍛樻槸鐢变綘鐩存帴閭�璇凤紝浜岀骇闃熷憳鏄敱浣犵殑涓�绾ч槦鍛橀個璇枫��");
+ resultData.put("helpLinkActivate", configService.get(ConfigKeyEnum.teamHelpUrl.getKey()));
+ tipCode.add("婵�娲婚個璇峰姛鑳藉悗鎵嶅彲浠ラ個璇风矇涓濓紝鐩存帴绮変笣鏄敱浣犵洿鎺ラ個璇凤紝闂存帴绮変笣鏄敱浣犵殑鐩存帴绮変笣閭�璇枫��");
tipCode.add("閭�璇锋縺娲诲姛鑳斤紝蹇呴』瑕佹湁閭�璇风爜锛岄個璇风爜鍙互閫氳繃閲戝竵鍏戞崲锛屼篃鍙互鍏ㄧ綉鎼滅储銆�");
resultData.put("tipCode", tipCode);
}
@@ -338,16 +414,33 @@
// 鏈坊鍔犲井淇″彿
List<String> tipWeiXin = new ArrayList<String>();
if (!bdWeiXin) {
- tipWeiXin.add("娣诲姞寰俊鍙峰悗锛屼綘鐨勯個璇蜂汉鍜屼竴绾ч槦鍛樺彲閫氳繃寰俊鍙蜂笌浣犲缓绔嬭仈绯伙紱");
- tipWeiXin.add("浣犱篃鍙互鍚戦個璇蜂汉瀛︿範鎴栧悜涓�绾ч槦鍛樻暀鎺堣禋閽辨妧宸с��");
+ tipWeiXin.add("娣诲姞寰俊鍙峰悗锛屼綘鐨勯個璇蜂汉鍜岀洿鎺ョ矇涓濆彲閫氳繃寰俊鍙蜂笌浣犲缓绔嬭仈绯伙紱");
+ tipWeiXin.add("浣犱篃鍙互鍚戦個璇蜂汉瀛︿範鎴栧悜鐩存帴绮変笣鏁欐巿璧氶挶鎶�宸с��");
}
resultData.put("tipWeiXin", tipWeiXin);
- resultData.put("tipWeiXinAdd", "娣诲姞寰俊鍙峰悗锛屼綘鐨勯個璇蜂汉鍜屼竴绾ч槦鍛樺彲浠ラ�氳繃寰俊涓庝綘寤虹珛鑱旂郴銆�");
+ 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));
+ }
+
+
/**
* 涓婄骇淇℃伅缁勭粐
*
@@ -356,7 +449,7 @@
* @param threeSale
* @return
*/
- private JSONObject getBossInfo(AcceptData acceptData, long uid, ThreeSale threeSale) {
+ private JSONObject getBossInfo(long uid, ThreeSale threeSale) {
JSONObject bossData = new JSONObject();
if (threeSale != null && threeSale.getBoss() != null) {
UserInfo boss = threeSale.getBoss();
@@ -385,7 +478,7 @@
bossData.put("inviteTime", "浣犱簬 " + sdf.format(inviteTime) + "鎺ュ彈浜員A鐨勯個璇�");
} else {
bossData.put("hasBoss", false);
- bossData.put("helpLink", configService.get("invite_code_hlep_link"));
+ bossData.put("helpLink", configService.get(ConfigKeyEnum.inviteCodeHlepLink.getKey()));
bossData.put("weiXinTip", "鎭枩浣狅紝鎴戜滑鐨勪紭璐ㄧ敤鎴凤紱\r\n浣犲苟娌℃湁閭�璇蜂汉锛屼絾浣犵殑閭�璇锋縺娲诲姛鑳芥槸琚粯璁ゅ紑鍚殑锛沑r\n浣犳嫢鏈夌嫭鐗圭殑鏃犻個璇蜂汉婵�娲荤爜銆�");
}
return bossData;
@@ -434,13 +527,13 @@
Long bossId = null;
Long workerId = null;
- String title = "闃熷憳鎻愰啋娑堟伅";
+ String title = "绮変笣鎻愰啋娑堟伅";
String content = "";
if (remindBoss) {
// 鎻愮ず闃熼暱
bossId = remindId;
workerId = uid;
- content = "浣犵殑涓�绾ч槦鍛�" + userInfo.getNickName()
+ content = "浣犵殑鐩存帴绮変笣" + userInfo.getNickName()
+ "锛屾彁閱掍綘娣诲姞寰俊鍙凤紝浠ヤ究浜庡拰浣犲彇寰楄仈绯诲拰瀛︿範鐪侀挶鎶�宸э紝璧跺揩鍘绘坊鍔犲惂锛涙敞锛氳鍗囩骇鍒版湰杞欢鏈�鏂扮増鏈湪鈥滄垜鐨�-鎴戠殑淇℃伅鈥濅腑娣诲姞銆�";
} else {
// 鎻愮ず闃熷憳
@@ -487,4 +580,75 @@
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));
+ }
+
+
+
}
--
Gitblit v1.8.0