喻健
2018-12-25 f28cb1b4e59305480ef1effee38b1dc411f775a4
fanli/src/main/java/com/yeshi/fanli/service/impl/order/CommonOrderServiceImpl.java
@@ -79,7 +79,7 @@
   }
   
   @Override
   public List<CommonOrderVO> getOrderByUid (Long page, Long uid, Integer state, Integer type,
   public List<CommonOrderVO> getOrderByUid (Integer page, Long uid, Integer state, Integer type,
         String orderNo, String startTime, String endTime) throws CommonOrderException {
      
      int pageSize = Constant.PAGE_SIZE;
@@ -99,6 +99,67 @@
      if (listGoods ==null || listGoods.size() == 0) {
         return listOrder; 
      }
      // 数据加工重新组织
      listDataFactory(listOrder, listGoods);
      return listOrder;
   }
   @Override
   public List<CommonOrderVO> listBonusOrder (Integer page, Long uid, Integer type,Integer day) throws CommonOrderException {
      int pageSize = Constant.PAGE_SIZE;
      List<CommonOrderVO> listOrder = commonOrderMapper.listBonusOrder((page - 1) * pageSize, pageSize, uid, type, day);
      // 订单信息为空
      if (listOrder == null || listOrder.size() == 0) {
         listOrder = new ArrayList<CommonOrderVO>();
         return listOrder;
      }
      // 商品信息
      List<CommonOrderVO> listGoods = commonOrderMapper.listByOrderNoAndType(listOrder);
      // 订单商品为空
      if (listGoods ==null || listGoods.size() == 0) {
         return listOrder;
      }
      // 数据加工重新组织
      listDataFactory(listOrder, listGoods);
      return listOrder;
   }
   @Override
   public Map<String, BigDecimal> countOrderByHongBaoType(Long uid, Integer day) {
      return commonOrderMapper.countOrderByHongBaoType(uid, day);
   }
   @Override
   public long countOrder(Long uid,Integer type, Integer day) {
      return commonOrderMapper.countBonusOrder(uid, type, day);
   }
   @Override
   public BigDecimal countOrderMoney(Long uid, Integer type, Integer day) {
      return commonOrderMapper.countBonusOrderMoney(uid, type, day);
   }
   @Override
   public Map<String, BigDecimal> countByUidAndOrderState(Long uid, Integer type, String startTime,String endTime) {
      return commonOrderMapper.countByUidAndOrderState(uid, type,  startTime, endTime);
   }
   @Override
   public Map<String, BigDecimal> countBonusOrderByState(Long uid,Integer type, Integer day) {
      return commonOrderMapper.countBonusOrderByState(uid, type, day);
   }
   public void listDataFactory (List<CommonOrderVO> listOrder, List<CommonOrderVO> listGoods ) {
      
      /* 组合商品信息  */
      for (CommonOrderVO commonOrder: listGoods) {
@@ -155,17 +216,6 @@
         if (settleTime != null) {
            order.setReceiveTime(format.format(settleTime));
         }
         Date accountTime = order.getAccountTime();
         if (accountTime != null) {
            order.setGetTime(formatday.format(accountTime));
         }
         Date preAccountTime = order.getPreAccountTime();
         if (preAccountTime != null) {
            order.setPreGetTime(formatday.format(preAccountTime));
         }
         
         /* 订单状态  转换处理*/
         String orderStateContent = "";
@@ -233,29 +283,52 @@
         }
         
         
         String hongBaoDate = "";
         String hongBaoState_Str = "";
         String hongbaoInfoFontColor = "#E5005C";
         /* 红包状态 转换 */
         String stateContent = "";
         Map<String, String> accountState = new HashMap<String, String>();
         Integer orderHongBaoState = null;
         Integer hongBaoState = order.getHongBaoState();
         if (HongBaoV2.STATE_KELINGQU == hongBaoState || HongBaoV2.STATE_BUKELINGQU == hongBaoState) {
            orderHongBaoState = 1;
            stateContent = "未到账";
            hongBaoState_Str = "预估";
            hongbaoInfoFontColor = "#888888";
            
            Date preAccountTime = order.getPreAccountTime();
            if (preAccountTime != null) {
               hongBaoDate = "预计到账时间" + formatday.format(preAccountTime);
            }
         } else if (HongBaoV2.STATE_YILINGQU == hongBaoState) {
            orderHongBaoState = 3;
            stateContent = "已到账";
            Date accountTime = order.getAccountTime();
            if (accountTime != null) {
               hongBaoDate = "到账时间" + formatday.format(accountTime);
            }
         } else if (HongBaoV2.STATE_BUFENSHIXIAO == hongBaoState) {
            stateContent = "部分失效";
            stateContent = "部分失效";
            orderHongBaoState = 3;
            Date accountTime = order.getAccountTime();
            if (accountTime != null) {
               hongBaoDate = "到账时间" + formatday.format(accountTime);
            }
         } else if (HongBaoV2.STATE_SHIXIAO == hongBaoState) {
            stateContent = "已失效";
            orderHongBaoState = 4;
            stateContent = "已失效";
            hongBaoDate = "  ";
         }
         accountState.put("content", stateContent);
         accountState.put("fontColor", "#E5005C");
         order.setAccountState(accountState);
         order.setHongBaoState(orderHongBaoState);
         order.setAccountState(stateContent);
         order.setHongBaoDate(hongBaoDate);
         
         if ("奖金".equals(hongbaoInfo) && hongBaoState_Str.trim().length() > 0) {
            hongbaoInfo = hongBaoState_Str + hongbaoInfo;
         }
@@ -267,32 +340,7 @@
         hongBaoMap.put("content", hongbaoInfo + " ¥" + hongBao);
         hongBaoMap.put("fontColor", hongbaoInfoFontColor);
         order.setHongBaoInfo(hongBaoMap);
      }
      
      return listOrder;
   }
   @Override
   public Map<String, BigDecimal> countOrderByHongBaoType(Long uid, Integer day) {
      return commonOrderMapper.countOrderByHongBaoType(uid, day);
   }
   @Override
   public long countOrder(Long uid, Integer isToday) {
      return commonOrderMapper.countOrder(uid, isToday);
   }
   @Override
   public BigDecimal countOrderMoney(Long uid, Integer isToday) {
      return commonOrderMapper.countOrderMoney(uid, isToday);
   }
   @Override
   public Map<String, BigDecimal> countByUidAndOrderState(Long uid, Integer type, String startTime,String endTime) {
      return commonOrderMapper.countByUidAndOrderState(uid, type,  startTime, endTime);
   }
}