| | |
| | | import com.oying.modules.sh.domain.*; |
| | | import com.oying.modules.sh.domain.request.GeneratorOrder; |
| | | import com.oying.modules.sh.domain.request.ProductOrder; |
| | | import com.oying.modules.sh.domain.request.StatusOrder; |
| | | import com.oying.modules.sh.domain.request.SubmitOrder; |
| | | import com.oying.modules.sh.domain.vo.OrderInfo; |
| | | import com.oying.modules.sh.domain.vo.OrderResponse; |
| | | import com.oying.modules.sh.domain.vo.ProductInfo; |
| | | import com.oying.modules.sh.service.*; |
| | | import com.oying.utils.*; |
| | | import com.oying.utils.enums.GenerateEnum; |
| | | import com.oying.utils.enums.OrderStatusEnum; |
| | | import com.oying.utils.enums.PayStateEnum; |
| | | import com.oying.utils.enums.PayTypeEnum; |
| | | import com.oying.utils.enums.*; |
| | | import lombok.RequiredArgsConstructor; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | |
| | | order.setOrderStatusDescribe(OrderStatusEnum.ZERO.getValue()); |
| | | order.setOrderRemark(submit.getRemark() != null ? submit.getRemark() : ""); |
| | | order.setOrderTime(submit.getDateTime()); |
| | | order.setSendPrice(store.getDeliveryFee()); |
| | | order.setSendType(SendTypeEnum.LY.getKey()); |
| | | order.setUserId(SecurityUtils.getCurrentUserId()); |
| | | order.setUsername(SecurityUtils.getCurrentUsername()); |
| | | order.setStoreId(submit.getStoreId()); |
| | | order.setStoreName(store.getStoreName()); |
| | | order.setStoreLogo(store.getLogoImageUrl()); |
| | | order.setSendPrice(store.getDeliveryFee()); |
| | | order.setStoreAddress(store.getAddress()); |
| | | order.setStoreLongitude(BigDecimal.valueOf(store.getLongitude())); |
| | | order.setStoreLatitude(BigDecimal.valueOf(store.getLatitude())); |
| | | order.setOrderDescribe(DESCRIBE + submit.getStoreId()); |
| | | order.setOriginalPrice(amount); |
| | | order.setPaidPrice(amount); |
| | |
| | | UserAddress address = userAddressService.getById(submit.getAddressId()); |
| | | OrderAddressSnapshot addressSnapshot = getOrderAddressSnapshot(orderNum, address); |
| | | |
| | | |
| | | addressSnapshotService.save(addressSnapshot); |
| | | orderMapper.insert(order); |
| | | productSnapshotService.saveBatch(snapshots); |
| | | |
| | | order.setProductSnapshots(new HashSet<>(snapshots)); |
| | | operationLogService.create(order, addressSnapshot); |
| | | OrderResponse response = new OrderResponse(order, addressSnapshot, null); |
| | | |
| | | operationLogService.create(response, OrderStatusEnum.ZERO, null); |
| | | 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; |
| | | public void statusOrder(StatusOrder statusOrder) { |
| | | operationLog(getByOrderNum(statusOrder.getOrderNum()), statusOrder.getStatus(), null); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void operationLog(OrderResponse order) { |
| | | orderMapper.updateOrderStatus(order.getOrder().getOrderNum(), OrderStatusEnum.TWO.getKey(), OrderStatusEnum.TWO.getValue()); |
| | | public OrderResponse getByOrderNum(String orderNum) { |
| | | return new OrderResponse(orderMapper.getByOrderNum(orderNum), |
| | | addressSnapshotService.queryByOrderNum(orderNum), |
| | | operationLogService.getByOrderNum(orderNum)); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void operationLog(OrderResponse order, OrderStatusEnum stateEnum, String cardName) { |
| | | operationLogService.create(order, stateEnum, cardName); |
| | | } |
| | | |
| | | @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, null); |
| | | orderMapper.updateCloseStatus(orderNum, PayStateEnum.CLOSED.getKey(), PayStateEnum.CLOSED.getValue()); |
| | | } |
| | | |
| | | @Override |