use of cn.exrick.manager.dto.front.PageOrder in project xmall by Exrick.
the class OrderServiceImpl method getOrderList.
@Override
public PageOrder getOrderList(Long userId, int page, int size) {
// 分页
if (page <= 0) {
page = 1;
}
PageHelper.startPage(page, size);
PageOrder pageOrder = new PageOrder();
List<Order> list = new ArrayList<>();
TbOrderExample example = new TbOrderExample();
TbOrderExample.Criteria criteria = example.createCriteria();
criteria.andUserIdEqualTo(userId);
example.setOrderByClause("create_time DESC");
List<TbOrder> listOrder = tbOrderMapper.selectByExample(example);
for (TbOrder tbOrder : listOrder) {
judgeOrder(tbOrder);
Order order = new Order();
// orderId
order.setOrderId(Long.valueOf(tbOrder.getOrderId()));
// orderStatus
order.setOrderStatus(String.valueOf(tbOrder.getStatus()));
// createDate
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm");
String date = formatter.format(tbOrder.getCreateTime());
order.setCreateDate(date);
// address
TbOrderShipping tbOrderShipping = tbOrderShippingMapper.selectByPrimaryKey(tbOrder.getOrderId());
TbAddress address = new TbAddress();
address.setUserName(tbOrderShipping.getReceiverName());
address.setStreetName(tbOrderShipping.getReceiverAddress());
address.setTel(tbOrderShipping.getReceiverPhone());
order.setAddressInfo(address);
// orderTotal
if (tbOrder.getPayment() == null) {
order.setOrderTotal(new BigDecimal(0));
} else {
order.setOrderTotal(tbOrder.getPayment());
}
// goodsList
TbOrderItemExample exampleItem = new TbOrderItemExample();
TbOrderItemExample.Criteria criteriaItem = exampleItem.createCriteria();
criteriaItem.andOrderIdEqualTo(tbOrder.getOrderId());
List<TbOrderItem> listItem = tbOrderItemMapper.selectByExample(exampleItem);
List<CartProduct> listProduct = new ArrayList<>();
for (TbOrderItem tbOrderItem : listItem) {
CartProduct cartProduct = DtoUtil.TbOrderItem2CartProduct(tbOrderItem);
listProduct.add(cartProduct);
}
order.setGoodsList(listProduct);
list.add(order);
}
PageInfo<Order> pageInfo = new PageInfo<>(list);
pageOrder.setTotal(getMemberOrderCount(userId));
pageOrder.setData(list);
return pageOrder;
}
Aggregations