yujian
2019-01-08 85b08b045c79180a81abd43be0ac7fd2ae50cd46
fanli/src/main/java/com/yeshi/fanli/controller/admin/OrderAdminController.java
@@ -20,6 +20,7 @@
import com.yeshi.fanli.entity.admin.OrderAdmin;
import com.yeshi.fanli.service.inter.count.HongBaoV2CountService;
import com.yeshi.fanli.service.inter.hongbao.HongBaoService;
import com.yeshi.fanli.service.inter.order.CommonOrderCountService;
import com.yeshi.fanli.service.inter.order.OrderService;
import com.yeshi.fanli.tag.PageEntity;
import com.yeshi.fanli.util.Constant;
@@ -37,6 +38,9 @@
   @Resource
   private HongBaoV2CountService hongBaoV2CountService;
   @Resource
   private CommonOrderCountService commonOrderCountService;
   @RequestMapping(value = "getOrderList", method = RequestMethod.POST)
   public void getOrderList(int pageIndex, String key, PrintWriter out) {
@@ -129,7 +133,7 @@
               resultList = new ArrayList<Object>();
            }
            channelData.put("name", channel);
            channelData.put("infos", resultList);
            channelData.put("data_list", resultList);
            array.add(channelData);
         }
@@ -288,7 +292,7 @@
            channel = "总计";
         }
         channelData.put("name", channel);
         channelData.put("infos", resultList);
         channelData.put("data_list", resultList);
         array.add(channelData);
      }
@@ -298,4 +302,221 @@
      return data;
   }
   /**
    * 分类型订单数与比例
    * @param callback
    * @param dateType 日 -1 月-2 年-3
    * @param type     返利订单-1  分享订单-2  邀请订单-3
    * @param year
    * @param startTime
    * @param endTime
    * @param out
    */
   @RequestMapping(value = "getTypeRate")
   public void getTypeRate(String callback, Integer dateType, Integer type, String year,
         String startTime, String endTime, PrintWriter out) {
      if (StringUtil.isNullOrEmpty(startTime) || StringUtil.isNullOrEmpty(endTime)) {
         JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("请选择正确时间区间"));
         return;
      }
      if (type == null || dateType ==null) {
         JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("视图类型、订单类型不能为空"));
         return;
      }
      try {
         List<Map<String, Object>> resultList = hongBaoV2CountService.getProportionByType(dateType,
               type, year, startTime, endTime);
         if (resultList == null) {
            resultList = new ArrayList<Map<String, Object>>();
         }
         JSONObject innerList = new JSONObject();
         if (type == 1) {
            innerList.put("name", "返利订单");
         } else if (type == 2) {
            innerList.put("name", "分享订单");
         } else if (type == 3) {
            innerList.put("name", "邀请订单");
         }
         innerList.put("data_list", resultList);
         JSONArray outList = new JSONArray();
         outList.add(innerList);
         JSONObject data = new JSONObject();
         data.put("result_list", outList);
         JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
      } catch (Exception e) {
         JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作异常"));
         e.printStackTrace();
      }
   }
   /**
    * 订单跟踪准确率(返利券用户订单/淘宝联盟订单)
    * @param callback
    * @param dateType
    * @param year
    * @param startTime
    * @param endTime
    * @param out
    */
   @RequestMapping(value = "getTrackAccuracyRate")
   public void getTrackAccuracyRate(String callback, Integer dateType, String year,
         String startTime, String endTime, PrintWriter out) {
      if (StringUtil.isNullOrEmpty(startTime) || StringUtil.isNullOrEmpty(endTime)) {
         JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("请选择正确时间区间"));
         return;
      }
      try {
         List<Map<String, Object>> resultList = commonOrderCountService.getTrackAccuracyRate(dateType,
                year, startTime, endTime);
         if (resultList == null) {
            resultList = new ArrayList<Map<String, Object>>();
         }
         JSONObject innerList = new JSONObject();
         innerList.put("name", "准确率");
         innerList.put("data_list", resultList);
         JSONArray outList = new JSONArray();
         outList.add(innerList);
         JSONObject data = new JSONObject();
         data.put("result_list", outList);
         JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
      } catch (Exception e) {
         JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作异常"));
         e.printStackTrace();
      }
   }
   /**
    * 当前未收货订单数
    * @param callback
    * @param type 订单状态-暂未使用
    * @param out
    */
   @RequestMapping(value = "getHistoryUnreceived")
   public void getHistoryUnreceived(String callback, Integer type, PrintWriter out) {
      try {
         Long total = commonOrderCountService.countByState(1);
         if (total == null) {
            total = 0L;
         }
         JSONObject data = new JSONObject();
         data.put("total", total);
         JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
      } catch (Exception e) {
         JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作异常"));
         e.printStackTrace();
      }
   }
   /**
    * 维权订单数
    * @param callback
    * @param dateType
    * @param year
    * @param startTime
    * @param endTime
    * @param out
    */
   @RequestMapping(value = "getWeiQaunOrderNumber")
   public void getWeiQaunOrderNumber(String callback, Integer dateType, String year,
         String startTime, String endTime, PrintWriter out) {
      if (StringUtil.isNullOrEmpty(startTime) || StringUtil.isNullOrEmpty(endTime)) {
         JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("请选择正确时间区间"));
         return;
      }
      try {
         List<Map<String, Object>> resultList = commonOrderCountService.countWeiQaunOrderNumber(dateType,
                year, startTime, endTime);
         if (resultList == null) {
            resultList = new ArrayList<Map<String, Object>>();
         }
         JSONObject innerList = new JSONObject();
         innerList.put("name", "数量");
         innerList.put("data_list", resultList);
         JSONArray outList = new JSONArray();
         outList.add(innerList);
         JSONObject data = new JSONObject();
         data.put("result_list", outList);
         JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
      } catch (Exception e) {
         JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作异常"));
         e.printStackTrace();
      }
   }
   /**
    * 维权订单金额
    * @param callback
    * @param dateType
    * @param year
    * @param startTime
    * @param endTime
    * @param out
    */
   @RequestMapping(value = "getWeiQaunOrderMoney")
   public void getWeiQaunOrderMoney(String callback, Integer dateType, String year,
         String startTime, String endTime, PrintWriter out) {
      if (StringUtil.isNullOrEmpty(startTime) || StringUtil.isNullOrEmpty(endTime)) {
         JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("请选择正确时间区间"));
         return;
      }
      try {
         List<Map<String, Object>> resultList = commonOrderCountService.countWeiQaunOrderMoney(dateType,
                year, startTime, endTime);
         if (resultList == null) {
            resultList = new ArrayList<Map<String, Object>>();
         }
         JSONObject innerList = new JSONObject();
         innerList.put("name", "金额");
         innerList.put("data_list", resultList);
         JSONArray outList = new JSONArray();
         outList.add(innerList);
         JSONObject data = new JSONObject();
         data.put("result_list", outList);
         JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
      } catch (Exception e) {
         JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作异常"));
         e.printStackTrace();
      }
   }
}