コード例 #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);
  }
コード例 #2
0
  private String remark(Order order) {
    StringBuilder sbd = new StringBuilder();
    String invoice = invoice(order);
    String message = message(order.getId());

    sbd.append(invoice);
    if (StringUtils.isNotBlank(invoice) && StringUtils.isNotBlank(message)) sbd.append("\n");
    sbd.append(message);

    return sbd.toString();
  }
コード例 #3
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();
  }
コード例 #4
0
  private String invoice(Order order) {
    // 不需要开发票
    if (!order.getInvoiceInfo().isInvoice()) return "";

    StringBuilder sbd = new StringBuilder("发票: (");
    sbd.append(order.getInvoiceInfo().getInvoiceType()).append("/");
    sbd.append(order.getInvoiceInfo().getInvoiceTitle().toDesc()).append("/");

    if (StringUtils.isNotBlank(order.getInvoiceInfo().getCompanyName()))
      sbd.append(order.getInvoiceInfo().getCompanyName()).append("/");

    sbd.append(order.getInvoiceInfo().getInvoiceContent()).append(")");
    return sbd.toString();
  }