feat: 新增退单操作接口及相关逻辑
主要修改: 1. 在LinkController中新增退单操作接口,支持用户对指定链接进行退单。 2. 在LinkStatusService中实现退单逻辑,确保用户只能退单自己的链接,并更新链接状态。 3. 在ScriptClient中新增调用退单接口的方法,处理与外部系统的交互。 技术细节: - 通过新增的退单功能,提升了用户对链接的管理能力,确保操作的安全性和有效性。
This commit is contained in:
@@ -253,6 +253,49 @@ public Mono<Boolean> deleteLink(@PathVariable("codeNo") String codeNo, Authentic
|
||||
});
|
||||
}
|
||||
|
||||
@PostMapping("/{codeNo}/refund")
|
||||
@Operation(summary = "退单操作", description = "对指定链接进行退单操作,会调用外部退单接口并更新数据库状态")
|
||||
public Mono<Boolean> refundOrder(@PathVariable("codeNo") String codeNo, Authentication authentication) {
|
||||
log.info("=== 开始退单操作 ===");
|
||||
log.info("链接编号: {}", codeNo);
|
||||
|
||||
if (authentication == null) {
|
||||
log.error("=== 认证失败:Authentication为空 ===");
|
||||
return Mono.error(new IllegalArgumentException("用户未认证:Authentication为空"));
|
||||
}
|
||||
|
||||
// 获取用户ID
|
||||
Claims claims = (Claims) authentication.getDetails();
|
||||
if (claims == null) {
|
||||
log.error("=== 认证失败:Claims为空 ===");
|
||||
log.error("Authentication details: {}", authentication.getDetails());
|
||||
return Mono.error(new IllegalArgumentException("用户未认证:Claims为空"));
|
||||
}
|
||||
|
||||
Long agentId = claims.get("userId", Long.class);
|
||||
String userType = claims.get("userType", String.class);
|
||||
|
||||
log.info("用户信息: agentId={}, userType={}", agentId, userType);
|
||||
|
||||
if (agentId == null) {
|
||||
log.error("=== 无法获取用户ID ===");
|
||||
return Mono.error(new IllegalArgumentException("无法获取用户ID"));
|
||||
}
|
||||
|
||||
return linkStatusService.refundOrder(codeNo, agentId)
|
||||
.doOnSuccess(success -> {
|
||||
if (success) {
|
||||
log.info("退单操作成功: codeNo={}, agentId={}", codeNo, agentId);
|
||||
} else {
|
||||
log.warn("退单操作失败: codeNo={}, agentId={}", codeNo, agentId);
|
||||
}
|
||||
})
|
||||
.doOnError(error -> {
|
||||
log.error("退单操作时发生错误: codeNo={}, agentId={}, error={}",
|
||||
codeNo, agentId, error.getMessage(), error);
|
||||
});
|
||||
}
|
||||
|
||||
@PostMapping("/batch-delete")
|
||||
@Operation(summary = "批量删除链接", description = "批量删除指定的链接,用户只能删除自己创建的链接,最多一次删除100个")
|
||||
public Mono<BatchDeleteResponse> batchDeleteLinks(@RequestBody BatchDeleteRequest request, Authentication authentication) {
|
||||
|
||||
Reference in New Issue
Block a user