Exemplo n.º 1
1
  @RequestMapping(value = "/order/search/integral")
  public void searchUserIntegralByOrder(String orderNoes, HttpServletResponse response)
      throws IOException {
    String[] orderNoArray = orderNoes.split("\\n");

    Map<Integer, UserIntegralAndCoupon> uicMap =
        new LinkedHashMap<Integer, UserIntegralAndCoupon>();
    StringBuilder sbd = new StringBuilder();
    for (String orderNo : orderNoArray) {
      if (StringUtils.isBlank(orderNo) || NumberUtils.toLong(orderNo) <= 0) continue;

      long no = NumberUtils.toLong(orderNo.trim());
      Order order = tradeCenterBossClient.queryOrderByOrderNo(no);
      if (order == null) continue;

      User user = userService.getUserById(order.getUserId());
      if (user == null || uicMap.get(user.getId()) != null) continue;

      UserIntegralAndCoupon uic = new UserIntegralAndCoupon();
      uic.setUserId(user.getId());
      uic.setUserName(user.getUserName());
      uic.setPhone(StringUtils.isNotBlank(user.getPhone()) ? user.getPhone() : "");
      uic.setEmail(StringUtils.isNotBlank(user.getEmail()) ? user.getEmail() : "");
      uic.setIntegral(user.getCurrency());

      List<Coupon> coupons = couponService.queryCouponByUserId(order.getUserId());
      sbd.delete(0, sbd.length());
      int i = 0;
      String str = "";
      for (Coupon coupon : coupons) {
        sbd.append(coupon.getCode());
        if (coupon.isUsed()) str = "已使用";
        else if (coupon.isExpire()) str = "已过期";
        if (StringUtils.isNotBlank(str)) sbd.append("(").append(str).append(")");

        if (i != coupons.size() - 1) sbd.append(", ");

        i++;
      }
      uic.setCoupon(sbd.toString());

      sbd.delete(0, sbd.length());
      // 从地址中去寻找
      List<Address> addresses = addressService.queryAllAddress(order.getUserId());
      i = 0;
      for (Address address : addresses) {
        sbd.append(address.getName()).append("/").append(address.getMobile()).append("/");
        sbd.append(address.getProvince()).append(address.getLocation());
        if (address.isDefaultAddress()) sbd.append("<span style='color:red;'>(默认地址)</span>");

        if (i != addresses.size() - 1) sbd.append("\n");
      }
      uic.setAddress(sbd.toString());

      uicMap.put(user.getId(), uic);
    }
    new JsonResult(true).addData("orderList", uicMap.values()).toJson(response);
  }
Exemplo n.º 2
0
  /**
   * 根据订单Id查询Sku列表
   *
   * @param orderId
   * @return
   */
  @RequestMapping(value = "/order/sku/{orderId}")
  public void skuGrid(@PathVariable("orderId") int orderId, HttpServletResponse response)
      throws IOException {
    List<OrderItem> orderItems =
        tradeCenterBossClient.queryOrderItemWithoutBackingNumberByOrderId(orderId);
    List<ProductSku> list = new ArrayList<ProductSku>();
    for (OrderItem orderItem : orderItems) {
      ProductSku sku = new ProductSku();
      sku.setNumber(orderItem.getNumber());
      sku.setSkuId(orderItem.getSkuId());
      sku.setProductId(orderItem.getProductId());
      sku.setSkuState(orderItem.getOrderState().serviceDesc());
      sku.setShipmentNum(orderItem.getShipmentNum());
      sku.setBackNumber(orderItem.getBackNum());
      sku.setBarCode(orderItem.getBarCode());
      StockKeepingUnit stockKeepingUnit = skuService.getStockKeepingUnit(orderItem.getSkuId());
      if (stockKeepingUnit != null) {
        Product product = productService.getProductById(stockKeepingUnit.getProductId());
        Money money = new Money();
        money.setCent(stockKeepingUnit.getPrice());
        sku.setSkuPrice(money.toString());
        sku.setProductName(product.getName());
        sku.setAttribute(skuService.getSkuPropertyToString(stockKeepingUnit));
        sku.setProductCode(stockKeepingUnit.getSkuCode()); // product.getProductCode());
      } else {
        sku.setProductName("没有此 SKU! 被删除或重新生成过.");
      }

      list.add(sku);
    }
    new JsonResult(true)
        .addData("totalCount", list.size())
        .addData("result", list)
        .toJson(response);
  }
Exemplo n.º 3
0
 @RequestMapping(value = "/order/logistics/{orderId}")
 public void logisticsInfo(@PathVariable("orderId") String orderId, HttpServletResponse response)
     throws IOException {
   List<ProgressDetail> list =
       tradeCenterBossClient.getProgressDetail(NumberUtils.toLong(orderId));
   new JsonResult(true)
       .addData("totalCount", list.size())
       .addData("result", list)
       .toJson(response);
 }
Exemplo n.º 4
0
 /**
  * 备注列表
  *
  * @param orderId
  * @param response
  * @throws IOException
  */
 @RequestMapping(value = "/order/message/{orderId}")
 public void displayOrderMessage(
     @PathVariable("orderId") long orderId, HttpServletResponse response) throws IOException {
   List<OrderMessage> orderMessages = tradeCenterBossClient.queryAllMessage(orderId);
   for (OrderMessage orderMessage : orderMessages) {
     orderMessage.setMessageInfo(
         orderMessage.getUserType().toDesc() + ":" + orderMessage.getMessageInfo());
   }
   new JsonResult(true)
       .addData("totalCount", orderMessages.size())
       .addData("result", orderMessages)
       .toJson(response);
 }
Exemplo n.º 5
0
  private String message(long orderId) {
    StringBuilder sbd = new StringBuilder();
    List<OrderMessage> orderMessages = tradeCenterBossClient.queryAllMessage(orderId);
    int i = 0;
    for (OrderMessage orderMessage : orderMessages) {
      sbd.append(orderMessage.getUserType().toDesc())
          .append("留言:")
          .append(orderMessage.getMessageInfo());
      if (i != orderMessages.size() - 1) sbd.append("\n");

      i++;
    }
    return sbd.toString();
  }
Exemplo n.º 6
0
 /**
  * 订单价格备注详情
  *
  * @param orderId
  * @param response
  * @throws IOException
  */
 @RequestMapping(value = "/order/priceMessageDetail/{orderId}")
 public void priceMessageDetailByOrderId(
     @PathVariable("orderId") long orderId, HttpServletResponse response) throws IOException {
   OrderDetail orderDetail = new OrderDetail();
   List<OrderDetail> list = new LinkedList<OrderDetail>();
   Order order = tradeCenterBossClient.queryOrderById(orderId);
   if (order.getPriceMessageDetail() != null) {
     orderDetail.setPriceMessageDetail(order.getPriceMessageDetail());
     list.add(orderDetail);
   }
   new JsonResult(true)
       .addData("totalCount", list.size())
       .addData("result", list)
       .toJson(response);
 }
Exemplo n.º 7
0
  @RequestMapping(value = "/order/export")
  public void exportOrder(
      OrderQuery orderQuery, HttpServletRequest request, HttpServletResponse response)
      throws IOException {
    List<List<Order>> orderList = tradeCenterBossClient.searchOrderListByQuery(orderQuery);

    String name = "订单统计";
    Map<String, List> exportOrderMap = new LinkedHashMap<String, List>();
    for (List<Order> orderArray : orderList) {
      if (orderArray == null || orderArray.size() == 0) continue;

      List<ExportOrder> exportOrderList = new ArrayList<ExportOrder>();
      for (Order order : orderArray) {
        long orderId = order.getId();
        Logistics logistics = order.getLogistics();

        int count = 0;
        for (OrderItem orderItem : order.getOrderItemList()) {
          ExportOrder exportOrder = new ExportOrder();

          Brand brand = supplierService.queryBrandById(orderItem.getBrandId());
          exportOrder.setBrandName(brand == null ? "" : brand.getName());
          exportOrder.setProductName(orderItem.getSkuName());
          exportOrder.setProductCode(orderItem.getItemNo());
          exportOrder.setNumber(String.valueOf(orderItem.getNumber()));
          exportOrder.setUnitPrice(Money.getMoneyString(orderItem.getUnitPrice()));
          exportOrder.setBackNumber(String.valueOf(orderItem.getBackNum()));
          exportOrder.setOrderState(orderItem.getOrderState().serviceDesc());

          if (count == 0) {
            exportOrder.setPayBank(order.getPayBank().toDesc());
            exportOrder.setCreateDate(formatDate(order.getCreateDate()));
            exportOrder.setSuccessDate(formatDate(tradeCenterBossClient.querySuccessDate(orderId)));
            exportOrder.setUserName(order.getUserName());
            exportOrder.setOrderNo(String.valueOf(order.getOrderNo()));

            exportOrder.setOldTotalPrice(Money.getMoneyString(order.calculateOldTotalPrice()));
            exportOrder.setPriceMessageDetail(order.getPriceMessageDetail());
            exportOrder.setTotalPrice(order.getTotalPrice());
            exportOrder.setRemark(remark(order));
            exportOrder.setLogisticsName(logistics.getName());
            exportOrder.setLogisticsAddress(
                logistics.getProvince() + "," + logistics.getLocation());
            exportOrder.setLogisticsPhone(
                getPhone(logistics.getMobile(), logistics.getTelephone()));
          }

          // 只存到最后一个订单项里, 主要用来多条订单项时合并单元格
          if (count == (order.getOrderItemList().size() - 1)) {
            exportOrder.setItemSize(order.getOrderItemList().size());
          }
          exportOrderList.add(exportOrder);
          count++;
        }
      }
      String sheetName = name;
      if (orderArray.size() > 0
          && orderArray.get(0).getOrderState()
              == orderArray.get(orderArray.size() - 1).getOrderState())
        sheetName = orderArray.get(0).getOrderState().serviceDesc();
      exportOrderMap.put(sheetName, exportOrderList);
    }

    String[] headerList =
        new String[] {
          "下单时间",
          "完成时间",
          "下单人",
          "订单编号",
          "品牌",
          "商品名称",
          "商品编码",
          "购买数量",
          "购买单价",
          "应付总金额",
          "使用积分/优惠券",
          "实付总金额",
          "退货数量",
          "订单状态",
          "备注(发票、留言)",
          "收货人",
          "收货人地址",
          "联系电话"
        };
    String[] fieldNameList =
        new String[] {
          "createDate",
          "successDate",
          "userName",
          "orderNo",
          "brandName",
          "productName",
          "productCode",
          "number",
          "unitPrice",
          "oldTotalPrice",
          "priceMessageDetail",
          "totalPrice",
          "backNumber",
          "orderState",
          "remark",
          "logisticsName",
          "logisticsAddress",
          "logisticsPhone"
        };

    response.setHeader(
        "Content-Disposition",
        "attachment; filename=\"" + encodeFileName(request, name) + ".xls\"");
    response.setContentType("application/vnd.ms-excel");
    ExportExcelUtil.exportExcel(
        exportOrderMap, headerList, fieldNameList, response.getOutputStream());
  }