yujian
2019-01-14 b42e88afc77b0d40ea8bbad87df6cc22d03414e1
fanli/src/main/java/com/yeshi/fanli/controller/admin/UserInfoAdminController.java
@@ -1188,8 +1188,8 @@
    * @param endTime   2018-12-01 
    * @param out
    */
   @RequestMapping(value = "getSameDayUserByChannel")
   public void getSameDayUserByChannel(String callback, String channelArray, Integer dateType,
   @RequestMapping(value = "getNewUserCharts")
   public void getNewUserCharts(String callback, String channelArray, Integer dateType,
       String year, String startTime, String endTime, PrintWriter out) {
      
      
@@ -1246,7 +1246,7 @@
         JSONArray line_list = new JSONArray();
         for (String channel : channelList) {
            
            List<Map<String, Object>> list = userActiveLogService.countSameDayByChannel(channel,
            List<Map<String, Object>> list = userInfoCountService.countNewUserByDate(channel,
                  dateType, year, startTime, endTime);
            
            if ("all".equalsIgnoreCase(channel)) {
@@ -1257,7 +1257,7 @@
            innerList.put("name", channel);
            if (dateType != 3) {
               innerList.put("data", gson.toJson(AdminUtils.dayOrMonthDataFactory(dateList, list)));
               innerList.put("data", gson.toJson(AdminUtils.dayOrMonthDataFactory(dateType, dateList, list)));
            } else {
               // 年视图
               Map<String, Object> map = AdminUtils.yearsDataFactory(list);
@@ -1299,8 +1299,8 @@
    * @param endTime   2018-12-01 
    * @param out
    */
   @RequestMapping(value = "getBuyProportion")
   public void getBuyProportion(String callback, String channelArray, Integer dateType,
   @RequestMapping(value = "getTodayBuyRate")
   public void getTodayBuyRate(String callback, String channelArray, Integer dateType,
       String year, String startTime, String endTime, Integer orderNum, PrintWriter out) {
      
      if (dateType != 1 && (!StringUtil.isNullOrEmpty(startTime) || !StringUtil.isNullOrEmpty(endTime))) {
@@ -1322,7 +1322,9 @@
         for (String channel: list) {
            JSONObject channelData = new JSONObject();
            List<Object> resultList = userActiveLogService.getBuyProportion(channel, dateType, year, startTime, endTime, orderNum);
            List<Object> resultList = null;
                  //userActiveLogService.getBuyProportion(channel, dateType, year, startTime, endTime, orderNum);
            if (resultList == null) {
               resultList = new ArrayList<Object>();
            }
@@ -1383,8 +1385,8 @@
            JSONObject channelData = new JSONObject();
            
            List<Map<String, Object>> resultList = userActiveLogService.countOneWeekUserInfo(channel,
                  startTime, endTime, orderNum);
            List<Map<String, Object>> resultList = null;
                  //userActiveLogService.countOneWeekUserInfo(channel,    startTime, endTime, orderNum);
            if (resultList == null) {
               resultList = new ArrayList<Map<String, Object>>();
@@ -1434,95 +1436,6 @@
         JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("统计异常"));
      }
      
   }
   /**
    * 统计历史新增用户
    * @param callback
    * @param dateType 类型  1日  2月  3年
    * @param year 2018
    * @param startTime 2018-12-01
    * @param endTime   2018-12-01
    * @param out
    */
   @RequestMapping(value = "getNewUserCharts")
   public void getNewUserCharts(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 && (!StringUtil.isNullOrEmpty(startTime) || !StringUtil.isNullOrEmpty(endTime))) {
         startTime = null;
         endTime = null;
      }
      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 {
         Gson gson = new Gson();
         Object objectDate = null;
         List<String> dateList = AdminUtils.getDateList(dateType, startTime, endTime, year);
         JSONArray line_list = new JSONArray();
         List<Map<String, Object>> list = userInfoCountService
               .countNewUserByDate(dateType, year, startTime, endTime);
         JSONObject innerList = new JSONObject();
         innerList.put("name", "总计");
         if (dateType != 3) {
            innerList.put("data", gson.toJson(AdminUtils.dayOrMonthDataFactory(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")));
         }
         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);
         JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
      } catch (Exception e) {
         JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作异常"));
         e.printStackTrace();
      }
   }
   
}