feat 流水记录功能微调、新增组合支付样例

This commit is contained in:
bootx
2024-02-19 22:39:15 +08:00
parent aa77586656
commit e55e845adb
8 changed files with 96 additions and 9 deletions

View File

@@ -1,10 +1,10 @@
2.0.1:
- [ ] 完善各种同步支付方式
- [x] 完善各种同步支付方式
- [x] 现金支付, 现金流水
- [x] 钱包支付, 钱包流水
- [x] 储值卡支付, 储值卡流水
- [ ] 支付回调通知和退款回调通知功能
- [ ] 通道配置启用停用配置生效
- [x] 通道配置启用停用配置生效
- [x] 支付对账的序列化生成器有问题待platform更新
2.0.x 版本内容
- [ ] 云闪付接入

View File

@@ -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));
}
}

View File

@@ -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;
}

View File

@@ -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("付款码不可为空");
}

View File

@@ -5,12 +5,15 @@ import cn.bootx.platform.daxpay.sdk.code.PayWayEnum;
import cn.bootx.platform.daxpay.sdk.model.pay.PayOrderModel;
import cn.bootx.platform.daxpay.sdk.net.DaxPayConfig;
import cn.bootx.platform.daxpay.sdk.net.DaxPayKit;
import cn.bootx.platform.daxpay.sdk.param.channel.VoucherPayParam;
import cn.bootx.platform.daxpay.sdk.param.channel.WalletPayParam;
import cn.bootx.platform.daxpay.sdk.param.pay.PayChannelParam;
import cn.bootx.platform.daxpay.sdk.param.pay.PayParam;
import cn.bootx.platform.daxpay.sdk.response.DaxPayResult;
import org.junit.Before;
import org.junit.Test;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
@@ -56,10 +59,47 @@ public class PayOrderTest {
}
/**
* 多通道支付
* 多通道支付. 全部为同步支付方式
*/
@Test
public void multiPay() {
PayParam param = new PayParam();
param.setClientIp("127.0.0.1");
param.setNotNotify(true);
param.setBusinessNo("P0002");
param.setTitle("测试组合支付");
// 现金支付
PayChannelParam cash = new PayChannelParam();
cash.setChannel(PayChannelEnum.CASH.getCode());
cash.setWay(PayWayEnum.NORMAL.getCode());
cash.setAmount(10);
// 储值卡支付
PayChannelParam card = new PayChannelParam();
card.setChannel(PayChannelEnum.VOUCHER.getCode());
card.setWay(PayWayEnum.NORMAL.getCode());
card.setAmount(10);
// 储值卡通道参数
VoucherPayParam voucherPayParam = new VoucherPayParam();
voucherPayParam.setCardNo("123456");
card.setChannelParam(voucherPayParam);
// 钱包支付
PayChannelParam wallet = new PayChannelParam();
wallet.setChannel(PayChannelEnum.WALLET.getCode());
wallet.setWay(PayWayEnum.NORMAL.getCode());
wallet.setAmount(10);
// 钱包通道支付参数
WalletPayParam walletPayParam = new WalletPayParam();
walletPayParam.setUserId("1");
wallet.setChannelParam(walletPayParam);
// 组装组合支付的参数
List<PayChannelParam> payChannels = Arrays.asList(cash, card, wallet);
param.setPayChannels(payChannels);
DaxPayResult<PayOrderModel> execute = DaxPayKit.execute(param);
System.out.println(execute);
System.out.println(execute.getData());
}
}

View File

@@ -34,7 +34,7 @@ public class CashController {
@Operation(summary = "查询记录详情")
@GetMapping("/findById")
@GetMapping("/record/findById")
public ResResult<CashRecordDto> findById(Long id){
return Res.ok(cashRecordService.findById(id));
}

View File

@@ -63,4 +63,10 @@ public class VoucherController {
public ResResult<PageResult<VoucherRecordDto>> recordPage(PageParam pageParam, VoucherRecordQuery query){
return Res.ok(voucherRecordService.page(pageParam, query));
}
@Operation(summary = "查询记录详情")
@GetMapping("/record/findById")
public ResResult<VoucherRecordDto> recordFindById(Long id){
return Res.ok(voucherRecordService.findById(id));
}
}

View File

@@ -56,8 +56,6 @@ public class WeChatPayService {
private final PaySyncService paySyncService;
private final WeChatPaySyncService weChatPaySyncService;
/**
* 校验
*/