ref 去除现金和储值卡

This commit is contained in:
xxm1995
2024-04-18 18:21:38 +08:00
parent fe38c35912
commit 135451dc35
73 changed files with 4 additions and 2939 deletions

View File

@@ -1,25 +1,7 @@
## 单商户
2.0.4: 分账初版
- [x] 支付通道配置是否支持分账
- [x] 分账接收方管理
- [x] 管理
- [x] 同步
- [x] 分账组管理
- [x] 管理
- [x] 绑定
- [x] 默认分账组
- [x] 分账订单管理
- [x] 订单创建
- [x] 发起分账
- [x] 分账完结
- [x] 分账处理
- [x] 发起分账
- [x] 分账同步
- [x] 修复创建支付订单报错时, 订单保存数据不完整
- [x] 收银台演示支持传输分账标识
- [x] SDK支持分账接口
2.0.6: 去除组合支付, 一系列代码优化
- [ ] 删除现金支付和储值卡支付方式
- [ ] 支付订单
- [ ] 去除组合支付和场景,降低逻辑的的复杂度
- [ ] 退款场景
- [ ] 关闭支付订单

View File

@@ -19,9 +19,8 @@ public enum PayChannelEnum {
ALI("ali_pay", "支付宝"),
WECHAT("wechat_pay", "微信支付"),
UNION_PAY("union_pay", "云闪付"),
CASH("cash_pay", "现金支付"),
WALLET("wallet_pay", "钱包支付"),
VOUCHER("voucher_pay", "储值卡支付");
;
/** 支付通道编码 */
private final String code;
/** 支付通道名称 */

View File

@@ -1,20 +0,0 @@
package cn.bootx.platform.daxpay.sdk.param.channel;
import cn.bootx.platform.daxpay.sdk.param.ChannelParam;
import lombok.Getter;
import lombok.Setter;
/**
* 储值卡支付参数
*
* @author xxm
* @since 2022/3/14
*/
@Getter
@Setter
public class VoucherPayParam implements ChannelParam {
/** 储值卡号 */
private String cardNo;
}

View File

@@ -4,7 +4,6 @@ import cn.bootx.platform.daxpay.sdk.code.PayChannelEnum;
import cn.bootx.platform.daxpay.sdk.code.PayWayEnum;
import cn.bootx.platform.daxpay.sdk.param.ChannelParam;
import cn.bootx.platform.daxpay.sdk.param.channel.AliPayParam;
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.channel.WeChatPayParam;
import lombok.Getter;

View File

@@ -6,7 +6,6 @@ import cn.bootx.platform.daxpay.sdk.model.pay.PayOrderModel;
import cn.bootx.platform.daxpay.sdk.net.DaxPayRequest;
import cn.bootx.platform.daxpay.sdk.param.ChannelParam;
import cn.bootx.platform.daxpay.sdk.param.channel.AliPayParam;
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.channel.WeChatPayParam;
import cn.bootx.platform.daxpay.sdk.response.DaxPayResult;

View File

@@ -6,15 +6,12 @@ import cn.bootx.platform.daxpay.sdk.code.SignTypeEnum;
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;
@@ -59,79 +56,4 @@ public class PayOrderTest {
System.out.println(execute.getData());
}
/**
* 多通道支付. 全部为同步支付方式
*/
@Test
public void multiSyncPay() {
PayParam param = new PayParam();
param.setClientIp("127.0.0.1");
param.setNotNotify(true);
param.setBusinessNo("P0005");
param.setTitle("测试组合支付(全同步)");
// 现金支付
PayChannelParam cash = new PayChannelParam();
cash.setChannel(PayChannelEnum.CASH.getCode());
cash.setWay(PayWayEnum.NORMAL.getCode());
cash.setAmount(22);
// 储值卡支付
PayChannelParam card = new PayChannelParam();
card.setChannel(PayChannelEnum.VOUCHER.getCode());
card.setWay(PayWayEnum.NORMAL.getCode());
card.setAmount(20001);
// 储值卡通道参数
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());
}
/**
* 多通道支付. 包含异步支付
*/
@Test
public void multiAsyncPay() {
PayParam param = new PayParam();
param.setClientIp("127.0.0.1");
param.setNotNotify(true);
param.setBusinessNo("P0015");
param.setTitle("测试组合支付(包含异步支付)");
// 现金支付
PayChannelParam cash = new PayChannelParam();
cash.setChannel(PayChannelEnum.CASH.getCode());
cash.setWay(PayWayEnum.NORMAL.getCode());
cash.setAmount(201);
// 异步支付
PayChannelParam async = new PayChannelParam();
async.setChannel(PayChannelEnum.ALI.getCode());
async.setWay(PayWayEnum.WEB.getCode());
async.setAmount(2207);
// 组装组合支付的参数
List<PayChannelParam> payChannels = Arrays.asList(cash, async);
param.setPayChannels(payChannels);
DaxPayResult<PayOrderModel> execute = DaxPayKit.execute(param);
System.out.println(execute);
System.out.println(execute.getData());
}
}

View File

@@ -77,40 +77,4 @@ public class RefundOrderTest {
System.out.println(execute.getData());
}
/**
* 多通道退款
*/
@Test
public void refundOrderByMultiple(){
RefundParam param = new RefundParam();
param.setClientIp("127.0.0.1");
param.setBusinessNo("P0001");
param.setRefundAll(false);
param.setRefundNo("R0001");
// 设置具体的退款参数
RefundChannelParam alipay = new RefundChannelParam();
// 支付宝
alipay.setChannel(PayChannelEnum.ALI.getCode());
alipay.setAmount(12);
// 钱包
RefundChannelParam wallet = new RefundChannelParam();
alipay.setChannel(PayChannelEnum.WALLET.getCode());
alipay.setAmount(10);
// 现金
RefundChannelParam cash = new RefundChannelParam();
alipay.setChannel(PayChannelEnum.CASH.getCode());
alipay.setAmount(20);
List<RefundChannelParam> refundChannels = Arrays.asList(alipay, wallet, cash);
param.setRefundChannels(refundChannels);
DaxPayResult<RefundModel> execute = DaxPayKit.execute(param);
System.out.println(execute);
System.out.println(execute.getData());
}
}

View File

@@ -51,23 +51,4 @@ public class SimplePayOrderTest {
System.out.println(data);
}
/**
* 同步通道+回调测试
*/
@Test
public void simplePayCallback() {
SimplePayParam param = new SimplePayParam();
param.setBusinessNo("P" + RandomUtil.randomNumbers(5));
param.setAmount(12);
param.setTitle("测试接口支付");
param.setChannel(PayChannelEnum.CASH.getCode());
param.setPayWay(PayWayEnum.NORMAL.getCode());
param.setClientIp("127.0.0.1");
param.setAttach("Attach");
param.setNotifyUrl("http://127.0.0.1:9000/demo/callback/payObject");
DaxPayResult<PayOrderModel> execute = DaxPayKit.execute(param);
System.out.println(execute);
PayOrderModel data = execute.getData();
System.out.println(data);
}
}

View File

@@ -1,47 +0,0 @@
package cn.bootx.platform.daxpay.admin.controller.channel;
import cn.bootx.platform.common.core.rest.Res;
import cn.bootx.platform.common.core.rest.ResResult;
import cn.bootx.platform.common.core.rest.dto.LabelValue;
import cn.bootx.platform.daxpay.service.core.channel.cash.service.CashPayConfigService;
import cn.bootx.platform.daxpay.service.dto.channel.cash.CashPayConfigDto;
import cn.bootx.platform.daxpay.service.param.channel.wechat.WalletConfigParam;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 现金支付配置
* @author xxm
* @since 2024/2/17
*/
@Tag(name = "现金支付配置")
@RestController
@RequestMapping("/cash/config")
@RequiredArgsConstructor
public class CashConfigController {
private final CashPayConfigService service;
@Operation(summary = "获取配置")
@GetMapping("/getConfig")
public ResResult<CashPayConfigDto> getConfig() {
return Res.ok(service.getConfig().toDto());
}
@Operation(summary = "更新")
@PostMapping("/update")
public ResResult<Void> update(@RequestBody WalletConfigParam param) {
service.update(param);
return Res.ok();
}
@Operation(summary = "支付宝支持支付方式")
@GetMapping("/findPayWays")
public ResResult<List<LabelValue>> findPayWays() {
return Res.ok(service.findPayWays());
}
}

View File

@@ -1,42 +0,0 @@
package cn.bootx.platform.daxpay.admin.controller.channel;
import cn.bootx.platform.common.core.rest.PageResult;
import cn.bootx.platform.common.core.rest.Res;
import cn.bootx.platform.common.core.rest.ResResult;
import cn.bootx.platform.common.core.rest.param.PageParam;
import cn.bootx.platform.daxpay.service.core.channel.cash.service.CashRecordService;
import cn.bootx.platform.daxpay.service.dto.channel.cash.CashRecordDto;
import cn.bootx.platform.daxpay.service.param.channel.cash.CashRecordQuery;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* 现金控制器
* @author xxm
* @since 2024/2/18
*/
@Tag(name = "现金控制器")
@RestController
@RequestMapping("/cash")
@RequiredArgsConstructor
public class CashController {
private final CashRecordService cashRecordService;
@Operation(summary = "记录分页")
@GetMapping("/record/page")
public ResResult<PageResult<CashRecordDto>> recordPage(PageParam pageParam, CashRecordQuery query){
return Res.ok(cashRecordService.page(pageParam, query));
}
@Operation(summary = "查询记录详情")
@GetMapping("/record/findById")
public ResResult<CashRecordDto> findById(Long id){
return Res.ok(cashRecordService.findById(id));
}
}

View File

@@ -1,46 +0,0 @@
package cn.bootx.platform.daxpay.admin.controller.channel;
import cn.bootx.platform.common.core.rest.Res;
import cn.bootx.platform.common.core.rest.ResResult;
import cn.bootx.platform.common.core.rest.dto.LabelValue;
import cn.bootx.platform.daxpay.service.core.channel.voucher.service.VoucherConfigService;
import cn.bootx.platform.daxpay.service.dto.channel.voucher.VoucherConfigDto;
import cn.bootx.platform.daxpay.service.param.channel.wechat.WalletConfigParam;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 储值卡支付配置
* @author xxm
* @since 2024/2/17
*/
@Tag(name = "储值卡支付配置")
@RestController
@RequestMapping("/voucher/config")
@RequiredArgsConstructor
public class VoucherConfigController {
private final VoucherConfigService service;
@Operation(summary = "获取配置")
@GetMapping("/getConfig")
public ResResult<VoucherConfigDto> getConfig() {
return Res.ok(service.getConfig().toDto());
}
@Operation(summary = "更新")
@PostMapping("/update")
public ResResult<Void> update(@RequestBody WalletConfigParam param) {
service.update(param);
return Res.ok();
}
@Operation(summary = "支付宝支持支付方式")
@GetMapping("/findPayWays")
public ResResult<List<LabelValue>> findPayWays() {
return Res.ok(service.findPayWays());
}
}

View File

@@ -1,72 +0,0 @@
package cn.bootx.platform.daxpay.admin.controller.channel;
import cn.bootx.platform.common.core.rest.PageResult;
import cn.bootx.platform.common.core.rest.Res;
import cn.bootx.platform.common.core.rest.ResResult;
import cn.bootx.platform.common.core.rest.param.PageParam;
import cn.bootx.platform.common.core.util.ValidationUtil;
import cn.bootx.platform.daxpay.service.core.channel.voucher.service.VoucherQueryService;
import cn.bootx.platform.daxpay.service.core.channel.voucher.service.VoucherRecordService;
import cn.bootx.platform.daxpay.service.core.channel.voucher.service.VoucherService;
import cn.bootx.platform.daxpay.service.dto.channel.voucher.VoucherDto;
import cn.bootx.platform.daxpay.service.dto.channel.voucher.VoucherRecordDto;
import cn.bootx.platform.daxpay.service.param.channel.voucher.VoucherImportParam;
import cn.bootx.platform.daxpay.service.param.channel.voucher.VoucherQuery;
import cn.bootx.platform.daxpay.service.param.channel.voucher.VoucherRecordQuery;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
/**
* 储值卡管理
* @author xxm
* @since 2024/2/18
*/
@Tag(name = "储值卡管理")
@RestController
@RequestMapping("/voucher")
@RequiredArgsConstructor
public class VoucherController {
private final VoucherService voucherService;
private final VoucherQueryService voucherQueryService;
private final VoucherRecordService voucherRecordService;
@Operation(summary = "导入储值卡")
@PostMapping("/import")
public ResResult<Void> voucherImport(@RequestBody VoucherImportParam param){
ValidationUtil.validateParam(param);
voucherService.voucherImport(param);
return Res.ok();
}
@Operation(summary = "储值卡分页")
@GetMapping("/page")
public ResResult<PageResult<VoucherDto>> page(PageParam pageParam, VoucherQuery query){
return Res.ok(voucherQueryService.page(pageParam, query));
}
@Operation(summary = "查询储值卡详情")
@GetMapping("/findById")
public ResResult<VoucherDto> findById(Long id){
return Res.ok(voucherQueryService.findById(id));
}
@Operation(summary = "判断卡号是否存在")
@GetMapping("/existsByCardNo")
public ResResult<Boolean> existsByCardNo(String userId){
return Res.ok(voucherQueryService.existsByCardNo(userId));
}
@Operation(summary = "记录分页")
@GetMapping("/record/page")
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

@@ -22,9 +22,8 @@ public enum PayChannelEnum {
ALI("ali_pay", "支付宝", "ali"),
WECHAT("wechat_pay", "微信支付", "wx"),
UNION_PAY("union_pay", "云闪付", "uni"),
CASH("cash_pay", "现金支付",null),
WALLET("wallet_pay", "钱包支付",null),
VOUCHER("voucher_pay", "储值卡支付",null);
;
/** 支付通道编码 */
private final String code;

View File

@@ -1,20 +0,0 @@
package cn.bootx.platform.daxpay.param.channel;
import cn.bootx.platform.daxpay.param.ChannelParam;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
/**
* 储值卡支付参数
*
* @author xxm
* @since 2022/3/14
*/
@Data
@Schema(title = "储值卡支付参数")
public class VoucherPayParam implements ChannelParam {
@Schema(description = "储值卡号")
private String cardNo;
}

View File

@@ -4,7 +4,6 @@ import cn.bootx.platform.daxpay.code.PayChannelEnum;
import cn.bootx.platform.daxpay.code.PayWayEnum;
import cn.bootx.platform.daxpay.param.PaymentCommonParam;
import cn.bootx.platform.daxpay.param.channel.AliPayParam;
import cn.bootx.platform.daxpay.param.channel.VoucherPayParam;
import cn.bootx.platform.daxpay.param.channel.WalletPayParam;
import cn.bootx.platform.daxpay.param.channel.WeChatPayParam;
import cn.bootx.platform.daxpay.serializer.TimestampToLocalDateTimeDeserializer;

View File

@@ -2,7 +2,6 @@ package cn.bootx.platform.daxpay.param.pay;
import cn.bootx.platform.daxpay.param.PaymentCommonParam;
import cn.bootx.platform.daxpay.param.channel.AliPayParam;
import cn.bootx.platform.daxpay.param.channel.VoucherPayParam;
import cn.bootx.platform.daxpay.param.channel.WalletPayParam;
import cn.bootx.platform.daxpay.param.channel.WeChatPayParam;
import io.swagger.v3.oas.annotations.media.Schema;

View File

@@ -1,26 +0,0 @@
package cn.bootx.platform.daxpay.service.code;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* 现金记录类型
* @author xxm
* @since 2024/2/18
*/
@Getter
@AllArgsConstructor
public enum CashRecordTypeEnum {
/** 支付 */
PAY("pay", "支付"),
/** 退款 */
REFUND("refund", "退款"),
/** 支付关闭 */
CLOSE_PAY("close_pay", "支付关闭");
private final String code;
private final String name;
}

View File

@@ -14,12 +14,6 @@ public interface PayWayExtraCode {
/** openId */
String OPEN_ID = "open_id";
/** 单张储值卡 */
String VOUCHER_NO = "voucher_no";
/** 多张储值卡 */
String VOUCHER_NO_LIST = "voucher_no_list";
/** 钱包ID */
String WALLET_ID = "wallet_id";

View File

@@ -1,55 +0,0 @@
package cn.bootx.platform.daxpay.service.code;
/**
* 储值卡常量
*
* @author xxm
* @since 2022/3/14
*/
public interface VoucherCode {
/**
* 状态-正常
*/
String STATUS_NORMAL = "normal";
/**
* 状态-停用
*/
String STATUS_FORBIDDEN = "forbidden";
/**
* 储值卡日志-开通
*/
String LOG_ACTIVE = "active";
/**
* 储值卡日志-导入
*/
String LOG_IMPORT = "import";
/**
* 储值卡日志-预冻结额度
*/
String LOG_FREEZE_BALANCE = "freeze";
/**
* 储值卡日志-扣减并解冻余额
*/
String LOG_REDUCE_AND_UNFREEZE_BALANCE = "reduceAndUnfreeze";
/**
* 储值卡日志-直接支付
*/
String LOG_PAY = "pay";
/**
* 储值卡日志-取消支付
*/
String LOG_CLOSE_PAY = "closePay";
/**
* 储值卡日志-退款到本卡中
*/
String LOG_REFUND_SELF = "refundSelf";
}

View File

@@ -1,38 +0,0 @@
package cn.bootx.platform.daxpay.service.code;
import cn.bootx.platform.daxpay.code.PayWayEnum;
import cn.bootx.platform.daxpay.exception.pay.PayFailureException;
import lombok.experimental.UtilityClass;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
/**
* 储值卡支付方式
* @author xxm
* @since 2024/2/17
*/
@UtilityClass
public class VoucherPayWay {
// 支付方式
private static final List<PayWayEnum> PAY_WAYS = Collections.singletonList(PayWayEnum.NORMAL);
/**
* 根据编码获取
*/
public PayWayEnum findByCode(String code) {
return PAY_WAYS.stream()
.filter(e -> Objects.equals(code, e.getCode()))
.findFirst()
.orElseThrow(() -> new PayFailureException("不存在的支付方式"));
}
/**
* 获取支持的支付方式
*/
public List<PayWayEnum> getPayWays() {
return PAY_WAYS;
}
}

View File

@@ -1,29 +0,0 @@
package cn.bootx.platform.daxpay.service.code;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* 储值卡记录类型
* @author xxm
* @since 2024/2/18
*/
@Getter
@AllArgsConstructor
public enum VoucherRecordTypeEnum {
/** 导入 */
IMPORT("import", "导入"),
/** 支付 */
PAY("pay", "支付"),
/** 退款 */
REFUND("refund", "退款"),
/** 支付关闭 */
CLOSE_PAY("close_pay", "支付关闭");
private final String code;
private final String name;
}

View File

@@ -1,20 +0,0 @@
package cn.bootx.platform.daxpay.service.code;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* 储值卡状态
* @author xxm
* @since 2024/2/17
*/
@Getter
@AllArgsConstructor
public enum VoucherStatusEnum {
NORMAL("normal", "正常"),
FORBIDDEN("forbidden", "禁用");
private final String code;
private final String name;
}

View File

@@ -1,23 +0,0 @@
package cn.bootx.platform.daxpay.service.core.channel.cash.convert;
import cn.bootx.platform.daxpay.service.core.channel.cash.entity.CashConfig;
import cn.bootx.platform.daxpay.service.core.channel.cash.entity.CashRecord;
import cn.bootx.platform.daxpay.service.dto.channel.cash.CashPayConfigDto;
import cn.bootx.platform.daxpay.service.dto.channel.cash.CashRecordDto;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
/**
*
* @author xxm
* @since 2024/2/17
*/
@Mapper
public interface CashPayConfigConvert {
CashPayConfigConvert CONVERT = Mappers.getMapper(CashPayConfigConvert.class);
CashPayConfigDto convert(CashConfig in);
CashRecordDto convert(CashRecord in);
}

View File

@@ -1,18 +0,0 @@
package cn.bootx.platform.daxpay.service.core.channel.cash.dao;
import cn.bootx.platform.common.mybatisplus.impl.BaseManager;
import cn.bootx.platform.daxpay.service.core.channel.cash.entity.CashConfig;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Repository;
/**
* 现金支付配置
* @author xxm
* @since 2024/2/17
*/
@Slf4j
@Repository
@RequiredArgsConstructor
public class CashConfigManager extends BaseManager<CashConfigMapper, CashConfig> {
}

View File

@@ -1,14 +0,0 @@
package cn.bootx.platform.daxpay.service.core.channel.cash.dao;
import cn.bootx.platform.daxpay.service.core.channel.cash.entity.CashConfig;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
/**
* 现金支付配置
* @author xxm
* @since 2024/2/17
*/
@Mapper
public interface CashConfigMapper extends BaseMapper<CashConfig> {
}

View File

@@ -1,33 +0,0 @@
package cn.bootx.platform.daxpay.service.core.channel.cash.dao;
import cn.bootx.platform.common.core.rest.param.PageParam;
import cn.bootx.platform.common.mybatisplus.impl.BaseManager;
import cn.bootx.platform.common.mybatisplus.util.MpUtil;
import cn.bootx.platform.common.query.generator.QueryGenerator;
import cn.bootx.platform.daxpay.service.core.channel.cash.entity.CashRecord;
import cn.bootx.platform.daxpay.service.param.channel.cash.CashRecordQuery;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Repository;
/**
*
* @author xxm
* @since 2024/2/18
*/
@Slf4j
@Repository
@RequiredArgsConstructor
public class CashRecordManager extends BaseManager<CashRecordMapper, CashRecord> {
/**
* 分页
*/
public Page<CashRecord> page(PageParam pageParam, CashRecordQuery param){
Page<CashRecord> mpPage = MpUtil.getMpPage(pageParam, CashRecord.class);
QueryWrapper<CashRecord> generator = QueryGenerator.generator(param);
return this.page(mpPage, generator);
}
}

View File

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

View File

@@ -1,57 +0,0 @@
package cn.bootx.platform.daxpay.service.core.channel.cash.entity;
import cn.bootx.platform.common.core.function.EntityBaseFunction;
import cn.bootx.platform.common.mybatisplus.base.MpBaseEntity;
import cn.bootx.platform.common.mybatisplus.handler.StringListTypeHandler;
import cn.bootx.platform.daxpay.service.core.channel.cash.convert.CashPayConfigConvert;
import cn.bootx.platform.daxpay.service.dto.channel.cash.CashPayConfigDto;
import cn.bootx.table.modify.annotation.DbColumn;
import cn.bootx.table.modify.annotation.DbTable;
import cn.bootx.table.modify.mysql.annotation.DbMySqlFieldType;
import cn.bootx.table.modify.mysql.constants.MySqlFieldTypeEnum;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.util.List;
/**
* 现金支付配置类
* @author xxm
* @since 2024/2/17
*/
@EqualsAndHashCode(callSuper = true)
@Data
@Accessors(chain = true)
@DbTable(comment = "现金支付配置")
@TableName(value = "pay_cash_config",autoResultMap = true)
public class CashConfig extends MpBaseEntity implements EntityBaseFunction<CashPayConfigDto> {
/** 是否启用 */
@DbColumn(comment = "是否启用")
private Boolean enable;
/** 单次支付最多多少金额 */
@DbColumn(comment = "单次支付最多多少金额 ")
private Integer singleLimit;
/** 可用支付方式 */
@DbColumn(comment = "可用支付方式")
@DbMySqlFieldType(MySqlFieldTypeEnum.VARCHAR)
@TableField(typeHandler = StringListTypeHandler.class)
private List<String> payWays;
/** 备注 */
@DbColumn(comment = "备注")
private String remark;
/**
* 转换
*/
@Override
public CashPayConfigDto toDto() {
return CashPayConfigConvert.CONVERT.convert(this);
}
}

View File

@@ -1,62 +0,0 @@
package cn.bootx.platform.daxpay.service.core.channel.cash.entity;
import cn.bootx.platform.common.core.function.EntityBaseFunction;
import cn.bootx.platform.common.mybatisplus.base.MpCreateEntity;
import cn.bootx.platform.daxpay.service.code.CashRecordTypeEnum;
import cn.bootx.platform.daxpay.service.core.channel.cash.convert.CashPayConfigConvert;
import cn.bootx.platform.daxpay.service.dto.channel.cash.CashRecordDto;
import cn.bootx.table.modify.annotation.DbColumn;
import cn.bootx.table.modify.annotation.DbTable;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* 现金记录
* @author xxm
* @since 2024/2/17
*/
@EqualsAndHashCode(callSuper = true)
@Data
@Accessors(chain = true)
@DbTable(comment = "现金记录")
public class CashRecord extends MpCreateEntity implements EntityBaseFunction<CashRecordDto> {
/** 标题 */
@DbColumn(comment = "标题")
private String title;
/**
* 业务类型
* @see CashRecordTypeEnum
*/
@DbColumn(comment = "业务类型")
private String type;
/** 金额 */
@DbColumn(comment = "金额")
private Integer amount;
/**
* 交易订单号
* 支付订单/退款订单
*/
@DbColumn(comment = "交易订单号")
private String orderId;
/** 终端ip */
@DbColumn(comment = "终端ip")
private String ip;
/** 备注 */
@DbColumn(comment = "备注")
private String remark;
/**
* 转换
*/
@Override
public CashRecordDto toDto() {
return CashPayConfigConvert.CONVERT.convert(this);
}
}

View File

@@ -1,74 +0,0 @@
package cn.bootx.platform.daxpay.service.core.channel.cash.service;
import cn.bootx.platform.common.core.exception.DataNotExistException;
import cn.bootx.platform.common.core.rest.dto.LabelValue;
import cn.bootx.platform.daxpay.code.PayChannelEnum;
import cn.bootx.platform.daxpay.exception.pay.PayFailureException;
import cn.bootx.platform.daxpay.service.code.WalletPayWay;
import cn.bootx.platform.daxpay.service.core.channel.cash.dao.CashConfigManager;
import cn.bootx.platform.daxpay.service.core.channel.cash.entity.CashConfig;
import cn.bootx.platform.daxpay.service.core.system.config.service.PayChannelConfigService;
import cn.bootx.platform.daxpay.service.param.channel.wechat.WalletConfigParam;
import cn.hutool.core.bean.BeanUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
/**
* 现金支付配置
* @author xxm
* @since 2024/2/17
*/
@Slf4j
@Service
@RequiredArgsConstructor
public class CashPayConfigService {
private final static Long ID = 0L;
private final CashConfigManager cashConfigManager;
private final PayChannelConfigService payChannelConfigService;
/**
* 获取钱包配置
*/
public CashConfig getConfig(){
return cashConfigManager.findById(ID).orElseThrow(() -> new DataNotExistException("现金配置不存在"));
}
/**
* 获取并检查钱包配置
*/
public CashConfig getAndCheckConfig() {
CashConfig config = this.getConfig();
if (!config.getEnable()){
throw new PayFailureException("钱包支付未启用");
}
return config;
}
/**
* 更新
*/
@Transactional(rollbackFor = Exception.class)
public void update(WalletConfigParam param){
CashConfig walletConfig = cashConfigManager.findById(param.getId()).orElseThrow(DataNotExistException::new);
// 启用或停用
if (!Objects.equals(param.getEnable(), walletConfig.getEnable())){
payChannelConfigService.setEnable(PayChannelEnum.CASH.getCode(), param.getEnable());
}
BeanUtil.copyProperties(param,walletConfig);
cashConfigManager.updateById(walletConfig);
}
public List<LabelValue> findPayWays() {
return WalletPayWay.getPayWays()
.stream()
.map(e -> new LabelValue(e.getName(),e.getCode()))
.collect(Collectors.toList());
}
}

View File

@@ -1,79 +0,0 @@
package cn.bootx.platform.daxpay.service.core.channel.cash.service;
import cn.bootx.platform.common.core.rest.PageResult;
import cn.bootx.platform.common.core.rest.param.PageParam;
import cn.bootx.platform.common.mybatisplus.util.MpUtil;
import cn.bootx.platform.daxpay.service.code.CashRecordTypeEnum;
import cn.bootx.platform.daxpay.service.core.channel.cash.dao.CashRecordManager;
import cn.bootx.platform.daxpay.service.core.channel.cash.entity.CashRecord;
import cn.bootx.platform.daxpay.service.core.order.pay.entity.PayChannelOrder;
import cn.bootx.platform.daxpay.service.core.order.refund.entity.RefundChannelOrder;
import cn.bootx.platform.daxpay.service.dto.channel.cash.CashRecordDto;
import cn.bootx.platform.daxpay.service.param.channel.cash.CashRecordQuery;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
/**
* 现金记录
*
* @author xxm
* @since 2021/6/23
*/
@Slf4j
@Service
@RequiredArgsConstructor
public class CashRecordService {
private final CashRecordManager cashRecordManager;
/**
* 支付保存
*/
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()));
cashRecordManager.save(record);
}
/**
* 退款保存
*/
public void refund(RefundChannelOrder channelOrder, String title){
CashRecord record = new CashRecord()
.setTitle(title)
.setType(CashRecordTypeEnum.REFUND.getCode())
.setAmount(channelOrder.getAmount())
.setOrderId(String.valueOf(channelOrder.getRefundId()));
cashRecordManager.save(record);
}
/**
* 支付关闭
*/
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()));
cashRecordManager.save(record);
}
/**
* 分页查询
*/
public PageResult<CashRecordDto> page(PageParam pageParam, CashRecordQuery param) {
return MpUtil.convert2DtoPageResult(cashRecordManager.page(pageParam, param));
}
/**
* 查询详情
*/
public CashRecordDto findById(Long id){
return cashRecordManager.findById(id).map(CashRecord::toDto).orElseGet(CashRecordDto::new);
}
}

View File

@@ -1,33 +0,0 @@
package cn.bootx.platform.daxpay.service.core.channel.voucher.convert;
import cn.bootx.platform.daxpay.service.core.channel.voucher.entity.Voucher;
import cn.bootx.platform.daxpay.service.core.channel.voucher.entity.VoucherConfig;
import cn.bootx.platform.daxpay.service.core.channel.voucher.entity.VoucherRecord;
import cn.bootx.platform.daxpay.service.dto.channel.voucher.VoucherConfigDto;
import cn.bootx.platform.daxpay.service.dto.channel.voucher.VoucherDto;
import cn.bootx.platform.daxpay.service.dto.channel.voucher.VoucherRecordDto;
import cn.bootx.platform.daxpay.service.param.channel.voucher.VoucherBatchImportParam;
import cn.bootx.platform.daxpay.service.param.channel.voucher.VoucherImportParam;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
/**
* @author xxm
* @since 2022/3/14
*/
@Mapper
public interface VoucherConvert {
VoucherConvert CONVERT = Mappers.getMapper(VoucherConvert.class);
VoucherDto convert(Voucher in);
VoucherRecordDto convert(VoucherRecord in);
VoucherConfigDto convert(VoucherConfig in);
Voucher convert(VoucherImportParam in);
Voucher convert(VoucherBatchImportParam in);
}

View File

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

View File

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

View File

@@ -1,86 +0,0 @@
package cn.bootx.platform.daxpay.service.core.channel.voucher.dao;
import cn.bootx.platform.common.core.rest.param.PageParam;
import cn.bootx.platform.common.mybatisplus.base.MpDelEntity;
import cn.bootx.platform.common.mybatisplus.base.MpIdEntity;
import cn.bootx.platform.common.mybatisplus.impl.BaseManager;
import cn.bootx.platform.common.mybatisplus.util.MpUtil;
import cn.bootx.platform.common.query.generator.QueryGenerator;
import cn.bootx.platform.daxpay.service.core.channel.voucher.entity.Voucher;
import cn.bootx.platform.daxpay.service.param.channel.voucher.VoucherQuery;
import cn.bootx.platform.starter.auth.util.SecurityUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Repository;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Optional;
/**
* @author xxm
* @since 2022/3/14
*/
@Slf4j
@Repository
@RequiredArgsConstructor
public class VoucherManager extends BaseManager<VoucherMapper, Voucher> {
/**
* 分页
*/
public Page<Voucher> page(PageParam pageParam, VoucherQuery query) {
QueryWrapper<Voucher> generator = QueryGenerator.generator(query);
Page<Voucher> mpPage = MpUtil.getMpPage(pageParam, Voucher.class);
return this.page(mpPage, generator);
}
/**
* 根据卡号查询
*/
public Optional<Voucher> findByCardNo(String cardNo) {
return this.findByField(Voucher::getCardNo, cardNo);
}
/**
* 根据卡号查询
*/
public List<Voucher> findByCardNoList(List<String> cardNos) {
return this.findAllByFields(Voucher::getCardNo, cardNos);
}
/**
* 更改状态
*/
public void changeStatus(Long id, String status) {
Long userIdOrDefaultId = SecurityUtil.getUserIdOrDefaultId();
this.lambdaUpdate()
.eq(MpIdEntity::getId, id)
.set(MpDelEntity::getLastModifiedTime, LocalDateTime.now())
.set(MpDelEntity::getLastModifier, userIdOrDefaultId)
.set(Voucher::getStatus, status)
.update();
}
/**
* 批量更改状态
*/
public void changeStatusBatch(List<Long> ids, String status) {
Long userIdOrDefaultId = SecurityUtil.getUserIdOrDefaultId();
this.lambdaUpdate().in(MpIdEntity::getId, ids)
.set(MpDelEntity::getLastModifiedTime, LocalDateTime.now())
.set(MpDelEntity::getLastModifier,userIdOrDefaultId)
.set(Voucher::getStatus, status)
.update();
}
/**
* 卡号是否存在
*/
public boolean existsByCardNo(String cardNo) {
return this.existedByField(Voucher::getCardNo, cardNo);
}
}

View File

@@ -1,14 +0,0 @@
package cn.bootx.platform.daxpay.service.core.channel.voucher.dao;
import cn.bootx.platform.daxpay.service.core.channel.voucher.entity.Voucher;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
/**
* @author xxm
* @since 2022/3/14
*/
@Mapper
public interface VoucherMapper extends BaseMapper<Voucher> {
}

View File

@@ -1,33 +0,0 @@
package cn.bootx.platform.daxpay.service.core.channel.voucher.dao;
import cn.bootx.platform.common.core.rest.param.PageParam;
import cn.bootx.platform.common.mybatisplus.impl.BaseManager;
import cn.bootx.platform.common.mybatisplus.util.MpUtil;
import cn.bootx.platform.common.query.generator.QueryGenerator;
import cn.bootx.platform.daxpay.service.core.channel.voucher.entity.VoucherRecord;
import cn.bootx.platform.daxpay.service.param.channel.voucher.VoucherRecordQuery;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Repository;
/**
*
* @author xxm
* @since 2024/2/18
*/
@Slf4j
@Repository
@RequiredArgsConstructor
public class VoucherRecordManager extends BaseManager<VoucherRecordMapper, VoucherRecord> {
/**
* 分页
*/
public Page<VoucherRecord> page(PageParam pageParam, VoucherRecordQuery param){
Page<VoucherRecord> mpPage = MpUtil.getMpPage(pageParam, VoucherRecord.class);
QueryWrapper<VoucherRecord> generator = QueryGenerator.generator(param);
return this.page(mpPage, generator);
}
}

View File

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

View File

@@ -1,68 +0,0 @@
package cn.bootx.platform.daxpay.service.core.channel.voucher.entity;
import cn.bootx.platform.common.core.function.EntityBaseFunction;
import cn.bootx.platform.common.mybatisplus.base.MpBaseEntity;
import cn.bootx.platform.daxpay.service.code.VoucherStatusEnum;
import cn.bootx.platform.daxpay.service.core.channel.voucher.convert.VoucherConvert;
import cn.bootx.platform.daxpay.service.dto.channel.voucher.VoucherDto;
import cn.bootx.table.modify.annotation.DbColumn;
import cn.bootx.table.modify.annotation.DbTable;
import cn.bootx.table.modify.mysql.annotation.DbMySqlIndex;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.time.LocalDateTime;
/**
* 储值卡
*
* @author xxm
* @since 2022/3/14
*/
@EqualsAndHashCode(callSuper = true)
@Data
@DbTable(comment = "储值卡")
@Accessors(chain = true)
@TableName("pay_voucher")
public class Voucher extends MpBaseEntity implements EntityBaseFunction<VoucherDto> {
/** 卡号 */
@DbColumn(comment = "卡号")
@DbMySqlIndex(comment = "卡号索引")
private String cardNo;
/** 面值 */
@DbColumn(comment = "面值")
private Integer faceValue;
/** 余额 */
@DbColumn(comment = "余额")
private Integer balance;
/** 是否长期有效 */
@DbColumn(comment = "是否长期有效")
private boolean enduring;
/** 开始时间 */
@DbColumn(comment = "开始时间")
private LocalDateTime startTime;
/** 结束时间 */
@DbColumn(comment = "结束时间")
private LocalDateTime endTime;
/**
* 状态
* @see VoucherStatusEnum
*/
@DbColumn(comment = "状态")
private String status;
@Override
public VoucherDto toDto() {
return VoucherConvert.CONVERT.convert(this);
}
}

View File

@@ -1,58 +0,0 @@
package cn.bootx.platform.daxpay.service.core.channel.voucher.entity;
import cn.bootx.platform.common.core.function.EntityBaseFunction;
import cn.bootx.platform.common.mybatisplus.base.MpBaseEntity;
import cn.bootx.platform.common.mybatisplus.handler.StringListTypeHandler;
import cn.bootx.platform.daxpay.service.core.channel.voucher.convert.VoucherConvert;
import cn.bootx.platform.daxpay.service.dto.channel.voucher.VoucherConfigDto;
import cn.bootx.table.modify.annotation.DbColumn;
import cn.bootx.table.modify.annotation.DbTable;
import cn.bootx.table.modify.mysql.annotation.DbMySqlFieldType;
import cn.bootx.table.modify.mysql.constants.MySqlFieldTypeEnum;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.util.List;
/**
* 储值卡配置
* @author xxm
* @since 2024/2/17
*/
@EqualsAndHashCode(callSuper = true)
@Data
@Accessors(chain = true)
@DbTable(comment = "储值卡配置")
@TableName(value = "pay_voucher_config",autoResultMap = true)
public class VoucherConfig extends MpBaseEntity implements EntityBaseFunction<VoucherConfigDto> {
/** 是否启用 */
@DbColumn(comment = "是否启用")
private Boolean enable;
/** 单次支付最多多少金额 */
@DbColumn(comment = "单次支付最多多少金额 ")
private Integer singleLimit;
/** 可用支付方式 */
@DbColumn(comment = "可用支付方式")
@DbMySqlFieldType(MySqlFieldTypeEnum.VARCHAR)
@TableField(typeHandler = StringListTypeHandler.class)
private List<String> payWays;
/** 备注 */
@DbColumn(comment = "备注")
private String remark;
/**
* 转换
*/
@Override
public VoucherConfigDto toDto() {
return VoucherConvert.CONVERT.convert(this);
}
}

View File

@@ -1,79 +0,0 @@
package cn.bootx.platform.daxpay.service.core.channel.voucher.entity;
import cn.bootx.platform.common.core.function.EntityBaseFunction;
import cn.bootx.platform.common.mybatisplus.base.MpCreateEntity;
import cn.bootx.platform.daxpay.service.code.VoucherRecordTypeEnum;
import cn.bootx.platform.daxpay.service.core.channel.voucher.convert.VoucherConvert;
import cn.bootx.platform.daxpay.service.dto.channel.voucher.VoucherRecordDto;
import cn.bootx.table.modify.annotation.DbColumn;
import cn.bootx.table.modify.annotation.DbTable;
import cn.bootx.table.modify.mysql.annotation.DbMySqlIndex;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* 储值卡记录
* @author xxm
* @since 2023/6/29
*/
@EqualsAndHashCode(callSuper = true)
@Data
@Accessors(chain = true)
@TableName(value = "pay_voucher_record")
@DbTable(comment = "储值卡记录")
public class VoucherRecord extends MpCreateEntity implements EntityBaseFunction<VoucherRecordDto> {
/** 储值卡id */
@DbMySqlIndex(comment = "储值卡ID")
@DbColumn(comment = "储值卡id")
private Long voucherId;
/** 标题 */
@DbColumn(comment = "标题")
private String title;
/**
* 业务类型
* @see VoucherRecordTypeEnum
*/
@DbColumn(comment = "业务类型")
private String type;
/** 金额 */
@DbColumn(comment = "金额")
private Integer amount;
/** 变动之前的金额 */
@DbColumn(comment = "变动之前的金额")
private Integer oldAmount;
/** 变动之后的金额 */
@DbColumn(comment = "变动之后的金额")
private Integer newAmount;
/**
* 交易订单号
* 支付订单/退款订单
*/
@DbColumn(comment = "交易订单号")
private String orderId;
/** 终端ip */
@DbColumn(comment = "终端ip")
private String ip;
/** 备注 */
@DbColumn(comment = "备注")
private String remark;
/**
* 转换
*/
@Override
public VoucherRecordDto toDto() {
return VoucherConvert.CONVERT.convert(this);
}
}

View File

@@ -1,75 +0,0 @@
package cn.bootx.platform.daxpay.service.core.channel.voucher.service;
import cn.bootx.platform.common.core.exception.DataNotExistException;
import cn.bootx.platform.common.core.rest.dto.LabelValue;
import cn.bootx.platform.daxpay.code.PayChannelEnum;
import cn.bootx.platform.daxpay.exception.pay.PayFailureException;
import cn.bootx.platform.daxpay.service.code.VoucherPayWay;
import cn.bootx.platform.daxpay.service.core.channel.voucher.dao.VoucherConfigManager;
import cn.bootx.platform.daxpay.service.core.channel.voucher.entity.VoucherConfig;
import cn.bootx.platform.daxpay.service.core.system.config.service.PayChannelConfigService;
import cn.bootx.platform.daxpay.service.param.channel.wechat.WalletConfigParam;
import cn.hutool.core.bean.BeanUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
/**
* 储值卡配置
* @author xxm
* @since 2024/2/17
*/
@Slf4j
@Service
@RequiredArgsConstructor
public class VoucherConfigService {
private final VoucherConfigManager manager;
private final static Long ID = 0L;
private final PayChannelConfigService payChannelConfigService;
/**
* 获取储值卡配置
*/
public VoucherConfig getConfig(){
return manager.findById(ID).orElseThrow(() -> new DataNotExistException("储值卡配置不存在"));
}
/**
* 获取并检查储值卡配置
*/
public VoucherConfig getAndCheckConfig() {
VoucherConfig config = this.getConfig();
if (!config.getEnable()){
throw new PayFailureException("储值卡支付未启用");
}
return config;
}
/**
* 更新
*/
@Transactional(rollbackFor = Exception.class)
public void update(WalletConfigParam param){
VoucherConfig walletConfig = manager.findById(param.getId()).orElseThrow(DataNotExistException::new);
// 启用或停用
if (!Objects.equals(param.getEnable(), walletConfig.getEnable())){
payChannelConfigService.setEnable(PayChannelEnum.VOUCHER.getCode(), param.getEnable());
}
BeanUtil.copyProperties(param,walletConfig);
manager.updateById(walletConfig);
}
public List<LabelValue> findPayWays() {
return VoucherPayWay.getPayWays()
.stream()
.map(e -> new LabelValue(e.getName(),e.getCode()))
.collect(Collectors.toList());
}
}

View File

@@ -1,62 +0,0 @@
package cn.bootx.platform.daxpay.service.core.channel.voucher.service;
import cn.bootx.platform.daxpay.exception.pay.PayFailureException;
import cn.bootx.platform.daxpay.param.channel.VoucherPayParam;
import cn.bootx.platform.daxpay.service.core.channel.voucher.dao.VoucherManager;
import cn.bootx.platform.daxpay.service.core.channel.voucher.entity.Voucher;
import cn.bootx.platform.daxpay.service.core.order.pay.entity.PayChannelOrder;
import cn.hutool.json.JSONUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/**
* 储值卡支付
*
* @author xxm
* @since 2022/3/14
*/
@Slf4j
@Service
@RequiredArgsConstructor
public class VoucherPayService {
private final VoucherManager voucherManager;
private final VoucherQueryService voucherQueryService;
/**
* 支付
*/
@Transactional(rollbackFor = Exception.class)
public void pay(Integer amount, Voucher voucher) {
// 记录当前卡扣了多少钱 储值卡余额-待支付额
voucher.setBalance(voucher.getBalance()-amount);
voucherManager.updateById(voucher);
}
/**
* 关闭支付,解除冻结的额度, 只有在异步支付中才会发生关闭操作
*/
public void close(PayChannelOrder channelOrder) {
// 获取使用的储值卡参数
String channelExtra = channelOrder.getChannelExtra();
VoucherPayParam voucherPayParam = JSONUtil.toBean(channelExtra, VoucherPayParam.class);
Voucher voucher = voucherManager.findByCardNo(voucherPayParam.getCardNo())
.orElseThrow(() -> new PayFailureException("储值卡不存在"));
voucher.setBalance(voucher.getBalance()+channelOrder.getAmount());
voucherManager.updateById(voucher);
}
/**
* 退款
*/
@Transactional(rollbackFor = Exception.class)
public void refund(int amount, Voucher voucher) {
voucher.setBalance(voucher.getBalance()+amount);
voucherManager.updateById(voucher);
}
}

View File

@@ -1,116 +0,0 @@
package cn.bootx.platform.daxpay.service.core.channel.voucher.service;
import cn.bootx.platform.common.core.exception.DataNotExistException;
import cn.bootx.platform.common.core.rest.PageResult;
import cn.bootx.platform.common.core.rest.param.PageParam;
import cn.bootx.platform.common.core.util.LocalDateTimeUtil;
import cn.bootx.platform.common.mybatisplus.util.MpUtil;
import cn.bootx.platform.daxpay.exception.pay.PayFailureException;
import cn.bootx.platform.daxpay.param.channel.VoucherPayParam;
import cn.bootx.platform.daxpay.service.core.channel.voucher.dao.VoucherManager;
import cn.bootx.platform.daxpay.service.core.channel.voucher.entity.Voucher;
import cn.bootx.platform.daxpay.service.dto.channel.voucher.VoucherDto;
import cn.bootx.platform.daxpay.service.param.channel.voucher.VoucherQuery;
import cn.hutool.core.util.StrUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
/**
* 储值卡查询
*
* @author xxm
* @since 2022/3/14
*/
@Slf4j
@Service
@RequiredArgsConstructor
public class VoucherQueryService {
private final VoucherManager voucherManager;
/**
* 分页
*/
public PageResult<VoucherDto> page(PageParam pageParam, VoucherQuery query) {
return MpUtil.convert2DtoPageResult(voucherManager.page(pageParam, query));
}
/**
* 根据id查询
*/
public VoucherDto findById(Long id) {
return voucherManager.findById(id).map(Voucher::toDto).orElseThrow(() -> new DataNotExistException("储值卡不存在"));
}
/**
* 根据卡号查询
*/
public VoucherDto findByCardNo(String cardNo) {
return voucherManager.findByCardNo(cardNo)
.map(Voucher::toDto)
.orElseThrow(() -> new DataNotExistException("储值卡不存在"));
}
/**
* 根据卡号查询
*/
public Voucher getVoucherByCardNo(String cardNo) {
return voucherManager.findByCardNo(cardNo)
.orElseThrow(() -> new DataNotExistException("储值卡不存在"));
}
/**
* 获取并检查储值卡
*/
public Voucher getAndCheckVoucher(VoucherPayParam voucherPayParam) {
String cardNo = voucherPayParam.getCardNo();
Voucher voucher = voucherManager.findByCardNo(cardNo).orElseThrow(()->new PayFailureException("储值卡不存在"));
// 卡信息校验
String timeCheck = this.check(voucher);
if (StrUtil.isNotBlank(timeCheck)) {
throw new PayFailureException(timeCheck);
}
return voucher;
}
/**
* 判断卡号是否存在
*/
public boolean existsByCardNo(String cardNo){
return voucherManager.existsByCardNo(cardNo);
}
/**
* 获取并判断卡状态
*/
public VoucherDto getAndJudgeVoucher(String cardNo){
Voucher voucher = voucherManager.findByCardNo(cardNo).orElseThrow(() -> new DataNotExistException("储值卡不存在"));
// 过期
String checkMsg = this.check(voucher);
if (StrUtil.isNotBlank(checkMsg)){
throw new PayFailureException(checkMsg);
}
return voucher.toDto();
}
/**
* 卡信息检查
*/
public String check(Voucher voucher) {
// 有效期校验
if (voucher.isEnduring()){
return null;
}
LocalDateTime now = LocalDateTime.now();
if (!LocalDateTimeUtil.between(now, voucher.getStartTime(), voucher.getEndTime())){
return "";
}
return null;
}
}

View File

@@ -1,102 +0,0 @@
package cn.bootx.platform.daxpay.service.core.channel.voucher.service;
import cn.bootx.platform.common.core.rest.PageResult;
import cn.bootx.platform.common.core.rest.param.PageParam;
import cn.bootx.platform.common.mybatisplus.util.MpUtil;
import cn.bootx.platform.daxpay.service.code.VoucherRecordTypeEnum;
import cn.bootx.platform.daxpay.service.core.channel.voucher.dao.VoucherRecordManager;
import cn.bootx.platform.daxpay.service.core.channel.voucher.entity.Voucher;
import cn.bootx.platform.daxpay.service.core.channel.voucher.entity.VoucherRecord;
import cn.bootx.platform.daxpay.service.core.order.pay.entity.PayChannelOrder;
import cn.bootx.platform.daxpay.service.core.order.refund.entity.RefundChannelOrder;
import cn.bootx.platform.daxpay.service.dto.channel.voucher.VoucherRecordDto;
import cn.bootx.platform.daxpay.service.param.channel.voucher.VoucherRecordQuery;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
/**
* 储值卡记录
* @author xxm
* @since 2024/2/18
*/
@Slf4j
@Service
@RequiredArgsConstructor
public class VoucherRecordService {
private final VoucherRecordManager manager;
/**
* 导入保存
*/
public void importVoucher(Voucher voucher){
VoucherRecord voucherRecord = new VoucherRecord()
.setTitle("导入储值卡")
.setType(VoucherRecordTypeEnum.IMPORT.getCode())
.setAmount(voucher.getBalance())
.setNewAmount(voucher.getBalance())
.setOldAmount(0)
.setVoucherId(voucher.getId());
manager.save(voucherRecord);
}
/**
* 支付保存
*/
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())
.setOldAmount(voucher.getBalance() - channelOrder.getAmount())
.setOrderId(String.valueOf(channelOrder.getPaymentId()))
.setVoucherId(voucher.getId());
manager.save(voucherRecord);
}
/**
* 退款保存
*/
public void refund(RefundChannelOrder channelOrder, String title, Voucher voucher){
VoucherRecord voucherRecord = new VoucherRecord()
.setTitle(title)
.setType(VoucherRecordTypeEnum.REFUND.getCode())
.setAmount(channelOrder.getAmount())
.setNewAmount(voucher.getBalance())
.setOldAmount(voucher.getBalance() + channelOrder.getAmount())
.setOrderId(String.valueOf(channelOrder.getRefundId()))
.setVoucherId(voucher.getId());
manager.save(voucherRecord);
}
/**
* 支付关闭
*/
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())
.setOldAmount(voucher.getBalance() - channelOrder.getAmount())
.setOrderId(String.valueOf(channelOrder.getPaymentId()))
.setVoucherId(voucher.getId());
manager.save(voucherRecord);
}
/**
* 分页查询
*/
public PageResult<VoucherRecordDto> page(PageParam pageParam, VoucherRecordQuery param) {
return MpUtil.convert2DtoPageResult(manager.page(pageParam, param));
}
/**
* 查询详情
*/
public VoucherRecordDto findById(Long id){
return manager.findById(id).map(VoucherRecord::toDto).orElseGet(VoucherRecordDto::new);
}
}

View File

@@ -1,74 +0,0 @@
package cn.bootx.platform.daxpay.service.core.channel.voucher.service;
import cn.bootx.platform.common.core.exception.BizException;
import cn.bootx.platform.daxpay.service.code.VoucherCode;
import cn.bootx.platform.daxpay.service.core.channel.voucher.convert.VoucherConvert;
import cn.bootx.platform.daxpay.service.core.channel.voucher.dao.VoucherManager;
import cn.bootx.platform.daxpay.service.core.channel.voucher.entity.Voucher;
import cn.bootx.platform.daxpay.service.param.channel.voucher.VoucherBatchImportParam;
import cn.bootx.platform.daxpay.service.param.channel.voucher.VoucherImportParam;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.stream.Collectors;
/**
* 储值卡
*
* @author xxm
* @since 2022/3/14
*/
@Slf4j
@Service
@RequiredArgsConstructor
public class VoucherService {
private final VoucherManager voucherManager;
private final VoucherRecordService recordService;
/**
* 导入
*/
@Transactional(rollbackFor = Exception.class)
public void voucherImport(VoucherImportParam param){
Voucher voucher = VoucherConvert.CONVERT.convert(param);
// 判断重复
if (voucherManager.existsByCardNo(param.getCardNo())) {
throw new BizException("储值卡已存在");
}
voucherManager.save(voucher);
recordService.importVoucher(voucher);
}
/**
* 批量导入
*/
@Transactional(rollbackFor = Exception.class)
public void voucherBatchImport(VoucherBatchImportParam param){
List<Voucher> voucherList = param.cardNoList.stream()
.map(cardNo -> VoucherConvert.CONVERT.convert(param)
.setCardNo(cardNo))
.collect(Collectors.toList());
voucherManager.saveAll(voucherList);
}
/**
* 启用
*/
public void unlock(Long id) {
voucherManager.findById(id).orElseThrow(() -> new BizException("储值卡不存在"));
voucherManager.changeStatus(id, VoucherCode.STATUS_NORMAL);
}
/**
* 冻结
*/
public void lock(Long id) {
voucherManager.changeStatus(id, VoucherCode.STATUS_FORBIDDEN);
}
}

View File

@@ -4,7 +4,6 @@ import cn.bootx.platform.common.core.function.EntityBaseFunction;
import cn.bootx.platform.common.mybatisplus.base.MpCreateEntity;
import cn.bootx.platform.daxpay.code.PayStatusEnum;
import cn.bootx.platform.daxpay.param.channel.AliPayParam;
import cn.bootx.platform.daxpay.param.channel.VoucherPayParam;
import cn.bootx.platform.daxpay.param.channel.WalletPayParam;
import cn.bootx.platform.daxpay.param.channel.WeChatPayParam;
import cn.bootx.platform.daxpay.service.core.order.pay.convert.PayOrderConvert;

View File

@@ -42,15 +42,9 @@ public class PayCloseStrategyFactory {
case UNION_PAY:
strategy = SpringUtil.getBean(UnionPayCloseStrategy.class);
break;
case CASH:
strategy = SpringUtil.getBean(CashPayCloseStrategy.class);
break;
case WALLET:
strategy = SpringUtil.getBean(WalletPayCloseStrategy.class);
break;
case VOUCHER:
strategy = SpringUtil.getBean(VoucherPayCloseStrategy.class);
break;
default:
throw new PayUnsupportedMethodException();
}

View File

@@ -1,37 +0,0 @@
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;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
import static org.springframework.beans.factory.config.BeanDefinition.SCOPE_PROTOTYPE;
/**
* 现金支付关闭策略
* @author xxm
* @since 2023/12/30
*/
@Slf4j
@Scope(SCOPE_PROTOTYPE)
@Service
@RequiredArgsConstructor
public class CashPayCloseStrategy extends AbsPayCloseStrategy {
private final CashRecordService cashRecordService;
@Override
public PayChannelEnum getChannel() {
return PayChannelEnum.CASH;
}
/**
* 关闭操作
*/
@Override
public void doCloseHandler() {
cashRecordService.payClose(this.getChannelOrder(),this.getOrder().getTitle());
}
}

View File

@@ -1,60 +0,0 @@
package cn.bootx.platform.daxpay.service.core.payment.close.strategy;
import cn.bootx.platform.daxpay.code.PayChannelEnum;
import cn.bootx.platform.daxpay.param.channel.VoucherPayParam;
import cn.bootx.platform.daxpay.service.core.channel.voucher.entity.Voucher;
import cn.bootx.platform.daxpay.service.core.channel.voucher.service.VoucherPayService;
import cn.bootx.platform.daxpay.service.core.channel.voucher.service.VoucherQueryService;
import cn.bootx.platform.daxpay.service.core.channel.voucher.service.VoucherRecordService;
import cn.bootx.platform.daxpay.service.func.AbsPayCloseStrategy;
import cn.hutool.json.JSONUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
import static org.springframework.beans.factory.config.BeanDefinition.SCOPE_PROTOTYPE;
/**
* 储值卡
* @author xxm
* @since 2023/12/30
*/
@Slf4j
@Scope(SCOPE_PROTOTYPE)
@Service
@RequiredArgsConstructor
public class VoucherPayCloseStrategy extends AbsPayCloseStrategy {
private final VoucherPayService voucherPayService;
private final VoucherRecordService voucherRecordService;
private final VoucherQueryService voucherQueryService;
private Voucher voucher;
@Override
public PayChannelEnum getChannel() {
return PayChannelEnum.VOUCHER;
}
/**
* 关闭前的处理方式
*/
@Override
public void doBeforeCloseHandler() {
String channelExtra = this.getChannelOrder().getChannelExtra();
VoucherPayParam params = JSONUtil.toBean(channelExtra, VoucherPayParam.class);
this.voucher = voucherQueryService.getVoucherByCardNo(params.getCardNo());
}
/**
* 关闭操作
*/
@Override
public void doCloseHandler() {
voucherPayService.close(this.getChannelOrder());
voucherRecordService.payClose(this.getChannelOrder(), this.getOrder().getTitle(), this.voucher);
}
}

View File

@@ -45,15 +45,9 @@ public class PayStrategyFactory {
case UNION_PAY:
strategy = SpringUtil.getBean(UnionPayStrategy.class);
break;
case CASH:
strategy = SpringUtil.getBean(CashPayStrategy.class);
break;
case WALLET:
strategy = SpringUtil.getBean(WalletPayStrategy.class);
break;
case VOUCHER:
strategy = SpringUtil.getBean(VoucherPayStrategy.class);
break;
default:
throw new PayUnsupportedMethodException();
}

View File

@@ -1,66 +0,0 @@
package cn.bootx.platform.daxpay.service.core.payment.pay.strategy;
import cn.bootx.platform.daxpay.code.PayChannelEnum;
import cn.bootx.platform.daxpay.exception.pay.PayAmountAbnormalException;
import cn.bootx.platform.daxpay.exception.pay.PayFailureException;
import cn.bootx.platform.daxpay.param.pay.PayChannelParam;
import cn.bootx.platform.daxpay.service.core.channel.cash.entity.CashConfig;
import cn.bootx.platform.daxpay.service.core.channel.cash.service.CashPayConfigService;
import cn.bootx.platform.daxpay.service.core.channel.cash.service.CashRecordService;
import cn.bootx.platform.daxpay.service.func.AbsPayStrategy;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
import static org.springframework.beans.factory.config.BeanDefinition.SCOPE_PROTOTYPE;
/**
* 现金支付
*
* @author xxm
* @since 2021/6/23
*/
@Slf4j
@Scope(SCOPE_PROTOTYPE)
@Service
@RequiredArgsConstructor
public class CashPayStrategy extends AbsPayStrategy {
private final CashRecordService cashRecordService;
private final CashPayConfigService cashPayConfigService;
/**
* 现金支付
*/
@Override
public PayChannelEnum getChannel() {
return PayChannelEnum.CASH;
}
/**
* 支付前检查
*/
@Override
public void doBeforePayHandler() {
CashConfig config = cashPayConfigService.getAndCheckConfig();
// 检查金额
PayChannelParam payChannelParam = this.getPayChannelParam();
if (payChannelParam.getAmount() <= 0) {
throw new PayAmountAbnormalException();
}
// 支付金额是否超限
if (payChannelParam.getAmount() > config.getSingleLimit()) {
throw new PayFailureException("现金支付金额超过限制");
}
}
/**
* 支付操作
*/
@Override
public void doPayHandler() {
cashRecordService.pay(this.getChannelOrder(),this.getOrder().getTitle());
}
}

View File

@@ -1,92 +0,0 @@
package cn.bootx.platform.daxpay.service.core.payment.pay.strategy;
import cn.bootx.platform.daxpay.code.PayChannelEnum;
import cn.bootx.platform.daxpay.exception.pay.PayFailureException;
import cn.bootx.platform.daxpay.param.channel.VoucherPayParam;
import cn.bootx.platform.daxpay.service.core.channel.voucher.entity.Voucher;
import cn.bootx.platform.daxpay.service.core.channel.voucher.entity.VoucherConfig;
import cn.bootx.platform.daxpay.service.core.channel.voucher.service.VoucherConfigService;
import cn.bootx.platform.daxpay.service.core.channel.voucher.service.VoucherPayService;
import cn.bootx.platform.daxpay.service.core.channel.voucher.service.VoucherQueryService;
import cn.bootx.platform.daxpay.service.core.channel.voucher.service.VoucherRecordService;
import cn.bootx.platform.daxpay.service.func.AbsPayStrategy;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.json.JSONException;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
import java.util.Map;
import static org.springframework.beans.factory.config.BeanDefinition.SCOPE_PROTOTYPE;
/**
* 储值卡支付
*
* @author xxm
* @since 2022/3/13
*/
@Slf4j
@Scope(SCOPE_PROTOTYPE)
@Service
@RequiredArgsConstructor
public class VoucherPayStrategy extends AbsPayStrategy {
private final VoucherPayService voucherPayService;
private final VoucherQueryService voucherQueryService;
private final VoucherRecordService voucherRecordService;
private final VoucherConfigService voucherConfigService;
private Voucher voucher;
@Override
public PayChannelEnum getChannel() {
return PayChannelEnum.VOUCHER;
}
/**
* 支付前处理
*/
@Override
public void doBeforePayHandler() {
VoucherPayParam voucherPayParam;
try {
// 储值卡参数验证
Map<String, Object> channelParam = this.getPayChannelParam().getChannelParam();
if (CollUtil.isNotEmpty(channelParam)) {
voucherPayParam = BeanUtil.toBean(channelParam, VoucherPayParam.class);
} else {
throw new PayFailureException("储值卡支付参数错误");
}
}
catch (JSONException e) {
throw new PayFailureException("储值卡支付参数错误");
}
VoucherConfig config = voucherConfigService.getAndCheckConfig();
// 支付金额是否超限
if (this.getPayChannelParam().getAmount() > config.getSingleLimit()) {
throw new PayFailureException("现金支付金额超过限制");
}
// 金额是否满足
this.voucher = voucherQueryService.getAndCheckVoucher(voucherPayParam);
if (this.getPayChannelParam().getAmount() > this.voucher.getBalance()) {
throw new PayFailureException("储值卡余额不足");
}
}
/**
* 支付操作
*/
@Override
public void doPayHandler() {
voucherPayService.pay(this.getPayChannelParam().getAmount(), this.voucher);
voucherRecordService.pay(this.getChannelOrder(), this.getOrder().getTitle(), this.voucher);
}
}

View File

@@ -57,15 +57,9 @@ public class RefundStrategyFactory {
case UNION_PAY:
strategy = SpringUtil.getBean(UnionRefundStrategy.class);
break;
case CASH:
strategy = SpringUtil.getBean(CashRefundStrategy.class);
break;
case WALLET:
strategy = SpringUtil.getBean(WalletRefundStrategy.class);
break;
case VOUCHER:
strategy = SpringUtil.getBean(VoucherRefundStrategy.class);
break;
default:
throw new PayUnsupportedMethodException();
}

View File

@@ -1,71 +0,0 @@
package cn.bootx.platform.daxpay.service.core.payment.refund.strategy;
import cn.bootx.platform.daxpay.code.PayChannelEnum;
import cn.bootx.platform.daxpay.code.PayStatusEnum;
import cn.bootx.platform.daxpay.code.RefundStatusEnum;
import cn.bootx.platform.daxpay.service.core.channel.cash.service.CashRecordService;
import cn.bootx.platform.daxpay.service.func.AbsRefundStrategy;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import java.util.Objects;
import static org.springframework.beans.factory.config.BeanDefinition.SCOPE_PROTOTYPE;
/**
* 现金支付退款
* @author xxm
* @since 2023/7/5
*/
@Scope(SCOPE_PROTOTYPE)
@Component
@RequiredArgsConstructor
public class CashRefundStrategy extends AbsRefundStrategy {
private final CashRecordService cashRecordService;
/**
* 策略标识
*/
@Override
public PayChannelEnum getChannel() {
return PayChannelEnum.CASH;
}
/**
* 退款操作
*/
@Override
public void doRefundHandler() {
// 如果任务执行完成, 则跳过
if (Objects.equals(this.getRefundChannelOrder().getStatus(), RefundStatusEnum.SUCCESS.getCode())){
return;
}
// 不包含异步支付
if (!this.getPayOrder().isAsyncPay()){
cashRecordService.refund(this.getRefundChannelOrder(),this.getPayOrder().getTitle());
}
}
/**
* 退款发起成功操作
*/
@Override
public void doSuccessHandler() {
// 如果任务执行完成, 则跳过
if (Objects.equals(this.getRefundChannelOrder().getStatus(), RefundStatusEnum.SUCCESS.getCode())){
return;
}
// 包含异步支付, 变更状态到退款中
if (this.getPayOrder().isAsyncPay()) {
this.getPayChannelOrder().setStatus(PayStatusEnum.REFUNDING.getCode());
this.getRefundChannelOrder().setStatus(RefundStatusEnum.PROGRESS.getCode());
} else{
// 同步支付, 直接标识状态为退款完成
super.doSuccessHandler();
}
}
}

View File

@@ -1,114 +0,0 @@
package cn.bootx.platform.daxpay.service.core.payment.refund.strategy;
import cn.bootx.platform.daxpay.code.PayChannelEnum;
import cn.bootx.platform.daxpay.code.PayStatusEnum;
import cn.bootx.platform.daxpay.code.RefundStatusEnum;
import cn.bootx.platform.daxpay.param.channel.VoucherPayParam;
import cn.bootx.platform.daxpay.service.core.channel.voucher.entity.Voucher;
import cn.bootx.platform.daxpay.service.core.channel.voucher.service.VoucherPayService;
import cn.bootx.platform.daxpay.service.core.channel.voucher.service.VoucherQueryService;
import cn.bootx.platform.daxpay.service.core.channel.voucher.service.VoucherRecordService;
import cn.bootx.platform.daxpay.service.core.order.pay.entity.PayChannelOrder;
import cn.bootx.platform.daxpay.service.core.order.pay.entity.PayOrder;
import cn.bootx.platform.daxpay.service.func.AbsRefundStrategy;
import cn.hutool.json.JSONUtil;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import java.util.Objects;
import static org.springframework.beans.factory.config.BeanDefinition.SCOPE_PROTOTYPE;
/**
* 储值卡支付退款
* @author xxm
* @since 2023/7/5
*/
@Scope(SCOPE_PROTOTYPE)
@Component
@RequiredArgsConstructor
public class VoucherRefundStrategy extends AbsRefundStrategy {
private final VoucherPayService voucherPayService;
private final VoucherQueryService voucherQueryService;
private final VoucherRecordService voucherRecordService;
private Voucher voucher;
private VoucherPayParam voucherPayParam;
/**
* 策略标识
*
* @see PayChannelEnum
*/
@Override
public PayChannelEnum getChannel() {
return PayChannelEnum.VOUCHER;
}
/**
* 退款前对处理
*/
@Override
public void initRefundParam(PayOrder payOrder, PayChannelOrder payChannelOrder) {
// 先设置参数
super.initRefundParam(payOrder, payChannelOrder);
// 从通道扩展参数中取出钱包参数
String channelExtra = this.getPayChannelOrder().getChannelExtra();
this.voucherPayParam = JSONUtil.toBean(channelExtra, VoucherPayParam.class);
}
/**
* 退款前对处理
*/
@Override
public void doBeforeRefundHandler() {
// 如果任务执行完成, 则跳过
if (Objects.equals(this.getRefundChannelOrder().getStatus(), RefundStatusEnum.SUCCESS.getCode())){
return;
}
// 不包含异步支付, 则只在支付订单中进行扣减, 等待异步退款完成, 再进行退款
if (!this.getPayOrder().isAsyncPay()) {
this.voucher = voucherQueryService.getVoucherByCardNo(this.voucherPayParam.getCardNo());
}
}
/**
* 退款
*/
@Override
public void doRefundHandler() {
// 如果任务执行完成, 则跳过
if (Objects.equals(this.getRefundChannelOrder().getStatus(), RefundStatusEnum.SUCCESS.getCode())){
return;
}
// 不包含异步支付, 直接完成退款
if (!this.getPayOrder().isAsyncPay()){
voucherPayService.refund(this.getRefundChannelParam().getAmount(), this.voucher);
voucherRecordService.refund(this.getRefundChannelOrder(), this.getPayOrder().getTitle(), this.voucher);
}
}
/**
* 退款发起成功操作, 异步支付通道需要进行重写
*/
@Override
public void doSuccessHandler() {
// 如果任务执行完成, 则跳过
if (Objects.equals(this.getRefundChannelOrder().getStatus(), RefundStatusEnum.SUCCESS.getCode())){
return;
}
// 包含异步支付, 变更状态到退款中
if (this.getPayOrder().isAsyncPay()) {
this.getPayChannelOrder().setStatus(PayStatusEnum.REFUNDING.getCode());
this.getRefundChannelOrder().setStatus(RefundStatusEnum.PROGRESS.getCode());
} else{
// 同步支付, 直接标识状态为退款完成
super.doSuccessHandler();
}
}
}

View File

@@ -41,15 +41,9 @@ public class PayRepairStrategyFactory {
case UNION_PAY:
strategy = SpringUtil.getBean(UnionPayRepairStrategy.class);
break;
case CASH:
strategy = SpringUtil.getBean(CashPayRepairStrategy.class);
break;
case WALLET:
strategy = SpringUtil.getBean(WalletPayRepairStrategy.class);
break;
case VOUCHER:
strategy = SpringUtil.getBean(VoucherPayRepairStrategy.class);
break;
default:
throw new PayUnsupportedMethodException();
}

View File

@@ -42,15 +42,9 @@ public class RefundRepairStrategyFactory {
case UNION_PAY:
strategy = SpringUtil.getBean(UnionRefundRepairStrategy.class);
break;
case CASH:
strategy = SpringUtil.getBean(CashRefundRepairStrategy.class);
break;
case WALLET:
strategy = SpringUtil.getBean(WalletRefundRepairStrategy.class);
break;
case VOUCHER:
strategy = SpringUtil.getBean(VoucherRefundRepairStrategy.class);
break;
default:
throw new PayUnsupportedMethodException();
}

View File

@@ -1,43 +0,0 @@
package cn.bootx.platform.daxpay.service.core.payment.repair.strategy.pay;
import cn.bootx.platform.daxpay.code.PayChannelEnum;
import cn.bootx.platform.daxpay.code.PayStatusEnum;
import cn.bootx.platform.daxpay.service.core.channel.cash.service.CashRecordService;
import cn.bootx.platform.daxpay.service.func.AbsPayRepairStrategy;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
import static org.springframework.beans.factory.config.BeanDefinition.SCOPE_PROTOTYPE;
/**
* 钱包支付修复策略
* @author xxm
* @since 2023/12/29
*/
@Slf4j
@Scope(SCOPE_PROTOTYPE)
@Service
@RequiredArgsConstructor
public class CashPayRepairStrategy extends AbsPayRepairStrategy {
private final CashRecordService cashRecordService;
/**
* 策略标识
*/
@Override
public PayChannelEnum getChannel() {
return PayChannelEnum.CASH;
}
/**
* 关闭支付
*/
@Override
public void doCloseLocalHandler() {
this.getChannelOrder().setStatus(PayStatusEnum.CLOSE.getCode());
cashRecordService.payClose(this.getChannelOrder(),this.getOrder().getTitle());
}
}

View File

@@ -1,66 +0,0 @@
package cn.bootx.platform.daxpay.service.core.payment.repair.strategy.pay;
import cn.bootx.platform.daxpay.code.PayChannelEnum;
import cn.bootx.platform.daxpay.code.PayStatusEnum;
import cn.bootx.platform.daxpay.param.channel.VoucherPayParam;
import cn.bootx.platform.daxpay.service.core.channel.voucher.entity.Voucher;
import cn.bootx.platform.daxpay.service.core.channel.voucher.service.VoucherPayService;
import cn.bootx.platform.daxpay.service.core.channel.voucher.service.VoucherQueryService;
import cn.bootx.platform.daxpay.service.core.channel.voucher.service.VoucherRecordService;
import cn.bootx.platform.daxpay.service.func.AbsPayRepairStrategy;
import cn.hutool.json.JSONUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
import static org.springframework.beans.factory.config.BeanDefinition.SCOPE_PROTOTYPE;
/**
*
* @author xxm
* @since 2023/12/29
*/
@Slf4j
@Scope(SCOPE_PROTOTYPE)
@Service
@RequiredArgsConstructor
public class VoucherPayRepairStrategy extends AbsPayRepairStrategy {
private final VoucherPayService voucherPayService;
private final VoucherRecordService voucherRecordService;
private final VoucherQueryService voucherQueryService;
private Voucher voucher;
/**
* 策略标识
*/
@Override
public PayChannelEnum getChannel() {
return PayChannelEnum.VOUCHER;
}
/**
* 关闭前的处理方式
*/
@Override
public void doBeforeHandler() {
String channelExtra = this.getChannelOrder().getChannelExtra();
VoucherPayParam params = JSONUtil.toBean(channelExtra, VoucherPayParam.class);
this.voucher = voucherQueryService.getVoucherByCardNo(params.getCardNo());
}
/**
* 关闭本地支付订单
*/
@Override
public void doCloseLocalHandler() {
voucherPayService.close(this.getChannelOrder());
voucherRecordService.payClose(this.getChannelOrder(), this.getOrder().getTitle(), this.voucher);
this.getChannelOrder().setStatus(PayStatusEnum.CLOSE.getCode());
}
}

View File

@@ -1,40 +0,0 @@
package cn.bootx.platform.daxpay.service.core.payment.repair.strategy.refund;
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.AbsRefundRepairStrategy;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
import static org.springframework.beans.factory.config.BeanDefinition.SCOPE_PROTOTYPE;
/**
* 现金退款修复策略
* @author xxm
* @since 2024/1/30
*/
@Slf4j
@Scope(SCOPE_PROTOTYPE)
@Service
@RequiredArgsConstructor
public class CashRefundRepairStrategy extends AbsRefundRepairStrategy {
private final CashRecordService cashRecordService;
/**
* 策略标识
*/
@Override
public PayChannelEnum getChannel() {
return PayChannelEnum.CASH;
}
/**
* 退款成功修复
*/
@Override
public void doSuccessHandler() {
cashRecordService.refund(this.getRefundChannelOrder(),this.getPayOrder().getTitle());
}
}

View File

@@ -1,62 +0,0 @@
package cn.bootx.platform.daxpay.service.core.payment.repair.strategy.refund;
import cn.bootx.platform.daxpay.code.PayChannelEnum;
import cn.bootx.platform.daxpay.param.channel.VoucherPayParam;
import cn.bootx.platform.daxpay.service.core.channel.voucher.entity.Voucher;
import cn.bootx.platform.daxpay.service.core.channel.voucher.service.VoucherPayService;
import cn.bootx.platform.daxpay.service.core.channel.voucher.service.VoucherQueryService;
import cn.bootx.platform.daxpay.service.core.channel.voucher.service.VoucherRecordService;
import cn.bootx.platform.daxpay.service.func.AbsRefundRepairStrategy;
import cn.hutool.json.JSONUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
import static org.springframework.beans.factory.config.BeanDefinition.SCOPE_PROTOTYPE;
/**
*
* @author xxm
* @since 2024/1/30
*/
@Slf4j
@Scope(SCOPE_PROTOTYPE)
@Service
@RequiredArgsConstructor
public class VoucherRefundRepairStrategy extends AbsRefundRepairStrategy {
private final VoucherQueryService voucherQueryService;
private final VoucherRecordService voucherRecordService;
private final VoucherPayService voucherPayService;
private Voucher voucher;
/**
* 策略标识
*/
@Override
public PayChannelEnum getChannel() {
return PayChannelEnum.VOUCHER;
}
/**
* 修复前处理
*/
@Override
public void doBeforeHandler() {
String channelExtra = this.getPayChannelOrder().getChannelExtra();
VoucherPayParam params = JSONUtil.toBean(channelExtra, VoucherPayParam.class);
this.voucher = voucherQueryService.getVoucherByCardNo(params.getCardNo());
}
/**
* 退款成功修复
*/
@Override
public void doSuccessHandler() {
voucherPayService.refund(this.getPayChannelOrder().getAmount(), this.voucher);
voucherRecordService.refund(this.getRefundChannelOrder(), this.getPayOrder().getTitle(), this.voucher);
}
}

View File

@@ -1,37 +0,0 @@
package cn.bootx.platform.daxpay.service.dto.channel.cash;
import cn.bootx.platform.common.core.rest.dto.BaseDto;
import cn.bootx.table.modify.annotation.DbColumn;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.util.List;
/**
* 现金支付配置
* @author xxm
* @since 2024/2/17
*/
@EqualsAndHashCode(callSuper = true)
@Data
@Accessors(chain = true)
@Schema(title = "现金支付配置")
public class CashPayConfigDto extends BaseDto {
/** 是否启用 */
@Schema(description = "是否启用")
private Boolean enable;
/** 可用支付方式 */
@Schema(description = "可用支付方式")
private List<String> payWays;
/** 单次支持支持多少钱 */
@Schema(description = "单次支持支持多少钱")
private Integer singleLimit;
/** 备注 */
@Schema(description = "备注")
private String remark;
}

View File

@@ -1,51 +0,0 @@
package cn.bootx.platform.daxpay.service.dto.channel.cash;
import cn.bootx.platform.common.core.rest.dto.BaseDto;
import cn.bootx.platform.daxpay.service.code.VoucherRecordTypeEnum;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* 现金记录
* @author xxm
* @since 2024/2/18
*/
@EqualsAndHashCode(callSuper = true)
@Data
@Accessors(chain = true)
@Schema(title = "现金记录")
public class CashRecordDto extends BaseDto {
/** 标题 */
@Schema(description = "标题")
private String title;
/**
* 业务类型
* @see VoucherRecordTypeEnum
*/
@Schema(description = "业务类型")
private String type;
/** 金额 */
@Schema(description = "金额")
private Integer amount;
/**
* 交易订单号
* 支付订单/退款订单
*/
@Schema(description = "交易订单号")
private String orderId;
/** 终端ip */
@Schema(description = "终端ip")
private String ip;
/** 备注 */
@Schema(description = "备注")
private String remark;
}

View File

@@ -1,38 +0,0 @@
package cn.bootx.platform.daxpay.service.dto.channel.voucher;
import cn.bootx.platform.common.core.rest.dto.BaseDto;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.util.List;
/**
* 储值卡配置
* @author xxm
* @since 2024/2/17
*/
@EqualsAndHashCode(callSuper = true)
@Data
@Accessors(chain = true)
@Schema(title = "储值卡配置")
public class VoucherConfigDto extends BaseDto {
/** 是否启用 */
@Schema(description = "是否启用")
private Boolean enable;
/** 可用支付方式 */
@Schema(description = "可用支付方式")
private List<String> payWays;
/** 单次支持支持多少钱 */
@Schema(description = "单次支持支持多少钱")
private Integer singleLimit;
/** 备注 */
@Schema(description = "备注")
private String remark;
}

View File

@@ -1,47 +0,0 @@
package cn.bootx.platform.daxpay.service.dto.channel.voucher;
import cn.bootx.platform.common.core.rest.dto.BaseDto;
import cn.bootx.platform.daxpay.service.code.VoucherCode;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.math.BigDecimal;
import java.time.LocalDateTime;
/**
* @author xxm
* @since 2022/3/14
*/
@EqualsAndHashCode(callSuper = true)
@Data
@Accessors(chain = true)
@Schema(title = "储值卡")
public class VoucherDto extends BaseDto {
@Schema(description = "卡号")
private String cardNo;
@Schema(description = "面值")
private BigDecimal faceValue;
@Schema(description = "余额")
private BigDecimal balance;
@Schema(description = "是否长期有效")
private Boolean enduring;
@Schema(description = "开始时间")
private LocalDateTime startTime;
@Schema(description = "结束时间")
private LocalDateTime endTime;
/**
* @see VoucherCode#STATUS_FORBIDDEN
*/
@Schema(description = "状态")
private String status;
}

View File

@@ -1,62 +0,0 @@
package cn.bootx.platform.daxpay.service.dto.channel.voucher;
import cn.bootx.platform.common.core.rest.dto.BaseDto;
import cn.bootx.platform.daxpay.service.code.VoucherRecordTypeEnum;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* 储值卡记录
* @author xxm
* @since 2024/2/18
*/
@EqualsAndHashCode(callSuper = true)
@Data
@Accessors(chain = true)
@Schema(title = "储值卡记录")
public class VoucherRecordDto extends BaseDto {
/** 储值卡id */
@Schema(description = "储值卡id")
private Long voucherId;
/** 标题 */
@Schema(description = "标题")
private String title;
/**
* 业务类型
* @see VoucherRecordTypeEnum
*/
@Schema(description = "业务类型")
private String type;
/** 金额 */
@Schema(description = "金额")
private Integer amount;
/** 变动之前的金额 */
@Schema(description = "变动之前的金额")
private Integer oldAmount;
/** 变动之后的金额 */
@Schema(description = "变动之后的金额")
private Integer newAmount;
/**
* 交易订单号
* 支付订单/退款订单
*/
@Schema(description = "交易订单号")
private String orderId;
/** 终端ip */
@Schema(description = "终端ip")
private String ip;
/** 备注 */
@Schema(description = "备注")
private String remark;
}

View File

@@ -1,21 +0,0 @@
package cn.bootx.platform.daxpay.service.param.channel.cash;
import cn.bootx.platform.common.core.annotation.QueryParam;
import cn.bootx.platform.common.core.rest.param.QueryOrder;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
*
* @author xxm
* @since 2024/2/18
*/
@QueryParam
@EqualsAndHashCode(callSuper = true)
@Data
@Accessors(chain = true)
@Schema(title = "现金记录查询参数")
public class CashRecordQuery extends QueryOrder {
}

View File

@@ -1,46 +0,0 @@
package cn.bootx.platform.daxpay.service.param.channel.voucher;
import cn.bootx.platform.daxpay.service.code.VoucherStatusEnum;
import cn.hutool.core.date.DatePattern;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.time.LocalDateTime;
import java.util.List;
/**
* 储值卡批量导入
* @author xxm
* @since 2024/2/17
*/
@Data
@Schema(title = "储值卡导入参数")
public class VoucherBatchImportParam {
@Schema(description = "卡号")
public List<String> cardNoList;
@Schema(description = "面值")
private Integer faceValue;
@Schema(description = "余额")
private Integer balance;
@Schema(description = "是否长期有效")
private boolean enduring;
@Schema(description = "开始时间")
@JsonFormat(pattern = DatePattern.NORM_DATETIME_PATTERN)
private LocalDateTime startTime;
@Schema(description = "结束时间")
@JsonFormat(pattern = DatePattern.NORM_DATETIME_PATTERN)
private LocalDateTime endTime;
/**
* @see VoucherStatusEnum
*/
@Schema(description = "默认状态")
private String status;
}

View File

@@ -1,46 +0,0 @@
package cn.bootx.platform.daxpay.service.param.channel.voucher;
import cn.bootx.platform.daxpay.service.code.VoucherStatusEnum;
import cn.hutool.core.date.DatePattern;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.time.LocalDateTime;
/**
* 储值卡导入参数
* @author xxm
* @since 2022/3/14
*/
@Data
@Schema(title = "储值卡导入参数")
public class VoucherImportParam {
@Schema(description = "卡号")
private String cardNo;
@Schema(description = "面值")
private Integer faceValue;
@Schema(description = "余额")
private Integer balance;
@Schema(description = "是否长期有效")
private boolean enduring;
@Schema(description = "开始时间")
@JsonFormat(pattern = DatePattern.NORM_DATETIME_PATTERN)
private LocalDateTime startTime;
@Schema(description = "结束时间")
@JsonFormat(pattern = DatePattern.NORM_DATETIME_PATTERN)
private LocalDateTime endTime;
/**
* @see VoucherStatusEnum
*/
@Schema(description = "默认状态")
private String status;
}

View File

@@ -1,54 +0,0 @@
package cn.bootx.platform.daxpay.service.param.channel.voucher;
import cn.bootx.platform.daxpay.service.code.VoucherCode;
import cn.hutool.core.date.DatePattern;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;
import java.math.BigDecimal;
import java.time.LocalDateTime;
/**
* @author xxm
* @since 2022/3/14
*/
@Data
@Accessors(chain = true)
@Schema(title = "储值卡查询参数")
public class VoucherParam {
@Schema(description = "主键")
private Long id;
@Schema(description = "卡号")
private String cardNo;
@Schema(description = "生成批次号")
private Long batchNo;
@Schema(description = "面值")
private BigDecimal faceValue;
@Schema(description = "余额")
private BigDecimal balance;
@Schema(description = "是否长期有效")
private Boolean enduring;
@Schema(description = "开始时间")
@DateTimeFormat(pattern = DatePattern.NORM_DATETIME_PATTERN)
private LocalDateTime startTime;
@Schema(description = "结束时间")
@DateTimeFormat(pattern = DatePattern.NORM_DATETIME_PATTERN)
private LocalDateTime endTime;
/**
* @see VoucherCode
*/
@Schema(description = "状态")
private Integer status;
}

View File

@@ -1,29 +0,0 @@
package cn.bootx.platform.daxpay.service.param.channel.voucher;
import cn.bootx.platform.common.core.annotation.QueryParam;
import cn.bootx.platform.common.core.rest.param.QueryOrder;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* 储值卡查询参数
* @author xxm
* @since 2024/2/17
*/
@EqualsAndHashCode(callSuper = true)
@Data
@QueryParam
@Accessors(chain = true)
@Schema(title = "储值卡查询参数")
public class VoucherQuery extends QueryOrder {
@Schema(description = "卡号")
@QueryParam(type = QueryParam.CompareTypeEnum.LIKE)
private String cardNo;
@Schema(description = "面值")
private Integer faceValue;
}

View File

@@ -1,24 +0,0 @@
package cn.bootx.platform.daxpay.service.param.channel.voucher;
import cn.bootx.platform.common.core.annotation.QueryParam;
import cn.bootx.platform.common.core.rest.param.QueryOrder;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* 储值卡查询参数
* @author xxm
* @since 2024/2/18
*/
@EqualsAndHashCode(callSuper = true)
@QueryParam
@Data
@Accessors(chain = true)
@Schema(title = "储值卡查询参数")
public class VoucherRecordQuery extends QueryOrder {
@Schema(description = "储值卡id")
private Long voucherId;
}