From 5e7b0ed4a154ad067cbcf4aa1a1c7cce32f9864c Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期五, 26 四月 2024 18:02:17 +0800
Subject: [PATCH] 唯品会链接解析升级

---
 fanli/src/main/java/com/yeshi/fanli/controller/admin/user/vip/UserVipApplyAdminController.java |  371 +++++++++++++++++++++++++++++-----------------------
 1 files changed, 209 insertions(+), 162 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/admin/user/vip/UserVipApplyAdminController.java b/fanli/src/main/java/com/yeshi/fanli/controller/admin/user/vip/UserVipApplyAdminController.java
index 4555516..514df4d 100644
--- a/fanli/src/main/java/com/yeshi/fanli/controller/admin/user/vip/UserVipApplyAdminController.java
+++ b/fanli/src/main/java/com/yeshi/fanli/controller/admin/user/vip/UserVipApplyAdminController.java
@@ -8,6 +8,8 @@
 import javax.servlet.http.HttpServletRequest;
 
 import com.yeshi.fanli.entity.accept.AdminAcceptData;
+import com.yeshi.fanli.exception.user.vip.UserVIPUpgradeException;
+import com.yeshi.fanli.service.inter.user.vip.UserVIPPreInfoService;
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.yeshi.utils.IPUtil;
@@ -39,189 +41,234 @@
 @RequestMapping("admin/new/api/v1/vip")
 public class UserVipApplyAdminController {
 
-	@Resource
-	private GiveVIPApplyInfoService giveVIPApplyInfoService;
+    @Resource
+    private GiveVIPApplyInfoService giveVIPApplyInfoService;
 
-	@Resource
-	private UserInfoService userInfoService;
+    @Resource
+    private UserInfoService userInfoService;
 
-	/**
-	 * 
-	 * @param callback
-	 * @param pageIndex
-	 * @param pageSize
-	 * @param key 鎼滅储锛氭殏鍙彁渚泆id
-	 * @param state 鐘舵�侊細
-	 * @param out
-	 */
-	@RequestMapping(value = "queryVip")
-	public void queryVip(AdminAcceptData acceptData, String callback, Integer pageIndex, Integer pageSize, String key, Integer state,
-						 PrintWriter out) {
-		try {
+    @Resource
+    private UserVIPPreInfoService userVIPPreInfoService;
 
-			Long targetUid = null;
-			try {
-				targetUid = Long.parseLong(key);
-			} catch (Exception e) {
-			}
+    /**
+     * @param callback
+     * @param pageIndex
+     * @param pageSize
+     * @param key       鎼滅储锛氭殏鍙彁渚泆id
+     * @param state     鐘舵�侊細
+     * @param out
+     */
+    @RequestMapping(value = "queryVip")
+    public void queryVip(AdminAcceptData acceptData, String callback, Integer pageIndex, Integer pageSize, String key, Integer state,
+                         PrintWriter out) {
+        try {
 
-			List<GiveVIPApplyInfo> list = giveVIPApplyInfoService.listByStateAndTargetUid(targetUid, state, pageIndex,
-					pageSize);
+            Long targetUid = null;
+            try {
+                targetUid = Long.parseLong(key);
+            } catch (Exception e) {
+            }
 
-			if (list == null || list.size() == 0) {
-				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏆傛棤鏁版嵁"));
-				return;
-			}
+            List<GiveVIPApplyInfo> list = giveVIPApplyInfoService.listByStateAndTargetUid(targetUid, state, pageIndex,
+                    pageSize);
 
-			for (GiveVIPApplyInfo info : list) {
-				// 缁勭粐鐢ㄦ埛淇℃伅
-				UserInfo userInfo = userInfoService.selectByPKey(info.getTargetUid());
-				UserInfo simpleInfo = new UserInfo(userInfo.getId());
-				simpleInfo.setNickName(userInfo.getNickName());
-				simpleInfo.setPortrait(userInfo.getPortrait());
-				info.setTargetUser(simpleInfo);
-				// 缁勭粐鍏朵粬骞冲彴淇℃伅
-				if (info.getHasDoOtherPlatform() != null && info.getHasDoOtherPlatform()) {
-					String st = "骞冲彴锛�" + (StringUtil.isNullOrEmpty(info.getOtherPlatformName()) ? "鏈煡"
-							: info.getOtherPlatformName());
-					st += "\n绮変笣鏁帮細";
-					st += "鐩存帴绮変笣鏁�(" + (info.getOtherDirectTeams() == null ? "鏈煡" : info.getOtherDirectTeams());
+            if (list == null || list.size() == 0) {
+                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏆傛棤鏁版嵁"));
+                return;
+            }
 
-					st += ") 闂存帴绮変笣鏁�(" + (info.getOtherInDirectTeams() == null ? "鏈煡" : info.getOtherInDirectTeams())
-							+ ")";
+            for (GiveVIPApplyInfo info : list) {
+                // 缁勭粐鐢ㄦ埛淇℃伅
+                UserInfo userInfo = userInfoService.selectByPKey(info.getTargetUid());
+                UserInfo simpleInfo = new UserInfo(userInfo.getId());
+                simpleInfo.setNickName(userInfo.getNickName());
+                simpleInfo.setPortrait(userInfo.getPortrait());
+                info.setTargetUser(simpleInfo);
+                // 缁勭粐鍏朵粬骞冲彴淇℃伅
+                if (info.getHasDoOtherPlatform() != null && info.getHasDoOtherPlatform()) {
+                    String st = "骞冲彴锛�" + (StringUtil.isNullOrEmpty(info.getOtherPlatformName()) ? "鏈煡"
+                            : info.getOtherPlatformName());
+                    st += "\n绮変笣鏁帮細";
+                    st += "鐩存帴绮変笣鏁�(" + (info.getOtherDirectTeams() == null ? "鏈煡" : info.getOtherDirectTeams());
 
-					st += "\n骞冲彴绛夌骇锛�" + (StringUtil.isNullOrEmpty(info.getOtherLevel()) ? "鏈煡" : info.getOtherLevel());
+                    st += ") 闂存帴绮変笣鏁�(" + (info.getOtherInDirectTeams() == null ? "鏈煡" : info.getOtherInDirectTeams())
+                            + ")";
 
-					st += "\n鏈堝潎鏀跺叆锛�" + (StringUtil.isNullOrEmpty(info.getOtherMonthIncome()) ? "鏈煡"
-							: info.getOtherMonthIncome());
+                    st += "\n骞冲彴绛夌骇锛�" + (StringUtil.isNullOrEmpty(info.getOtherLevel()) ? "鏈煡" : info.getOtherLevel());
 
-					info.setOtherPlatformInfo(st);
-				} else {
-					info.setOtherPlatformInfo("鏆傛棤");
-				}
+                    st += "\n鏈堝潎鏀跺叆锛�" + (StringUtil.isNullOrEmpty(info.getOtherMonthIncome()) ? "鏈煡"
+                            : info.getOtherMonthIncome());
 
-			}
+                    info.setOtherPlatformInfo(st);
+                } else {
+                    info.setOtherPlatformInfo("鏆傛棤");
+                }
 
-			long count = giveVIPApplyInfoService.countByStateAndTargetUid(targetUid, state);
-			int totalPage = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1);
-			PageEntity pe = new PageEntity(pageIndex, pageSize, count, totalPage);
+            }
 
-			GsonBuilder gsonBuilder = new GsonBuilder().registerTypeAdapter(UserLevelEnum.class,
-					new JsonSerializer<UserLevelEnum>() {
+            long count = giveVIPApplyInfoService.countByStateAndTargetUid(targetUid, state);
+            int totalPage = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1);
+            PageEntity pe = new PageEntity(pageIndex, pageSize, count, totalPage);
 
-						public JsonElement serialize(UserLevelEnum arg0, Type arg1, JsonSerializationContext arg2) {
-							return new JsonPrimitive(arg0.getName());
-						}
-					});
-			gsonBuilder.serializeNulls();
-			Gson gson = gsonBuilder.setDateFormat("yyyy/MM/dd HH:mm:ss").create();
+            GsonBuilder gsonBuilder = new GsonBuilder().registerTypeAdapter(UserLevelEnum.class,
+                    new JsonSerializer<UserLevelEnum>() {
 
-			JSONObject data = new JSONObject();
-			data.put("pe", pe);
-			data.put("result_list", gson.toJson(list));
-			JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
-		} catch (Exception e) {
-			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎿嶄綔寮傚父"));
-			e.printStackTrace();
-		}
-	}
+                        public JsonElement serialize(UserLevelEnum arg0, Type arg1, JsonSerializationContext arg2) {
+                            return new JsonPrimitive(arg0.getName());
+                        }
+                    });
+            gsonBuilder.serializeNulls();
+            Gson gson = gsonBuilder.setDateFormat("yyyy/MM/dd HH:mm:ss").create();
 
-	/**
-	 * 瓒呯骇浼氬憳鍗囩骇閫氳繃
-	 * @param callback
-	 * @param id
-	 * @param out
-	 * @param request
-	 * @throws UserVIPPreInfoException 
-	 */
-	@RequestSerializableByKey(key = "'passApplyVIP-' +#id")
-	@RequestMapping(value = "passVIP")
-	public void passVIP(AdminAcceptData acceptData,String callback, String id, PrintWriter out, HttpServletRequest request) {
-		try {
-			/* 妫�楠屾槸鍚︾櫥闄� */
-			AdminUser admin = (AdminUser) request.getSession().getAttribute(Constant.SESSION_ADMIN);
-			if (admin == null) {
-				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("褰撳墠璐︽埛澶辨晥,璇烽噸鏂扮櫥闄嗐��"));
-				return;
-			}
-			giveVIPApplyInfoService.pass(id, admin.getId());
-			JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("鎿嶄綔鎴愬姛"));
-			LogHelper.userInfo(
-					"[ip:" + IPUtil.getRemotIP(request) + "]" + admin.getName() + "閫氳繃浜哰id=" + id + "]鐨勫崌绾т細鍛樼敵璇�!");
-		} catch (GiveVIPApplyInfoException e) {
-			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
-			return;
-		} catch (UserVIPPreInfoException e) {
-			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
-		}
-	}
+            JSONObject data = new JSONObject();
+            data.put("pe", pe);
+            data.put("result_list", gson.toJson(list));
+            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
+        } catch (Exception e) {
+            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎿嶄綔寮傚父"));
+            e.printStackTrace();
+        }
+    }
 
-	/**
-	 * 瓒呯骇浼氬憳鍗囩骇鎷掔粷
-	 * @param callback
-	 * @param id
-	 * @param reason
-	 * @param out
-	 * @param request
-	 */
+    /**
+     * 瓒呯骇浼氬憳鍗囩骇閫氳繃
+     *
+     * @param callback
+     * @param id
+     * @param out
+     * @param request
+     * @throws UserVIPPreInfoException
+     */
+    @RequestSerializableByKey(key = "'passApplyVIP-' +#id")
+    @RequestMapping(value = "passVIP")
+    public void passVIP(AdminAcceptData acceptData, String callback, String id, PrintWriter out, HttpServletRequest request) {
+        try {
+            /* 妫�楠屾槸鍚︾櫥闄� */
+            AdminUser admin = (AdminUser) request.getSession().getAttribute(Constant.SESSION_ADMIN);
+            if (admin == null) {
+                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("褰撳墠璐︽埛澶辨晥,璇烽噸鏂扮櫥闄嗐��"));
+                return;
+            }
+            giveVIPApplyInfoService.pass(id, admin.getId());
+            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("鎿嶄綔鎴愬姛"));
+            LogHelper.userInfo(
+                    "[ip:" + IPUtil.getRemotIP(request) + "]" + admin.getName() + "閫氳繃浜哰id=" + id + "]鐨勫崌绾т細鍛樼敵璇�!");
+        } catch (GiveVIPApplyInfoException e) {
+            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
+            return;
+        } catch (UserVIPPreInfoException e) {
+            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
+        }
+    }
 
-	@RequestMapping(value = "rejectVIP")
-	public void rejectVIP(AdminAcceptData acceptData,String callback, String id, String reason, PrintWriter out, HttpServletRequest request) {
-		try {
-			/* 妫�楠屾槸鍚︾櫥闄� */
-			AdminUser admin = (AdminUser) request.getSession().getAttribute(Constant.SESSION_ADMIN);
-			if (admin == null) {
-				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("褰撳墠璐︽埛澶辨晥,璇烽噸鏂扮櫥闄�"));
-				return;
-			}
+    /**
+     * 瓒呯骇浼氬憳鍗囩骇鎷掔粷
+     *
+     * @param callback
+     * @param id
+     * @param reason
+     * @param out
+     * @param request
+     */
 
-			giveVIPApplyInfoService.reject(id, admin.getId(), reason);
-			JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("鎷掔粷鎴愬姛"));
-			LogHelper.userInfo("[ip:" + IPUtil.getRemotIP(request) + "][绠$悊鍛�:" + admin.getName() + "] 鎷掔粷鎻愮幇id=" + id
-					+ "鐨勫崌绾ц秴绾т細鍛樼敵璇蜂笉瀛樺湪!");
-		} catch (GiveVIPApplyInfoException e) {
-			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
-			return;
-		} catch (Exception e) {
-			e.printStackTrace();
-			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎿嶄綔澶辫触"));
-			return;
-		}
-	}
+    @RequestMapping(value = "rejectVIP")
+    public void rejectVIP(AdminAcceptData acceptData, String callback, String id, String reason, PrintWriter out, HttpServletRequest request) {
+        try {
+            /* 妫�楠屾槸鍚︾櫥闄� */
+            AdminUser admin = (AdminUser) request.getSession().getAttribute(Constant.SESSION_ADMIN);
+            if (admin == null) {
+                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("褰撳墠璐︽埛澶辨晥,璇烽噸鏂扮櫥闄�"));
+                return;
+            }
 
-	@RequestMapping(value = "apply")
-	public void apply(AdminAcceptData acceptData,String callback, Long uid, String level, String applyReason, PrintWriter out,
-			HttpServletRequest request) {
-		try {
-			/* 妫�楠屾槸鍚︾櫥闄� */
-			AdminUser admin = (AdminUser) request.getSession().getAttribute(Constant.SESSION_ADMIN);
-			if (admin == null) {
-				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("褰撳墠璐︽埛澶辨晥,璇烽噸鏂扮櫥闄�"));
-				return;
-			}
+            giveVIPApplyInfoService.reject(id, admin.getId(), reason);
+            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("鎷掔粷鎴愬姛"));
+            LogHelper.userInfo("[ip:" + IPUtil.getRemotIP(request) + "][绠$悊鍛�:" + admin.getName() + "] 鎷掔粷鎻愮幇id=" + id
+                    + "鐨勫崌绾ц秴绾т細鍛樼敵璇蜂笉瀛樺湪!");
+        } catch (GiveVIPApplyInfoException e) {
+            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
+            return;
+        } catch (Exception e) {
+            e.printStackTrace();
+            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎿嶄綔澶辫触"));
+            return;
+        }
+    }
 
-			UserInfo user = userInfoService.selectAvailableByPrimaryKey(uid);
-			if (user == null) {
-				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鐢ㄦ埛涓嶅瓨鍦ㄦ垨宸茬粡琚皝绂�"));
-				return;
-			}
+    @RequestMapping(value = "apply")
+    public void apply(AdminAcceptData acceptData, String callback, Long uid, String level, String applyReason, PrintWriter out,
+                      HttpServletRequest request) {
+        try {
+            /* 妫�楠屾槸鍚︾櫥闄� */
+            AdminUser admin = (AdminUser) request.getSession().getAttribute(Constant.SESSION_ADMIN);
+            if (admin == null) {
+                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("褰撳墠璐︽埛澶辨晥,璇烽噸鏂扮櫥闄�"));
+                return;
+            }
 
-			GiveVIPApplyInfo info = new GiveVIPApplyInfo();
-			info.setApplyReason(applyReason);
-			info.setTargetUid(uid);
-			info.setSourceUid(uid);
-			info.setMark(String.format("绠$悊鍛�(%s)浠d负鐢宠", admin.getName()));
-			info.setLevel(UserLevelEnum.valueOf(level));
-			giveVIPApplyInfoService.addGiveVIPApplyInfo(info);
-			JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("鎴愬姛"));
-		} catch (GiveVIPApplyInfoException e) {
-			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
-			return;
-		} catch (Exception e) {
-			e.printStackTrace();
-			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎿嶄綔澶辫触"));
-			return;
-		}
-	}
+            UserInfo user = userInfoService.selectAvailableByPrimaryKey(uid);
+            if (user == null) {
+                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鐢ㄦ埛涓嶅瓨鍦ㄦ垨宸茬粡琚皝绂�"));
+                return;
+            }
+
+            GiveVIPApplyInfo info = new GiveVIPApplyInfo();
+            info.setApplyReason(applyReason);
+            info.setTargetUid(uid);
+            info.setSourceUid(uid);
+            info.setMark(String.format("绠$悊鍛�(%s)浠d负鐢宠", admin.getName()));
+            info.setLevel(UserLevelEnum.valueOf(level));
+            giveVIPApplyInfoService.addGiveVIPApplyInfo(info);
+            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("鎴愬姛"));
+        } catch (GiveVIPApplyInfoException e) {
+            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
+            return;
+        } catch (Exception e) {
+            e.printStackTrace();
+            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎿嶄綔澶辫触"));
+            return;
+        }
+    }
+
+
+    /**
+     * 鐢宠楂樼骇浼氬憳
+     *
+     * @param acceptData
+     * @param callback
+     * @param uid
+     * @param type       1-璁㈠崟  2-閭�璇�
+     * @param out
+     * @param request
+     */
+    @RequestMapping(value = "applyHighLevel")
+    public void applyHighLevel(AdminAcceptData acceptData, String callback, Long uid, int type, PrintWriter out,
+                               HttpServletRequest request) {
+
+        /* 妫�楠屾槸鍚︾櫥闄� */
+        AdminUser admin = (AdminUser) request.getSession().getAttribute(Constant.SESSION_ADMIN);
+        if (admin == null) {
+            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("褰撳墠璐︽埛澶辨晥,璇烽噸鏂扮櫥闄�"));
+            return;
+        }
+
+        UserInfo user = userInfoService.selectAvailableByPrimaryKey(uid);
+        if (user == null) {
+            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鐢ㄦ埛涓嶅瓨鍦ㄦ垨宸茬粡琚皝绂�"));
+            return;
+        }
+
+        try {
+            if (type == 1) {
+                userVIPPreInfoService.upgradeVipByMyOrder(uid);
+            } else
+                userVIPPreInfoService.upgradeVipByTeamNum(uid);
+            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("鎴愬姛"));
+        } catch (UserVIPUpgradeException e) {
+            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMessage()));
+        }
+
+
+    }
 
 }

--
Gitblit v1.8.0