fix:支付宝支付
This commit is contained in:
+6
-9
@@ -5,9 +5,11 @@ import com.central.alipay.entity.AlipayConfig;
|
||||
import com.central.alipay.notify.AlipayNotifyVerifier;
|
||||
import com.central.alipay.service.AlipayPayService;
|
||||
import com.central.alipay.service.AlipayRefundService;
|
||||
import com.central.common.context.LoginUserContextHolder;
|
||||
import com.central.common.context.TenantContextHolder;
|
||||
import com.central.common.feign.UserService;
|
||||
import com.central.common.model.LoginAppUser;
|
||||
import com.central.common.model.Result;
|
||||
import com.central.common.model.SysUser;
|
||||
import com.central.common.utils.SecurityTenantUtils;
|
||||
import com.central.order.enums.OrderStatus;
|
||||
@@ -83,7 +85,7 @@ public class AliPayController {
|
||||
required = true,
|
||||
content = @Content(schema = @Schema(example = "{\"orderId\": 1001, \"buyerId\": \"2088xxxxxxxxxxxx\"}")))
|
||||
@PostMapping("/order/pay")
|
||||
public Map<String, Object> payOrder(@RequestBody Map<String, Object> body) {
|
||||
public Result<AlipayTradeCreateResponse> payOrder(@RequestBody Map<String, Object> body) {
|
||||
Object rawOrderId = body.get("orderId");
|
||||
Assert.notNull(rawOrderId, "orderId 不能为空");
|
||||
Long orderId = Long.valueOf(rawOrderId.toString());
|
||||
@@ -91,7 +93,7 @@ public class AliPayController {
|
||||
Assert.notNull(order, "订单不存在: " + orderId);
|
||||
|
||||
// 校验当前登录用户拥有该订单(防止替他人订单发起支付)
|
||||
LoginAppUser currentUser = SecurityTenantUtils.getCurrentUser();
|
||||
LoginAppUser currentUser = LoginUserContextHolder.getUser();
|
||||
Assert.notNull(currentUser, "未登录或登录已过期");
|
||||
if (order.getUserId() == null || !order.getUserId().equals(currentUser.getId())) {
|
||||
throw new IllegalStateException("无权操作他人订单, orderId: " + orderId);
|
||||
@@ -143,16 +145,11 @@ public class AliPayController {
|
||||
}
|
||||
|
||||
AlipayTradeCreateResponse response = alipayPayService.create(config, req);
|
||||
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
if (response.isSuccess()) {
|
||||
result.put("tradeNo", response.getTradeNo());
|
||||
result.put("outTradeNo", response.getOutTradeNo());
|
||||
return Result.succeed(response,response.getMsg());
|
||||
} else {
|
||||
result.put("error", response.getSubMsg());
|
||||
result.put("code", response.getCode());
|
||||
return Result.failed(response.getMsg());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// ==================== 支付异步回调 ====================
|
||||
|
||||
Reference in New Issue
Block a user