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

This commit is contained in:
bootx
2024-02-19 23:33:04 +08:00
parent e55e845adb
commit 40199a6355
33 changed files with 215 additions and 33 deletions

View File

@@ -0,0 +1,18 @@
package cn.bootx.platform.daxpay.service.core.channel.alipay.dao;
import cn.bootx.platform.common.mybatisplus.impl.BaseManager;
import cn.bootx.platform.daxpay.service.core.channel.alipay.entity.AliPayRecord;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Repository;
/**
*
* @author xxm
* @since 2024/2/19
*/
@Slf4j
@Repository
@RequiredArgsConstructor
public class AliPayRecordManager extends BaseManager<AliPayRecordMapper, AliPayRecord> {
}

View File

@@ -0,0 +1,14 @@
package cn.bootx.platform.daxpay.service.core.channel.alipay.dao;
import cn.bootx.platform.daxpay.service.core.channel.alipay.entity.AliPayRecord;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
/**
*
* @author xxm
* @since 2024/2/19
*/
@Mapper
public interface AliPayRecordMapper extends BaseMapper<AliPayRecord> {
}

View File

@@ -0,0 +1,31 @@
package cn.bootx.platform.daxpay.service.core.channel.alipay.entity;
import cn.bootx.platform.common.mybatisplus.base.MpCreateEntity;
import cn.bootx.table.modify.annotation.DbTable;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* 支付宝流水记录
* @author xxm
* @since 2024/2/19
*/
@EqualsAndHashCode(callSuper = true)
@Data
@Accessors(chain = true)
@DbTable(comment = "支付宝流水记录")
@TableName("pay_alipay_record")
public class AliPayRecord extends MpCreateEntity {
/** 标题 */
/** 金额 */
/** 业务类型 */
/** 本地订单号 */
/** 网关订单号 */
}

View File

@@ -0,0 +1,17 @@
package cn.bootx.platform.daxpay.service.core.channel.alipay.service;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
/**
* 支付宝流水
* @author xxm
* @since 2024/2/1+9
*/
@Slf4j
@Service
@RequiredArgsConstructor
public class AliPayRecordService {
}

View File

@@ -22,6 +22,10 @@ import lombok.experimental.Accessors;
@DbTable(comment = "现金记录")
public class CashRecord extends MpCreateEntity implements EntityBaseFunction<CashRecordDto> {
/** 标题 */
@DbColumn(comment = "标题")
private String title;
/**
* 业务类型
* @see CashRecordTypeEnum

View File

@@ -29,8 +29,9 @@ public class CashRecordService {
/**
* 支付保存
*/
public void pay(PayChannelOrder channelOrder){
public void pay(PayChannelOrder channelOrder, String title){
CashRecord record = new CashRecord()
.setTitle(title)
.setType(CashRecordTypeEnum.PAY.getCode())
.setAmount(channelOrder.getAmount())
.setOrderId(String.valueOf(channelOrder.getPaymentId()));
@@ -40,8 +41,9 @@ public class CashRecordService {
/**
* 退款保存
*/
public void refund(PayRefundChannelOrder channelOrder){
public void refund(PayRefundChannelOrder channelOrder, String title){
CashRecord record = new CashRecord()
.setTitle(title)
.setType(CashRecordTypeEnum.REFUND.getCode())
.setAmount(channelOrder.getAmount())
.setOrderId(String.valueOf(channelOrder.getRefundId()));
@@ -51,8 +53,9 @@ public class CashRecordService {
/**
* 支付关闭
*/
public void payClose(PayChannelOrder channelOrder){
public void payClose(PayChannelOrder channelOrder, String title){
CashRecord record = new CashRecord()
.setTitle(title)
.setType(CashRecordTypeEnum.CLOSE_PAY.getCode())
.setAmount(channelOrder.getAmount())
.setOrderId(String.valueOf(channelOrder.getPaymentId()));

View File

@@ -1,7 +1,7 @@
package cn.bootx.platform.daxpay.service.core.channel.union.dao;
import cn.bootx.platform.common.mybatisplus.impl.BaseManager;
import cn.bootx.platform.daxpay.service.core.channel.union.entity.UnionPayOrder;
import cn.bootx.platform.daxpay.service.core.channel.union.entity.UnionPayRecord;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Repository;
@@ -13,6 +13,6 @@ import org.springframework.stereotype.Repository;
@Slf4j
@Repository
@RequiredArgsConstructor
public class UnionPayOrderManager extends BaseManager<UnionPayOrderMapper, UnionPayOrder> {
public class UnionPayRecordManager extends BaseManager<UnionPayRecordMapper, UnionPayRecord> {
}

View File

@@ -1,6 +1,6 @@
package cn.bootx.platform.daxpay.service.core.channel.union.dao;
import cn.bootx.platform.daxpay.service.core.channel.union.entity.UnionPayOrder;
import cn.bootx.platform.daxpay.service.core.channel.union.entity.UnionPayRecord;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
@@ -9,6 +9,6 @@ import org.apache.ibatis.annotations.Mapper;
* @since 2022/3/11
*/
@Mapper
public interface UnionPayOrderMapper extends BaseMapper<UnionPayOrder> {
public interface UnionPayRecordMapper extends BaseMapper<UnionPayRecord> {
}

View File

@@ -8,15 +8,15 @@ import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* 云闪付支付订单
* 云闪付流水记录
* @author xxm
* @since 2022/3/11
* @since 2024/2/19
*/
@EqualsAndHashCode(callSuper = true)
@Data
@DbTable(comment = "云闪付支付订单")
@DbTable(comment = "云闪付流水记录")
@Accessors(chain = true)
@TableName("pay_union_pay_order")
public class UnionPayOrder extends BasePayOrder {
@TableName("pay_union_pay_record")
public class UnionPayRecord extends BasePayOrder {
}

View File

@@ -30,6 +30,10 @@ public class VoucherRecord extends MpCreateEntity implements EntityBaseFunction<
@DbColumn(comment = "储值卡id")
private Long voucherId;
/** 标题 */
@DbColumn(comment = "标题")
private String title;
/**
* 业务类型
* @see VoucherRecordTypeEnum

View File

@@ -31,6 +31,7 @@ public class VoucherRecordService {
*/
public void importVoucher(Voucher voucher){
VoucherRecord voucherRecord = new VoucherRecord()
.setTitle("导入储值卡")
.setType(VoucherRecordTypeEnum.IMPORT.getCode())
.setAmount(voucher.getBalance())
.setNewAmount(voucher.getBalance())
@@ -43,8 +44,9 @@ public class VoucherRecordService {
/**
* 支付保存
*/
public void pay(PayChannelOrder channelOrder, Voucher voucher){
public void pay(PayChannelOrder channelOrder, String title, Voucher voucher){
VoucherRecord voucherRecord = new VoucherRecord()
.setTitle(title)
.setType(VoucherRecordTypeEnum.PAY.getCode())
.setAmount(channelOrder.getAmount())
.setNewAmount(voucher.getBalance())
@@ -57,8 +59,9 @@ public class VoucherRecordService {
/**
* 退款保存
*/
public void refund(PayRefundChannelOrder channelOrder, Voucher voucher){
public void refund(PayRefundChannelOrder channelOrder, String title, Voucher voucher){
VoucherRecord voucherRecord = new VoucherRecord()
.setTitle(title)
.setType(VoucherRecordTypeEnum.REFUND.getCode())
.setAmount(channelOrder.getAmount())
.setNewAmount(voucher.getBalance())
@@ -71,8 +74,9 @@ public class VoucherRecordService {
/**
* 支付关闭
*/
public void payClose(PayChannelOrder channelOrder, Voucher voucher){
public void payClose(PayChannelOrder channelOrder, String title, Voucher voucher){
VoucherRecord voucherRecord = new VoucherRecord()
.setTitle(title)
.setType(VoucherRecordTypeEnum.CLOSE_PAY.getCode())
.setAmount(channelOrder.getAmount())
.setNewAmount(voucher.getBalance())

View File

@@ -30,6 +30,10 @@ public class WalletRecord extends MpCreateEntity implements EntityBaseFunction<W
@DbColumn(comment = "钱包id")
private Long walletId;
/** 标题 */
@DbColumn(comment = "标题")
private String title;
/**
* 业务类型
* @see WalletRecordTypeEnum

View File

@@ -12,6 +12,7 @@ import cn.bootx.platform.daxpay.service.core.order.pay.entity.PayChannelOrder;
import cn.bootx.platform.daxpay.service.core.order.refund.entity.PayRefundChannelOrder;
import cn.bootx.platform.daxpay.service.dto.channel.wallet.WalletRecordDto;
import cn.bootx.platform.daxpay.service.param.channel.wallet.WalletRecordQuery;
import cn.hutool.core.util.StrUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@@ -32,6 +33,7 @@ public class WalletRecordService {
*/
public void create(Wallet wallet){
WalletRecord walletRecord = new WalletRecord()
.setTitle("创建钱包")
.setType(WalletRecordTypeEnum.CREATE.getCode())
.setAmount(wallet.getBalance())
.setNewAmount(wallet.getBalance())
@@ -45,6 +47,7 @@ public class WalletRecordService {
*/
public void recharge(Wallet wallet, int amount){
WalletRecord walletRecord = new WalletRecord()
.setTitle(StrUtil.format("余额充值:{} 分", amount))
.setType(WalletRecordTypeEnum.RECHARGE.getCode())
.setAmount(wallet.getBalance())
.setNewAmount(wallet.getBalance())
@@ -58,6 +61,7 @@ public class WalletRecordService {
*/
public void deduct(Wallet wallet, int amount){
WalletRecord walletRecord = new WalletRecord()
.setTitle(StrUtil.format("余额扣减:{} 分", amount))
.setType(WalletRecordTypeEnum.DEDUCT.getCode())
.setWalletId(wallet.getId())
.setAmount(wallet.getBalance())
@@ -69,8 +73,9 @@ public class WalletRecordService {
/**
* 支付保存
*/
public void pay(PayChannelOrder channelOrder, Wallet wallet){
public void pay(PayChannelOrder channelOrder, String title, Wallet wallet){
WalletRecord walletRecord = new WalletRecord()
.setTitle(title)
.setType(WalletRecordTypeEnum.PAY.getCode())
.setAmount(channelOrder.getAmount())
.setNewAmount(wallet.getBalance())
@@ -83,8 +88,9 @@ public class WalletRecordService {
/**
* 退款保存
*/
public void refund(PayRefundChannelOrder channelOrder, Wallet wallet){
public void refund(PayRefundChannelOrder channelOrder, String title, Wallet wallet){
WalletRecord walletRecord = new WalletRecord()
.setTitle(title)
.setType(WalletRecordTypeEnum.REFUND.getCode())
.setAmount(channelOrder.getAmount())
.setNewAmount(wallet.getBalance())
@@ -97,8 +103,9 @@ public class WalletRecordService {
/**
* 支付关闭
*/
public void payClose(PayChannelOrder channelOrder, Wallet wallet){
public void payClose(PayChannelOrder channelOrder, String title, Wallet wallet){
WalletRecord walletRecord = new WalletRecord()
.setTitle(title)
.setType(WalletRecordTypeEnum.CLOSE_PAY.getCode())
.setAmount(channelOrder.getAmount())
.setNewAmount(wallet.getBalance())

View File

@@ -0,0 +1,16 @@
package cn.bootx.platform.daxpay.service.core.channel.wechat.dao;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Repository;
/**
*
* @author xxm
* @since 2024/2/19
*/
@Slf4j
@Repository
@RequiredArgsConstructor
public class WeChatPayRecordManager {
}

View File

@@ -0,0 +1,14 @@
package cn.bootx.platform.daxpay.service.core.channel.wechat.dao;
import cn.bootx.platform.daxpay.service.core.channel.wechat.entity.WeChatPayRecord;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
/**
*
* @author xxm
* @since 2024/2/19
*/
@Mapper
public interface WeChatPayRecordMapper extends BaseMapper<WeChatPayRecord> {
}

View File

@@ -0,0 +1,21 @@
package cn.bootx.platform.daxpay.service.core.channel.wechat.entity;
import cn.bootx.platform.common.mybatisplus.base.MpCreateEntity;
import cn.bootx.table.modify.annotation.DbTable;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* 微信支付记录
* @author xxm
* @since 2024/2/19
*/
@EqualsAndHashCode(callSuper = true)
@Data
@DbTable(comment = "微信支付记录")
@Accessors(chain = true)
@TableName("pay_wechat_pay_record")
public class WeChatPayRecord extends MpCreateEntity {
}

View File

@@ -0,0 +1,18 @@
package cn.bootx.platform.daxpay.service.core.channel.wechat.service;
import cn.bootx.platform.daxpay.service.core.channel.wechat.dao.WeChatPayRecordManager;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
/**
*
* @author xxm
* @since 2024/2/19
*/
@Slf4j
@Service
@RequiredArgsConstructor
public class WeChatPayRecordService {
private final WeChatPayRecordManager weChatPayRecordManager;
}

View File

@@ -1,6 +1,7 @@
package cn.bootx.platform.daxpay.service.core.payment.close.strategy;
import cn.bootx.platform.daxpay.code.PayChannelEnum;
import cn.bootx.platform.daxpay.service.core.channel.cash.service.CashRecordService;
import cn.bootx.platform.daxpay.service.func.AbsPayCloseStrategy;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@@ -19,6 +20,7 @@ import static org.springframework.beans.factory.config.BeanDefinition.SCOPE_PROT
@Service
@RequiredArgsConstructor
public class CashPayCloseStrategy extends AbsPayCloseStrategy {
private final CashRecordService cashRecordService;
@Override
public PayChannelEnum getChannel() {
@@ -26,9 +28,10 @@ public class CashPayCloseStrategy extends AbsPayCloseStrategy {
}
/**
* 关闭操作, 不需要进行处理
* 关闭操作
*/
@Override
public void doCloseHandler() {
cashRecordService.payClose(this.getChannelOrder(),this.getOrder().getTitle());
}
}

View File

@@ -55,6 +55,6 @@ public class VoucherPayCloseStrategy extends AbsPayCloseStrategy {
@Override
public void doCloseHandler() {
voucherPayService.close(this.getChannelOrder());
voucherRecordService.payClose(this.getChannelOrder(),this.voucher);
voucherRecordService.payClose(this.getChannelOrder(), this.getOrder().getTitle(), this.voucher);
}
}

View File

@@ -54,6 +54,6 @@ public class WalletPayCloseStrategy extends AbsPayCloseStrategy {
@Override
public void doCloseHandler() {
walletPayService.close(this.getChannelOrder(),this.wallet);
walletRecordService.payClose(this.getChannelOrder(),this.wallet);
walletRecordService.payClose(this.getChannelOrder(), this.getOrder().getTitle(), this.wallet);
}
}

View File

@@ -51,7 +51,7 @@ public class CashPayStrategy extends AbsPayStrategy {
*/
@Override
public void doPayHandler() {
cashRecordService.pay(this.getChannelOrder());
cashRecordService.pay(this.getChannelOrder(),this.getOrder().getTitle());
}
}

View File

@@ -76,7 +76,7 @@ public class VoucherPayStrategy extends AbsPayStrategy {
@Override
public void doPayHandler() {
voucherPayService.pay(this.getPayChannelParam().getAmount(), this.voucher);
voucherRecordService.pay(this.getChannelOrder(), this.voucher);
voucherRecordService.pay(this.getChannelOrder(), this.getOrder().getTitle(), this.voucher);
}
}

View File

@@ -97,6 +97,6 @@ public class WalletPayStrategy extends AbsPayStrategy {
@Override
public void doPayHandler() {
walletPayService.pay(getPayChannelParam().getAmount(), this.wallet);
walletRecordService.pay(this.getChannelOrder(), this.wallet);
walletRecordService.pay(this.getChannelOrder(), this.getOrder().getTitle(),this.wallet);
}
}

View File

@@ -38,7 +38,7 @@ public class CashPayRefundStrategy extends AbsRefundStrategy {
public void doRefundHandler() {
// 不包含异步支付
if (!this.getPayOrder().isAsyncPay()){
cashRecordService.refund(this.getRefundChannelOrder());
cashRecordService.refund(this.getRefundChannelOrder(),this.getPayOrder().getTitle());
}
}

View File

@@ -66,7 +66,7 @@ public class VoucherPayRefundStrategy extends AbsRefundStrategy {
// 不包含异步支付
if (!this.getPayOrder().isAsyncPay()){
voucherPayService.refund(this.getRefundChannelParam().getAmount(), this.voucher);
voucherRecordService.refund(this.getRefundChannelOrder(), this.voucher);
voucherRecordService.refund(this.getRefundChannelOrder(), this.getPayOrder().getTitle(), this.voucher);
}
}

View File

@@ -65,7 +65,7 @@ public class WalletPayRefundStrategy extends AbsRefundStrategy {
// 不包含异步支付
if (!this.getPayOrder().isAsyncPay()){
walletPayService.refund(this.wallet, this.getRefundChannelParam().getAmount());
walletRecordService.refund(this.getRefundChannelOrder(), this.wallet);
walletRecordService.refund(this.getRefundChannelOrder(), this.getPayOrder().getTitle(), this.wallet);
}
}

View File

@@ -37,6 +37,6 @@ public class CashPayRepairStrategy extends AbsPayRepairStrategy {
@Override
public void doCloseLocalHandler() {
this.getChannelOrder().setStatus(PayStatusEnum.CLOSE.getCode());
cashRecordService.payClose(this.getChannelOrder());
cashRecordService.payClose(this.getChannelOrder(),this.getOrder().getTitle());
}
}

View File

@@ -60,7 +60,7 @@ public class VoucherPayRepairStrategy extends AbsPayRepairStrategy {
@Override
public void doCloseLocalHandler() {
voucherPayService.close(this.getChannelOrder());
voucherRecordService.payClose(this.getChannelOrder(), this.voucher);
voucherRecordService.payClose(this.getChannelOrder(), this.getOrder().getTitle(), this.voucher);
this.getChannelOrder().setStatus(PayStatusEnum.CLOSE.getCode());
}
}

View File

@@ -61,7 +61,7 @@ public class WalletPayRepairStrategy extends AbsPayRepairStrategy {
@Override
public void doCloseLocalHandler() {
walletPayService.close(this.getChannelOrder(),this.wallet);
walletRecordService.payClose(this.getChannelOrder(),this.wallet);
walletRecordService.payClose(this.getChannelOrder(), this.getOrder().getTitle(), this.wallet);
this.getChannelOrder().setStatus(PayStatusEnum.CLOSE.getCode());
}
}

View File

@@ -35,6 +35,6 @@ public class CashRefundRepairStrategy extends AbsRefundRepairStrategy {
*/
@Override
public void doSuccessHandler() {
cashRecordService.refund(this.getRefundChannelOrder());
cashRecordService.refund(this.getRefundChannelOrder(),this.getPayOrder().getTitle());
}
}

View File

@@ -57,6 +57,6 @@ public class VoucherRefundRepairStrategy extends AbsRefundRepairStrategy {
@Override
public void doSuccessHandler() {
voucherPayService.refund(this.getPayChannelOrder().getAmount(), this.voucher);
voucherRecordService.refund(this.getRefundChannelOrder(), this.voucher);
voucherRecordService.refund(this.getRefundChannelOrder(), this.getPayOrder().getTitle(), this.voucher);
}
}

View File

@@ -77,6 +77,6 @@ public class WalletRefundRepairStrategy extends AbsRefundRepairStrategy {
refundChannelOrder.setStatus(RefundStatusEnum.SUCCESS.getCode());
// 退款真正执行和保存
walletPayService.refund(this.wallet, this.getRefundChannelOrder().getAmount());
walletRecordService.refund(this.getRefundChannelOrder(), this.wallet);
walletRecordService.refund(this.getRefundChannelOrder(), this.getPayOrder().getTitle(), this.wallet);
}
}

View File

@@ -22,6 +22,10 @@ public class WalletRecordDto extends BaseDto {
@Schema(description = "钱包id")
private Long walletId;
/** 标题 */
@Schema(description = "标题")
private String title;
/**
* 业务类型
* @see WalletRecordTypeEnum