mirror of
https://gitee.com/dromara/dax-pay.git
synced 2025-09-03 11:06:46 +00:00
feat 流水记录功能微调、新增组合支付样例
This commit is contained in:
@@ -68,8 +68,8 @@ public class AggregateController {
|
||||
|
||||
@Operation(summary = "通过付款码发起支付")
|
||||
@PostMapping("/barCodePay")
|
||||
public ResResult<Void> barCodePay(@RequestBody AggregateSimplePayParam param){
|
||||
return Res.ok();
|
||||
public ResResult<PayOrderResult> barCodePay(@RequestBody AggregateSimplePayParam param){
|
||||
return Res.ok(aggregateService.barPay(param));
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package cn.bootx.platform.daxpay.demo.result;
|
||||
|
||||
import cn.bootx.platform.daxpay.sdk.code.PayChannelEnum;
|
||||
import cn.bootx.platform.daxpay.sdk.code.PayStatusEnum;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@@ -28,4 +29,10 @@ public class PayOrderResult {
|
||||
/** 支付参数体(通常用于发起异步支付的参数) */
|
||||
private String payBody;
|
||||
|
||||
/**
|
||||
* 支付状态
|
||||
* @see PayStatusEnum
|
||||
*/
|
||||
private String status;
|
||||
|
||||
}
|
||||
|
@@ -200,10 +200,46 @@ public class AggregateService {
|
||||
return payOrderResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* 条码支付
|
||||
*/
|
||||
public PayOrderResult barPay(AggregateSimplePayParam param){
|
||||
// 判断通道属于什么
|
||||
PayChannelEnum payChannel = this.getPayChannel(param.getAuthCode());
|
||||
|
||||
int amount = param.getAmount()
|
||||
.multiply(BigDecimal.valueOf(100))
|
||||
.intValue();
|
||||
|
||||
SimplePayParam simplePayParam = new SimplePayParam();
|
||||
simplePayParam.setBusinessNo(param.getBusinessNo());
|
||||
simplePayParam.setTitle(param.getTitle());
|
||||
simplePayParam.setAmount(amount);
|
||||
simplePayParam.setChannel(payChannel.getCode());
|
||||
simplePayParam.setPayWay(PayWayEnum.BARCODE.getCode());
|
||||
|
||||
String ip = Optional.ofNullable(WebServletUtil.getRequest())
|
||||
.map(ServletUtil::getClientIP)
|
||||
.orElse("127.0.0.1");
|
||||
simplePayParam.setClientIp(ip);
|
||||
// 异步回调地址
|
||||
simplePayParam.setNotNotify(true);
|
||||
|
||||
DaxPayResult<PayOrderModel> execute = DaxPayKit.execute(simplePayParam);
|
||||
|
||||
// 判断是否支付成功
|
||||
if (execute.getCode() != 0){
|
||||
throw new BizException(execute.getMsg());
|
||||
}
|
||||
PayOrderResult payOrderResult = new PayOrderResult();
|
||||
BeanUtil.copyProperties(execute.getData(),payOrderResult);
|
||||
return payOrderResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据付款码判断属于那种支付通道
|
||||
*/
|
||||
public PayChannelEnum getPayChannel(String authCode) {
|
||||
private PayChannelEnum getPayChannel(String authCode) {
|
||||
if (StrUtil.isBlank(authCode)) {
|
||||
throw new BizException("付款码不可为空");
|
||||
}
|
||||
|
Reference in New Issue
Block a user