Пример #1
0
  /**
   * 后台订单的筛选地址
   *
   * @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);
  }
Пример #2
0
  @SuppressWarnings("unchecked")
  public static void main(String[] args) throws IOException, InterruptedException {

    /*
     *  Check if port is open. Currently the client pool is hard coded to look for a server on 40404, the default. If already taken,
     *  this process will wait for a while so this forces an immediate exit if the port is in use. There are better ways to handle this
     *  situation, but hey, this is sample code.
     */
    try {
      new ServerPortGenerator().bind(new ServerSocket(), 40404, 1);
    } catch (IOException e) {
      System.out.println(
          "Sorry port 40404 is in use. Do you have another cache server process already running?");
      System.exit(1);
    }

    ApplicationContext context = new ClassPathXmlApplicationContext("server/cache-config.xml");

    Region<Long, Order> region = context.getBean("Order", Region.class);

    /*
     * Create some customer orders
     */

    Product ipod =
        new Product(1L, "Apple iPod", new BigDecimal(99.99), "An Apple portable music player");
    Product ipad = new Product(2L, "Apple iPad", new BigDecimal(499.99), "An Apple tablet device");
    Product macbook =
        new Product(3L, "Apple macBook", new BigDecimal(899.99), "An Apple notebook computer");
    macbook.setAttribute("warantee", "included");

    Order davesOrder = new Order(1L, 1L, new Address("Dave Street", "Matthews", "USA"));

    davesOrder.add(new LineItem(ipad, 2));
    davesOrder.add(new LineItem(macbook));

    Order aliciasFirstOrder = new Order(2L, 2L, new Address("Alicia Street", "Keys", "USA"));

    aliciasFirstOrder.add(new LineItem(ipod, 3));

    Order aliciasNextOrder = new Order(3L, 2L, new Address("Alicia Street", "Keys", "USA"));

    aliciasNextOrder.add(new LineItem(macbook, 4));
    aliciasNextOrder.add(new LineItem(ipad));

    System.out.println("Press <ENTER> to update cache");
    System.in.read();

    region.put(davesOrder.getId(), davesOrder);
    region.put(aliciasFirstOrder.getId(), aliciasFirstOrder);
    region.put(aliciasNextOrder.getId(), aliciasNextOrder);

    System.out.println("Press <ENTER> to terminate the cache server");
    System.in.read();
    System.exit(0);
  }
Пример #3
0
  @Test
  public void testConstructorShouldIncreaseIdWhenNewInstanceCreated() {
    // GIVEN
    underTest = new Order(mockCashier, mockFood, mockCondiment);

    // WHEN
    Integer id1 = underTest.getId();
    Order anotherOrder = new Order(mockCashier, mockFood, mockCondiment);
    Integer id2 = anotherOrder.getId();

    // THEN
    Assert.assertEquals(1, id2 - id1);
  }
  public void testChanged() throws Exception {

    Order po = OrderMother.makeOrder();
    save(po.getRestaurant());
    save(po);
    final Serializable orderId = po.getId();

    Order detachedOrder = am.detach(po);

    doWithTransaction(
        new TxnCallback() {
          public void execute() throws Exception {
            Order po = (Order) load(Order.class, orderId.toString());
            po.noteSent("msgid", new Date());
            po.accept("x");
          }
        });

    try {
      Order attachedOrder = am.attach(detachedOrder);
      fail("Expected exception");
    } catch (OptimisticLockingFailureException e) {

    }
  }
Пример #5
0
 /** @inheritdoc */
 @Override
 public Long getKey(Order entity) {
   if (entity != null) {
     return entity.getId();
   } else {
     return null;
   }
 }
 @Test
 @Transactional
 public void testSaveOrderWithItems() throws Exception {
   Order order = new Order();
   order.getItems().add(new Item());
   entityManager.persist(order);
   entityManager.flush();
   assertNotNull(order.getId());
 }
Пример #7
0
  /** Test of nextValue method, of class UjoSequencer. */
  public void testNextValue_3() {
    System.out.println("testNextValue_3");

    final int sequenceCache = 3;
    final OrmHandler handler = createHandler(sequenceCache);
    final Session session = handler.createSession();

    Order orderBeg = createAndSaveOrder(session);
    Order orderEnd = null;
    int count = 53;
    for (long i = 0; i < count; i++) {
      orderEnd = createAndSaveOrder(session);
    }
    session.close();
    assertEquals(
        "ID sequences must be the same",
        orderBeg.getId().longValue() + count,
        orderEnd.getId().longValue());
  }
 @Test
 @Transactional
 public void testSaveOrderWithItems() throws Exception {
   Session session = sessionFactory.getCurrentSession();
   Order order = new Order();
   order.getItems().add(new Item());
   session.save(order);
   session.flush();
   assertNotNull(order.getId());
 }
Пример #9
0
  @Override
  public byte[] toBinary(Object o) {
    Order order = (Order) o;
    OrderFormat orderFormat = new OrderFormat();

    orderFormat.id = order.getId();
    orderFormat.items = new ArrayList<>(order.getItems().reverse().toCollection());
    orderFormat.cancelled = order.isCancelled();

    return SerializationExtension.get(system).serialize(orderFormat).get();
  }
Пример #10
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();
  }
Пример #11
0
  @Override
  protected void onListItemClick(ListView l, View v, int position, long id) {
    super.onListItemClick(l, v, position, id);

    Order order = adapter.getItem(position);
    if (order == null) return;

    Intent orderDetailIntent = new Intent(this, OrderDetailActivity.class);
    orderDetailIntent.putExtra("orderId", order.getId());
    startActivity(orderDetailIntent);
  }
 @Test
 @Transactional
 public void testSaveAndGet() throws Exception {
   Order order = new Order();
   order.getItems().add(new Item());
   entityManager.persist(order);
   entityManager.flush();
   // Otherwise the query returns the existing order (and we didn't set the
   // parent in the item)...
   entityManager.clear();
   Order other = (Order) entityManager.find(Order.class, order.getId());
   assertEquals(1, other.getItems().size());
   assertEquals(other, other.getItems().iterator().next().getOrder());
 }
 @Test
 @Transactional
 public void testSaveAndGet() throws Exception {
   Session session = sessionFactory.getCurrentSession();
   Order order = new Order();
   order.getItems().add(new Item());
   session.save(order);
   session.flush();
   // Otherwise the query returns the existing order (and we didn't set the
   // parent in the item)...
   session.clear();
   Order other = (Order) session.get(Order.class, order.getId());
   assertEquals(1, other.getItems().size());
   assertEquals(other, other.getItems().iterator().next().getOrder());
 }
Пример #14
0
  final void init() {
    Customer c = new Customer();
    c.setName("John");
    c.setId(123);
    customers.put(c.getId(), c);

    c = new Customer();
    c.setName("Dan");
    c.setId(113);
    customers.put(c.getId(), c);

    Order o = new Order();
    o.setDescription("order 223");
    o.setId(223);
    orders.put(o.getId(), o);
  }
Пример #15
0
 /**
  * 配送和支付信息
  *
  * @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);
 }
  @Test
  public void setTest() {
    Random r = new Random();
    int[] vals = {r.nextInt(500), r.nextInt(500), r.nextInt(500)};
    int i = 0;
    Order o = orderDiscount.set(vals[i++], vals[i++], String.valueOf(vals[i]));
    assertNotNull(o.getId());
    i = 0;

    assertEquals(vals[i++], orderDiscount.getDiscountTaxFree(), 0);
    assertEquals(vals[i++], orderDiscount.getDiscountTaxIncluded(), 0);
    assertEquals(String.valueOf(vals[i]), orderDiscount.getPromotionalCode());

    orderDiscount =
        orderDiscount.setDiscountTaxFree(1).setDiscountTaxIncluded(1).setPromotionalCode("p");
    assertEquals(1, orderDiscount.getDiscountTaxFree(), 0);
    assertEquals(1, orderDiscount.getDiscountTaxIncluded(), 0);
    assertEquals("p", orderDiscount.getPromotionalCode());
  }
Пример #17
0
  /** @inheritdoc */
  @Override
  protected void bindValues(SQLiteStatement stmt, Order entity) {
    stmt.clearBindings();

    Long id = entity.getId();
    if (id != null) {
      stmt.bindLong(1, id);
    }

    String type = entity.getType();
    if (type != null) {
      stmt.bindString(2, type);
    }

    String topic = entity.getTopic();
    if (topic != null) {
      stmt.bindString(3, topic);
    }

    String startTime = entity.getStartTime();
    if (startTime != null) {
      stmt.bindString(4, startTime);
    }

    String endTime = entity.getEndTime();
    if (endTime != null) {
      stmt.bindString(5, endTime);
    }

    Double price = entity.getPrice();
    if (price != null) {
      stmt.bindDouble(6, price);
    }

    Boolean realtime = entity.getRealtime();
    if (realtime != null) {
      stmt.bindLong(7, realtime ? 1L : 0L);
    }

    String contactName = entity.getContactName();
    if (contactName != null) {
      stmt.bindString(8, contactName);
    }

    String contactGender = entity.getContactGender();
    if (contactGender != null) {
      stmt.bindString(9, contactGender);
    }

    String contactPhone = entity.getContactPhone();
    if (contactPhone != null) {
      stmt.bindString(10, contactPhone);
    }

    Long expertId = entity.getExpertId();
    if (expertId != null) {
      stmt.bindLong(11, expertId);
    }

    Long userId = entity.getUserId();
    if (userId != null) {
      stmt.bindLong(12, userId);
    }
  }
 // POST /orders
 public HttpHeaders create() {
   ordersService.save(model);
   addActionMessage("New order created successfully");
   return new DefaultHttpHeaders("success").setLocationId(model.getId());
 }
Пример #19
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());
  }
Пример #20
0
 public BillImpl(Order order) {
   this.orderId = order.getId();
 }