|
@@ -1,10 +1,13 @@
|
|
|
package com.yonge.cooleshow.teacher.controller.open;
|
|
|
|
|
|
+import cn.hutool.extra.servlet.ServletUtil;
|
|
|
import com.microsvc.toolkit.common.response.template.R;
|
|
|
import com.microsvc.toolkit.common.webportal.exception.BizException;
|
|
|
import com.microsvc.toolkit.config.jwt.utils.JwtUserInfo;
|
|
|
+import com.yonge.cooleshow.biz.dal.enums.ClientEnum;
|
|
|
import com.yonge.cooleshow.biz.dal.service.UserPaymentCoreService;
|
|
|
import com.yonge.cooleshow.biz.dal.wrapper.UserPaymentOrderWrapper;
|
|
|
+import com.yonge.cooleshow.teacher.vo.UserPaymentOrderVo;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
@@ -16,6 +19,7 @@ import org.springframework.web.bind.annotation.RequestBody;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
import java.util.Objects;
|
|
|
|
|
|
@Slf4j
|
|
@@ -28,25 +32,20 @@ public class UserPaymentClient {
|
|
|
private UserPaymentCoreService userPaymentCoreService;
|
|
|
|
|
|
@ApiOperation(value = "用户付款", notes = "用户付款")
|
|
|
- @PostMapping("/executePayment")
|
|
|
- public R<UserPaymentOrderWrapper.PaymentReq> executePayment(@Validated @RequestBody UserPaymentOrderWrapper.PaymentOrderReqConfig config) {
|
|
|
+ @PostMapping("/executePayment/v2")
|
|
|
+ public R<UserPaymentOrderWrapper.PaymentReq> executePayment(@Validated @RequestBody UserPaymentOrderVo.PaymentReqConfig config, HttpServletRequest request) {
|
|
|
+ // 设置下单用户信息
|
|
|
|
|
|
- // 用户登录状态校验
|
|
|
- if (StringUtils.isBlank(config.getUserId())) {
|
|
|
- throw BizException.from("用户未登录");
|
|
|
- }
|
|
|
|
|
|
// 用户下单请求
|
|
|
UserPaymentOrderWrapper.PaymentOrderReqConfig reqConfig = UserPaymentOrderWrapper.PaymentOrderReqConfig.from(config.jsonString());
|
|
|
|
|
|
- JwtUserInfo<Object> userInfo = JwtUserInfo.builder()
|
|
|
- .userId(config.getUserId())
|
|
|
- .clientType(config.getUserType().getCode())
|
|
|
- .build();
|
|
|
+ reqConfig.setIp(ServletUtil.getClientIP(request));
|
|
|
// 创建用户支付数据
|
|
|
- UserPaymentOrderWrapper.PaymentReq paymentConfig = userPaymentCoreService.executePayment(userInfo, reqConfig);
|
|
|
+ UserPaymentOrderWrapper.PaymentReq paymentConfig = userPaymentCoreService.executePayment(JwtUserInfo.builder()
|
|
|
+ .userId(config.getUserId()).clientType(ClientEnum.TENANT.getCode()).build(), reqConfig);
|
|
|
if (Objects.isNull(paymentConfig)) {
|
|
|
- throw BizException.from("用户支付请求错误");
|
|
|
+ throw BizException.from("付款失败");
|
|
|
}
|
|
|
|
|
|
return R.from(paymentConfig);
|