admin
2020-03-20 c3a5e164cbabbfc5f66e1356cb0de657ce3f58b9
fanli/src/main/java/com/yeshi/fanli/controller/admin/OrderAdminController.java
@@ -20,12 +20,16 @@
import com.google.gson.reflect.TypeToken;
import com.yeshi.fanli.controller.admin.utils.AdminUtils;
import com.yeshi.fanli.dto.ChartTDO;
import com.yeshi.fanli.dto.common.CategoryInfoDTO;
import com.yeshi.fanli.dto.common.GoodsOtherInfoDTO;
import com.yeshi.fanli.entity.bus.user.HongBaoV2;
import com.yeshi.fanli.entity.goods.CommonGoods;
import com.yeshi.fanli.entity.money.UserMoneyDebt;
import com.yeshi.fanli.entity.money.UserMoneyDebt.UserMoneyDebtTypeEnum;
import com.yeshi.fanli.entity.money.UserMoneyDetail;
import com.yeshi.fanli.entity.money.UserMoneyDetail.UserMoneyDetailTypeEnum;
import com.yeshi.fanli.entity.order.CommonOrder;
import com.yeshi.fanli.entity.order.CommonOrderGoods;
import com.yeshi.fanli.entity.order.HongBaoOrder;
import com.yeshi.fanli.entity.order.UserOrderWeiQuanRecord;
import com.yeshi.fanli.entity.system.ConfigKeyEnum;
@@ -35,6 +39,7 @@
import com.yeshi.fanli.service.inter.config.ConfigService;
import com.yeshi.fanli.service.inter.count.HongBaoV2CountService;
import com.yeshi.fanli.service.inter.count.TaoBaoOrderCountService;
import com.yeshi.fanli.service.inter.goods.CommonGoodsService;
import com.yeshi.fanli.service.inter.money.UserMoneyDebtService;
import com.yeshi.fanli.service.inter.money.UserMoneyDetailService;
import com.yeshi.fanli.service.inter.money.tb.TaoBaoWeiQuanDrawBackService;
@@ -104,6 +109,9 @@
   @Resource
   private UserOrderWeiQuanRecordService userOrderWeiQuanRecordService;
   @Resource
   private CommonGoodsService commonGoodsService;
   /**
    * 统计历史订单-淘宝订单
@@ -219,8 +227,27 @@
         long count = commonOrderService.countQuery(keyType, key, state, type, orderState, startTime, endTime,
               sourceType, listShopId, listGoodsId, minTime, money, payment);
         // 查询是否维权
         for (CommonOrderVO order : list) {
            CommonOrderGoods goods = order.getCommonOrderGoods();
            if (goods != null) {
               CommonGoods commonGoods = commonGoodsService.getCommonGoodsByGoodsIdAndGoodsType(Long.parseLong(goods.getGoodsId()),
                     goods.getGoodsType());
               if (commonGoods != null) {
                  String categoryInfo = commonGoods.getCategoryInfo();
                  if (!StringUtil.isNullOrEmpty(categoryInfo)) {
                     JSONObject json = JSONObject.fromObject(categoryInfo);
                     CategoryInfoDTO otherDTO = (CategoryInfoDTO) JSONObject.toBean(json, CategoryInfoDTO.class);
                     if (otherDTO != null) {
                        goods.setCategory1(otherDTO.getCid1Name());
                        goods.setCategory2(otherDTO.getCid2Name());
                        goods.setCategory3(otherDTO.getCid3Name());
                     }
                  }
               }
            }
            if (order.getUserId() == null)
               continue;
@@ -808,5 +835,88 @@
         JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("更新失败"));
      }
   }
   /**
    * 订单跟踪准确率(板栗快省用户订单/淘宝联盟订单)
    *
    * @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,
         int sourceType, PrintWriter out) {
      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<ChartTDO> list = commonOrderCountService.getTrackAccuracyRate(dateType, year, startTime, endTime,
               sourceType);
         JSONObject innerList = new JSONObject();
         innerList.put("name", "总计");
         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")));
         }
         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();
      }
   }
}