admin
2020-02-18 ddf5db7d31af51fcf697eac0cee7dd46ff73bcc1
fanli/src/main/java/com/yeshi/fanli/controller/admin/ExtractAdminController.java
@@ -1,11 +1,5 @@
package com.yeshi.fanli.controller.admin;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.math.BigDecimal;
@@ -28,23 +22,25 @@
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.commons.CommonsMultipartFile;
import org.yeshi.utils.CsvUtil;
import org.yeshi.utils.DateUtil;
import org.yeshi.utils.IPUtil;
import org.yeshi.utils.JsonUtil;
import org.yeshi.utils.entity.wx.RedPackRecord;
import org.yeshi.utils.wx.WXUtil;
import org.yeshi.utils.wx.WXRedPackUtil;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;
import com.yeshi.fanli.controller.admin.utils.AdminUtils;
import com.yeshi.fanli.dto.ChartTDO;
import com.yeshi.fanli.entity.admin.count.CountUserInfo;
import com.yeshi.fanli.entity.bus.user.Extract;
import com.yeshi.fanli.entity.bus.user.ExtractAuditRecord;
import com.yeshi.fanli.entity.bus.user.HongBaoV2;
import com.yeshi.fanli.entity.bus.user.UserInfo;
import com.yeshi.fanli.entity.bus.user.UserInfoExtra;
import com.yeshi.fanli.entity.common.AdminUser;
import com.yeshi.fanli.entity.system.ConfigKeyEnum;
import com.yeshi.fanli.exception.ExtractException;
import com.yeshi.fanli.exception.NotExistObjectException;
import com.yeshi.fanli.exception.ObjectStateException;
@@ -56,12 +52,14 @@
import com.yeshi.fanli.service.inter.money.extract.ExtractAuditRecordService;
import com.yeshi.fanli.service.inter.money.extract.ExtractCountService;
import com.yeshi.fanli.service.inter.money.extract.ExtractService;
import com.yeshi.fanli.service.inter.order.CommonOrderCountService;
import com.yeshi.fanli.service.inter.order.tb.TaoBaoOrderService;
import com.yeshi.fanli.service.inter.order.tb.TaoBaoWeiQuanOrderService;
import com.yeshi.fanli.service.inter.push.PushRecordService;
import com.yeshi.fanli.service.inter.user.UserInfoExtraService;
import com.yeshi.fanli.tag.PageEntity;
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.FileUtil;
import com.yeshi.fanli.util.MoneyBigDecimalUtil;
import com.yeshi.fanli.util.RedisManager;
import com.yeshi.fanli.util.StringUtil;
import com.yeshi.fanli.util.TimeUtil;
@@ -108,6 +106,12 @@
   @Resource
   private TaoBaoWeiQuanOrderService taoBaoWeiQuanOrderService;
   @Resource
   private UserInfoExtraService userInfoExtraService;
   @Resource
   private CommonOrderCountService commonOrderCountService;
   /**
    * 
@@ -230,8 +234,8 @@
      // 当前用户余额总计:所有用户总余额
      BigDecimal amountMoney = userInfoCountService.countAllMoney(null);
      // 可提现金额限制
      String minMoney = configService.get(Constant.EXTRACT_MIN_MONEY);
      // 可提现金额限制
      String minMoney = configService.get(ConfigKeyEnum.extractMoneyMin.getKey());
      if (minMoney == null) {
         minMoney = "0";
      }
@@ -399,6 +403,11 @@
            if (adminUser == null) {
               record.setAdminUser(new AdminUser());
            }
            // 查询用户备注信息
            UserInfoExtra extra = userInfoExtraService.getUserInfoExtra(record.getExtract().getUserInfo().getId());
            if (extra != null) {
               record.getExtract().getUserInfo().setStateDesc(extra.getMark());
            }
            int warnLevel = 0;
            Extract extract = record.getExtract();
@@ -423,7 +432,7 @@
                  desc.append("维权订单数:" + record.getExtraInfo().getWeiQuanOrderCount() + "\n#");
                  desc.append("维权订单佣金:" + record.getExtraInfo().getWeiQuanOrderFanAmount() + "\n#");
                  if (record.getExtraInfo().getOrderCount50More() > 0
                        || record.getExtraInfo().getWeiQuanOrderCount() > 1
                        || record.getExtraInfo().getWeiQuanOrderCount() > 0
                        || record.getExtraInfo().getWeiQuanOrderFanAmount().compareTo(new BigDecimal(10)) >= 0)
                     warnLevel = 2;
               } else {
@@ -438,7 +447,29 @@
               }
               record.setExtraInfoStr(desc.toString());
            }
            // if (warnLevel == 0) {
            // // 查询同店铺商品,同商品订单超过一定数量的
            // List<Integer> typeList = new ArrayList<>();
            // typeList.add(HongBaoV2.TYPE_ZIGOU);
            // long sameGoodsOrderCount =
            // commonOrderCountService.countSameGoodsOrderByUidAndHongBaoType(typeList,
            // record.getExtract().getUserInfo().getId(),
            // Integer.parseInt(configService.get(ConfigKeyEnum.adminMinSameGoodsOrderCount.getKey())));
            // long sameShopOrderCount =
            // commonOrderCountService.countSameShopOrderByUidAndHongBaoType(typeList,
            // record.getExtract().getUserInfo().getId(),
            // Integer.parseInt(configService.get(ConfigKeyEnum.adminMinSameShopOrderCount.getKey())));
            // if (sameGoodsOrderCount > 0 || sameShopOrderCount > 0) {
            // warnLevel = 3;
            // record.setExtraInfoStr(
            // String.format("同店铺:%s 同商品:%s", sameShopOrderCount,
            // sameGoodsOrderCount));
            // }
            // }
            record.setWarnLevel(warnLevel);
         }
         int count = extractAuditRecordService.getMyAuditedTimeSlotCount(key, state, null, days);
@@ -448,7 +479,7 @@
         GsonBuilder gsonBuilder = new GsonBuilder();
         gsonBuilder.serializeNulls();
         gsonBuilder.setDateFormat("yyyy-MM-dd HH:mm:ss");
         Gson gson = gsonBuilder.create();
         JSONObject data = new JSONObject();
@@ -461,6 +492,27 @@
         e.printStackTrace();
         out.print(JsonUtil.loadFalseResult(e.getMessage()));
      }
   }
   @RequestMapping(value = "getMyAuditedDanger")
   public void getMyAuditedDanger(String callback, Long uid, PrintWriter out) {
      if (uid == null) {
         JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("请登录"));
         return;
      }
      // 查询同店铺商品,同商品订单超过一定数量的
      List<Integer> typeList = new ArrayList<>();
      typeList.add(HongBaoV2.TYPE_ZIGOU);
      long sameGoodsOrderCount = commonOrderCountService.countSameGoodsOrderByUidAndHongBaoType(typeList, uid,
            Integer.parseInt(configService.get(ConfigKeyEnum.adminMinSameGoodsOrderCount.getKey())));
      long sameShopOrderCount = commonOrderCountService.countSameShopOrderByUidAndHongBaoType(typeList, uid,
            Integer.parseInt(configService.get(ConfigKeyEnum.adminMinSameShopOrderCount.getKey())));
      if (sameGoodsOrderCount > 0 || sameShopOrderCount > 0) {
         String text = (String.format("同店铺:%s 同商品:%s", sameShopOrderCount, sameGoodsOrderCount));
         JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(text));
         return;
      }
      JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("店铺/商品无异常"));
   }
   /**
@@ -563,6 +615,13 @@
               surplusTime = DateUtil.dateDiff(formattodayTime, formatTime);
            }
            String mark = "";
            UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(extract.getUserInfo().getId());
            if (userInfoExtra != null && !StringUtil.isNullOrEmpty(userInfoExtra.getMark())) {
               mark = "警惕!! " + userInfoExtra.getMark();
            }
            data.put("mark", mark);
            data.put("extract", extract);
            data.put("beforeMoney", beforeMoney);
            data.put("surplusTime", surplusTime);
@@ -626,6 +685,13 @@
                  surplusTime = DateUtil.dateDiff(formattodayTime, formatTime);
               }
               String mark = "";
               UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(extract.getUserInfo().getId());
               if (userInfoExtra != null && !StringUtil.isNullOrEmpty(userInfoExtra.getMark())) {
                  mark = "警惕!! " + userInfoExtra.getMark();
               }
               data.put("mark", mark);
               data.put("extract", extract);
               data.put("beforeMoney", beforeMoney);
               data.put("surplusTime", surplusTime);
@@ -792,81 +858,122 @@
   @RequestMapping(value = "getAuditTotal")
   public void getAuditTotal(String callback, String stateArray, Integer dateType, String year, String startTime,
         String endTime, PrintWriter out) {
      String validateMsg = AdminUtils.validateParams(dateType, startTime, endTime);
      if (validateMsg != null) {
         JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(validateMsg));
         return;
      }
      if (dateType == 1 && year != null) {
         year = null; // 设置为空
      } else if (dateType == 2) {
         if (startTime != null)
            startTime = null;
         if (endTime != null)
            endTime = null;
      } else if (dateType == 3) {
         if (year != null)
            year = null;
         if (startTime != null)
            startTime = null;
         if (endTime != null)
            endTime = null;
      }
      try {
         Object objectDate = null;
         List<String> dateList = AdminUtils.getDateList(dateType, startTime, endTime, year);
         String validateMsg = AdminUtils.validateParams(dateType, startTime, endTime);
         if (validateMsg != null) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(validateMsg));
            return;
         }
         if (dateType != 1 && (!StringUtil.isNullOrEmpty(startTime) || !StringUtil.isNullOrEmpty(endTime))) {
            startTime = null;
            endTime = null;
         }
         Date beginDate = null;
         Date endDate = null;
         if (dateType == 1) {
            beginDate = TimeUtil.parse(startTime);
            endDate = TimeUtil.parse(endTime);
         } else if (dateType == 2) {
            Calendar calendar=Calendar.getInstance();
            int currentYear = calendar.get(Calendar.YEAR);
            if (!StringUtil.isNullOrEmpty(year)) {
               currentYear = Integer.parseInt(year);
            }
            calendar.clear();
             calendar.set(Calendar.YEAR, currentYear);
             beginDate =calendar.getTime();
            calendar.clear();
            calendar.set(Calendar.YEAR, currentYear);
            calendar.roll(Calendar.DAY_OF_YEAR, -1);
            endDate=calendar.getTime();
         } else if (dateType == 3) {
            beginDate = TimeUtil.parse("2018-01-01");
            endDate = new Date();
         }
         Gson gson = new Gson();
         List<Integer> stateList = gson.fromJson(stateArray, new TypeToken<ArrayList<Integer>>() {
         }.getType());
         List<String> dateList = AdminUtils.getDateList(dateType, startTime, endTime, year);
         String substring = stateArray.substring(1, stateArray.length()-1);
         List<Integer> channelList = null;
         if (stateArray != null && stateArray.trim().length() > 4) {
            channelList = gson.fromJson(stateArray, new TypeToken<ArrayList<Integer>>() {}.getType());
         }
         JSONArray line_list = new JSONArray();
         for (Integer state : stateList) {
            JSONObject innerList = new JSONObject();
            if (state == null || state == 3) {
               innerList.put("name", "总计");
            } else if (state == 1) {
               innerList.put("name", "通过数");
            } else if (state == 2) {
               innerList.put("name", "驳回数");
            }
            List<ChartTDO> list = extractAuditRecordService.countAuditTotal(state, dateType, year,
                  startTime, endTime);
            if (dateType != 3) {
               innerList.put("data", gson.toJson(AdminUtils.dayOrMonthDataFactory(dateType, dateList, list)));
            } else {
               // 年视图
               Map<String, Object> map = AdminUtils.yearsDataFactory(list);
               if (objectDate == null) {
                  objectDate = map.get("date");
         if (channelList != null && channelList.size() > 0) {
            for (Integer state : channelList) {
               List<Object> list = getAuditData(dateList, dateType, beginDate, endDate, state);
               String name = "";
               if (state == 1) {
                  name = "通过";
               } else if (state == 2) {
                  name = "驳回";
               }
               innerList.put("data", gson.toJson(map.get("value")));
               JSONObject innerList = new JSONObject();
               innerList.put("name", name);
               innerList.put("data", gson.toJson(list));
               line_list.add(innerList);
            }
         } else {
            List<Object> list = getAuditData(dateList, dateType, beginDate, endDate, null);
            JSONObject innerList = new JSONObject();
            innerList.put("name", "全部");
            innerList.put("data", gson.toJson(list));
            line_list.add(innerList);
         }
         JSONObject data = new JSONObject();
         if (objectDate != null) {
            data.put("xAxis_list", gson.toJson(objectDate));
         } else {
            data.put("xAxis_list", gson.toJson(dateList));
         }
         data.put("line_list", line_list);
         data.put("xAxis_list", gson.toJson(dateList));
         JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
      } catch (Exception e) {
         JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作异常"));
         JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("系统异常"));
         e.printStackTrace();
      }
   }
   private List<Object> getAuditData(List<String> dateList, Integer dateType, Date beginDate, Date endDate,
         Integer state) throws Exception{
      List<Object> list = new ArrayList<>();
      List<CountUserInfo> listHistory = extractAuditRecordService.getAuditCount(beginDate, endDate, state);
      for (String date: dateList) {
         int value = 0;
         if (listHistory != null) {
            for (CountUserInfo history: listHistory) {
               if (dateType == 1) {
                  String gernalTime = TimeUtil.getGernalTime(history.getDay().getTime());
                  if (gernalTime.equalsIgnoreCase(date)) {
                     value += history.getNum();
                     continue;
                  }
               } else if (dateType == 2){
                  String gernalTime = TimeUtil.getMonthOnlyMM(history.getDay());
                  if(gernalTime.startsWith("0")) {
                     gernalTime = gernalTime.substring(1, 2);
                  }
                  if (gernalTime.equalsIgnoreCase(date)) {
                     value +=  history.getNum();
                     continue;
                  }
               } else if (dateType == 3) {
                  String gernalTime = TimeUtil.getYearOnlyYYYY(history.getDay());
                  if (gernalTime.equalsIgnoreCase(date)) {
                     value +=  history.getNum();
                     continue;
                  }
               }
            }
         }
         list.add(value + "");
      }
      return list;
   }
   /**
@@ -888,66 +995,90 @@
   @RequestMapping(value = "getExtractApplyMoney")
   public void getExtractApplyMoney(String callback, Integer dateType, String year, String startTime, String endTime,
         PrintWriter out) {
      String validateMsg = AdminUtils.validateParams(dateType, startTime, endTime);
      if (validateMsg != null) {
         JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(validateMsg));
         return;
      }
      if (dateType == 1 && year != null) {
         year = null; // 设置为空
      } else if (dateType == 2) {
         if (startTime != null)
            startTime = null;
         if (endTime != null)
            endTime = null;
      } else if (dateType == 3) {
         if (year != null)
            year = null;
         if (startTime != null)
            startTime = null;
         if (endTime != null)
            endTime = null;
      }
      try {
         Object objectDate = null;
         List<String> dateList = AdminUtils.getDateList(dateType, startTime, endTime, year);
         Gson gson = new Gson();
         JSONObject innerList = new JSONObject();
         innerList.put("name", "总计");
         List<ChartTDO> list = extractAuditRecordService.countExtractApplyMoney(null, dateType, year,
               startTime, endTime);
         if (dateType != 3) {
            innerList.put("data", gson.toJson(AdminUtils.dayOrMonthDataFactory(dateType, dateList, list)));
         } else {
            // 年视图
            Map<String, Object> map = AdminUtils.yearsDataFactory(list);
            if (objectDate == null) {
               objectDate = map.get("date");
            }
            innerList.put("data", gson.toJson(map.get("value")));
         String validateMsg = AdminUtils.validateParams(dateType, startTime, endTime);
         if (validateMsg != null) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(validateMsg));
            return;
         }
         if (dateType != 1 && (!StringUtil.isNullOrEmpty(startTime) || !StringUtil.isNullOrEmpty(endTime))) {
            startTime = null;
            endTime = null;
         }
         Date beginDate = null;
         Date endDate = null;
         if (dateType == 1) {
            beginDate = TimeUtil.parse(startTime);
            endDate = TimeUtil.parse(endTime);
         } else if (dateType == 2) {
            Calendar calendar=Calendar.getInstance();
            int currentYear = calendar.get(Calendar.YEAR);
            if (!StringUtil.isNullOrEmpty(year)) {
               currentYear = Integer.parseInt(year);
            }
            calendar.clear();
             calendar.set(Calendar.YEAR, currentYear);
             beginDate =calendar.getTime();
            calendar.clear();
            calendar.set(Calendar.YEAR, currentYear);
            calendar.roll(Calendar.DAY_OF_YEAR, -1);
            endDate=calendar.getTime();
         } else if (dateType == 3) {
            beginDate = TimeUtil.parse("2018-01-01");
            endDate = new Date();
         }
         Gson gson = new Gson();
         List<String> dateList = AdminUtils.getDateList(dateType, startTime, endTime, year);
         List<String> list = new ArrayList<>();
         List<CountUserInfo> listHistory = extractAuditRecordService.getApplyMoney(beginDate, endDate);
         for (String date: dateList) {
            BigDecimal money = new BigDecimal("0");
            if (listHistory == null) {
               list.add(money.toString());
               continue;
            }
            for (CountUserInfo history: listHistory) {
               if (dateType == 1) {
                  String gernalTime = TimeUtil.getGernalTime(history.getDay().getTime());
                  if (gernalTime.equalsIgnoreCase(date)) {
                     money = MoneyBigDecimalUtil.add(money, history.getMoney());
                     continue;
                  }
               } else if (dateType == 2){
                  String gernalTime = TimeUtil.getMonthOnlyMM(history.getDay());
                  if(gernalTime.startsWith("0")) {
                     gernalTime = gernalTime.substring(1, 2);
                  }
                  if (gernalTime.equalsIgnoreCase(date)) {
                     money = MoneyBigDecimalUtil.add(money, history.getMoney());
                     continue;
                  }
               } else if (dateType == 3) {
                  String gernalTime = TimeUtil.getYearOnlyYYYY(history.getDay());
                  if (gernalTime.equalsIgnoreCase(date)) {
                     money = MoneyBigDecimalUtil.add(money, history.getMoney());
                     continue;
                  }
               }
            }
            list.add(money.toString());
         }
         JSONObject innerList = new JSONObject();
         innerList.put("name", "金额");
         innerList.put("data", gson.toJson(list));
         JSONArray line_list = new JSONArray();
         line_list.add(innerList);
         JSONObject data = new JSONObject();
         if (objectDate != null) {
            data.put("xAxis_list", gson.toJson(objectDate));
         } else {
            data.put("xAxis_list", gson.toJson(dateList));
         }
         data.put("xAxis_list", gson.toJson(dateList));
         data.put("line_list", line_list);
         JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
      } catch (Exception e) {
@@ -977,74 +1108,107 @@
   @RequestMapping(value = "getExtractApplyNumber")
   public void getExtractApplyNumber(String callback, Integer state, Integer dateType, String year, String startTime,
         String endTime, PrintWriter out) {
      String validateMsg = AdminUtils.validateParams(dateType, startTime, endTime);
      if (validateMsg != null) {
         JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(validateMsg));
         return;
      }
      if (dateType == 1 && year != null) {
         year = null; // 设置为空
      } else if (dateType == 2) {
         if (startTime != null)
            startTime = null;
         if (endTime != null)
            endTime = null;
      } else if (dateType == 3) {
         if (year != null)
            year = null;
         if (startTime != null)
            startTime = null;
         if (endTime != null)
            endTime = null;
      }
      try {
         Object objectDate = null;
         String validateMsg = AdminUtils.validateParams(dateType, startTime, endTime);
         if (validateMsg != null) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(validateMsg));
            return;
         }
         if (dateType != 1 && (!StringUtil.isNullOrEmpty(startTime) || !StringUtil.isNullOrEmpty(endTime))) {
            startTime = null;
            endTime = null;
         }
         Date beginDate = null;
         Date endDate = null;
         if (dateType == 1) {
            beginDate = TimeUtil.parse(startTime);
            endDate = TimeUtil.parse(endTime);
         } else if (dateType == 2) {
            Calendar calendar=Calendar.getInstance();
            int currentYear = calendar.get(Calendar.YEAR);
            if (!StringUtil.isNullOrEmpty(year)) {
               currentYear = Integer.parseInt(year);
            }
            calendar.clear();
             calendar.set(Calendar.YEAR, currentYear);
             beginDate =calendar.getTime();
            calendar.clear();
            calendar.set(Calendar.YEAR, currentYear);
            calendar.roll(Calendar.DAY_OF_YEAR, -1);
            endDate=calendar.getTime();
         } else if (dateType == 3) {
            beginDate = TimeUtil.parse("2018-01-01");
            endDate = new Date();
         }
         Gson gson = new Gson();
         List<String> dateList = AdminUtils.getDateList(dateType, startTime, endTime, year);
         JSONObject innerList = new JSONObject();
         innerList.put("name", "总计");
         List<ChartTDO> list = extractAuditRecordService.countExtractApplyNumber(null, dateType, year,
               startTime, endTime);
         if (dateType != 3) {
            innerList.put("data", gson.toJson(AdminUtils.dayOrMonthDataFactory(dateType, dateList, list)));
         } else {
            // 年视图
            Map<String, Object> map = AdminUtils.yearsDataFactory(list);
            if (objectDate == null) {
               objectDate = map.get("date");
         List<Object> list = new ArrayList<>();
         List<CountUserInfo> listHistory = extractAuditRecordService.geApplyNumber(beginDate, endDate);
         for (String date: dateList) {
            int value = 0;
            if (listHistory == null) {
               list.add(value + "");
               continue;
            }
            innerList.put("data", gson.toJson(map.get("value")));
            for (CountUserInfo history: listHistory) {
               if (dateType == 1) {
                  String gernalTime = TimeUtil.getGernalTime(history.getDay().getTime());
                  if (gernalTime.equalsIgnoreCase(date)) {
                     value += history.getNum();
                     continue;
                  }
               } else if (dateType == 2){
                  String gernalTime = TimeUtil.getMonthOnlyMM(history.getDay());
                  if(gernalTime.startsWith("0")) {
                     gernalTime = gernalTime.substring(1, 2);
                  }
                  if (gernalTime.equalsIgnoreCase(date)) {
                     value += history.getNum();
                     continue;
                  }
               } else if (dateType == 3) {
                  String gernalTime = TimeUtil.getYearOnlyYYYY(history.getDay());
                  if (gernalTime.equalsIgnoreCase(date)) {
                     value += history.getNum();
                     continue;
                  }
               }
            }
            list.add(value + "");
         }
         JSONObject innerList = new JSONObject();
         innerList.put("name", "数量");
         innerList.put("data", gson.toJson(list));
         JSONArray line_list = new JSONArray();
         line_list.add(innerList);
         JSONObject data = new JSONObject();
         if (objectDate != null) {
            data.put("xAxis_list", gson.toJson(objectDate));
         } else {
            data.put("xAxis_list", gson.toJson(dateList));
         }
         data.put("xAxis_list", gson.toJson(dateList));
         data.put("line_list", line_list);
         JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
      } catch (Exception e) {
         JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作异常"));
         JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("系统异常"));
         e.printStackTrace();
      }
   }
   /**
    * 下载提现红包Openid
    *
    * @param callback
    * @param response
    * @param out
    */
   @RequestMapping(value = "downAutoExtractTxt")
   public void downAutoExtractTxt(String callback, HttpServletResponse response, PrintWriter out) {
      try {
@@ -1053,30 +1217,41 @@
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("暂无用户满足自动提现条件"));
            return;
         }
         String filepath = "自动提现OpenId "+ java.lang.System.currentTimeMillis() + ".txt";
         String filepath = "自动提现OpenId " + java.lang.System.currentTimeMillis() + ".txt";
         response.reset();
          response.setContentType("application/octet-stream");
          String fileName= URLDecoder.decode(filepath,"utf-8");
          response.addHeader("Content-Disposition","attachment;"+ "filename=\"" +URLEncoder.encode(fileName, "utf-8") + "\"");
         response.setContentType("application/octet-stream");
         String fileName = URLDecoder.decode(filepath, "utf-8");
         response.addHeader("Content-Disposition",
               "attachment;" + "filename=\"" + URLEncoder.encode(fileName, "utf-8") + "\"");
         StringBuilder sb = new StringBuilder();
         for(String t:list){
            sb.append(t+"\r\n");
         for (String t : list) {
            sb.append(t + "\r\n");
         }
          OutputStream os = response.getOutputStream();
            byte[] byt = sb.toString().getBytes();
            os.write(byt);
            os.flush();
          os.close();
         String opid_str = sb.toString();
         if (!StringUtil.isNullOrEmpty(opid_str) && opid_str.endsWith("\r\n")) {
            opid_str = opid_str.substring(0, opid_str.length() - 2);
         }
         OutputStream os = response.getOutputStream();
         byte[] byt = opid_str.getBytes();
         os.write(byt);
         os.flush();
         os.close();
      } catch (Exception e) {
         JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作异常"));
         e.printStackTrace();
      }
   }
   /**
    * 上传提现红包Excel
    *
    * @param file
    * @param out
    */
   @RequestMapping(value = "uploadExcel", method = RequestMethod.POST)
   public void uploadExcel(@RequestParam("file") CommonsMultipartFile file, PrintWriter out) {
      if (file == null) {
@@ -1085,7 +1260,7 @@
      }
      try {
         List<RedPackRecord> list = CsvUtil.getCsvData(file, RedPackRecord.class);
         List<RedPackRecord> list = WXRedPackUtil.readCsv(file.getInputStream());
         extractService.updateManualExtractRecord(list);
         out.print(JsonUtil.loadTrueResult("上传成功"));
      } catch (ExtractException e) {
@@ -1095,6 +1270,64 @@
         out.print(JsonUtil.loadFalseResult("上传失败"));
      }
   }
   public static String getValue(String[] item,int index){
        if(item.length > index){
            String value = item[index];
            return value;
        }
        return "";
    }
   /**
    * 预览红包发生人
    *
    * @param callback
    * @param pageIndex
    * @param out
    */
   @RequestMapping(value = "preAutoUser")
   public void preAutoUser(String callback, Integer pageIndex, PrintWriter out) {
      try {
         List<UserInfo> list = extractService.preAutoUser();
         if (list == null || list.isEmpty()) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("暂无用户满足自动提现条件"));
            return;
         }
         if (pageIndex == null || pageIndex < 1) {
            pageIndex = 1;
         }
         Integer pageSize = 100;
         if (pageSize == null || pageSize < 1) {
            pageSize = Constant.PAGE_SIZE;
         }
         int count = list.size();
         int totalPage = count % pageSize == 0 ? count / pageSize : count / pageSize + 1;
         PageEntity pe = new PageEntity(pageIndex, pageSize, count, totalPage);
         List<UserInfo> listResult = null;
         if (pageIndex < totalPage) {
            int start = (pageIndex - 1) * pageSize;
            listResult = list.subList(start, start + pageSize);
         } else if (pageIndex == totalPage) {
            listResult = list.subList((pageIndex - 1) * pageSize, list.size());
         } else {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("没有更多了"));
            return;
         }
         JSONObject data = new JSONObject();
         data.put("pe", pe);
         data.put("result_list", listResult);
         JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
      } catch (Exception e) {
         JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作异常"));
         e.printStackTrace();
      }
   }
}