|
@@ -12,10 +12,15 @@ import com.haha.common.vo.PageResult;
|
|
|
import com.haha.common.vo.Result;
|
|
import com.haha.common.vo.Result;
|
|
|
import com.haha.entity.Order;
|
|
import com.haha.entity.Order;
|
|
|
import com.haha.service.OrderService;
|
|
import com.haha.service.OrderService;
|
|
|
|
|
+import com.haha.service.payment.payscore.PayScoreCancelRequest;
|
|
|
|
|
+import com.haha.service.payment.payscore.PayScoreResult;
|
|
|
|
|
+import com.haha.service.payment.payscore.PayScoreStrategy;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -29,23 +34,24 @@ public class OrderController {
|
|
|
|
|
|
|
|
private final OrderService orderService;
|
|
private final OrderService orderService;
|
|
|
|
|
|
|
|
|
|
+ @Autowired(required = false)
|
|
|
|
|
+ private PayScoreStrategy payScoreStrategy;
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 分页查询订单列表
|
|
* 分页查询订单列表
|
|
|
- * @param queryDTO 查询参数
|
|
|
|
|
- * @return 订单列表
|
|
|
|
|
*/
|
|
*/
|
|
|
@RequirePermission("order:read")
|
|
@RequirePermission("order:read")
|
|
|
@GetMapping("/list")
|
|
@GetMapping("/list")
|
|
|
public Result<PageResult<Order>> list(OrderQueryDTO queryDTO) {
|
|
public Result<PageResult<Order>> list(OrderQueryDTO queryDTO) {
|
|
|
- log.info("订单列表查询参数:page={}, pageSize={}, orderNo={}, deviceId={}, phone={}, status={}, statusList={}",
|
|
|
|
|
- queryDTO.getPage(), queryDTO.getPageSize(),
|
|
|
|
|
|
|
+ log.info("订单列表查询参数:page={}, pageSize={}, orderNo={}, deviceId={}, phone={}, status={}, statusList={}",
|
|
|
|
|
+ queryDTO.getPage(), queryDTO.getPageSize(),
|
|
|
queryDTO.getOrderNo(), queryDTO.getDeviceId(),
|
|
queryDTO.getOrderNo(), queryDTO.getDeviceId(),
|
|
|
queryDTO.getPhone(), queryDTO.getStatus(), queryDTO.getStatusList());
|
|
queryDTO.getPhone(), queryDTO.getStatus(), queryDTO.getStatusList());
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
queryDTO.validate();
|
|
queryDTO.validate();
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
IPage<Order> orderPage = orderService.getPage(
|
|
IPage<Order> orderPage = orderService.getPage(
|
|
|
- queryDTO.getPage(),
|
|
|
|
|
|
|
+ queryDTO.getPage(),
|
|
|
queryDTO.getPageSize(),
|
|
queryDTO.getPageSize(),
|
|
|
queryDTO.getOrderNo(),
|
|
queryDTO.getOrderNo(),
|
|
|
queryDTO.getDeviceId(),
|
|
queryDTO.getDeviceId(),
|
|
@@ -62,8 +68,6 @@ public class OrderController {
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 获取订单详情(包含商品列表)
|
|
* 获取订单详情(包含商品列表)
|
|
|
- * @param id 订单ID
|
|
|
|
|
- * @return 订单详情
|
|
|
|
|
*/
|
|
*/
|
|
|
@RequirePermission("order:read")
|
|
@RequirePermission("order:read")
|
|
|
@GetMapping("/{id}")
|
|
@GetMapping("/{id}")
|
|
@@ -77,9 +81,6 @@ public class OrderController {
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 获取订单统计数据
|
|
* 获取订单统计数据
|
|
|
- * @param startDate 开始日期
|
|
|
|
|
- * @param endDate 结束日期
|
|
|
|
|
- * @return 统计数据
|
|
|
|
|
*/
|
|
*/
|
|
|
@RequirePermission("order:read")
|
|
@RequirePermission("order:read")
|
|
|
@GetMapping("/statistics")
|
|
@GetMapping("/statistics")
|
|
@@ -92,9 +93,6 @@ public class OrderController {
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 订单退款
|
|
* 订单退款
|
|
|
- * @param id 订单ID
|
|
|
|
|
- * @param params 退款参数
|
|
|
|
|
- * @return 退款结果
|
|
|
|
|
*/
|
|
*/
|
|
|
@RequirePermission("order:update")
|
|
@RequirePermission("order:update")
|
|
|
@Log(module = "订单管理", operation = OperationType.UPDATE, summary = "订单退款")
|
|
@Log(module = "订单管理", operation = OperationType.UPDATE, summary = "订单退款")
|
|
@@ -103,4 +101,46 @@ public class OrderController {
|
|
|
boolean success = orderService.refund(id, dto.getReason());
|
|
boolean success = orderService.refund(id, dto.getReason());
|
|
|
return success ? Result.success("退款成功", null) : Result.error(500, "退款失败");
|
|
return success ? Result.success("退款成功", null) : Result.error(500, "退款失败");
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 手动取消支付分订单(通过 outOrderNo 直接调用微信支付分取消API)
|
|
|
|
|
+ */
|
|
|
|
|
+ @RequirePermission("order:update")
|
|
|
|
|
+ @Log(module = "订单管理", operation = OperationType.UPDATE, summary = "手动取消支付分订单")
|
|
|
|
|
+ @PostMapping("/payscore/cancel")
|
|
|
|
|
+ public Result<Map<String, Object>> cancelPayScore(@RequestBody Map<String, String> params) {
|
|
|
|
|
+ if (payScoreStrategy == null) {
|
|
|
|
|
+ return Result.error(500, "支付分服务未配置,无法取消");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ String outOrderNo = params.get("outOrderNo");
|
|
|
|
|
+ if (outOrderNo == null || outOrderNo.trim().isEmpty()) {
|
|
|
|
|
+ return Result.error(400, "outOrderNo 不能为空");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ String reason = params.getOrDefault("reason", "管理员手动取消");
|
|
|
|
|
+
|
|
|
|
|
+ try {
|
|
|
|
|
+ PayScoreCancelRequest cancelReq = new PayScoreCancelRequest();
|
|
|
|
|
+ cancelReq.setOutOrderNo(outOrderNo.trim());
|
|
|
|
|
+ cancelReq.setReason(reason);
|
|
|
|
|
+
|
|
|
|
|
+ PayScoreResult result = payScoreStrategy.cancelServiceOrder(cancelReq);
|
|
|
|
|
+
|
|
|
|
|
+ Map<String, Object> data = new HashMap<>();
|
|
|
|
|
+ data.put("outOrderNo", outOrderNo);
|
|
|
|
|
+ data.put("success", result.isSuccess());
|
|
|
|
|
+ if (result.isSuccess()) {
|
|
|
|
|
+ data.put("state", result.getState());
|
|
|
|
|
+ return Result.success("支付分订单取消成功", data);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ data.put("errorCode", result.getErrorCode());
|
|
|
|
|
+ data.put("errorMsg", result.getErrorMsg());
|
|
|
|
|
+ return Result.error(500, "取消失败: " + result.getErrorMsg());
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log.error("手动取消支付分订单失败 - outOrderNo: {}", outOrderNo, e);
|
|
|
|
|
+ return Result.error(500, "取消异常: " + e.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|