| | |
| | | import com.oying.exception.BadRequestException; |
| | | import com.oying.modules.hwc.service.SwiftPassService; |
| | | import com.oying.modules.sh.domain.Order; |
| | | import com.oying.modules.sh.domain.OrderProductSnapshot; |
| | | import com.oying.modules.sh.domain.OrderReturn; |
| | | import com.oying.modules.sh.domain.OrderReturnProductSnapshot; |
| | | import com.oying.modules.sh.domain.request.AuditOrderReturn; |
| | | import com.oying.modules.sh.domain.request.ProductOrder; |
| | | import com.oying.modules.sh.domain.request.ReturnOrder; |
| | | import com.oying.modules.sh.domain.vo.OrderResponse; |
| | | import com.oying.modules.sh.domain.vo.OrderReturnResponse; |
| | |
| | | private final OrderAddressSnapshotService addressSnapshotService; |
| | | private static final String ORDER_RETURN_KEY = "oying:order:refund"; |
| | | private static final String ORDER_CODE = "REFUND"; |
| | | public static final Integer DAY = 30; |
| | | |
| | | @Override |
| | | public PageResult<OrderReturn> queryAll(OrderReturnQueryCriteria criteria, Page<Object> page) { |
| | |
| | | if (returnOrder2 != null) { |
| | | throw new BadRequestException("退款订单已处理"); |
| | | } |
| | | if (!DateUtil.isBefore(order.getPayTime(), DateUtil.DAY)) { |
| | | if (!DateUtil.isBefore(order.getPayTime(), DAY)) { |
| | | throw new BadRequestException("订单已超过售后有效期"); |
| | | } |
| | | // 退款订单 |
| | |
| | | returnOrder.setPhotos(resources.getPhotos()); |
| | | returnOrder.setAuditStatus(ReturnAuditEnum.ZERO.getKey()); |
| | | orderReturnMapper.insert(returnOrder); |
| | | List<OrderReturnProductSnapshot> productSnapshots = new ArrayList<>(); |
| | | for (ProductOrder productOrder : resources.getProductOrders()) { |
| | | for (OrderProductSnapshot snapshot : order.getProductSnapshots()) { |
| | | if (productOrder.getProductId().equals(snapshot.getProductId())) { |
| | | OrderReturnProductSnapshot productSnapshot = getSnapshot(snapshot, returnNum); |
| | | productSnapshots.add(productSnapshot); |
| | | } |
| | | } |
| | | } |
| | | productSnapshotService.saveBatch(productSnapshots); |
| | | } |
| | | |
| | | private static OrderReturnProductSnapshot getSnapshot(OrderProductSnapshot snapshot, String returnNum) { |
| | | OrderReturnProductSnapshot productSnapshot = new OrderReturnProductSnapshot(); |
| | | productSnapshot.setReturnNum(returnNum); |
| | | productSnapshot.setStoreId(snapshot.getStoreId()); |
| | | productSnapshot.setProductId(snapshot.getProductId()); |
| | | productSnapshot.setProductCode(snapshot.getProductCode() != null ? snapshot.getProductCode() : null); |
| | | productSnapshot.setProductBarcode(snapshot.getProductBarcode()); |
| | | productSnapshot.setProductName(snapshot.getProductName()); |
| | | productSnapshot.setProductTitle(snapshot.getProductTitle()); |
| | | productSnapshot.setProductMainImage(snapshot.getProductMainImage()); |
| | | productSnapshot.setProductDescription(snapshot.getProductDescription()); |
| | | productSnapshot.setParamData(snapshot.getParamData() != null ? snapshot.getParamData() : null); |
| | | productSnapshot.setUnitPrice(snapshot.getUnitPrice()); |
| | | productSnapshot.setDetailCount(snapshot.getDetailCount()); |
| | | productSnapshot.setOriginalPrice(snapshot.getOriginalPrice()); |
| | | productSnapshot.setPaidPrice(snapshot.getPaidPrice()); |
| | | productSnapshot.setActuallyPayPrice(snapshot.getActuallyPayPrice()); |
| | | return productSnapshot; |
| | | } |
| | | |
| | | @Override |