use of cn.exrick.manager.dto.front.Order in project xmall by Exrick.
the class OrderServiceImpl method getOrder.
@Override
public Order getOrder(Long orderId) {
Order order = new Order();
TbOrder tbOrder = tbOrderMapper.selectByPrimaryKey(String.valueOf(orderId));
if (tbOrder == null) {
throw new XmallException("通过id获取订单失败");
}
String validTime = judgeOrder(tbOrder);
if (validTime != null) {
order.setFinishDate(validTime);
}
// 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 createDate = formatter.format(tbOrder.getCreateTime());
order.setCreateDate(createDate);
// closeDate
if (tbOrder.getCloseTime() != null) {
String closeDate = formatter.format(tbOrder.getCloseTime());
order.setCloseDate(closeDate);
}
// finishDate
if (tbOrder.getEndTime() != null && tbOrder.getStatus() == 4) {
String finishDate = formatter.format(tbOrder.getEndTime());
order.setFinishDate(finishDate);
}
// 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);
return order;
}
use of cn.exrick.manager.dto.front.Order 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