| | |
| | | import com.oying.modules.sh.domain.OrderReturn; |
| | | import com.oying.modules.sh.domain.request.AuditOrderReturn; |
| | | import com.oying.modules.sh.domain.request.ReturnOrder; |
| | | import com.oying.modules.sh.service.OrderReturnProductSnapshotService; |
| | | import com.oying.modules.sh.service.OrderService; |
| | | import com.oying.modules.sh.domain.vo.OrderResponse; |
| | | import com.oying.modules.sh.domain.vo.OrderReturnResponse; |
| | | import com.oying.modules.sh.service.*; |
| | | import com.oying.utils.*; |
| | | import com.oying.utils.enums.GenerateEnum; |
| | | import com.oying.utils.enums.OrderStatusEnum; |
| | |
| | | import lombok.RequiredArgsConstructor; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.oying.modules.sh.service.OrderReturnService; |
| | | import com.oying.modules.sh.domain.dto.OrderReturnQueryCriteria; |
| | | import com.oying.modules.sh.mapper.OrderReturnMapper; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | public class OrderReturnServiceImpl extends ServiceImpl<OrderReturnMapper, OrderReturn> implements OrderReturnService { |
| | | |
| | | private final OrderReturnMapper orderReturnMapper; |
| | | private final OrderOperationLogService operationLogService; |
| | | private final OrderService orderService; |
| | | private final OrderReturnProductSnapshotService productSnapshotService; |
| | | private final RedisUtils redisUtils; |
| | | private final SwiftPassService swiftPassService; |
| | | private final OrderAddressSnapshotService addressSnapshotService; |
| | | private static final String ORDER_RETURN_KEY = "oying:order:refund"; |
| | | private static final String ORDER_CODE = "REFUND"; |
| | | |
| | | @Override |
| | | public PageResult<OrderReturn> queryAll(OrderReturnQueryCriteria criteria, Page<Object> page) { |
| | |
| | | } |
| | | |
| | | @Override |
| | | public OrderReturn getByReturnNum(String returnNum) { |
| | | return orderReturnMapper.getByReturnNum(returnNum); |
| | | public OrderReturnResponse getByReturnNum(String returnNum) { |
| | | OrderReturn orderReturn = orderReturnMapper.getByReturnNum(returnNum); |
| | | return new OrderReturnResponse(orderReturn, |
| | | addressSnapshotService.queryByOrderNum(orderReturn.getOrderNum()), |
| | | operationLogService.getByOrderNum(orderReturn.getOrderNum(), ORDER_CODE)); |
| | | } |
| | | |
| | | @Override |
| | | public void updatePayStatus(String returnNum, String status, String time) { |
| | | orderReturnMapper.updatePayStatus(returnNum, status, time); |
| | | public void updatePayStatus(String returnNum, String refundStatus, String successTime) { |
| | | orderReturnMapper.updatePayStatus(returnNum, refundStatus, successTime); |
| | | } |
| | | |
| | | @Override |
| | |
| | | returnOrder.setPhotos(resources.getPhotos()); |
| | | returnOrder.setAuditStatus(ReturnAuditEnum.ZERO.getKey()); |
| | | orderReturnMapper.insert(returnOrder); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void cancel(String returnNum) { |
| | | OrderReturn orderReturn = orderReturnMapper.getByReturnNum(returnNum); |
| | | if (orderReturn == null) { |
| | | throw new BadRequestException("订单不存在!"); |
| | | } |
| | | if (!orderReturn.getUserId().equals(SecurityUtils.getCurrentUserId())) { |
| | | throw new BadRequestException("不能修改他人订单"); |
| | | } |
| | | orderReturnMapper.updateStatus(returnNum, OrderStatusEnum.FIFTEEN.getKey(), OrderStatusEnum.FIFTEEN.getValue(), |
| | | ReturnAuditEnum.THREE.getKey()); |
| | | OrderResponse response = orderService.getByOrderNum(orderReturn.getOrderNum()); |
| | | operationLogService.create(response, OrderStatusEnum.FIFTEEN, null); |
| | | } |
| | | |
| | | @Override |
| | |
| | | public synchronized void audit(AuditOrderReturn resources) { |
| | | OrderReturn orderReturn = orderReturnMapper.getByReturnNum(resources.getReturnNum()); |
| | | if (orderReturn == null) { |
| | | throw new BadRequestException("订单不存在"); |
| | | throw new BadRequestException("订单不存在!"); |
| | | } |
| | | if (!Objects.equals(orderReturn.getReturnStatus(), ReturnAuditEnum.ZERO.getKey())) { |
| | | throw new BadRequestException("订单已处理或取消"); |
| | |
| | | // 审核信息 |
| | | orderReturn.setAuditMessage(resources.getMessage()); |
| | | orderReturnMapper.updateById(orderReturn); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void deleteAll(List<Long> ids) { |
| | | orderReturnMapper.deleteBatchIds(ids); |
| | | } |
| | | |
| | | @Override |