/**
   * 后台订单的筛选地址
   *
   * @param orderQuery
   * @param response
   * @throws IOException
   */
  @RequestMapping(value = "/order/search")
  public void searchOrder(OrderQuery orderQuery, HttpServletResponse response) throws IOException {
    List<OrderDetail> list = new ArrayList<OrderDetail>();
    Page<Order> orderPage = tradeCenterBossClient.searchOrderByQuery(orderQuery);
    for (Order order : orderPage.getResult()) {
      OrderDetail orderDetail = new OrderDetail();
      orderDetail.setUserId(order.getUserId());
      orderDetail.setUserName(order.getUserName());
      orderDetail.setOrderId(order.getId());
      orderDetail.setOrderNo(order.getOrderNo());
      orderDetail.setAccountType(order.getAccountType());
      if (order.getOrderState() == OrderState.Success) {
        orderDetail.setEndDate(
            DateUtils.formatDate(order.getEndDate(), DateUtils.DateFormatType.DATE_FORMAT_STR));
      }
      orderDetail.setStartDate(
          DateUtils.formatDate(order.getCreateDate(), DateUtils.DateFormatType.DATE_FORMAT_STR));
      orderDetail.setInvoice(order.getInvoiceInfo().isInvoice());
      orderDetail.setOrderState(order.getOrderState().toString());
      orderDetail.setOrderStateDesc(order.getOrderState().serviceDesc());

      Logistics logistics = tradeCenterBossClient.queryLogisticsByOrderId(order.getId());
      orderDetail.setGoodToUserName(logistics.getName());

      list.add(orderDetail);
    }
    new JsonResult(true)
        .addData("totalCount", orderPage.getTotalCount())
        .addData("result", list)
        .toJson(response);
  }
  /**
   * 显示订单的收货信息,客服可修改,修改的和原来的用-隔开
   *
   * @param orderId
   * @param response
   * @throws IOException
   */
  @RequestMapping(value = "/order/addressInfo/{orderId}")
  public void addressInfoGrid(@PathVariable("orderId") long orderId, HttpServletResponse response)
      throws IOException {
    AddressInfo addressInfo = new AddressInfo();
    Logistics logistics = tradeCenterBossClient.queryLogisticsByOrderId(orderId);
    LogisticsRedundancy logisticsRedundancy =
        tradeCenterBossClient.queryLogisticsRedundancy(logistics.getId());
    Order order = tradeCenterBossClient.queryOrderById(orderId);
    List<AddressInfo> list = new LinkedList<AddressInfo>();
    if (order != null) {
      addressInfo.setOrderState(order.getOrderState().toString());
      String[] province = (logistics.getProvince()).split(",");
      if (province.length == 2) {
        addressInfo.setProvince(province[0]);
        addressInfo.setCity(province[0]);
        addressInfo.setDistricts(province[1]);
      } else {
        addressInfo.setProvince(province[0]);
        addressInfo.setCity(province[1]);
        addressInfo.setDistricts(province[2]);
      }
      addressInfo.setConsignee(logistics.getName());
      addressInfo.setLocation(logistics.getLocation());
      addressInfo.setMobile(logistics.getMobile());
      addressInfo.setZipCode(logistics.getZipCode());

      if (StringUtils.isNotEmpty(logisticsRedundancy.getNameRewrite())) {
        addressInfo.setConsignee(
            addressInfo.getConsignee() + Old_New_Gap + logisticsRedundancy.getNameRewrite());
      }
      if (StringUtils.isNotEmpty(logisticsRedundancy.getLocationRewrite())) {
        addressInfo.setLocation(
            addressInfo.getLocation() + Old_New_Gap + logisticsRedundancy.getLocationRewrite());
      }
      if (StringUtils.isNotEmpty(logisticsRedundancy.getMobileRewrite())) {
        addressInfo.setMobile(
            addressInfo.getMobile() + Old_New_Gap + logisticsRedundancy.getMobileRewrite());
      }
      if (StringUtils.isNotEmpty(logisticsRedundancy.getZipCodeRewrite())) {
        addressInfo.setZipCode(
            addressInfo.getZipCode() + Old_New_Gap + logisticsRedundancy.getZipCodeRewrite());
      }

      String provinceRewrite = logisticsRedundancy.getProvinceRewrite();
      if (StringUtils.isNotEmpty(provinceRewrite)) {
        String[] newProvince = (logisticsRedundancy.getProvinceRewrite()).split(",");
        addressInfo.setProvince(addressInfo.getProvince() + Old_New_Gap + newProvince[0]);
        addressInfo.setCity(addressInfo.getCity() + Old_New_Gap + newProvince[1]);
        addressInfo.setDistricts(addressInfo.getDistricts() + Old_New_Gap + newProvince[2]);
      }
      list.add(addressInfo);
    }
    new JsonResult(true).addData("totalCount", 1).addData("result", list).toJson(response);
  }
 /**
  * 配送和支付信息
  *
  * @param orderId
  * @param response
  * @throws IOException
  */
 @RequestMapping(value = "/order/pay/delivery/{orderId}")
 public void payDeliveryInfoGrid(
     @PathVariable("orderId") long orderId, HttpServletResponse response) throws IOException {
   Order order = tradeCenterBossClient.queryOrderById(orderId);
   List<PayDeliveryInfo> list = new LinkedList<PayDeliveryInfo>();
   if (order != null) {
     Logistics logistics = tradeCenterBossClient.queryLogisticsByOrderId(order.getId());
     PayDeliveryInfo payDeliveryInfo = new PayDeliveryInfo();
     payDeliveryInfo.setPayType(order.getPayType());
     payDeliveryInfo.setTotalPrice(order.getTotalPrice());
     payDeliveryInfo.setDeliveryType(logistics.getDeliveryInfo().getDeliveryType());
     payDeliveryInfo.setPayBank(order.getPayBank().toDesc());
     payDeliveryInfo.setOrderState(order.getOrderState().toString());
     payDeliveryInfo.setWaybillNumber(logistics.getDeliveryInfo().getWaybillNumber());
     list.add(payDeliveryInfo);
   }
   new JsonResult(true).addData("totalCount", 1).addData("result", list).toJson(response);
 }
  /**
   * 显示订单的发票信息,客服也可修改,修改后的和原来的用-隔开
   *
   * @param orderId
   * @param response
   * @throws IOException
   */
  @RequestMapping(value = "/order/invoice/{orderId}")
  public void invoiceInfoGrid(@PathVariable("orderId") long orderId, HttpServletResponse response)
      throws IOException {
    Order order = tradeCenterBossClient.queryOrderById(orderId);
    List<InvoiceVoInfo> list = new LinkedList<InvoiceVoInfo>();
    if (order != null) {
      InvoiceInfo change = tradeCenterBossClient.queryOrderInvoiceInfoRedundancy(orderId);
      InvoiceVoInfo invoiceInfo = new InvoiceVoInfo();
      invoiceInfo.setInvoiceContent(order.getInvoiceInfo().getInvoiceContent());
      invoiceInfo.setInvoiceTitle(order.getInvoiceInfo().getInvoiceTitle().toDesc());
      invoiceInfo.setInvoiceType(order.getInvoiceInfo().getInvoiceType());
      invoiceInfo.setCompanyName(order.getInvoiceInfo().getCompanyName());

      if (StringUtils.isNotEmpty(change.getInvoiceContentRewrite())) {
        invoiceInfo.setInvoiceContent(
            invoiceInfo.getInvoiceContent() + Old_New_Gap + change.getInvoiceContentRewrite());
      }
      if (change.getInvoiceTitleRewrite() != null) {
        invoiceInfo.setInvoiceTitle(
            invoiceInfo.getInvoiceTitle() + Old_New_Gap + change.getInvoiceTitleRewrite().toDesc());
      }
      if (StringUtils.isNotEmpty(change.getInvoiceTypeRewrite())) {
        invoiceInfo.setInvoiceType(
            invoiceInfo.getInvoiceType() + Old_New_Gap + change.getInvoiceTypeRewrite());
      }
      if (StringUtils.isNotEmpty(change.getCompanyNameRewrite())) {
        String companyName = invoiceInfo.getCompanyName();
        if (StringUtils.isNotEmpty(companyName)) {
          invoiceInfo.setCompanyName(companyName + Old_New_Gap + change.getCompanyNameRewrite());
        } else {
          invoiceInfo.setCompanyName("不开公司发票^" + change.getCompanyNameRewrite());
        }
      }
      invoiceInfo.setOrderState(order.getOrderState().toString());
      list.add(invoiceInfo);
    }
    new JsonResult(true).addData("totalCount", 1).addData("result", list).toJson(response);
  }