mirror of
https://gitee.com/dromara/dax-pay.git
synced 2025-09-02 10:36:57 +00:00
feat(core): 完善收银台功能并优化相关配置
- 新增小程序支付方式 - 更新聚合支付名称 - 添加收银台签名接口 - 实现收银台链接创建功能 -优化收银台配置查询 - 修复聚合支付URL生成逻辑- 优化微信授权URL生成格式
This commit is contained in:
@@ -75,7 +75,7 @@ public class WechatAuthService {
|
||||
PlatformConfig platformConfig = platformConfigService.getConfig();
|
||||
serverUrl = platformConfig.getGatewayMobileUrl();
|
||||
}
|
||||
String redirectUrl = StrUtil.format("{}/{}", serverUrl, authPath);
|
||||
String redirectUrl = StrUtil.format("{}{}", serverUrl, authPath);
|
||||
return wxMpService.getOAuth2Service().buildAuthorizationUrl(redirectUrl, WxConsts.OAuth2Scope.SNSAPI_BASE, "");
|
||||
}
|
||||
|
||||
|
@@ -41,7 +41,7 @@ public class WechatCheckoutStrategy extends AbsCheckoutStrategy {
|
||||
*/
|
||||
@Override
|
||||
public String generateAuthUrl(String orderNo) {
|
||||
String redirectUrl = StrUtil.format("/checkout/wechat/{}", orderNo);
|
||||
String redirectUrl = StrUtil.format("/aggregate/wechat/{}", orderNo);
|
||||
return wechatAuthService.generateInnerAuthUrl(redirectUrl);
|
||||
}
|
||||
|
||||
|
@@ -20,9 +20,10 @@ public enum CheckoutCallTypeEnum {
|
||||
QR_CODE("qr_code", "扫码支付"),
|
||||
BAR_CODE("bar_code", "条码支付"),
|
||||
LINK("link", "跳转链接"),
|
||||
JSAPI("jsapi", "JSAPI"),
|
||||
MINI_APP("mini_app", "小程序"),
|
||||
AGGREGATE("aggregate", "聚合支付"),
|
||||
APP("app", "APP支付"),
|
||||
JSAPI("jsapi", "JSAPI"),
|
||||
;
|
||||
|
||||
private final String code;
|
||||
|
@@ -9,6 +9,7 @@ import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 收银台类型
|
||||
* 字典 checkout_type
|
||||
* @author xxm
|
||||
* @since 2024/11/26
|
||||
*/
|
||||
@@ -19,7 +20,7 @@ public enum CheckoutTypeEnum {
|
||||
H5("h5", "H5"),
|
||||
PC("pc", "PC"),
|
||||
MINI_APP("mini_app", "小程序"),
|
||||
AGGREGATE("aggregate", "聚合扫码"),
|
||||
AGGREGATE("aggregate", "聚合支付"),
|
||||
;
|
||||
|
||||
private final String code;
|
||||
|
@@ -4,16 +4,18 @@ import cn.bootx.platform.core.annotation.RequestGroup;
|
||||
import cn.bootx.platform.core.annotation.RequestPath;
|
||||
import cn.bootx.platform.core.rest.Res;
|
||||
import cn.bootx.platform.core.rest.result.Result;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.daxpay.core.param.checkout.CheckoutCreatParam;
|
||||
import org.dromara.daxpay.core.param.trade.pay.PayParam;
|
||||
import org.dromara.daxpay.core.param.trade.refund.RefundParam;
|
||||
import org.dromara.daxpay.core.param.trade.transfer.TransferParam;
|
||||
import org.dromara.daxpay.core.result.checkout.CheckoutUrlResult;
|
||||
import org.dromara.daxpay.core.result.trade.pay.PayResult;
|
||||
import org.dromara.daxpay.core.result.trade.refund.RefundResult;
|
||||
import org.dromara.daxpay.core.result.trade.transfer.TransferResult;
|
||||
import org.dromara.daxpay.service.service.develop.DevelopTradeService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
@@ -34,7 +36,6 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
public class DevelopTradeController {
|
||||
private final DevelopTradeService developTradeService;
|
||||
|
||||
|
||||
@Operation(summary = "支付参数签名")
|
||||
@RequestPath("支付参数签名")
|
||||
@PostMapping("/sign/pay")
|
||||
@@ -56,6 +57,13 @@ public class DevelopTradeController {
|
||||
return Res.ok(developTradeService.genSign(param));
|
||||
}
|
||||
|
||||
@Operation(summary = "收银台签名")
|
||||
@RequestPath("收银台签名")
|
||||
@PostMapping("/sign/checkout")
|
||||
public Result<String> checkoutSign(@RequestBody CheckoutCreatParam param){
|
||||
return Res.ok(developTradeService.genSign(param));
|
||||
}
|
||||
|
||||
|
||||
@Operation(summary = "支付接口")
|
||||
@RequestPath("支付接口")
|
||||
@@ -78,4 +86,11 @@ public class DevelopTradeController {
|
||||
return Res.ok(developTradeService.transfer(param));
|
||||
}
|
||||
|
||||
@Operation(summary = "收银台链接创建接口")
|
||||
@RequestPath("收银台链接创建接口")
|
||||
@PostMapping("/checkoutUrl")
|
||||
public Result<CheckoutUrlResult> checkoutUrl(@RequestBody @Validated CheckoutCreatParam param){
|
||||
return Res.ok(developTradeService.checkoutUrl(param));
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -25,16 +25,7 @@ public class CheckoutGroupConfigManager extends BaseManager<CheckoutGroupConfigM
|
||||
return lambdaQuery()
|
||||
.eq(CheckoutGroupConfig::getAppId, appId)
|
||||
.eq(CheckoutGroupConfig::getType, type)
|
||||
.orderByDesc(CheckoutGroupConfig::getSortNo)
|
||||
.list();
|
||||
}
|
||||
/**
|
||||
* 查询指定类型的分组, 不进行排序
|
||||
*/
|
||||
public List<CheckoutGroupConfig> findAllByAppIdAndType(String appId, String type){
|
||||
return lambdaQuery()
|
||||
.eq(CheckoutGroupConfig::getAppId, appId)
|
||||
.eq(CheckoutGroupConfig::getType, type)
|
||||
.orderByAsc(CheckoutGroupConfig::getSortNo)
|
||||
.list();
|
||||
}
|
||||
|
||||
|
@@ -103,7 +103,7 @@ public class CheckoutService {
|
||||
return StrUtil.format("{}/checkout/{}",config.getGatewayPcUrl(), orderNo);
|
||||
}
|
||||
case AGGREGATE -> {
|
||||
return StrUtil.format("{}/aggregate/{}",config.getGatewayPcUrl(), orderNo);
|
||||
return StrUtil.format("{}/aggregate/{}",config.getGatewayMobileUrl(), orderNo);
|
||||
}
|
||||
case MINI_APP -> throw new UnsupportedAbilityException("暂不支持小程序收银台");
|
||||
default -> throw new UnsupportedAbilityException("不支持的收银台类型");
|
||||
@@ -170,11 +170,10 @@ public class CheckoutService {
|
||||
public PayResult aggregatePay(CheckoutAggregatePayParam param){
|
||||
// 订单信息
|
||||
PayOrder payOrder = checkoutAssistService.getOrderAndCheck(param.getOrderNo());
|
||||
|
||||
// 获取聚合类型
|
||||
CheckoutAggregateConfig aggregateConfig = checkoutAggregateConfigManager.findByAppIdAndType(payOrder.getAppId(), param.getAggregateType())
|
||||
.orElseThrow(() -> new ConfigNotExistException("聚合支付配置项不存在"));
|
||||
|
||||
paymentAssistService.initMchApp(payOrder.getAppId());
|
||||
// 构建支付参数
|
||||
String clientIP = JakartaServletUtil.getClientIP(WebServletUtil.getRequest());
|
||||
PayParam payParam = new PayParam();
|
||||
|
@@ -46,7 +46,7 @@ public class CheckoutConfigQueryService {
|
||||
* 获取指定类型收银台分组列表
|
||||
*/
|
||||
public List<CheckoutGroupConfigVo> getGroupConfigs(String appId, String checkoutType){
|
||||
return MpUtil.toListResult(checkoutGroupConfigManager.findAllByAppIdAndType(appId, checkoutType));
|
||||
return MpUtil.toListResult(checkoutGroupConfigManager.findAllSortByAppIdAndType(appId, checkoutType));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -1,13 +1,16 @@
|
||||
package org.dromara.daxpay.service.service.develop;
|
||||
|
||||
import org.dromara.daxpay.core.param.PaymentCommonParam;
|
||||
import org.dromara.daxpay.core.param.checkout.CheckoutCreatParam;
|
||||
import org.dromara.daxpay.core.param.trade.pay.PayParam;
|
||||
import org.dromara.daxpay.core.param.trade.refund.RefundParam;
|
||||
import org.dromara.daxpay.core.param.trade.transfer.TransferParam;
|
||||
import org.dromara.daxpay.core.result.checkout.CheckoutUrlResult;
|
||||
import org.dromara.daxpay.core.result.trade.pay.PayResult;
|
||||
import org.dromara.daxpay.core.result.trade.refund.RefundResult;
|
||||
import org.dromara.daxpay.core.result.trade.transfer.TransferResult;
|
||||
import org.dromara.daxpay.service.service.assist.PaymentAssistService;
|
||||
import org.dromara.daxpay.service.service.checkout.CheckoutService;
|
||||
import org.dromara.daxpay.service.service.trade.pay.PayService;
|
||||
import org.dromara.daxpay.service.service.trade.refund.RefundService;
|
||||
import org.dromara.daxpay.service.service.trade.transfer.TransferService;
|
||||
@@ -28,6 +31,8 @@ public class DevelopTradeService {
|
||||
private final PayService payService;
|
||||
private final RefundService refundService;
|
||||
private final TransferService transferService;
|
||||
private final CheckoutService checkoutService;
|
||||
|
||||
/**
|
||||
* 生成签名
|
||||
*/
|
||||
@@ -68,4 +73,15 @@ public class DevelopTradeService {
|
||||
paymentAssistService.signVerify(param);
|
||||
return transferService.transfer(param);
|
||||
}
|
||||
|
||||
/**
|
||||
* 收银台链接创建接口
|
||||
*/
|
||||
public CheckoutUrlResult checkoutUrl(CheckoutCreatParam param) {
|
||||
// 初始化
|
||||
paymentAssistService.initMchApp(param.getAppId());
|
||||
// 签名校验
|
||||
paymentAssistService.signVerify(param);
|
||||
return checkoutService.creat(param);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user