|
@@ -11,20 +11,17 @@ import com.microsvc.toolkit.config.jwt.utils.JwtUserInfo;
|
|
|
import com.microsvc.toolkit.middleware.payment.common.api.PaymentServiceContext;
|
|
|
import com.microsvc.toolkit.middleware.payment.common.api.entity.PaymentResp;
|
|
|
import com.microsvc.toolkit.middleware.payment.common.api.entity.RefundResp;
|
|
|
+import com.microsvc.toolkit.middleware.payment.common.api.enums.PaymentStatus;
|
|
|
import com.yeepay.g3.sdk.yop.encrypt.DigitalEnvelopeDTO;
|
|
|
import com.yeepay.g3.sdk.yop.utils.DigitalEnvelopeUtils;
|
|
|
import com.yeepay.g3.sdk.yop.utils.RSAKeyUtils;
|
|
|
import com.yonge.cooleshow.biz.dal.entity.PaymentMerchantConfig;
|
|
|
import com.yonge.cooleshow.biz.dal.entity.TenantMember;
|
|
|
import com.yonge.cooleshow.biz.dal.enums.AuthStatusEnum;
|
|
|
-import com.yonge.cooleshow.biz.dal.service.PaymentMerchantConfigService;
|
|
|
-import com.yonge.cooleshow.biz.dal.service.TenantMemberService;
|
|
|
-import com.yonge.cooleshow.biz.dal.service.UserOrderRefundBillService;
|
|
|
-import com.yonge.cooleshow.biz.dal.service.UserOrderService;
|
|
|
-import com.yonge.cooleshow.biz.dal.service.UserPaymentCoreService;
|
|
|
-import com.yonge.cooleshow.biz.dal.service.UserPaymentOrderService;
|
|
|
+import com.yonge.cooleshow.biz.dal.service.*;
|
|
|
import com.yonge.cooleshow.biz.dal.wrapper.UserPaymentOrderWrapper;
|
|
|
import com.yonge.cooleshow.common.enums.EPayerType;
|
|
|
+import com.yonge.cooleshow.common.enums.payment.EPaymentStatus;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiImplicitParam;
|
|
|
import io.swagger.annotations.ApiImplicitParams;
|
|
@@ -33,12 +30,8 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
-import org.springframework.web.bind.annotation.PathVariable;
|
|
|
-import org.springframework.web.bind.annotation.PostMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestBody;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+import springfox.documentation.annotations.ApiIgnore;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import java.security.PrivateKey;
|
|
@@ -101,6 +94,60 @@ public class UserPaymentClient {
|
|
|
return paymentServiceContext.getPaymentService(vendor).returnNotifyResult(request);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 关闭订单测试
|
|
|
+ * @param orderNo 订单号
|
|
|
+ * @return R<UserPaymentOrderVo.UserPaymentOrder>
|
|
|
+ */
|
|
|
+ @ApiOperation(value = "关闭订单测试", notes = "关闭订单测试")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "orderNo", value = "订单号", dataType = "String")
|
|
|
+ })
|
|
|
+ @GetMapping("/closed/{orderNo}")
|
|
|
+ public R<Object> testOrderClosed(@PathVariable("orderNo") String orderNo) {
|
|
|
+
|
|
|
+ // 支付订单详情
|
|
|
+ UserPaymentOrderWrapper.UserPaymentOrder paymentOrder = userPaymentOrderService.getUserPaymentOrderByOrderNo( orderNo);
|
|
|
+ if (Objects.isNull(paymentOrder)) {
|
|
|
+ throw BizException.from("订单不存在");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 测试订单关闭
|
|
|
+ PaymentResp paymentResp = userPaymentCoreService.closedPayment( paymentOrder);
|
|
|
+
|
|
|
+ return R.from(paymentResp);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "关单消息回调", notes = "三方支付平台关单消息通知")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "vendor", value = "服务提供方", dataType = "String")
|
|
|
+ })
|
|
|
+ @RequestMapping(value = "/closed/callback/{vendor}", method = {RequestMethod.GET, RequestMethod.POST})
|
|
|
+ public String closed(@PathVariable("vendor") String vendor, HttpServletRequest request) {
|
|
|
+
|
|
|
+ // 支付回调消息
|
|
|
+ PaymentResp paymentResp = paymentServiceContext.getPaymentService(vendor).callbackNotifyForClosed(request);
|
|
|
+ // 关单回调对象为空或关闭失败,直接返回忽略后续流程
|
|
|
+ if (Objects.isNull(paymentResp) || paymentResp.getPaymentStatus() != PaymentStatus.CLOSED) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ log.info("closed vendor={}, paymentResp={}", vendor, JSON.toJSONString(paymentResp));
|
|
|
+
|
|
|
+ // 支付订单确认
|
|
|
+ UserPaymentOrderWrapper.UserPaymentOrder paymentOrder = userPaymentOrderService.getUserPaymentOrderByTranNo(paymentResp.getTransNo());
|
|
|
+ if (Objects.isNull(paymentOrder) || paymentOrder.getStatus() == EPaymentStatus.PAID || paymentOrder.getStatus() == EPaymentStatus.CLOSED) {
|
|
|
+ return paymentResp.getMsg();
|
|
|
+ }
|
|
|
+ // 关单订单编号
|
|
|
+ paymentResp.setMerOrderNo(paymentOrder.getOrderNo());
|
|
|
+
|
|
|
+ // 执行支付回调流程
|
|
|
+ userPaymentCoreService.executePaymentCallback(paymentResp);
|
|
|
+
|
|
|
+ return paymentServiceContext.getPaymentService(vendor).returnNotifyResult(request);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
@ApiOperation(value = "用户付款", notes = "用户付款")
|
|
|
@PostMapping("/executePayment/v2")
|
|
|
public R<UserPaymentOrderWrapper.PaymentReq> executePayment(@Validated @RequestBody UserPaymentOrderWrapper.PaymentOrderReqConfig config,
|