| | |
| | | productSnapshotService.saveBatch(snapshots); |
| | | |
| | | order.setProductSnapshots(new HashSet<>(snapshots)); |
| | | operationLogService.create(order, addressSnapshot); |
| | | OrderResponse response = new OrderResponse(order, addressSnapshot, null); |
| | | |
| | | operationLogService.create(response, OrderStatusEnum.ZERO); |
| | | return order; |
| | | } |
| | | |
| | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public OrderResponse getByOrderNum(String orderNum) { |
| | | OrderResponse response = new OrderResponse(); |
| | | response.setOrder(orderMapper.getByOrderNum(orderNum)); |
| | | response.setAddress(addressSnapshotService.queryByOrderNum(orderNum)); |
| | | response.setOperation(operationLogService.getByOrderNum(orderNum)); |
| | | return response; |
| | | return new OrderResponse(orderMapper.getByOrderNum(orderNum), |
| | | addressSnapshotService.queryByOrderNum(orderNum), |
| | | operationLogService.getByOrderNum(orderNum)); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void operationLog(OrderResponse order) { |
| | | orderMapper.updateOrderStatus(order.getOrder().getOrderNum(), OrderStatusEnum.TWO.getKey(), OrderStatusEnum.TWO.getValue()); |
| | | public void operationLog(OrderResponse order, OrderStatusEnum stateEnum) { |
| | | operationLogService.create(order, stateEnum); |
| | | } |
| | | |
| | | @Override |
| | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void closeOrder(String orderNum) { |
| | | Order order = orderMapper.getByOrderNum(orderNum); |
| | | OrderResponse response = getByOrderNum(orderNum); |
| | | Order order = response.getOrder(); |
| | | if (order == null) { |
| | | throw new BadRequestException("订单不存在"); |
| | | } |
| | | if (!SecurityUtils.getCurrentUserId().equals(order.getUserId())) { |
| | | throw new BadRequestException("不能修改他人订单"); |
| | | } |
| | | if (!order.getPayState().equals(PayStateEnum.NOTPAY.getKey())) { |
| | | throw new BadRequestException(PayStateEnum.getValue(order.getPayState())); |
| | |
| | | swiftPassService.closeOrder(orderNum, anEnum); |
| | | break; |
| | | } |
| | | orderMapper.updateCloseStatus(orderNum, PayStateEnum.CLOSED.getKey()); |
| | | operationLogService.create(response, OrderStatusEnum.NINE); |
| | | orderMapper.updateCloseStatus(orderNum, PayStateEnum.CLOSED.getKey(), PayStateEnum.CLOSED.getValue()); |
| | | } |
| | | |
| | | @Override |