| | |
| | | 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; |
| | |
| | | @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 搜索:暂只提供uid |
| | | * @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 搜索:暂只提供uid |
| | | * @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)代为申请", 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)代为申请", 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())); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | } |