ref 参数修改+联调接口

This commit is contained in:
bootx
2024-04-25 23:15:24 +08:00
parent ad495b4a08
commit c108859c17
9 changed files with 34 additions and 38 deletions

View File

@@ -18,31 +18,32 @@ import java.math.BigDecimal;
@Schema(title = "结算台简单支付参数(单通道支付)")
public class CashierSimplePayParam {
@Schema(description = "业务")
@NotNull
@Schema(description = "商户订单")
@NotNull(message = "商户订单号不能为空")
private String bizOrderNo;
@Schema(description = "是否分账")
@NotNull(message = "分账是否启用必输")
private Boolean allocation;
@Schema(description = "标题")
@NotNull
@NotNull(message = "标题不能为空")
private String title;
@Schema(description = "金额")
@NotNull
@NotNull(message = "金额不能为空")
private BigDecimal amount;
@Schema(description = "openId(微信支付时使用)")
private String openId;
@Schema(description = "支付通道")
@NotNull
@NotNull(message = "支付通道不能为空")
private String channel;
@Schema(description = "支付方式")
@NotNull
private String payWay;
@NotNull(message = "支付方式不能为空")
private String method;
@Schema(description = "付款码")
private String authCode;

View File

@@ -50,49 +50,49 @@ public class CashierService {
*/
public PayOrderResult simplePayCashier(CashierSimplePayParam param){
// 将参数转换为简单支付参数
PayParam simplePayParam = new PayParam();
simplePayParam.setBizOrderNo(param.getChannel());
simplePayParam.setAllocation(param.getAllocation());
PayParam payParam = new PayParam();
payParam.setBizOrderNo(param.getBizOrderNo());
payParam.setAllocation(param.getAllocation());
int amount = param.getAmount()
.multiply(BigDecimal.valueOf(100))
.intValue();
simplePayParam.setTitle(param.getTitle());
simplePayParam.setAmount(amount);
simplePayParam.setChannel(param.getChannel());
simplePayParam.setMethod(param.getPayWay());
payParam.setTitle(param.getTitle());
payParam.setAmount(amount);
payParam.setChannel(param.getChannel());
payParam.setMethod(param.getMethod());
// 支付宝通道
if (Objects.equals(PayChannelEnum.ALI.getCode(), param.getChannel())){
// 付款码支付
if (Objects.equals(PayMethodEnum.BARCODE.getCode(), param.getPayWay())){
if (Objects.equals(PayMethodEnum.BARCODE.getCode(), param.getMethod())){
AliPayParam aliPayParam = new AliPayParam();
aliPayParam.setAuthCode(param.getAuthCode());
simplePayParam.setExtraParam(aliPayParam);
payParam.setExtraParam(aliPayParam);
}
}
// 微信通道
if (Objects.equals(PayChannelEnum.WECHAT.getCode(), param.getChannel())){
WeChatPayParam wechatPayParam = new WeChatPayParam();
// 付款码支付
if (Objects.equals(PayMethodEnum.BARCODE.getCode(), param.getPayWay())){
if (Objects.equals(PayMethodEnum.BARCODE.getCode(), param.getMethod())){
wechatPayParam.setAuthCode(param.getAuthCode());
simplePayParam.setExtraParam(wechatPayParam);
payParam.setExtraParam(wechatPayParam);
}
// 微信jsapi 方式支付
if (Objects.equals(PayMethodEnum.JSAPI.getCode(), param.getPayWay())){
if (Objects.equals(PayMethodEnum.JSAPI.getCode(), param.getMethod())){
wechatPayParam.setOpenId(param.getOpenId());
simplePayParam.setExtraParam(wechatPayParam);
payParam.setExtraParam(wechatPayParam);
}
}
String ip = Optional.ofNullable(WebServletUtil.getRequest())
.map(ServletUtil::getClientIP)
.orElse("127.0.0.1");
simplePayParam.setClientIp(ip);
payParam.setClientIp(ip);
// 同步回调地址
simplePayParam.setReturnUrl(StrUtil.format("{}/result/success", daxPayDemoProperties.getFrontH5Url()));
payParam.setReturnUrl(StrUtil.format("{}/result/success", daxPayDemoProperties.getFrontH5Url()));
// 发起支付
DaxPayResult<PayModel> execute = DaxPayKit.execute(simplePayParam);
DaxPayResult<PayModel> execute = DaxPayKit.execute(payParam);
// 判断是否支付成功
if (execute.getCode() != 0){
throw new BizException(execute.getMsg());