mirror of
https://gitee.com/dromara/dax-pay.git
synced 2025-09-02 10:36:57 +00:00
feat(core): 添加表单支付方式并优化收银台逻辑
- 在 CheckoutCallTypeEnum 中新增 FROM表单支付方式 - 在 CheckoutController 中添加 getCheckoutUrl 接口 - 优化 CheckoutQueryService 中的配置查询逻辑 -简化 CheckoutService 中的支付流程
This commit is contained in:
@@ -21,9 +21,9 @@ public enum CheckoutCallTypeEnum {
|
||||
BAR_CODE("bar_code", "条码支付"),
|
||||
LINK("link", "跳转链接"),
|
||||
MINI_APP("mini_app", "小程序"),
|
||||
AGGREGATE("aggregate", "聚合支付"),
|
||||
APP("app", "APP支付"),
|
||||
JSAPI("jsapi", "JSAPI"),
|
||||
FROM("from", "表单方式"),
|
||||
;
|
||||
|
||||
private final String code;
|
||||
|
@@ -41,6 +41,14 @@ public class CheckoutController {
|
||||
return DaxRes.ok(checkoutService.creat(checkoutParam));
|
||||
}
|
||||
|
||||
@Operation(summary = "根据订单号和收银台方式获取收银台链接")
|
||||
@GetMapping("/getCheckoutUrl")
|
||||
public Result<String> getCheckoutUrl(String orderNo, String checkoutType){
|
||||
return Res.ok(checkoutService.getCheckoutUrl(orderNo, checkoutType));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Operation(summary = "获取收银台订单和配置信息")
|
||||
@GetMapping("/getOrderAndConfig")
|
||||
public Result<CheckoutOrderAndConfigResult> getOrderAndConfig(String orderNo, String checkoutType){
|
||||
|
@@ -70,7 +70,11 @@ public class CheckoutQueryService {
|
||||
return groups.stream()
|
||||
.map(o->{
|
||||
var result = CheckoutGroupConfigConvert.CONVERT.toResult(o);
|
||||
result.setItems(itemGroupMap.get(o.getId()).stream().map(CheckoutItemConfigConvert.CONVERT::toResult).toList());
|
||||
List<CheckoutItemConfigResult> list = itemGroupMap.getOrDefault(o.getId(), new ArrayList<>())
|
||||
.stream()
|
||||
.map(CheckoutItemConfigConvert.CONVERT::toResult)
|
||||
.toList();
|
||||
result.setItems(list);
|
||||
return result;
|
||||
})
|
||||
.toList();
|
||||
|
@@ -9,7 +9,6 @@ import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.daxpay.core.enums.CheckoutCallTypeEnum;
|
||||
import org.dromara.daxpay.core.enums.CheckoutTypeEnum;
|
||||
import org.dromara.daxpay.core.enums.PayStatusEnum;
|
||||
import org.dromara.daxpay.core.exception.ConfigNotExistException;
|
||||
import org.dromara.daxpay.core.exception.TradeProcessingException;
|
||||
import org.dromara.daxpay.core.exception.UnsupportedAbilityException;
|
||||
@@ -75,13 +74,9 @@ public class CheckoutService {
|
||||
if (Objects.isNull(payOrder)){
|
||||
// 执行支付前的保存动作, 保存支付订单和扩展记录
|
||||
payOrder = checkoutAssistService.createPayOrder(checkoutParam);
|
||||
String checkoutUrl = this.getCheckoutUrl(payOrder.getOrderNo(), checkoutParam.getCheckoutType());
|
||||
return new CheckoutUrlResult().setUrl(checkoutUrl);
|
||||
} else {
|
||||
// 直接返回收银台链接
|
||||
String checkoutUrl = this.getCheckoutUrl(payOrder.getOrderNo(), checkoutParam.getCheckoutType());
|
||||
return new CheckoutUrlResult().setUrl(checkoutUrl);
|
||||
}
|
||||
String checkoutUrl = this.getCheckoutUrl(payOrder.getOrderNo(), checkoutParam.getCheckoutType());
|
||||
return new CheckoutUrlResult().setUrl(checkoutUrl);
|
||||
} finally {
|
||||
lockTemplate.releaseLock(lock);
|
||||
}
|
||||
@@ -92,9 +87,7 @@ public class CheckoutService {
|
||||
*/
|
||||
public String getCheckoutUrl(String orderNo, String checkoutType){
|
||||
CheckoutTypeEnum checkoutTypeEnum = CheckoutTypeEnum.findBuyCode(checkoutType);
|
||||
|
||||
PlatformConfig config = platformConfigService.getConfig();
|
||||
|
||||
switch (checkoutTypeEnum) {
|
||||
case H5 -> {
|
||||
return StrUtil.format("{}/checkout/{}",config.getGatewayMobileUrl(), orderNo);
|
||||
@@ -123,18 +116,9 @@ public class CheckoutService {
|
||||
// 判断支付调用类型
|
||||
CheckoutCallTypeEnum callTypeEnum = CheckoutCallTypeEnum.findBuyCode(itemConfig.getCallType());
|
||||
switch (callTypeEnum) {
|
||||
case QR_CODE, LINK, BAR_CODE,JSAPI -> {
|
||||
case QR_CODE, LINK, BAR_CODE,JSAPI,FROM -> {
|
||||
return this.checkoutPay(param, payOrder);
|
||||
}
|
||||
case AGGREGATE -> {
|
||||
PlatformConfig config = platformConfigService.getConfig();
|
||||
// 直接返回手机端的聚合收银台链接
|
||||
String url = StrUtil.format("{}/aggregate/{}", config.getGatewayPcUrl(), payOrder.getOrderNo());
|
||||
PayResult payResult = new PayResult();
|
||||
payResult.setPayBody(url);
|
||||
payResult.setStatus(PayStatusEnum.WAIT.getCode());
|
||||
return payResult;
|
||||
}
|
||||
default -> throw new UnsupportedAbilityException("不支持的支付调用类型");
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user