admin
2020-05-20 98b1a0affd69bbe63223c21fdd2c404e8bedfccb
fanli/src/main/java/com/yeshi/fanli/controller/wxmp/v1/OrderController.java
@@ -50,10 +50,10 @@
   @Resource
   private UserCustomSettingsService userCustomSettingsService;
   @Resource
   private HongBaoV2CountService hongBaoV2CountService;
   @Resource
   private CommonOrderService commonOrderService;
@@ -68,7 +68,7 @@
   @Resource
   private RedisManager redisManager;
   @Resource
   private ESOrderService esOrderService;
@@ -98,7 +98,7 @@
      List<Integer> listSource = new ArrayList<>();
      listSource.add(Constant.SOURCE_TYPE_JD);
      listSource.add(Constant.SOURCE_TYPE_PDD);
      // 验证是否显示模块
      if (settings != null && settings.getNoBonusCount() != null) {
         if (settings.getNoBonusCount() == 1) {
@@ -121,10 +121,7 @@
      data.put("inviteMoney", inviteMoney.setScale(2, BigDecimal.ROUND_DOWN).toString());
      out.print(JsonUtil.loadTrueResult(data));
   }
   /**
    * 订单列表
    * 
@@ -147,28 +144,28 @@
    *            时间段:1-最近三天 2-最近七天 3最近半月 4本月 5近三月 6近半年
    * @param dateType
    *            1-今日 2-昨天 3-本月 4-上个月 |
    * @param source
    *          页面来源:welfareCore-福利中心、bonus -奖金统计(我的界面)
    * @param source
    *            页面来源:welfareCore-福利中心、bonus -奖金统计(我的界面)
    * @param out
    */
   @RequestMapping(value = "getOrderList", method = RequestMethod.POST)
   public void getOrderList(AcceptData acceptData, Integer page, Long uid, Integer state, String type,
         Integer orderState, String orderNo,   String startTime, String endTime, Integer slotTime,
         Integer dateType, Integer goodsType, String source, PrintWriter out) {
   public void getOrderList(AcceptData acceptData, Integer page, Long uid, Integer state, String type,
         Integer orderState, String orderNo, String startTime, String endTime, Integer slotTime, Integer dateType,
         Integer goodsType, String source, PrintWriter out) {
      if (uid == null) {
         out.print(JsonUtil.loadFalseResult(1, "用户未登录"));
         return;
      }
      if (page == null || page < 1)
         page = 1;
      // 搜索内容、订单号
      if (!StringUtil.isNullOrEmpty(orderNo)) {
         searchOrder(orderNo, page, uid, out);
         return;
      }
      // 转换状态
      if (state != null) {
         if (state == 0) {
@@ -189,13 +186,13 @@
      Integer orderType = null;
      if (StringUtil.isNullOrEmpty(type)) {
         orderType = null;
      } else if (!"0".equalsIgnoreCase(type)){
         orderType = Integer.parseInt(type);
      }
      } else if (!"0".equalsIgnoreCase(type)) {
         orderType = Integer.parseInt(type);
      }
      if (goodsType != null && goodsType == 0)
         goodsType = null;
      // 筛选时间
      if (slotTime != null) {
         try {
@@ -229,7 +226,7 @@
            e.printStackTrace();
         }
      }
      if (endTime != null && endTime.trim().length() > 0) {
         endTime += " 23:59:59";
      }
@@ -241,9 +238,7 @@
         listSource.add(Constant.SOURCE_TYPE_JD);
         listSource.add(Constant.SOURCE_TYPE_PDD);
      }
      try {
         // 筛选结果顶部统计
         String validMoney = "0.00";
@@ -251,14 +246,14 @@
         if (page == 1) {
            BigDecimal predictMoney = hongBaoV2CountService.getRewardMoneyByToSearch(uid, dateType, orderType, 1,
                  orderNo, state, startTime, endTime, listSource);
            if (predictMoney != null)
            if (predictMoney != null)
               validMoney = predictMoney.setScale(2, BigDecimal.ROUND_DOWN).toString();
            BigDecimal postSaleMoney = hongBaoV2CountService.getRewardMoneyByToSearch(uid, dateType, orderType, 2,
                  orderNo, state, startTime, endTime, listSource);
            if (postSaleMoney != null)
            if (postSaleMoney != null)
               invalidMoney = postSaleMoney.setScale(2, BigDecimal.ROUND_DOWN).toString();
            if (orderType != null && dateType != null && dateType == 4) {
               if (orderType == 1) {
                  dateType = 6; // 返利订单有效
@@ -267,22 +262,22 @@
               }
            }
         }
         // 查询列表
         List<CommonOrderVO> list = commonOrderService.getOrderByUid(acceptData, page, uid, state, orderType, orderState,
               orderNo, startTime, endTime, dateType, listSource);
         // 统计总数
         long count = commonOrderService.countGroupOrderNoByUid(uid, state, orderType, orderState, orderNo, startTime,
               endTime, dateType, listSource);
         // 判断是否需要显示订单找回提示   8秒内请求3次触发
         // 查询列表
         List<CommonOrderVO> list = commonOrderService.getOrderByUid(acceptData, page, uid, state, orderType,
               orderState, orderNo, startTime, endTime, dateType, listSource);
         // 统计总数
         long count = commonOrderService.countGroupOrderNoByUid(uid, state, orderType, orderState, orderNo,
               startTime, endTime, dateType, listSource);
         // 判断是否需要显示订单找回提示 8秒内请求3次触发
         String orderFindUrl = null;
         if (state ==null && page == 1) {
            if (redisManager.frequencyLimit("orderlist-" + acceptData.getDevice(), 8, 4)||count==0L) {
         if (state == null && page == 1) {
            if (redisManager.frequencyLimit("orderlist-" + acceptData.getDevice(), 8, 4) || count == 0L) {
               orderFindUrl = configService.get(ConfigKeyEnum.orderFindNotifyUrl.getKey());
            }
         }
         JSONObject data = new JSONObject();
         data.put("count", count);
         data.put("list", JsonUtil.getApiCommonGson().toJson(list));
@@ -294,13 +289,17 @@
      } catch (CommonOrderException e) {
         out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMsg()));
      } catch (Exception e) {
         out.print(JsonUtil.loadFalseResult(1, "查询失败"));
         if (Constant.IS_TEST) {
            e.printStackTrace(out);
         } else
            out.print(JsonUtil.loadFalseResult(1, "查询失败"));
         LogHelper.errorDetailInfo(e);
      }
   }
   /**
    * 搜索订单
    *
    * @param key
    * @param out
    */
@@ -312,16 +311,20 @@
         listSource.add(Constant.SOURCE_TYPE_JD);
         listSource.add(Constant.SOURCE_TYPE_PDD);
         List<ESOrder> listES = esOrderService.query(key, uid.toString(), listSource);
         if (listES.size() != 0) {
            list = commonOrderService.searchOrderByUid(page, Constant.PAGE_SIZE, uid, listES);
            // 2.1版本
            AcceptData acceptData = new AcceptData();
            acceptData.setPlatform("android");
            acceptData.setVersion("56");
            list = commonOrderService.searchOrderByUid(acceptData, page, Constant.PAGE_SIZE, uid, listES);
            count = commonOrderService.countSearchOrderByUid(uid, listES);
         }
         if (list == null) {
            list = new ArrayList<>();
         }
         JSONObject data = new JSONObject();
         data.put("count", count);
         data.put("list", JsonUtil.getApiCommonGson().toJson(list));
@@ -333,14 +336,12 @@
      }
   }
   /**
    * 用户订单统计
    * 
    * @param acceptData
    * @param uid
    *            用户id
    *   type 类型:0全部、1淘宝 2京东、拼多多
    *            用户id type 类型:0全部、1淘宝 2京东、拼多多
    * @param out
    */
   @RequestMapping(value = "getOrderCount", method = RequestMethod.POST)
@@ -349,7 +350,7 @@
         out.print(JsonUtil.loadFalseResult(1, "请求参数不正确"));
         return;
      }
      try {
         UserInfo user = userInfoService.selectByPKey(uid);
         if (user == null) {
@@ -365,12 +366,12 @@
         }
         JSONObject data = new JSONObject();
         data.put("userInfo", userInfo);
         List<Integer> listSource = new ArrayList<>();
         if (type == null || type == 0) {
            listSource.add(Constant.SOURCE_TYPE_JD);
            listSource.add(Constant.SOURCE_TYPE_PDD);
            OrderCountVO total = commonOrderService.getOrderCount(uid, null, listSource);
            data.put("total", total.getSelf() + total.getShared() + total.getInvite());
            data.put("self", total.getSelf());
@@ -383,7 +384,7 @@
            data.put("invite", 0);
            listSource.add(type);
         }
         // 今天
         OrderCountVO today = commonOrderService.getOrderCount(uid, 1, listSource);
         today.setTotal(today.getSelf() + today.getShared() + today.getInvite());
@@ -407,7 +408,5 @@
         e.printStackTrace();
      }
   }
}