From e92685e32285d8d631dc0dcea0a55a36e18311b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=81=E5=AE=87=E5=A5=87?= Date: Sun, 13 Jul 2025 16:43:19 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/xkt/StoreOrderController.java | 37 +++++++ .../vo/order/PlatformInvolveApplyReqVO.java | 25 +++++ .../vo/order/PlatformInvolveCompleteVO.java | 25 +++++ .../xkt/vo/order/RefundCompleteVO.java | 21 ++++ .../xkt/vo/order/StoreOrderInfoVO.java | 6 ++ .../xkt/vo/order/StoreOrderPageItemVO.java | 6 ++ .../xkt/vo/order/StoreOrderQueryVO.java | 2 +- .../java/com/ruoyi/xkt/domain/StoreOrder.java | 8 ++ .../ruoyi/xkt/dto/order/StoreOrderDTO.java | 8 ++ .../com/ruoyi/xkt/enums/EOrderAction.java | 3 + .../ruoyi/xkt/service/IStoreOrderService.java | 31 ++++++ .../service/impl/StoreOrderServiceImpl.java | 102 ++++++++++++++++++ 12 files changed, 273 insertions(+), 1 deletion(-) create mode 100644 ruoyi-admin/src/main/java/com/ruoyi/web/controller/xkt/vo/order/PlatformInvolveApplyReqVO.java create mode 100644 ruoyi-admin/src/main/java/com/ruoyi/web/controller/xkt/vo/order/PlatformInvolveCompleteVO.java create mode 100644 ruoyi-admin/src/main/java/com/ruoyi/web/controller/xkt/vo/order/RefundCompleteVO.java diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/xkt/StoreOrderController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/xkt/StoreOrderController.java index 769c05c9c..ce1775b0d 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/xkt/StoreOrderController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/xkt/StoreOrderController.java @@ -15,6 +15,7 @@ import com.ruoyi.common.exception.ServiceException; import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.framework.notice.fs.FsNotice; import com.ruoyi.web.controller.xkt.vo.order.*; +import com.ruoyi.xkt.domain.StoreOrder; import com.ruoyi.xkt.domain.StoreOrderDetail; import com.ruoyi.xkt.dto.express.ExpressCancelReqDTO; import com.ruoyi.xkt.dto.express.ExpressInterceptReqDTO; @@ -268,6 +269,42 @@ public class StoreOrderController extends XktBaseController { return success(afterSaleApplyResult.getStoreOrderId()); } + @PreAuthorize("@ss.hasAnyRoles('seller,store')||@ss.hasSupplierSubRole()") + @Log(title = "订单", businessType = BusinessType.OTHER) + @ApiOperation("申请平台介入") + @PostMapping("platform-involve/apply") + public R applyPlatformInvolve(@Valid @RequestBody PlatformInvolveApplyReqVO vo) { + Long orderId = vo.getStoreOrderId(); + Long userId = SecurityUtils.getUserId(); + Long storeId = SecurityUtils.getStoreId(); + StoreOrder order = storeOrderService.getById(orderId); + Assert.notNull(order, "订单不存在"); + if (Objects.equals(order.getStoreId(), storeId) + || Objects.equals(order.getOrderUserId(), userId)) { + storeOrderService.applyPlatformInvolve(orderId, vo.getPlatformInvolveReason()); + return R.ok(orderId); + } + return R.fail("无权限"); + } + + @PreAuthorize("@ss.hasAnyRoles('admin,general_admin')") + @Log(title = "订单", businessType = BusinessType.OTHER) + @ApiOperation("平台介入完成(管理员)") + @PostMapping("platform-involve/complete") + public R completePlatformInvolve(@Valid @RequestBody PlatformInvolveCompleteVO vo) { + storeOrderService.completePlatformInvolve(vo.getStoreOrderId(), vo.getPlatformInvolveResult()); + return R.ok(vo.getStoreOrderId()); + } + + @PreAuthorize("@ss.hasAnyRoles('seller')") + @Log(title = "订单", businessType = BusinessType.OTHER) + @ApiOperation("售后完成(用户)") + @PostMapping("refund/complete") + public R completeRefundByUser(@Valid @RequestBody RefundCompleteVO vo) { + storeOrderService.completeRefundByUser(vo.getStoreOrderId()); + return R.ok(vo.getStoreOrderId()); + } + @PreAuthorize("@ss.hasAnyRoles('admin,general_admin,store')||@ss.hasSupplierSubRole()") @Log(title = "订单", businessType = BusinessType.OTHER) @ApiOperation("确认退款") diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/xkt/vo/order/PlatformInvolveApplyReqVO.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/xkt/vo/order/PlatformInvolveApplyReqVO.java new file mode 100644 index 000000000..342156fad --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/xkt/vo/order/PlatformInvolveApplyReqVO.java @@ -0,0 +1,25 @@ +package com.ruoyi.web.controller.xkt.vo.order; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotNull; + +/** + * @author liangyq + * @date 2025-07-12 + */ +@ApiModel +@Data +public class PlatformInvolveApplyReqVO { + + @NotNull(message = "订单ID不能为空") + @ApiModelProperty(value = "订单ID", required = true) + private Long storeOrderId; + + @NotNull(message = "平台介入原因不能为空") + @ApiModelProperty(value = "平台介入原因", required = true) + private String platformInvolveReason; + +} diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/xkt/vo/order/PlatformInvolveCompleteVO.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/xkt/vo/order/PlatformInvolveCompleteVO.java new file mode 100644 index 000000000..26655855e --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/xkt/vo/order/PlatformInvolveCompleteVO.java @@ -0,0 +1,25 @@ +package com.ruoyi.web.controller.xkt.vo.order; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotNull; + +/** + * @author liangyq + * @date 2025-07-12 + */ +@ApiModel +@Data +public class PlatformInvolveCompleteVO { + + @NotNull(message = "订单ID不能为空") + @ApiModelProperty(value = "订单ID", required = true) + private Long storeOrderId; + + @NotNull(message = "平台介入处理结果不能为空") + @ApiModelProperty(value = "平台介入处理结果", required = true) + private String platformInvolveResult; + +} diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/xkt/vo/order/RefundCompleteVO.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/xkt/vo/order/RefundCompleteVO.java new file mode 100644 index 000000000..512219b99 --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/xkt/vo/order/RefundCompleteVO.java @@ -0,0 +1,21 @@ +package com.ruoyi.web.controller.xkt.vo.order; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotNull; + +/** + * @author liangyq + * @date 2025-07-12 + */ +@ApiModel +@Data +public class RefundCompleteVO { + + @NotNull(message = "订单ID不能为空") + @ApiModelProperty(value = "订单ID", required = true) + private Long storeOrderId; + +} diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/xkt/vo/order/StoreOrderInfoVO.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/xkt/vo/order/StoreOrderInfoVO.java index 34f3a46da..c8131ccfe 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/xkt/vo/order/StoreOrderInfoVO.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/xkt/vo/order/StoreOrderInfoVO.java @@ -446,6 +446,12 @@ public class StoreOrderInfoVO { @ApiModelProperty(value = "档口地址") private String storeAddress; + @ApiModelProperty(value = "平台介入原因") + private String platformInvolveReason; + + @ApiModelProperty(value = "平台介入结果") + private String platformInvolveResult; + } @ApiModel diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/xkt/vo/order/StoreOrderPageItemVO.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/xkt/vo/order/StoreOrderPageItemVO.java index 1b5ae603d..b6039e982 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/xkt/vo/order/StoreOrderPageItemVO.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/xkt/vo/order/StoreOrderPageItemVO.java @@ -250,6 +250,12 @@ public class StoreOrderPageItemVO extends StoreOrderDTO { @ApiModelProperty(value = "订单明细") private List orderDetails; + @ApiModelProperty(value = "平台介入原因") + private String platformInvolveReason; + + @ApiModelProperty(value = "平台介入结果") + private String platformInvolveResult; + @ApiModel @Data public static class Detail { diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/xkt/vo/order/StoreOrderQueryVO.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/xkt/vo/order/StoreOrderQueryVO.java index 971930556..3cc381bf6 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/xkt/vo/order/StoreOrderQueryVO.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/xkt/vo/order/StoreOrderQueryVO.java @@ -92,7 +92,7 @@ public class StoreOrderQueryVO extends BasePageVO { private String prodArtNum; @NotNull(message = "来源页面不能为空") - @ApiModelProperty(value = "来源页面[1:卖家订单列表 2:档口订单列表]", required = true) + @ApiModelProperty(value = "来源页面[1:卖家订单列表 2:档口/平台订单列表]", required = true) private Integer srcPage; } diff --git a/xkt/src/main/java/com/ruoyi/xkt/domain/StoreOrder.java b/xkt/src/main/java/com/ruoyi/xkt/domain/StoreOrder.java index 12656df95..07f05cf46 100644 --- a/xkt/src/main/java/com/ruoyi/xkt/domain/StoreOrder.java +++ b/xkt/src/main/java/com/ruoyi/xkt/domain/StoreOrder.java @@ -155,6 +155,14 @@ public class StoreOrder extends SimpleEntity { * 凭证日期 */ private Date voucherDate; + /** + * 平台介入原因 + */ + private String platformInvolveReason; + /** + * 平台介入结果 + */ + private String platformInvolveResult; /** * 版本号 */ diff --git a/xkt/src/main/java/com/ruoyi/xkt/dto/order/StoreOrderDTO.java b/xkt/src/main/java/com/ruoyi/xkt/dto/order/StoreOrderDTO.java index 0766e5b2d..447894b34 100644 --- a/xkt/src/main/java/com/ruoyi/xkt/dto/order/StoreOrderDTO.java +++ b/xkt/src/main/java/com/ruoyi/xkt/dto/order/StoreOrderDTO.java @@ -173,6 +173,14 @@ public class StoreOrderDTO { * 更新时间 */ private Date updateTime; + /** + * 平台介入原因 + */ + private String platformInvolveReason; + /** + * 平台介入结果 + */ + private String platformInvolveResult; /** * 版本号 */ diff --git a/xkt/src/main/java/com/ruoyi/xkt/enums/EOrderAction.java b/xkt/src/main/java/com/ruoyi/xkt/enums/EOrderAction.java index 5130d2a80..ee1466db9 100644 --- a/xkt/src/main/java/com/ruoyi/xkt/enums/EOrderAction.java +++ b/xkt/src/main/java/com/ruoyi/xkt/enums/EOrderAction.java @@ -22,6 +22,9 @@ public enum EOrderAction { REJECT_AFTER_SALE(9, "拒绝售后"), CONFIRM_AFTER_SALE(10, "确认售后"), REFUND(11, "退款"), + APPLY_PLATFORM_INVOLVE(12, "申请平台介入"), + COMPLETE_PLATFORM_INVOLVE(13, "平台介入完成"), + USER_COMPLETE_AFTER_SALE(14, "用户确认售后完成"), ; private final Integer value; diff --git a/xkt/src/main/java/com/ruoyi/xkt/service/IStoreOrderService.java b/xkt/src/main/java/com/ruoyi/xkt/service/IStoreOrderService.java index be94d17e9..5e87d0a46 100644 --- a/xkt/src/main/java/com/ruoyi/xkt/service/IStoreOrderService.java +++ b/xkt/src/main/java/com/ruoyi/xkt/service/IStoreOrderService.java @@ -45,6 +45,14 @@ public interface IStoreOrderService { */ StoreOrder getByOrderNo(String orderNo); + /** + * 通过ID获取订单 + * + * @param id + * @return + */ + StoreOrder getById(Long id); + /** * 获取订单详情 * @@ -218,4 +226,27 @@ public interface IStoreOrderService { * @param storeId */ void checkOrderStore(Collection storeOrderDetailIds, Long storeId); + + /** + * 申请平台介入 + * + * @param storeOrderId + * @param platformInvolveReason + */ + void applyPlatformInvolve(Long storeOrderId, String platformInvolveReason); + + /** + * 平台介入完成 + * + * @param storeOrderId + * @param platformInvolveResult + */ + void completePlatformInvolve(Long storeOrderId, String platformInvolveResult); + + /** + * 售后完成 + * + * @param storeOrderId + */ + void completeRefundByUser(Long storeOrderId); } diff --git a/xkt/src/main/java/com/ruoyi/xkt/service/impl/StoreOrderServiceImpl.java b/xkt/src/main/java/com/ruoyi/xkt/service/impl/StoreOrderServiceImpl.java index 4cfba48db..5ce1620f2 100644 --- a/xkt/src/main/java/com/ruoyi/xkt/service/impl/StoreOrderServiceImpl.java +++ b/xkt/src/main/java/com/ruoyi/xkt/service/impl/StoreOrderServiceImpl.java @@ -359,6 +359,11 @@ public class StoreOrderServiceImpl implements IStoreOrderService { .eq(StoreOrder::getOrderNo, orderNo)); } + @Override + public StoreOrder getById(Long id) { + return storeOrderMapper.selectById(id); + } + @Override public StoreOrderInfoDTO getInfo(Long storeOrderId) { StoreOrder order = storeOrderMapper.selectById(storeOrderId); @@ -1349,6 +1354,103 @@ public class StoreOrderServiceImpl implements IStoreOrderService { storeOrderIds.forEach(id -> checkOrderStore(id, storeId)); } + @Transactional(rollbackFor = Exception.class) + @Override + public void applyPlatformInvolve(Long storeOrderId, String platformInvolveReason) { + StoreOrder order = getAndBaseCheck(storeOrderId); + if (!EOrderStatus.AFTER_SALE_IN_PROGRESS.getValue().equals(order.getOrderStatus()) + && !EOrderStatus.AFTER_SALE_REJECTED.getValue().equals(order.getOrderStatus())) { + throw new ServiceException(CharSequenceUtil.format("订单[{}]状态异常", order.getId())); + } + order.setOrderStatus(EOrderStatus.PLATFORM_INTERVENED.getValue()); + order.setPlatformInvolveReason(platformInvolveReason); + int orderSuccess = storeOrderMapper.updateById(prepareUpdate(order)); + if (orderSuccess == 0) { + throw new ServiceException(Constants.VERSION_LOCK_ERROR_COMMON_MSG); + } + //操作记录 + addOperationRecords(order.getId(), + EOrderAction.APPLY_PLATFORM_INVOLVE, + null, + EOrderAction.APPLY_PLATFORM_INVOLVE, + SecurityUtils.getUserIdSafe(), + new Date()); + } + + @Transactional(rollbackFor = Exception.class) + @Override + public void completePlatformInvolve(Long storeOrderId, String platformInvolveResult) { + StoreOrder order = getAndBaseCheck(storeOrderId); + if (!EOrderStatus.PLATFORM_INTERVENED.getValue().equals(order.getOrderStatus())) { + throw new ServiceException(CharSequenceUtil.format("订单[{}]状态异常", order.getId())); + } + List incompleteOrderDetails = storeOrderDetailMapper.selectList(Wrappers + .lambdaQuery(StoreOrderDetail.class) + .eq(StoreOrderDetail::getStoreOrderId, order.getId()) + //售后未完成明细 + .ne(StoreOrderDetail::getDetailStatus, EOrderStatus.AFTER_SALE_COMPLETED) + .eq(SimpleEntity::getDelFlag, Constants.UNDELETED)); + List storeOrderDetailIds = new ArrayList<>(incompleteOrderDetails.size()); + for (StoreOrderDetail storeOrderDetail : incompleteOrderDetails) { + storeOrderDetail.setDetailStatus(EOrderStatus.AFTER_SALE_COMPLETED.getValue()); + int orderDetailSuccess = storeOrderDetailMapper.updateById(prepareUpdate(storeOrderDetail)); + if (orderDetailSuccess == 0) { + throw new ServiceException(Constants.VERSION_LOCK_ERROR_COMMON_MSG); + } + storeOrderDetailIds.add(storeOrderDetail.getId()); + } + order.setOrderStatus(EOrderStatus.AFTER_SALE_COMPLETED.getValue()); + order.setPlatformInvolveResult(platformInvolveResult); + int orderSuccess = storeOrderMapper.updateById(prepareUpdate(order)); + if (orderSuccess == 0) { + throw new ServiceException(Constants.VERSION_LOCK_ERROR_COMMON_MSG); + } + //操作记录 + addOperationRecords(order.getId(), + EOrderAction.COMPLETE_PLATFORM_INVOLVE, + storeOrderDetailIds, + EOrderAction.COMPLETE_PLATFORM_INVOLVE, + SecurityUtils.getUserIdSafe(), + new Date()); + } + + @Transactional(rollbackFor = Exception.class) + @Override + public void completeRefundByUser(Long storeOrderId) { + StoreOrder order = getAndBaseCheck(storeOrderId); + if (!EOrderStatus.AFTER_SALE_IN_PROGRESS.getValue().equals(order.getOrderStatus()) + && !EOrderStatus.AFTER_SALE_REJECTED.getValue().equals(order.getOrderStatus())) { + throw new ServiceException(CharSequenceUtil.format("订单[{}]状态异常", order.getId())); + } + List incompleteOrderDetails = storeOrderDetailMapper.selectList(Wrappers + .lambdaQuery(StoreOrderDetail.class) + .eq(StoreOrderDetail::getStoreOrderId, order.getId()) + //售后未完成明细 + .ne(StoreOrderDetail::getDetailStatus, EOrderStatus.AFTER_SALE_COMPLETED) + .eq(SimpleEntity::getDelFlag, Constants.UNDELETED)); + List storeOrderDetailIds = new ArrayList<>(incompleteOrderDetails.size()); + for (StoreOrderDetail storeOrderDetail : incompleteOrderDetails) { + storeOrderDetail.setDetailStatus(EOrderStatus.AFTER_SALE_COMPLETED.getValue()); + int orderDetailSuccess = storeOrderDetailMapper.updateById(prepareUpdate(storeOrderDetail)); + if (orderDetailSuccess == 0) { + throw new ServiceException(Constants.VERSION_LOCK_ERROR_COMMON_MSG); + } + storeOrderDetailIds.add(storeOrderDetail.getId()); + } + order.setOrderStatus(EOrderStatus.AFTER_SALE_COMPLETED.getValue()); + int orderSuccess = storeOrderMapper.updateById(prepareUpdate(order)); + if (orderSuccess == 0) { + throw new ServiceException(Constants.VERSION_LOCK_ERROR_COMMON_MSG); + } + //操作记录 + addOperationRecords(order.getId(), + EOrderAction.USER_COMPLETE_AFTER_SALE, + storeOrderDetailIds, + EOrderAction.USER_COMPLETE_AFTER_SALE, + SecurityUtils.getUserIdSafe(), + new Date()); + } + /** * 添加操作记录 *