fix(withdrawal): preserve callback HTTP status
This commit is contained in:
parent
4ebfb3cc6b
commit
c09787831c
@ -1,6 +1,8 @@
|
|||||||
package com.red.circle.console.adapter.integration;
|
package com.red.circle.console.adapter.integration;
|
||||||
|
|
||||||
import com.red.circle.console.app.service.app.user.UserBankBalanceBackService;
|
import com.red.circle.console.app.service.app.user.UserBankBalanceBackService;
|
||||||
|
import com.red.circle.framework.core.asserts.ResponseAssert;
|
||||||
|
import com.red.circle.framework.core.response.ResponseErrorCode;
|
||||||
import com.red.circle.wallet.inner.model.cmd.ApprovalMoneyApplyCmd;
|
import com.red.circle.wallet.inner.model.cmd.ApprovalMoneyApplyCmd;
|
||||||
import jakarta.validation.Valid;
|
import jakarta.validation.Valid;
|
||||||
import jakarta.validation.constraints.NotBlank;
|
import jakarta.validation.constraints.NotBlank;
|
||||||
@ -12,7 +14,6 @@ import java.util.List;
|
|||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.http.HttpStatus;
|
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
@ -20,7 +21,6 @@ import org.springframework.web.bind.annotation.RequestBody;
|
|||||||
import org.springframework.web.bind.annotation.RequestHeader;
|
import org.springframework.web.bind.annotation.RequestHeader;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
import org.springframework.web.server.ResponseStatusException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* hyapp-server 统一提现双审对 ChatApp3/Yumi 钱包的终态回调入口.
|
* hyapp-server 统一提现双审对 ChatApp3/Yumi 钱包的终态回调入口.
|
||||||
@ -43,22 +43,24 @@ public class WithdrawalReviewIntegrationController {
|
|||||||
@RequestHeader(value = "Authorization", required = false) String authorization,
|
@RequestHeader(value = "Authorization", required = false) String authorization,
|
||||||
@RequestBody @Valid DecisionRequest request) {
|
@RequestBody @Valid DecisionRequest request) {
|
||||||
verifyToken(authorization);
|
verifyToken(authorization);
|
||||||
if (!"PASS".equals(request.getDecision()) && !"NOT_PASS".equals(request.getDecision())) {
|
// Console 的全局异常处理器只识别框架 ResponseException;使用统一断言才能保留
|
||||||
throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "invalid withdrawal decision");
|
// 401/400 HTTP 语义,避免 Admin 把确定性的鉴权或参数错误误当成 500 后持续重试。
|
||||||
}
|
ResponseAssert.isTrue(ResponseErrorCode.REQUEST_PARAMETER_ERROR,
|
||||||
if ("PASS".equals(request.getDecision())
|
"invalid withdrawal decision",
|
||||||
&& (request.getCredentialUrls() == null || request.getCredentialUrls().isEmpty())) {
|
"PASS".equals(request.getDecision()) || "NOT_PASS".equals(request.getDecision()));
|
||||||
// 财务通过必须带打款凭证;来源钱包再次校验,不能只依赖 Admin 前端门禁。
|
ResponseAssert.isTrue(ResponseErrorCode.REQUEST_PARAMETER_ERROR,
|
||||||
throw new ResponseStatusException(HttpStatus.BAD_REQUEST,
|
"withdrawal approval credential is required",
|
||||||
"withdrawal approval credential is required");
|
!"PASS".equals(request.getDecision())
|
||||||
}
|
|| (request.getCredentialUrls() != null && !request.getCredentialUrls().isEmpty()));
|
||||||
|
|
||||||
long sourceApplicationId;
|
long sourceApplicationId;
|
||||||
try {
|
try {
|
||||||
sourceApplicationId = Long.parseLong(request.getSourceApplicationId());
|
sourceApplicationId = Long.parseLong(request.getSourceApplicationId());
|
||||||
} catch (NumberFormatException exception) {
|
} catch (NumberFormatException exception) {
|
||||||
throw new ResponseStatusException(HttpStatus.BAD_REQUEST,
|
ResponseAssert.failure(ResponseErrorCode.REQUEST_PARAMETER_ERROR,
|
||||||
"invalid source withdrawal application id", exception);
|
"invalid source withdrawal application id");
|
||||||
|
// failure 必然抛出 ResponseException;赋值只为满足 Java 的确定赋值检查。
|
||||||
|
sourceApplicationId = 0L;
|
||||||
}
|
}
|
||||||
userBankBalanceBackService.approvalMoneyApply(new ApprovalMoneyApplyCmd()
|
userBankBalanceBackService.approvalMoneyApply(new ApprovalMoneyApplyCmd()
|
||||||
.setId(sourceApplicationId)
|
.setId(sourceApplicationId)
|
||||||
@ -76,10 +78,8 @@ public class WithdrawalReviewIntegrationController {
|
|||||||
boolean valid = !provided.isEmpty() && !expected.isEmpty()
|
boolean valid = !provided.isEmpty() && !expected.isEmpty()
|
||||||
&& MessageDigest.isEqual(provided.getBytes(StandardCharsets.UTF_8),
|
&& MessageDigest.isEqual(provided.getBytes(StandardCharsets.UTF_8),
|
||||||
expected.getBytes(StandardCharsets.UTF_8));
|
expected.getBytes(StandardCharsets.UTF_8));
|
||||||
if (!valid) {
|
ResponseAssert.isTrue(ResponseErrorCode.UNAUTHORIZED,
|
||||||
throw new ResponseStatusException(HttpStatus.UNAUTHORIZED,
|
"withdrawal callback authentication failed", valid);
|
||||||
"withdrawal callback authentication failed");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user