admin
2019-01-11 20f1758957a19bb5fec47fcc1c83818ee268676b
fanli/src/main/java/com/yeshi/fanli/controller/admin/OrderAdminController.java
@@ -17,6 +17,7 @@
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.yeshi.fanli.controller.admin.utils.AdminUtils;
import com.yeshi.fanli.entity.admin.OrderAdmin;
import com.yeshi.fanli.service.inter.count.HongBaoV2CountService;
import com.yeshi.fanli.service.inter.hongbao.HongBaoService;
@@ -199,7 +200,7 @@
      }
      try {
         JSONObject data = countHongBao(channelArray, dateType, state, year, startTime,  endTime, 1);
         JSONObject data = countHistoryHongBao(channelArray, dateType, state, year, startTime,  endTime, 1);
         JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
      } catch (Exception e) {
         JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("系统异常"));
@@ -222,14 +223,15 @@
   public void getHongBaoMoney(String callback,String channelArray, Integer dateType, Integer state,
         String year, String startTime, String endTime, PrintWriter out) {
      String validateMsg = validateParams(dateType, startTime, endTime);
      String validateMsg = AdminUtils.validateParams(dateType, startTime, endTime);
      if (validateMsg != null) {
         JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(validateMsg));
         return;
      }
      try {
         JSONObject data = countHongBao( channelArray, dateType, state, year, startTime, endTime, 2);
         JSONObject data = countHistoryHongBao(channelArray, dateType, state, year, startTime,  endTime, 1);
         JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
      } catch (Exception e) {
         JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("系统异常"));
@@ -237,6 +239,10 @@
      }
   }
   
   
@@ -251,7 +257,7 @@
    * @return
    * @throws Exception
    */
   public JSONObject countHongBao(String channelArray, Integer dateType, Integer state, String year, String startTime,
   public JSONObject countHistoryHongBao(String channelArray, Integer dateType, Integer state, String year, String startTime,
         String endTime, int countType) throws Exception {
      if (dateType != 1 && (!StringUtil.isNullOrEmpty(startTime) || !StringUtil.isNullOrEmpty(endTime))) {
@@ -259,6 +265,7 @@
         endTime = null;
      }
      List<String> channelList = null;
      if (channelArray != null && channelArray.trim().length() > 0) {
         Gson gson = new Gson();
@@ -270,34 +277,73 @@
         channelList.add("all");
      }
      JSONArray array = new JSONArray();
      for (String channel : channelList) {
         JSONObject channelData = new JSONObject();
      if (dateType == 1 && year != null) {
         year = null; // 设置为空
      } else if (dateType == 2) {
         if (startTime != null)
            startTime = null;
         
         List<Map<String, Object>> resultList = 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;
      }
      Gson gson = new Gson();
      Object objectDate = null;
      List<String> dateList = AdminUtils.getDateList(dateType, startTime, endTime, year);
      JSONArray line_list = new JSONArray();
      for (String channel : channelList) {
         List<Map<String, Object>> list = null;
         if (countType == 1 ) {
            resultList = hongBaoV2CountService.countHongBaoNum(channel, dateType, state, year,
            list = hongBaoV2CountService.countHongBaoNum(channel, dateType, state, year,
                  startTime, endTime);
         } else if (countType == 2) {
            resultList = hongBaoV2CountService.countHongBaoMoney(channel, dateType, state, year,
            list = hongBaoV2CountService.countHongBaoMoney(channel, dateType, state, year,
                  startTime, endTime);
         }
         if (resultList == null) {
            resultList = new ArrayList<Map<String, Object>>();
         }
         if ("all".equalsIgnoreCase(channel)) {
            channel = "总计";
         }
         channelData.put("name", channel);
         channelData.put("data_list", resultList);
         array.add(channelData);
         JSONObject innerList = new JSONObject();
         innerList.put("name", channel);
         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();
      data.put("result_list", array);
      if (objectDate != null) {
         data.put("xAxis_list", gson.toJson(objectDate));
      } else {
         data.put("xAxis_list", gson.toJson(dateList));
      }
      data.put("line_list", line_list);
      
      return data;
   }