yujian
2020-06-18 52bc8ff0de3c7538d1401423c1cba9615c0c2082
fanli/src/main/java/com/yeshi/fanli/controller/admin/UserInfoAdminController.java
@@ -146,30 +146,23 @@
   @Resource
   private HongBaoV2CountService hongBaoV2CountService;
   
   /**
    * 查询用户信息列表 正常用户/异常用户
    * 
    * @param callback
    * @param pageIndex
    * @param key
    *            查询条件
    * @param userType
    *            用户类型:金冠、银冠、铜冠
    * @param days
    *            查询天数
    * @param startTime
    *            注册时间
    * @param endTime
    *            注册时间
    * @param orderMode
    *            排序方式 订单数量 今日订单 累计队员
    * @param key       查询条件
    * @param userType  用户类型:金冠、银冠、铜冠
    * @param days      查询天数
    * @param startTime 注册时间
    * @param endTime   注册时间
    * @param orderMode 排序方式 订单数量 今日订单 累计队员
    * @param out
    */
   @RequestMapping(value = "query")
   public void query(String callback, Integer pageIndex, Integer pageSize, String key, Integer keyType, Integer rank,Integer userType,
         Integer days, String startTime, String endTime, Integer orderMode, Integer type,String level,
         Integer activeCode, PrintWriter out) {
   public void query(String callback, Integer pageIndex, Integer pageSize, String key, Integer keyType, Integer rank,
         Integer userType, Integer days, String startTime, String endTime, Integer orderMode, Integer type,
         String level, Integer activeCode, PrintWriter out) {
      try {
         if (type == null) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("用户类型type不能为空"));
@@ -224,7 +217,8 @@
            return;
         }
         long count = userInfoService.queryCount(type, key, keyType, userRank, days, startTime, endTime,userType, level, activeCode);
         long count = userInfoService.queryCount(type, key, keyType, userRank, days, startTime, endTime, userType,
               level, activeCode);
         int totalPage = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1);
         PageEntity pe = new PageEntity(pageIndex, pageSize, count, totalPage);
@@ -245,6 +239,7 @@
   /**
    * 用户基础信息查询
    *
    * @param callback
    * @param pageIndex
    * @param pageSize
@@ -261,8 +256,8 @@
    * @param out
    */
   @RequestMapping(value = "queryInfo")
   public void queryInfo(String callback, Integer pageIndex, Integer pageSize, String key, Integer keyType, Integer rank,Integer userType,
         Integer days, String startTime, String endTime, Integer state,String level,
   public void queryInfo(String callback, Integer pageIndex, Integer pageSize, String key, Integer keyType,
         Integer rank, Integer userType, Integer days, String startTime, String endTime, Integer state, String level,
         Integer activeCode, PrintWriter out) {
      try {
         if (pageIndex == null)
@@ -291,15 +286,16 @@
            }
         }
         List<UserInfoVO> userList = userInfoService.queryInfo((pageIndex - 1) * pageSize, pageSize, state, key, keyType,
               userRank, days, startTime, endTime, userType, level, activeCode);
         List<UserInfoVO> userList = userInfoService.queryInfo((pageIndex - 1) * pageSize, pageSize, state, key,
               keyType, userRank, days, startTime, endTime, userType, level, activeCode);
         if (userList == null || userList.size() == 0) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("暂无相关数据"));
            return;
         }
         long count = userInfoService.countInfo(state, key, keyType, userRank, days, startTime, endTime,userType, level, activeCode);
         long count = userInfoService.countInfo(state, key, keyType, userRank, days, startTime, endTime, userType,
               level, activeCode);
         int totalPage = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1);
         PageEntity pe = new PageEntity(pageIndex, pageSize, count, totalPage);
@@ -318,9 +314,9 @@
      }
   }
   
   /**
    * 资金统计
    *
    * @param callback
    * @param uid
    * @param out
@@ -349,8 +345,8 @@
         minDate = new Date(0L);
         maxDate = new Date(timeStamp);
         // 累计成功提现
         BigDecimal totalExtractMoney = userMoneyDetailService.statisticUserTypeMoneyWithDate(uid, typeList, minDate,
               maxDate, 1).abs();
         BigDecimal totalExtractMoney = userMoneyDetailService
               .statisticUserTypeMoneyWithDate(uid, typeList, minDate, maxDate, 1).abs();
         // 提现中金额
         BigDecimal extractingMoney = extractService.sumVerifyingMoney(uid);
         
@@ -371,9 +367,9 @@
      }
   }
   
   /**
    * 权益统计
    *
    * @param callback
    * @param uid
    * @param out
@@ -396,7 +392,6 @@
         e.printStackTrace();
      }
   }
   
   /**
    *  用户粉丝统计
@@ -447,10 +442,9 @@
      JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
   }
   
   /**
    * 用户详细信息
    *
    * @param callback
    * @param uid
    * @param out
@@ -458,8 +452,9 @@
   @RequestMapping(value = "getInfoDetail")
   public void getInfoDetail(String callback, Long uid, PrintWriter out) {
      
      UserInfo user = userInfoService.getUserByIdWithMybatis(uid);
      UserInfo user = userInfoService.selectByPKey(uid);
      UserInfoVO userInfoVO = new UserInfoVO();
      userInfoVO.setId(uid);
      userInfoVO.setPhone(user.getPhone());
      userInfoVO.setState(user.getState());
      userInfoVO.setCreatetime(user.getCreatetime());
@@ -471,6 +466,7 @@
         }
         userInfoVO.setInviteCode(userInfoExtra.getInviteCode());
         userInfoVO.setInviteCodeVip(userInfoExtra.getInviteCodeVip());
         userInfoVO.setWxId(userInfoExtra.getWeiXin());
      }
      
      // 最近一次下单时间
@@ -486,15 +482,14 @@
      }
      
      // 显示用户微信 淘宝 老版本存在
      String wxUnionId = user.getWxUnionId();
      if (wxUnionId == null || wxUnionId.trim().length() == 0) {
         user.setWxName(null);
      String wxId = userInfoVO.getWxId();
      if (wxId == null) {
         userInfoVO.setWxId("");
      }
      user.setWxName(user.getWxUnionId());
      // 是否绑定支付宝(购买 + 分享权限)
      UserExtraTaoBaoInfo extraTaoBaoInfo = userExtraTaoBaoInfoService.getByUid(uid);
      if (extraTaoBaoInfo != null) {
        String taoBaoUid = extraTaoBaoInfo.getTaoBaoUid();
        String specialId = extraTaoBaoInfo.getSpecialId();
        String relationId = extraTaoBaoInfo.getRelationId();
@@ -505,6 +500,7 @@
      } else {
         userInfoVO.setTbName(extraTaoBaoInfo.getTaoBaoNickName());
         userInfoVO.setTaoBaoUid(extraTaoBaoInfo.getTaoBaoUid());
         }
      }
      /* 绑定收款账号信息 */
@@ -527,6 +523,82 @@
      JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(userInfoVO));
   }
   
   /**
    *  绑定详情
    *
    * @param callback
    * @param uid
    * @param out
    */
   @RequestMapping(value = "getBindDetail")
   public void getBindDetail(String callback, Long uid, PrintWriter out) {
      UserInfo user = userInfoService.selectByPKey(uid);
      JSONObject data = new JSONObject();
      Integer state = user.getState();
      if (state == UserInfo.STATE_FORBIDDEN) {
         data.put("state", false);
      } else {
         data.put("state", true);
      }
      data.put("phone", user.getPhone());
      // 微信授权
      String wxUnionId = user.getWxUnionId();
      if(StringUtil.isNullOrEmpty(wxUnionId)) {
         data.put("wxName", "");
         data.put("wxState", false);
      } else {
         data.put("wxName", user.getWxName());
         data.put("wxnState", true);
      }
      String mark = "";
      UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid);
      if (userInfoExtra != null) {
         if (!StringUtil.isNullOrEmpty(userInfoExtra.getMark())) {
            mark = userInfoExtra.getMark();
         }
      }
      data.put("mark", mark);
      // 淘宝授权
      String tbName = "";
      boolean tbState = false;
      UserExtraTaoBaoInfo extraTaoBaoInfo = userExtraTaoBaoInfoService.getByUid(uid);
      if (extraTaoBaoInfo != null) {
         String taoBaoUid = extraTaoBaoInfo.getTaoBaoUid();
         String specialId = extraTaoBaoInfo.getSpecialId();
         String relationId = extraTaoBaoInfo.getRelationId();
         if (!StringUtil.isNullOrEmpty(taoBaoUid) && StringUtil.isNullOrEmpty(specialId) && StringUtil.isNullOrEmpty(relationId)) {
            tbState = true;
            tbName = extraTaoBaoInfo.getTaoBaoNickName();
         }
      }
      data.put("tbName", tbName);
      data.put("tbState", tbState);
      /* 绑定收款账号信息 */
      String accountName = "";
      boolean accountState = false;
      List<BindingAccount> account = bindingAccountService.getBindingAccountByUid(uid);
      if (account != null && account.size() > 0) {
         BindingAccount bindingAccount = account.get(0);
         Integer type = bindingAccount.getType();
         // 支付宝
         if (type != null && type == 1) {
            accountState = true;
            accountName = bindingAccount.getName();
         }
      }
      data.put("accountName", accountName);
      data.put("accountState", accountState);
      JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
   }
   
   /**
    * 统计今日用户总情况
@@ -590,13 +662,11 @@
          * // 统计所有总金额 BigDecimal countTotalMoney =
          * userInfoCountService.countAllMoney(null);
          * 
          * // 统计所有可提现金额 String minMoney =
          * configService.get(Constant.EXTRACT_MIN_MONEY); if (minMoney ==
          * null) { minMoney = "20"; } double min =
          * // 统计所有可提现金额 String minMoney = configService.get(Constant.EXTRACT_MIN_MONEY);
          * if (minMoney == null) { minMoney = "20"; } double min =
          * Double.parseDouble(minMoney); BigDecimal countCanAssets =
          * userInfoCountService.countAllMoney(min);
          * data.put("countTotalMoney", countTotalMoney);
          * data.put("countCanAssets", countCanAssets);
          * userInfoCountService.countAllMoney(min); data.put("countTotalMoney",
          * countTotalMoney); data.put("countCanAssets", countCanAssets);
          */
         // 今日新增用户数量
@@ -615,10 +685,8 @@
   /**
    * 
    * @param data
    * @param uid
    *            用户ID
    * @param type
    *            需要解绑的账户类型
    * @param uid  用户ID
    * @param type 需要解绑的账户类型
    */
   @RequestMapping("unBindUserInfo")
   public void unBindUserInfo(String callback, Long uid, String typeArray, PrintWriter out) {
@@ -695,10 +763,9 @@
      }
   }
   
   /**
    * 修改用户备注
    *
    * @param callback
    * @param uid
    * @param mark
@@ -723,6 +790,7 @@
   /**
    * 删除用户-改变其状态
    *
    * @param callback
    * @param idArray
    * @param out
@@ -742,7 +810,8 @@
         }
         Gson gson = new Gson();
         List<Long> list = gson.fromJson(idArray, new TypeToken<ArrayList<Long>>() {}.getType());
         List<Long> list = gson.fromJson(idArray, new TypeToken<ArrayList<Long>>() {
         }.getType());
         if (list == null || list.size() == 0) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("未检测到删除的数据"));
            return;
@@ -760,8 +829,6 @@
         e.printStackTrace();
      }
   }
   
   /**
    * 封禁用户ID
@@ -867,8 +934,7 @@
    * 
    * @param callback
    * @param code
    * @param type
    *            1("微信unionId"), 2("淘宝ID"), 3("手机号"), 4("支付宝账号");
    * @param type     1("微信unionId"), 2("淘宝ID"), 3("手机号"), 4("支付宝账号");
    * @param out
    */
   @RequestMapping(value = "saveForbiddenInfo")
@@ -889,8 +955,6 @@
         JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作异常"));
      }
   }
   /**
    * 队员关系
@@ -956,7 +1020,6 @@
            UserInfo worker = threeSale.getWorker();
            threeSale.setWorker(userInfoService.selectByPKey(worker.getId()));
            
            Integer expire = threeSale.getExpire();
            if (threeSale.getState()) {
               threeSale.setExpire(1); // 邀请成功
@@ -968,7 +1031,6 @@
               }
            }
         }
         long count = 0;
         if (type == 0) {
@@ -1048,16 +1110,11 @@
   /**
    * 根据渠道 统计当日新增用户数量
    * 
    * @param channelArray
    *            名字数组
    * @param dateType
    *            类型 1日 2月 3年
    * @param year
    *            2018
    * @param startTime
    *            2018-12-01
    * @param endTime
    *            2018-12-01
    * @param channelArray 名字数组
    * @param dateType     类型 1日 2月 3年
    * @param year         2018
    * @param startTime    2018-12-01
    * @param endTime      2018-12-01
    * @param out
    */
   @RequestMapping(value = "getNewUserCharts")
@@ -1137,8 +1194,8 @@
      }
   }
   
   private List<Object> getNewUserData(List<String> dateList, Integer dateType, Date beginDate, Date endDate, String channel) {
   private List<Object> getNewUserData(List<String> dateList, Integer dateType, Date beginDate, Date endDate,
         String channel) {
      List<Object> list = new ArrayList<>();
      List<CountUserInfo> listHistory = userInfoCountService.getNewUserData(beginDate, endDate, channel);
      for (String date: dateList) {
@@ -1179,16 +1236,11 @@
   /**
    * 根据渠道 统计当日新增用户数量
    * 
    * @param channelArray
    *            名字数组
    * @param dateType
    *            类型 1日 2月 3年
    * @param year
    *            2018
    * @param startTime
    *            2018-12-01
    * @param endTime
    *            2018-12-01
    * @param channelArray 名字数组
    * @param dateType     类型 1日 2月 3年
    * @param year         2018
    * @param startTime    2018-12-01
    * @param endTime      2018-12-01
    * @param out
    */
   @RequestMapping(value = "getTodayBuyRate")
@@ -1252,8 +1304,7 @@
         JSONArray line_list = new JSONArray();
         for (String channel : channelList) {
            List<ChartTDO> list = userInfoCountService.getTodayBuyRate(channel, dateType, year,
                  startTime, endTime);
            List<ChartTDO> list = userInfoCountService.getTodayBuyRate(channel, dateType, year, startTime, endTime);
            if ("all".equalsIgnoreCase(channel)) {
               channel = "总计";
@@ -1299,12 +1350,10 @@
    * 当周产生3单的新增用户概率
    * 
    * @param callback
    * @param channelArray
    *            渠道名称
    * @param channelArray 渠道名称
    * @param startTime
    * @param endTime
    * @param orderNum
    *            订单数量
    * @param orderNum     订单数量
    * @param out
    */
   @RequestMapping(value = "getWeekBuyRate")
@@ -1365,9 +1414,9 @@
      }
   }
   /**
    * 获取金币排行榜
    *
    * @param callback
    * @param pageIndex
    * @param pageSize
@@ -1401,7 +1450,6 @@
      if(list == null)
         list = new ArrayList<>();
      
      int totalPage = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1);
      PageEntity pe = new PageEntity(pageIndex, pageSize, count, totalPage);
@@ -1411,9 +1459,9 @@
      JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
   }
   
   /**
    * 获取金币排行榜
    *
    * @param callback
    * @param pageIndex
    * @param pageSize
@@ -1451,14 +1499,11 @@
      gsonBuilder.serializeNulls();
      Gson gson = gsonBuilder.setDateFormat("yyyy/MM/dd HH:mm:ss").create();
      
      JSONObject data = new JSONObject();
      data.put("pe", pe);
      data.put("list", gson.toJson(list));
      JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
   }
   
   /**
    * 
@@ -1470,7 +1515,8 @@
    * @param out
    */
   @RequestMapping(value = "queryVip")
   public void queryVip(String callback, Integer pageIndex, Integer pageSize, String key, Integer state, PrintWriter out) {
   public void queryVip(String callback, Integer pageIndex, Integer pageSize, String key, Integer state,
         PrintWriter out) {
      try {
         List<UserVIPInfo> list = userVIPInfoService.listQuery(pageIndex, pageSize, key, state);
         if (list == null || list.size() == 0) {
@@ -1496,10 +1542,9 @@
      }
   }
   /**
    * 超级会员升级通过
    *
    * @param callback
    * @param id
    * @param out
@@ -1517,7 +1562,8 @@
         }
         userVIPInfoService.passVIPApply(id);
         JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("操作成功"));
         LogHelper.userInfo("[ip:" + IPUtil.getRemotIP(request) + "]" + admin.getName() + "通过了[id=" + id + "]的升级超级会员申请!");
         LogHelper.userInfo(
               "[ip:" + IPUtil.getRemotIP(request) + "]" + admin.getName() + "通过了[id=" + id + "]的升级超级会员申请!");
      } catch (UserVIPInfoException e) {
         JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
         return;
@@ -1528,9 +1574,9 @@
      }
   }
   
   /**
    * 超级会员升级拒绝
    *
    * @param callback
    * @param id
    * @param reason
@@ -1549,7 +1595,8 @@
         }
         userVIPInfoService.rejectVIPApply(id, reason);
         JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("拒绝成功"));
         LogHelper.userInfo("[ip:" + IPUtil.getRemotIP(request) + "][管理员:" + admin.getName() + "] 拒绝提现id=" + id + "的升级超级会员申请不存在!");
         LogHelper.userInfo("[ip:" + IPUtil.getRemotIP(request) + "][管理员:" + admin.getName() + "] 拒绝提现id=" + id
               + "的升级超级会员申请不存在!");
      } catch (UserVIPInfoException e) {
         JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
         return;
@@ -1559,8 +1606,6 @@
         return;
      }
   }
   
   /**
    * 用户账户明细
@@ -1602,9 +1647,11 @@
         PageEntity pe = new PageEntity(pageIndex, pageSize, count, totalPage);
         
         GsonBuilder gsonBuilder = new GsonBuilder().setDateFormat("yyyy-MM-dd HH:mm:ss");
         gsonBuilder.registerTypeAdapter(UserMoneyDetailTypeEnum.class, new JsonSerializer<UserMoneyDetailTypeEnum>() {
         gsonBuilder.registerTypeAdapter(UserMoneyDetailTypeEnum.class,
               new JsonSerializer<UserMoneyDetailTypeEnum>() {
            @Override
            public JsonElement serialize(UserMoneyDetailTypeEnum value, Type theType, JsonSerializationContext context) {
                  public JsonElement serialize(UserMoneyDetailTypeEnum value, Type theType,
                        JsonSerializationContext context) {
               if (value == null) {
                  return new JsonPrimitive("");
               } else {
@@ -1623,10 +1670,5 @@
         JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("查询失败"));
      }
   }
         
}