diff --git a/_doc/Task.md b/_doc/Task.md index b20ed5115..86d7aa668 100644 --- a/_doc/Task.md +++ b/_doc/Task.md @@ -11,8 +11,8 @@ - [x] 请求IP参数增加正则校验 - [x] 支付接口公共参数添加随机数字段, 预防重放问题 - [x] 请求接口增加有效期校验, 超时后失效 -- [ ] 数据库表进行规则, 字段设置长度, 增加索引 - - [ ] 订单 +- [ ] 数据库表进行规则, 字段设置长度, 增加索引, 对应请求参数添加校验 + - [x] 订单 - [ ] 记录 - [ ] 配置 - [x] 订单和扩展信息进行合并 @@ -35,11 +35,14 @@ - [ ] 脚手架优化 - [ ] 请求权限改版, 使用专用配置类 - [X] 去除消息通知模块 + 2.0.9: 消息通知改版和系统优化 - [ ] 增加类似支付宝应用通知的方式, 先支持http方式通信 - [ ] 优化前端各种状态颜色展示 +- [ ] 增加验签调试等功能的页面 +- [ ] 聚合支付UA在前端判断, 提高响应速度 - 2.1.x 版本内容 +**任务池** - [ ] 增加收单收银台功能 - [ ] 增加资金对账单功能 - [ ] 新增支付单预警功能, 处理支付单与网关状态不一致且无法自动修复的情况 @@ -54,6 +57,4 @@ - [ ] 针对同步/对账等出现脏数据导致阻塞的问题, 进行优化 - [ ] 同步接口 - [ ] 对账接口 -**任务池** -- [ ] 支付宝接口升级为V3接口 -- [ ] 增加验签调试等功能的页面 + diff --git a/daxpay-single/daxpay-single-admin/src/main/java/cn/daxpay/single/admin/controller/allocation/AllocationOrderController.java b/daxpay-single/daxpay-single-admin/src/main/java/cn/daxpay/single/admin/controller/allocation/AllocationOrderController.java index 906a92795..fa5b25b26 100644 --- a/daxpay-single/daxpay-single-admin/src/main/java/cn/daxpay/single/admin/controller/allocation/AllocationOrderController.java +++ b/daxpay-single/daxpay-single-admin/src/main/java/cn/daxpay/single/admin/controller/allocation/AllocationOrderController.java @@ -10,12 +10,12 @@ import cn.daxpay.single.param.payment.allocation.AllocFinishParam; import cn.daxpay.single.param.payment.allocation.AllocSyncParam; import cn.daxpay.single.param.payment.allocation.AllocationParam; import cn.daxpay.single.service.annotation.InitPaymentContext; -import cn.daxpay.single.service.core.order.allocation.service.AllocationOrderQueryService; +import cn.daxpay.single.service.core.order.allocation.service.AllocOrderQueryService; import cn.daxpay.single.service.core.payment.allocation.service.AllocationService; import cn.daxpay.single.service.core.payment.allocation.service.AllocationSyncService; +import cn.daxpay.single.service.dto.order.allocation.AllocOrderDto; import cn.daxpay.single.service.dto.order.allocation.AllocationOrderDetailDto; -import cn.daxpay.single.service.dto.order.allocation.AllocationOrderDto; -import cn.daxpay.single.service.param.order.AllocationOrderQuery; +import cn.daxpay.single.service.param.order.AllocOrderQuery; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import lombok.RequiredArgsConstructor; @@ -37,7 +37,7 @@ import java.util.List; @RequiredArgsConstructor public class AllocationOrderController { - private final AllocationOrderQueryService queryService; + private final AllocOrderQueryService queryService; private final AllocationService allocationService; @@ -45,7 +45,7 @@ public class AllocationOrderController { @Operation(summary = "分页") @GetMapping("/page") - public ResResult> page(PageParam pageParam, AllocationOrderQuery param){ + public ResResult> page(PageParam pageParam, AllocOrderQuery param){ return Res.ok(queryService.page(pageParam,param)); } @@ -57,7 +57,7 @@ public class AllocationOrderController { @Operation(summary = "查询详情") @GetMapping("/findById") - public ResResult findById(Long id){ + public ResResult findById(Long id){ return Res.ok(queryService.findById(id)); } @@ -69,7 +69,7 @@ public class AllocationOrderController { @Operation(summary = "查询扩展信息") @GetMapping("/findByAllocNo") - public ResResult findByAllocNo(String allocNo){ + public ResResult findByAllocNo(String allocNo){ return Res.ok(queryService.findByAllocNo(allocNo)); } diff --git a/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/exception/pay/PayAmountAbnormalException.java b/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/exception/pay/AmountAbnormalException.java similarity index 69% rename from daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/exception/pay/PayAmountAbnormalException.java rename to daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/exception/pay/AmountAbnormalException.java index 82b94ef9d..ad6f88b48 100644 --- a/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/exception/pay/PayAmountAbnormalException.java +++ b/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/exception/pay/AmountAbnormalException.java @@ -9,13 +9,13 @@ import cn.daxpay.single.code.DaxPayErrorCode; * @author xxm * @since 2020/12/8 */ -public class PayAmountAbnormalException extends FatalException { +public class AmountAbnormalException extends FatalException { - public PayAmountAbnormalException(String msg) { + public AmountAbnormalException(String msg) { super(DaxPayErrorCode.PAYMENT_AMOUNT_ABNORMAL, msg); } - public PayAmountAbnormalException() { + public AmountAbnormalException() { super(DaxPayErrorCode.PAYMENT_AMOUNT_ABNORMAL, "异常金额"); } diff --git a/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/param/PaymentCommonParam.java b/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/param/PaymentCommonParam.java index 516bc7368..82f162901 100644 --- a/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/param/PaymentCommonParam.java +++ b/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/param/PaymentCommonParam.java @@ -7,6 +7,7 @@ import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; import java.time.LocalDateTime; /** @@ -21,14 +22,17 @@ public abstract class PaymentCommonParam { /** 客户端ip */ @Schema(description = "客户端ip") @IpAddress + @Size(max=64, message = "客户端ip不可超过64位") private String clientIp; /** 随机数 */ @Schema(description = "随机数") + @Size(max = 32, message = "随机数不可超过32位") private String nonceStr; /** 签名 */ @Schema(description = "签名") + @Size(max = 64, message = "签名不可超过64位") private String sign; diff --git a/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/param/payment/allocation/AllocationParam.java b/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/param/payment/allocation/AllocationParam.java index 4a3cc54d4..e4414e302 100644 --- a/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/param/payment/allocation/AllocationParam.java +++ b/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/param/payment/allocation/AllocationParam.java @@ -7,6 +7,7 @@ import lombok.EqualsAndHashCode; import javax.validation.Valid; import javax.validation.constraints.NotBlank; +import javax.validation.constraints.Size; import java.util.List; /** @@ -20,25 +21,30 @@ import java.util.List; public class AllocationParam extends PaymentCommonParam { /** 商户分账单号 */ - @Schema(description = "商户分账单号") @NotBlank(message = "商户分账单号不可为空") + @Size(max = 100, message = "商户分账单号不可超过100位") + @Schema(description = "商户分账单号") private String bizAllocationNo; /** 支付订单号 */ + @Size(max = 32, message = "支付订单号不可超过32位") @Schema(description = "支付订单号") private String orderNo; /** 商户支付订单号 */ + @Size(max = 100, message = "商户支付订单号不可超过100位") @Schema(description = "商户支付订单号") private String bizOrderNo; /** 分账描述 */ + @Size(max = 150, message = "分账描述不可超过150位") @Schema(description = "分账描述") private String description; /** * 优先级 分账接收方列表 > 分账组编号 > 默认分账组 */ + @Size(max = 20, message = "分账组编号不可超过20位") @Schema(description = "分账组编号") private String groupNo; @@ -48,11 +54,13 @@ public class AllocationParam extends PaymentCommonParam { private List receivers; /** 回调通知地址 */ + @Size(max = 200, message = "回调通知地址不可超过200位") @Schema(description = "回调通知地址") private String notifyUrl; /** 商户扩展参数,回调时会原样返回 */ - @Schema(description = "商户扩展参数,回调时会原样返回") + @Size(max = 500, message = "商户扩展参数不可超过500位") + @Schema(description = "商户扩展参数") private String attach; } diff --git a/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/param/payment/pay/PayParam.java b/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/param/payment/pay/PayParam.java index 3dbd84a0e..6907bdd6f 100644 --- a/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/param/payment/pay/PayParam.java +++ b/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/param/payment/pay/PayParam.java @@ -12,9 +12,7 @@ import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import lombok.EqualsAndHashCode; -import javax.validation.constraints.Min; -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; +import javax.validation.constraints.*; import java.time.LocalDateTime; import java.util.Map; @@ -32,15 +30,18 @@ public class PayParam extends PaymentCommonParam { /** 商户订单号 */ @Schema(description = "商户订单号") @NotBlank(message = "商户订单号不可为空") + @Size(max = 100, message = "商户订单号不可超过100位") private String bizOrderNo; /** 支付标题 */ @Schema(description = "支付标题") @NotBlank(message = "支付标题不可为空") + @Size(max = 100, message = "支付标题不可超过100位") private String title; /** 支付描述 */ @Schema(description = "支付描述") + @Size(max = 500, message = "支付描述不可超过500位") private String description; /** 是否开启分账 */ @@ -62,6 +63,7 @@ public class PayParam extends PaymentCommonParam { */ @Schema(description = "支付通道编码") @NotBlank(message = "支付通道编码不可为空") + @Size(max = 20, message = "支付通道编码不可超过20位") private String channel; /** @@ -70,6 +72,7 @@ public class PayParam extends PaymentCommonParam { */ @Schema(description = "支付方式编码") @NotBlank(message = "支付方式不可为空") + @Size(max = 20, message = "支付方式编码不可超过20位") private String method; /** 支付金额 */ @@ -85,21 +88,26 @@ public class PayParam extends PaymentCommonParam { * @see WalletPayParam */ @Schema(description = "支付扩展参数") + @Size(max = 2048, message = "支付扩展参数不可超过2048位") private Map extraParam; /** 商户扩展参数,回调时会原样返回 */ - @Schema(description = "商户扩展参数,回调时会原样返回") + @Schema(description = "商户扩展参数") + @Size(max = 500, message = "商户扩展参数不可超过500位") private String attach; /** 同步跳转地址, 支付完毕后用户浏览器返回到该地址, 不传输跳转到默认地址 */ @Schema(description = "同步通知URL") + @Size(max = 200, message = "同步通知URL不可超过200位") private String returnUrl; - /** 退出地址 */ - @Schema(description = "用户付款中途退出返回商户网站的地址(部分支付场景中可用)") + /** 用户付款中途退出返回商户网站的地址(部分支付场景中可用) */ + @Schema(description = "退出地址") + @Size(max = 200, message = "退出地址不可超过200位") private String quitUrl; /** 异步通知地址 */ @Schema(description = "异步通知地址") + @Size(max = 200, message = "异步通知地址不可超过200位") private String notifyUrl; } diff --git a/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/param/payment/refund/RefundParam.java b/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/param/payment/refund/RefundParam.java index dcb85a0a2..94ec90746 100644 --- a/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/param/payment/refund/RefundParam.java +++ b/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/param/payment/refund/RefundParam.java @@ -10,7 +10,7 @@ import lombok.EqualsAndHashCode; import javax.validation.constraints.Min; import javax.validation.constraints.NotBlank; -import java.util.Map; +import javax.validation.constraints.Size; /** * 退款参数,适用于组合支付的订单退款操作中, @@ -27,18 +27,21 @@ public class RefundParam extends PaymentCommonParam { */ @Schema(description = "商户退款号") @NotBlank(message = "商户退款号不可为空") + @Size(max = 100, message = "商户退款号不可超过100位") private String bizRefundNo; /** * 支付订单号,与商户订单号至少要传输一个,同时传输以订单号为准 */ @Schema(description = "订单号") + @Size(max = 32, message = "支付订单号不可超过32位") private String orderNo; /** * 商户支付订单号,与订单号至少要传输一个,同时传输以订单号为准 */ @Schema(description = "商户订单号") + @Size(max = 100, message = "商户支付订单号不可超过100位") private String bizOrderNo; /** 退款金额 */ @@ -53,18 +56,22 @@ public class RefundParam extends PaymentCommonParam { * @see WalletPayParam */ @Schema(description = "退款扩展参数") - private Map extraParam; + @Size(max = 2048, message = "退款扩展参数不可超过2048位") + private String extraParam; /** 退款原因 */ @Schema(description = "退款原因") + @Size(max = 150, message = "退款原因不可超过150位") private String reason; /** 商户扩展参数,回调时会原样返回 */ - @Schema(description = "商户扩展参数,回调时会原样返回") + @Schema(description = "商户扩展参数") + @Size(max = 500, message = "商户扩展参数不可超过500位") private String attach; /** 异步通知地址 */ @Schema(description = "异步通知地址") + @Size(max = 200, message = "异步通知地址不可超过200位") private String notifyUrl; } diff --git a/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/param/payment/transfer/TransferParam.java b/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/param/payment/transfer/TransferParam.java index d71fd488e..8cf0e5ec0 100644 --- a/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/param/payment/transfer/TransferParam.java +++ b/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/param/payment/transfer/TransferParam.java @@ -9,6 +9,10 @@ import lombok.Data; import lombok.EqualsAndHashCode; import lombok.experimental.Accessors; +import javax.validation.constraints.Min; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; + /** * 转账参数 * @author xxm @@ -21,6 +25,8 @@ import lombok.experimental.Accessors; public class TransferParam extends PaymentCommonParam { /** 商户转账号 */ + @NotNull(message = "商户转账号必填") + @Size(max = 100, message = "商户转账号不可超过100位") @Schema(description = "商户转账号") private String bizTransferNo; @@ -28,18 +34,24 @@ public class TransferParam extends PaymentCommonParam { * 支付通道 * @see PayChannelEnum */ + @NotNull(message = "支付通道必填") + @Size(max = 20, message = "支付通道不可超过20位") @Schema(description = "支付通道") private String channel; /** 转账金额 */ + @NotNull(message = "转账金额必填") + @Min(value = 1, message = "转账金额至少为0.01") @Schema(description = "转账金额") private Integer amount; /** 标题 */ + @Size(max = 100, message = "标题不可超过100位") @Schema(description = "标题") private String title; /** 转账原因/备注 */ + @Size(max = 150, message = "转账原因/备注不可超过150位") @Schema(description = "转账原因/备注") private String reason; @@ -47,32 +59,40 @@ public class TransferParam extends PaymentCommonParam { * 转账类型, 微信使用 * @see TransferTypeEnum */ + @Size(max = 20, message = "转账类型不可超过20位") @Schema(description = "转账类型, 微信使用") private String transferType; /** 付款方显示名称 */ + @Size(max = 50, message = "付款方显示名称不可超过50位") + @Schema(description = "付款方显示名称") private String payerShowName; /** * 收款人账号类型 * @see TransferPayeeTypeEnum */ + @Size(max = 20, message = "收款人账号类型不可超过20位") @Schema(description = "收款人账号类型") private String payeeType; /** 收款人账号 */ + @Size(max = 100, message = "收款人账号不可超过100位") @Schema(description = "收款人账号") private String payeeAccount; /** 收款人姓名 */ + @Size(max = 50, message = "收款人姓名不可超过50位") @Schema(description = "收款人姓名") private String payeeName; /** 回调通知地址 */ + @Size(max = 200, message = "回调通知地址不可超过200位") @Schema(description = "回调通知地址") private String notifyUrl; /** 商户扩展参数,回调时会原样返回 */ + @Size(max = 500, message = "商户扩展参数,回调时会原样返回不可超过500位") @Schema(description = "商户扩展参数,回调时会原样返回") private String attach; } diff --git a/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/result/order/PayOrderResult.java b/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/result/order/PayOrderResult.java index a73c460fb..a9c8a11e8 100644 --- a/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/result/order/PayOrderResult.java +++ b/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/result/order/PayOrderResult.java @@ -56,7 +56,7 @@ public class PayOrderResult extends PaymentCommonResult { * 支付通道 * @see PayChannelEnum */ - @Schema(description = "异步支付通道") + @Schema(description = "支付通道") private String channel; /** diff --git a/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/util/PayUtil.java b/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/util/PayUtil.java index 7ab669d39..cfe3cd918 100644 --- a/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/util/PayUtil.java +++ b/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/util/PayUtil.java @@ -1,8 +1,6 @@ package cn.daxpay.single.util; import cn.bootx.platform.common.core.util.LocalDateTimeUtil; -import cn.daxpay.single.exception.pay.PayAmountAbnormalException; -import cn.daxpay.single.param.payment.pay.PayParam; import cn.hutool.core.date.DatePattern; import lombok.experimental.UtilityClass; @@ -20,24 +18,6 @@ import java.time.temporal.ChronoUnit; public class PayUtil { private static final BigDecimal HUNDRED = new BigDecimal(100); - /** - * 校验参数 - */ - public void validation(PayParam payParam) { - // 验证支付金额 - validationAmount(payParam); - } - - /** - * 检查支付金额 - */ - public void validationAmount(PayParam param) { - // 验证支付金额 - if (param.getAmount() <= 0) { - throw new PayAmountAbnormalException("支付金额不能小于等于0"); - } - } - /** * 获取支付宝的过期时间 yyyy-MM-dd HH:mm:ss */ diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/channel/alipay/service/AliPayAllocationService.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/channel/alipay/service/AliPayAllocationService.java index dd2985a5c..281ffc919 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/channel/alipay/service/AliPayAllocationService.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/channel/alipay/service/AliPayAllocationService.java @@ -6,8 +6,8 @@ import cn.daxpay.single.code.AllocDetailResultEnum; import cn.daxpay.single.exception.pay.PayFailureException; import cn.daxpay.single.service.code.AliPayCode; import cn.daxpay.single.service.common.local.PaymentContextLocal; -import cn.daxpay.single.service.core.order.allocation.entity.AllocationOrder; -import cn.daxpay.single.service.core.order.allocation.entity.AllocationOrderDetail; +import cn.daxpay.single.service.core.order.allocation.entity.AllocOrder; +import cn.daxpay.single.service.core.order.allocation.entity.AllocOrderDetail; import cn.daxpay.single.service.core.payment.sync.result.AllocRemoteSyncResult; import cn.daxpay.single.util.PayUtil; import cn.hutool.core.date.LocalDateTimeUtil; @@ -46,11 +46,11 @@ public class AliPayAllocationService { * 发起分账 */ @SneakyThrows - public void allocation(AllocationOrder allocationOrder, List orderDetails){ + public void allocation(AllocOrder allocOrder, List orderDetails){ // 分账主体参数 AlipayTradeOrderSettleModel model = new AlipayTradeOrderSettleModel(); - model.setOutRequestNo(allocationOrder.getAllocNo()); - model.setTradeNo(allocationOrder.getOutOrderNo()); + model.setOutRequestNo(allocOrder.getAllocNo()); + model.setTradeNo(allocOrder.getOutOrderNo()); model.setRoyaltyMode(AliPayCode.ALLOC_ASYNC); // 分账子参数 根据Id排序 @@ -76,11 +76,11 @@ public class AliPayAllocationService { * 分账完结 */ @SneakyThrows - public void finish(AllocationOrder allocationOrder, List orderDetails ){ + public void finish(AllocOrder allocOrder, List orderDetails ){ // 分账主体参数 AlipayTradeOrderSettleModel model = new AlipayTradeOrderSettleModel(); - model.setOutRequestNo(String.valueOf(allocationOrder.getAllocNo())); - model.setTradeNo(allocationOrder.getOutOrderNo()); + model.setOutRequestNo(String.valueOf(allocOrder.getAllocNo())); + model.setTradeNo(allocOrder.getOutOrderNo()); model.setRoyaltyMode(AliPayCode.ALLOC_ASYNC); // 分账完结参数 SettleExtendParams extendParams = new SettleExtendParams(); @@ -106,21 +106,21 @@ public class AliPayAllocationService { * 分账状态同步 */ @SneakyThrows - public AllocRemoteSyncResult sync(AllocationOrder allocationOrder, List allocationOrderDetails){ + public AllocRemoteSyncResult sync(AllocOrder allocOrder, List allocOrderDetails){ AlipayTradeOrderSettleQueryModel model = new AlipayTradeOrderSettleQueryModel(); - model.setTradeNo(allocationOrder.getOutOrderNo()); - model.setOutRequestNo(allocationOrder.getAllocNo()); + model.setTradeNo(allocOrder.getOutOrderNo()); + model.setOutRequestNo(allocOrder.getAllocNo()); AlipayTradeOrderSettleQueryRequest request = new AlipayTradeOrderSettleQueryRequest(); request.setBizModel(model); AlipayTradeOrderSettleQueryResponse response = AliPayApi.execute(request); // 验证 this.verifyErrorMsg(response); - Map detailMap = allocationOrderDetails.stream() - .collect(Collectors.toMap(AllocationOrderDetail::getReceiverAccount, Function.identity(), CollectorsFunction::retainLatest)); + Map detailMap = allocOrderDetails.stream() + .collect(Collectors.toMap(AllocOrderDetail::getReceiverAccount, Function.identity(), CollectorsFunction::retainLatest)); List royaltyDetailList = response.getRoyaltyDetailList(); // 转换成通用的明细详情 for (RoyaltyDetail receiver : royaltyDetailList) { - AllocationOrderDetail detail = detailMap.get(receiver.getTransIn()); + AllocOrderDetail detail = detailMap.get(receiver.getTransIn()); if (Objects.nonNull(detail)) { detail.setResult(this.getDetailResultEnum(receiver.getState()).getCode()); detail.setErrorCode(receiver.getErrorCode()); diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/channel/wechat/service/WeChatPayAllocationService.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/channel/wechat/service/WeChatPayAllocationService.java index c27a9d2df..422f86658 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/channel/wechat/service/WeChatPayAllocationService.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/channel/wechat/service/WeChatPayAllocationService.java @@ -7,8 +7,8 @@ import cn.daxpay.single.code.AllocReceiverTypeEnum; import cn.daxpay.single.exception.pay.PayFailureException; import cn.daxpay.single.service.code.WeChatPayCode; import cn.daxpay.single.service.core.channel.wechat.entity.WeChatPayConfig; -import cn.daxpay.single.service.core.order.allocation.entity.AllocationOrder; -import cn.daxpay.single.service.core.order.allocation.entity.AllocationOrderDetail; +import cn.daxpay.single.service.core.order.allocation.entity.AllocOrder; +import cn.daxpay.single.service.core.order.allocation.entity.AllocOrderDetail; import cn.daxpay.single.service.core.payment.sync.result.AllocRemoteSyncResult; import cn.daxpay.single.service.dto.channel.wechat.WeChatPayAllocationReceiver; import cn.hutool.core.codec.Base64; @@ -51,8 +51,8 @@ public class WeChatPayAllocationService { * 发起分账 */ @SneakyThrows - public void allocation(AllocationOrder allocationOrder, List orderDetails, WeChatPayConfig config){ - String description = allocationOrder.getDescription(); + public void allocation(AllocOrder allocOrder, List orderDetails, WeChatPayConfig config){ + String description = allocOrder.getDescription(); if (StrUtil.isBlank(description)){ description = "分账"; } @@ -74,8 +74,8 @@ public class WeChatPayAllocationService { .mch_id(config.getWxMchId()) .appid(config.getWxAppId()) .nonce_str(WxPayKit.generateStr()) - .transaction_id(allocationOrder.getOutOrderNo()) - .out_order_no(allocationOrder.getAllocNo()) + .transaction_id(allocOrder.getOutOrderNo()) + .out_order_no(allocOrder.getAllocNo()) .receivers(JSON.toJSONString(list)) .build() .createSign(config.getApiKeyV2(), SignType.HMACSHA256); @@ -90,14 +90,14 @@ public class WeChatPayAllocationService { /** * 完成分账 */ - public void finish(AllocationOrder allocationOrder, WeChatPayConfig config){ + public void finish(AllocOrder allocOrder, WeChatPayConfig config){ Map params = ProfitSharingModel.builder() .mch_id(config.getWxMchId()) .appid(config.getWxAppId()) .nonce_str(WxPayKit.generateStr()) - .transaction_id(allocationOrder.getOutOrderNo()) + .transaction_id(allocOrder.getOutOrderNo()) // 分账要使用单独的的流水号, 不能与分账号相同 - .out_order_no(allocationOrder.getAllocNo()+'F') + .out_order_no(allocOrder.getAllocNo()+'F') .description("分账已完成") .build() .createSign(config.getApiKeyV2(), SignType.HMACSHA256); @@ -112,13 +112,13 @@ public class WeChatPayAllocationService { /** * 同步分账状态 */ - public AllocRemoteSyncResult sync(AllocationOrder allocationOrder, List allocationOrderDetails, WeChatPayConfig config){ + public AllocRemoteSyncResult sync(AllocOrder allocOrder, List allocOrderDetails, WeChatPayConfig config){ // 不要传输AppId参数, 否则会失败 Map params = ProfitSharingModel.builder() .mch_id(config.getWxMchId()) .nonce_str(WxPayKit.generateStr()) - .transaction_id(allocationOrder.getOutOrderNo()) - .out_order_no(allocationOrder.getAllocNo()) + .transaction_id(allocOrder.getOutOrderNo()) + .out_order_no(allocOrder.getAllocNo()) .build() .createSign(config.getApiKeyV2(), SignType.HMACSHA256); String xmlResult = WxPayApi.profitSharingQuery(params); @@ -126,11 +126,11 @@ public class WeChatPayAllocationService { this.verifyErrorMsg(result); String json = result.get(WeChatPayCode.ALLOC_RECEIVERS); List receivers = JSONUtil.toBean(json, new TypeReference>() {}, false); - Map detailMap = allocationOrderDetails.stream() - .collect(Collectors.toMap(AllocationOrderDetail::getReceiverAccount, Function.identity(), CollectorsFunction::retainLatest)); + Map detailMap = allocOrderDetails.stream() + .collect(Collectors.toMap(AllocOrderDetail::getReceiverAccount, Function.identity(), CollectorsFunction::retainLatest)); // 根据明细更新订单明细内容 for (WeChatPayAllocationReceiver receiver : receivers) { - AllocationOrderDetail detail = detailMap.get(receiver.getAccount()); + AllocOrderDetail detail = detailMap.get(receiver.getAccount()); if (Objects.nonNull(detail)){ detail.setResult(this.getDetailResultEnum(receiver.getResult()).getCode()); detail.setErrorMsg(receiver.getFailReason()); diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/allocation/convert/AllocationConvert.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/allocation/convert/AllocOrderConvert.java similarity index 56% rename from daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/allocation/convert/AllocationConvert.java rename to daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/allocation/convert/AllocOrderConvert.java index 1010d19f0..6e5f623f7 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/allocation/convert/AllocationConvert.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/allocation/convert/AllocOrderConvert.java @@ -2,12 +2,12 @@ package cn.daxpay.single.service.core.order.allocation.convert; import cn.daxpay.single.result.order.AllocOrderDetailResult; import cn.daxpay.single.result.order.AllocOrderResult; -import cn.daxpay.single.service.core.order.allocation.entity.AllocationOrder; -import cn.daxpay.single.service.core.order.allocation.entity.AllocationOrderDetail; +import cn.daxpay.single.service.core.order.allocation.entity.AllocOrder; +import cn.daxpay.single.service.core.order.allocation.entity.AllocOrderDetail; import cn.daxpay.single.service.core.payment.notice.result.AllocDetailNoticeResult; import cn.daxpay.single.service.core.payment.notice.result.AllocNoticeResult; +import cn.daxpay.single.service.dto.order.allocation.AllocOrderDto; import cn.daxpay.single.service.dto.order.allocation.AllocationOrderDetailDto; -import cn.daxpay.single.service.dto.order.allocation.AllocationOrderDto; import org.mapstruct.Mapper; import org.mapstruct.factory.Mappers; @@ -17,19 +17,19 @@ import org.mapstruct.factory.Mappers; * @since 2024/4/7 */ @Mapper -public interface AllocationConvert { - AllocationConvert CONVERT = Mappers.getMapper(AllocationConvert.class); +public interface AllocOrderConvert { + AllocOrderConvert CONVERT = Mappers.getMapper(AllocOrderConvert.class); - AllocationOrderDto convert(AllocationOrder in); + AllocOrderDto convert(AllocOrder in); - AllocOrderResult toResult(AllocationOrder in); + AllocOrderResult toResult(AllocOrder in); - AllocOrderDetailResult toResult(AllocationOrderDetail in); + AllocOrderDetailResult toResult(AllocOrderDetail in); - AllocationOrderDetailDto convert(AllocationOrderDetail in); + AllocationOrderDetailDto convert(AllocOrderDetail in); - AllocNoticeResult toNotice(AllocationOrder in); + AllocNoticeResult toNotice(AllocOrder in); - AllocDetailNoticeResult toNotice(AllocationOrderDetail in); + AllocDetailNoticeResult toNotice(AllocOrderDetail in); } diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/allocation/dao/AllocationOrderDetailManager.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/allocation/dao/AllocOrderDetailManager.java similarity index 62% rename from daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/allocation/dao/AllocationOrderDetailManager.java rename to daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/allocation/dao/AllocOrderDetailManager.java index 0b3918eed..5494034ba 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/allocation/dao/AllocationOrderDetailManager.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/allocation/dao/AllocOrderDetailManager.java @@ -1,7 +1,7 @@ package cn.daxpay.single.service.core.order.allocation.dao; import cn.bootx.platform.common.mybatisplus.impl.BaseManager; -import cn.daxpay.single.service.core.order.allocation.entity.AllocationOrderDetail; +import cn.daxpay.single.service.core.order.allocation.entity.AllocOrderDetail; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Repository; @@ -16,12 +16,12 @@ import java.util.List; @Slf4j @Repository @RequiredArgsConstructor -public class AllocationOrderDetailManager extends BaseManager { +public class AllocOrderDetailManager extends BaseManager { /** * 根据订单ID查询 */ - public List findAllByOrderId(Long orderId) { - return findAllByField(AllocationOrderDetail::getAllocationId, orderId); + public List findAllByOrderId(Long orderId) { + return findAllByField(AllocOrderDetail::getAllocationId, orderId); } } diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/allocation/dao/AllocationOrderDetailMapper.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/allocation/dao/AllocOrderDetailMapper.java similarity index 72% rename from daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/allocation/dao/AllocationOrderDetailMapper.java rename to daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/allocation/dao/AllocOrderDetailMapper.java index 2eb08e6b0..c3952be42 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/allocation/dao/AllocationOrderDetailMapper.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/allocation/dao/AllocOrderDetailMapper.java @@ -1,6 +1,6 @@ package cn.daxpay.single.service.core.order.allocation.dao; -import cn.daxpay.single.service.core.order.allocation.entity.AllocationOrderDetail; +import cn.daxpay.single.service.core.order.allocation.entity.AllocOrderDetail; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.apache.ibatis.annotations.Mapper; @@ -10,5 +10,5 @@ import org.apache.ibatis.annotations.Mapper; * @since 2024/4/7 */ @Mapper -public interface AllocationOrderDetailMapper extends BaseMapper { +public interface AllocOrderDetailMapper extends BaseMapper { } diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/allocation/dao/AllocationOrderMapper.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/allocation/dao/AllocOrderMapper.java similarity index 75% rename from daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/allocation/dao/AllocationOrderMapper.java rename to daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/allocation/dao/AllocOrderMapper.java index 0047ab807..847548f93 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/allocation/dao/AllocationOrderMapper.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/allocation/dao/AllocOrderMapper.java @@ -1,6 +1,6 @@ package cn.daxpay.single.service.core.order.allocation.dao; -import cn.daxpay.single.service.core.order.allocation.entity.AllocationOrder; +import cn.daxpay.single.service.core.order.allocation.entity.AllocOrder; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.apache.ibatis.annotations.Mapper; @@ -10,5 +10,5 @@ import org.apache.ibatis.annotations.Mapper; * @since 2024/4/7 */ @Mapper -public interface AllocationOrderMapper extends BaseMapper { +public interface AllocOrderMapper extends BaseMapper { } diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/allocation/dao/AllocationOrderManager.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/allocation/dao/AllocationOrderManager.java index aa9cdf1a5..25c1ca739 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/allocation/dao/AllocationOrderManager.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/allocation/dao/AllocationOrderManager.java @@ -5,8 +5,8 @@ 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.daxpay.single.code.AllocOrderStatusEnum; -import cn.daxpay.single.service.core.order.allocation.entity.AllocationOrder; -import cn.daxpay.single.service.param.order.AllocationOrderQuery; +import cn.daxpay.single.service.core.order.allocation.entity.AllocOrder; +import cn.daxpay.single.service.param.order.AllocOrderQuery; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import lombok.RequiredArgsConstructor; @@ -25,38 +25,38 @@ import java.util.Optional; @Slf4j @Repository @RequiredArgsConstructor -public class AllocationOrderManager extends BaseManager { +public class AllocationOrderManager extends BaseManager { /** * 根据分账单号查询 */ - public Optional findByAllocationNo(String allocationNo){ - return findByField(AllocationOrder::getAllocNo, allocationNo); + public Optional findByAllocNo(String allocNo){ + return findByField(AllocOrder::getAllocNo, allocNo); } /** * 根据商户分账号查询 */ - public Optional findByBizAllocationNo(String bizAllocationNo){ - return findByField(AllocationOrder::getBizAllocNo, bizAllocationNo); + public Optional findByBizAllocNo(String bizAllocNo){ + return findByField(AllocOrder::getBizAllocNo, bizAllocNo); } /** * 分页 */ - public Page page(PageParam pageParam, AllocationOrderQuery param){ - Page mpPage = MpUtil.getMpPage(pageParam, AllocationOrder.class); - QueryWrapper generator = QueryGenerator.generator(param); + public Page page(PageParam pageParam, AllocOrderQuery param){ + Page mpPage = MpUtil.getMpPage(pageParam, AllocOrder.class); + QueryWrapper generator = QueryGenerator.generator(param); return this.page(mpPage, generator); } /** * 查询待同步的分账单 */ - public List findSyncOrder(){ + public List findSyncOrder(){ List statusList = Arrays.asList(AllocOrderStatusEnum.ALLOCATION_PROCESSING.getCode(), AllocOrderStatusEnum.ALLOCATION_END.getCode()); return lambdaQuery() - .in(AllocationOrder::getStatus, statusList) + .in(AllocOrder::getStatus, statusList) .list(); } } diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/allocation/entity/AllocationOrder.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/allocation/entity/AllocOrder.java similarity index 53% rename from daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/allocation/entity/AllocationOrder.java rename to daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/allocation/entity/AllocOrder.java index ab2a5c9aa..0f7abc285 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/allocation/entity/AllocationOrder.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/allocation/entity/AllocOrder.java @@ -4,11 +4,12 @@ import cn.bootx.platform.common.core.function.EntityBaseFunction; import cn.bootx.platform.common.mybatisplus.base.MpBaseEntity; import cn.bootx.table.modify.annotation.DbColumn; import cn.bootx.table.modify.annotation.DbTable; +import cn.bootx.table.modify.mysql.annotation.DbMySqlIndex; import cn.daxpay.single.code.AllocOrderResultEnum; import cn.daxpay.single.code.AllocOrderStatusEnum; import cn.daxpay.single.code.PayChannelEnum; -import cn.daxpay.single.service.core.order.allocation.convert.AllocationConvert; -import cn.daxpay.single.service.dto.order.allocation.AllocationOrderDto; +import cn.daxpay.single.service.core.order.allocation.convert.AllocOrderConvert; +import cn.daxpay.single.service.dto.order.allocation.AllocOrderDto; import com.baomidou.mybatisplus.annotation.FieldStrategy; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableName; @@ -27,86 +28,85 @@ import java.time.LocalDateTime; @Data @Accessors(chain = true) @DbTable(comment = "分账订单") -@TableName("pay_allocation_order") -public class AllocationOrder extends MpBaseEntity implements EntityBaseFunction { +@TableName("pay_alloc_order") +public class AllocOrder extends MpBaseEntity implements EntityBaseFunction { /** * 分账单号 */ - @DbColumn(comment = "分账单号") + @DbMySqlIndex(comment = "分账单号索引") + @DbColumn(comment = "分账单号", length = 32, isNull = false) private String allocNo; /** * 商户分账单号 */ - @DbColumn(comment = "商户分账单号") + @DbMySqlIndex(comment = "商户分账单号索引") + @DbColumn(comment = "商户分账单号", length = 100, isNull = false) private String bizAllocNo; /** * 通道分账号 */ - @DbColumn(comment = "通道分账号") + @DbMySqlIndex(comment = "通道分账号索引") + @DbColumn(comment = "通道分账号", length = 150, isNull = false) private String outAllocNo; /** 支付订单ID */ - @DbColumn(comment = "支付订单ID") + @DbMySqlIndex(comment = "支付订单ID索引") + @DbColumn(comment = "支付订单ID", isNull = false) private Long orderId; - /** - * 支付订单号 - */ - @DbColumn(comment = "支付订单号") + /** 支付订单号 */ + @DbMySqlIndex(comment = "支付订单号索引") + @DbColumn(comment = "支付订单号", length = 32, isNull = false) private String orderNo; - /** - * 商户支付订单号 - */ - @DbColumn(comment = "商户支付订单号") + /** 商户支付订单号 */ + @DbMySqlIndex(comment = "商户支付订单号索引") + @DbColumn(comment = "商户支付订单号", length = 100, isNull = false) private String bizOrderNo; - /** - * 通道系统支付订单号 - */ - @DbColumn(comment = "通道支付订单号") + /** 通道支付订单号 */ + @DbMySqlIndex(comment = "通道支付订单号索引") + @DbColumn(comment = "通道支付订单号", length = 150, isNull = false) private String outOrderNo; - /** - * 支付订单标题 - */ - @DbColumn(comment = "支付订单标题") + /** 支付标题 */ + @DbColumn(comment = "支付标题", length = 100, isNull = false) private String title; /** * 所属通道 * @see PayChannelEnum */ - @DbColumn(comment = "所属通道") + @DbColumn(comment = "所属通道", length = 20, isNull = false) private String channel; /** * 总分账金额 */ - @DbColumn(comment = "总分账金额") + @DbColumn(comment = "总分账金额", length = 15, isNull = false) private Integer amount; /** * 分账描述 */ - @DbColumn(comment = "分账描述") + @DbColumn(comment = "分账描述", length = 150) private String description; /** * 状态 * @see AllocOrderStatusEnum */ - @DbColumn(comment = "状态") + @DbColumn(comment = "状态", length = 20, isNull = false) private String status; /** * 处理结果 * @see AllocOrderResultEnum */ - @DbColumn(comment = "处理结果") + @DbColumn(comment = "处理结果", length = 20, isNull = false) private String result; /** 分账完成时间 */ @@ -114,12 +114,12 @@ public class AllocationOrder extends MpBaseEntity implements EntityBaseFunction< private LocalDateTime finishTime; /** 异步通知地址 */ - @DbColumn(comment = "异步通知地址") + @DbColumn(comment = "异步通知地址", length = 200) @TableField(updateStrategy = FieldStrategy.ALWAYS) private String notifyUrl; /** 商户扩展参数,回调时会原样返回, 以最后一次为准 */ - @DbColumn(comment = "商户扩展参数") + @DbColumn(comment = "商户扩展参数", length = 500) private String attach; /** 请求时间,时间戳转时间 */ @@ -127,28 +127,22 @@ public class AllocationOrder extends MpBaseEntity implements EntityBaseFunction< private LocalDateTime reqTime; /** 终端ip */ - @DbColumn(comment = "支付终端ip") + @DbColumn(comment = "支付终端ip", length = 64) private String clientIp; - /** - * 错误码 - */ - @DbColumn(comment = "错误码") - @TableField(updateStrategy = FieldStrategy.ALWAYS) + /** 错误码 */ + @DbColumn(comment = "错误码", length = 10) private String errorCode; - /** - * 错误信息 - */ - @DbColumn(comment = "错误原因") - @TableField(updateStrategy = FieldStrategy.ALWAYS) + /** 错误信息 */ + @DbColumn(comment = "错误信息", length = 150) private String errorMsg; /** * 转换 */ @Override - public AllocationOrderDto toDto() { - return AllocationConvert.CONVERT.convert(this); + public AllocOrderDto toDto() { + return AllocOrderConvert.CONVERT.convert(this); } } diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/allocation/entity/AllocationOrderDetail.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/allocation/entity/AllocOrderDetail.java similarity index 64% rename from daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/allocation/entity/AllocationOrderDetail.java rename to daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/allocation/entity/AllocOrderDetail.java index fc335aeea..59c10eed2 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/allocation/entity/AllocationOrderDetail.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/allocation/entity/AllocOrderDetail.java @@ -4,10 +4,11 @@ import cn.bootx.platform.common.core.function.EntityBaseFunction; import cn.bootx.platform.common.mybatisplus.base.MpBaseEntity; import cn.bootx.table.modify.annotation.DbColumn; import cn.bootx.table.modify.annotation.DbTable; +import cn.bootx.table.modify.mysql.annotation.DbMySqlIndex; import cn.daxpay.single.code.AllocDetailResultEnum; import cn.daxpay.single.code.AllocReceiverTypeEnum; import cn.daxpay.single.service.common.typehandler.DecryptTypeHandler; -import cn.daxpay.single.service.core.order.allocation.convert.AllocationConvert; +import cn.daxpay.single.service.core.order.allocation.convert.AllocOrderConvert; import cn.daxpay.single.service.dto.order.allocation.AllocationOrderDetailDto; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableName; @@ -26,58 +27,59 @@ import java.time.LocalDateTime; @Data @Accessors(chain = true) @DbTable(comment = "分账订单明细") -@TableName(value = "pay_allocation_order_detail",autoResultMap = true) -public class AllocationOrderDetail extends MpBaseEntity implements EntityBaseFunction { +@TableName(value = "pay_alloc_order_detail",autoResultMap = true) +public class AllocOrderDetail extends MpBaseEntity implements EntityBaseFunction { /** 分账订单ID */ - @DbColumn(comment = "分账订单ID") + @DbMySqlIndex(comment = "分账订单ID索引") + @DbColumn(comment = "分账订单ID", isNull = false) private Long allocationId; /** 接收者ID */ - @DbColumn(comment = "接收者ID") + @DbColumn(comment = "接收者ID", isNull = false) private Long receiverId; /** 分账接收方编号 */ - @DbColumn(comment = "分账接收方编号") + @DbColumn(comment = "分账接收方编号", length = 20, isNull = false) private String receiverNo; /** 分账比例 */ - @DbColumn(comment = "分账比例(万分之多少)") + @DbColumn(comment = "分账比例(万分之多少)", length = 5, isNull = false) private Integer rate; /** 分账金额 */ - @DbColumn(comment = "分账金额") + @DbColumn(comment = "分账金额", length = 15, isNull = false) private Integer amount; /** * 分账接收方类型 * @see AllocReceiverTypeEnum */ - @DbColumn(comment = "分账接收方类型") + @DbColumn(comment = "分账接收方类型", length = 20, isNull = false) private String receiverType; /** 接收方账号 */ - @DbColumn(comment = "接收方账号") + @DbColumn(comment = "接收方账号", length = 150, isNull = false) @TableField(typeHandler = DecryptTypeHandler.class) private String receiverAccount; /** 接收方姓名 */ - @DbColumn(comment = "接收方姓名") + @DbColumn(comment = "接收方姓名", length = 150) private String receiverName; /** * 分账结果 * @see AllocDetailResultEnum */ - @DbColumn(comment = "分账结果") + @DbColumn(comment = "分账结果", length = 20, isNull = false) private String result; /** 错误代码 */ - @DbColumn(comment = "错误代码") + @DbColumn(comment = "错误代码", length = 10) private String errorCode; /** 错误原因 */ - @DbColumn(comment = "错误原因") + @DbColumn(comment = "错误原因", length = 150) private String errorMsg; /** 分账完成时间 */ @@ -89,6 +91,6 @@ public class AllocationOrderDetail extends MpBaseEntity implements EntityBaseFun */ @Override public AllocationOrderDetailDto toDto() { - return AllocationConvert.CONVERT.convert(this); + return AllocOrderConvert.CONVERT.convert(this); } } diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/allocation/entity/OrderAndDetail.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/allocation/entity/OrderAndDetail.java index b7e53c2b8..8981adc32 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/allocation/entity/OrderAndDetail.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/allocation/entity/OrderAndDetail.java @@ -15,7 +15,7 @@ import java.util.List; public class OrderAndDetail { /** 分账订单 */ - private AllocationOrder order; + private AllocOrder order; /** 分账订单明细 */ - private List details; + private List details; } diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/allocation/service/AllocationOrderQueryService.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/allocation/service/AllocOrderQueryService.java similarity index 61% rename from daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/allocation/service/AllocationOrderQueryService.java rename to daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/allocation/service/AllocOrderQueryService.java index a8717aef3..ab2f6dc2f 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/allocation/service/AllocationOrderQueryService.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/allocation/service/AllocOrderQueryService.java @@ -7,13 +7,13 @@ import cn.bootx.platform.common.core.rest.param.PageParam; import cn.bootx.platform.common.core.util.ResultConvertUtil; import cn.bootx.platform.common.mybatisplus.util.MpUtil; import cn.daxpay.single.code.PayChannelEnum; -import cn.daxpay.single.service.core.order.allocation.dao.AllocationOrderDetailManager; +import cn.daxpay.single.service.core.order.allocation.dao.AllocOrderDetailManager; import cn.daxpay.single.service.core.order.allocation.dao.AllocationOrderManager; -import cn.daxpay.single.service.core.order.allocation.entity.AllocationOrder; -import cn.daxpay.single.service.core.order.allocation.entity.AllocationOrderDetail; +import cn.daxpay.single.service.core.order.allocation.entity.AllocOrder; +import cn.daxpay.single.service.core.order.allocation.entity.AllocOrderDetail; +import cn.daxpay.single.service.dto.order.allocation.AllocOrderDto; import cn.daxpay.single.service.dto.order.allocation.AllocationOrderDetailDto; -import cn.daxpay.single.service.dto.order.allocation.AllocationOrderDto; -import cn.daxpay.single.service.param.order.AllocationOrderQuery; +import cn.daxpay.single.service.param.order.AllocOrderQuery; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; @@ -29,9 +29,9 @@ import java.util.List; @Slf4j @Service @RequiredArgsConstructor -public class AllocationOrderQueryService { +public class AllocOrderQueryService { - private final AllocationOrderDetailManager allocationOrderDetailManager; + private final AllocOrderDetailManager allocOrderDetailManager; private final AllocationOrderManager allocationOrderManager; @@ -48,36 +48,36 @@ public class AllocationOrderQueryService { /** * 分页查询 */ - public PageResult page(PageParam pageParam, AllocationOrderQuery param){ + public PageResult page(PageParam pageParam, AllocOrderQuery param){ return MpUtil.convert2DtoPageResult(allocationOrderManager.page(pageParam, param)); } /** * 查询详情 */ - public AllocationOrderDto findById(Long id) { - return allocationOrderManager.findById(id).map(AllocationOrder::toDto).orElseThrow(() -> new DataNotExistException("分账订单不存在")); + public AllocOrderDto findById(Long id) { + return allocationOrderManager.findById(id).map(AllocOrder::toDto).orElseThrow(() -> new DataNotExistException("分账订单不存在")); } /** * 查询详情 */ - public AllocationOrderDto findByAllocNo(String allocNo) { - return allocationOrderManager.findByAllocationNo(allocNo).map(AllocationOrder::toDto).orElseThrow(() -> new DataNotExistException("分账订单不存在")); + public AllocOrderDto findByAllocNo(String allocNo) { + return allocationOrderManager.findByAllocNo(allocNo).map(AllocOrder::toDto).orElseThrow(() -> new DataNotExistException("分账订单不存在")); } /** * 查询订单明细列表 */ public List findDetailsByOrderId(Long orderId){ - return ResultConvertUtil.dtoListConvert(allocationOrderDetailManager.findAllByOrderId(orderId)); + return ResultConvertUtil.dtoListConvert(allocOrderDetailManager.findAllByOrderId(orderId)); } /** * 查询订单明细详情 */ public AllocationOrderDetailDto findDetailById(Long id){ - return allocationOrderDetailManager.findById(id).map(AllocationOrderDetail::toDto).orElseThrow(() -> new DataNotExistException("分账订单明细不存在")); + return allocOrderDetailManager.findById(id).map(AllocOrderDetail::toDto).orElseThrow(() -> new DataNotExistException("分账订单明细不存在")); } } diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/allocation/service/AllocationOrderService.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/allocation/service/AllocOrderService.java similarity index 88% rename from daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/allocation/service/AllocationOrderService.java rename to daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/allocation/service/AllocOrderService.java index e80d67e27..8689f02ca 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/allocation/service/AllocationOrderService.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/allocation/service/AllocOrderService.java @@ -6,10 +6,10 @@ import cn.daxpay.single.code.PayOrderAllocStatusEnum; import cn.daxpay.single.exception.pay.PayFailureException; import cn.daxpay.single.param.payment.allocation.AllocReceiverParam; import cn.daxpay.single.param.payment.allocation.AllocationParam; -import cn.daxpay.single.service.core.order.allocation.dao.AllocationOrderDetailManager; +import cn.daxpay.single.service.core.order.allocation.dao.AllocOrderDetailManager; import cn.daxpay.single.service.core.order.allocation.dao.AllocationOrderManager; -import cn.daxpay.single.service.core.order.allocation.entity.AllocationOrder; -import cn.daxpay.single.service.core.order.allocation.entity.AllocationOrderDetail; +import cn.daxpay.single.service.core.order.allocation.entity.AllocOrder; +import cn.daxpay.single.service.core.order.allocation.entity.AllocOrderDetail; import cn.daxpay.single.service.core.order.allocation.entity.OrderAndDetail; import cn.daxpay.single.service.core.order.pay.dao.PayOrderManager; import cn.daxpay.single.service.core.order.pay.entity.PayOrder; @@ -39,12 +39,12 @@ import java.util.stream.Collectors; @Slf4j @Service @RequiredArgsConstructor -public class AllocationOrderService { +public class AllocOrderService { private final AllocationReceiverManager receiverManager; private final AllocationOrderManager allocationOrderManager; - private final AllocationOrderDetailManager allocationOrderDetailManager; + private final AllocOrderDetailManager allocOrderDetailManager; private final PayOrderManager payOrderManager; @@ -55,7 +55,7 @@ public class AllocationOrderService { @Transactional(rollbackFor = Exception.class) public OrderAndDetail createAndUpdate(AllocationParam param, PayOrder payOrder, List receiversByGroups){ // 订单明细 - List details = receiversByGroups.stream() + List details = receiversByGroups.stream() .map(o -> { // 计算分账金额, 小数部分直接舍弃, 防止分账金额超过上限 Integer rate = o.getRate(); @@ -64,7 +64,7 @@ public class AllocationOrderService { .multiply(BigDecimal.valueOf(rate)) .divide(BigDecimal.valueOf(10000), 0, RoundingMode.DOWN).intValue(); - AllocationOrderDetail detail = new AllocationOrderDetail() + AllocOrderDetail detail = new AllocOrderDetail() .setReceiverNo(o.getReceiverNo()) .setReceiverId(o.getId()) .setAmount(amount) @@ -117,14 +117,14 @@ public class AllocationOrderService { long allocId = IdUtil.getSnowflakeNextId(); // 订单明细 - List details = receivers.stream() + List details = receivers.stream() .map(o -> { // 计算分账比例, 不是很精确 Integer amount = receiverNoMap.get(o.getReceiverNo()); Integer rate = BigDecimal.valueOf(amount) .divide(BigDecimal.valueOf(payOrder.getAmount()), 4, RoundingMode.DOWN) .multiply(BigDecimal.valueOf(10000)).intValue(); - AllocationOrderDetail detail = new AllocationOrderDetail(); + AllocOrderDetail detail = new AllocOrderDetail(); detail.setAllocationId(allocId) .setReceiverId(o.getId()) .setReceiverNo(o.getReceiverNo()) @@ -143,16 +143,16 @@ public class AllocationOrderService { /** * 保存分账相关订单信息 */ - private OrderAndDetail saveAllocOrder(AllocationParam param, PayOrder payOrder, List details ) { + private OrderAndDetail saveAllocOrder(AllocationParam param, PayOrder payOrder, List details ) { long allocId = IdUtil.getSnowflakeNextId(); // 分账明细设置ID details.forEach(o -> o.setAllocationId(allocId)); // 求分账的总额 Integer sumAmount = details.stream() - .map(AllocationOrderDetail::getAmount) + .map(AllocOrderDetail::getAmount) .reduce(0, Integer::sum); // 分账订单 - AllocationOrder allocationOrder = new AllocationOrder() + AllocOrder allocOrder = new AllocOrder() .setOrderId(payOrder.getId()) .setOrderNo(payOrder.getOrderNo()) .setBizOrderNo(payOrder.getBizOrderNo()) @@ -169,19 +169,19 @@ public class AllocationOrderService { .setClientIp(param.getClientIp()); // 如果分账订单金额为0, 设置为忽略状态 if (sumAmount == 0){ - allocationOrder.setStatus(AllocOrderStatusEnum.IGNORE.getCode()) + allocOrder.setStatus(AllocOrderStatusEnum.IGNORE.getCode()) .setFinishTime(LocalDateTime.now()) .setResult(AllocOrderStatusEnum.ALLOCATION_FAILED.getCode()) .setErrorMsg("分账比例有误或金额太小, 无法进行分账"); } - allocationOrder.setId(allocId); + allocOrder.setId(allocId); // 更新支付订单分账状态 payOrder.setAllocStatus(PayOrderAllocStatusEnum.ALLOCATION.getCode()); payOrderManager.updateById(payOrder); - allocationOrderDetailManager.saveAll(details); - allocationOrderManager.save(allocationOrder); - return new OrderAndDetail().setOrder(allocationOrder).setDetails(details); + allocOrderDetailManager.saveAll(details); + allocationOrderManager.save(allocOrder); + return new OrderAndDetail().setOrder(allocOrder).setDetails(details); } } diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/pay/entity/PayOrder.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/pay/entity/PayOrder.java index cfa0779e7..f3326a6b7 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/pay/entity/PayOrder.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/pay/entity/PayOrder.java @@ -2,20 +2,15 @@ package cn.daxpay.single.service.core.order.pay.entity; import cn.bootx.platform.common.core.function.EntityBaseFunction; import cn.bootx.platform.common.mybatisplus.base.MpBaseEntity; -import cn.daxpay.single.code.PayMethodEnum; -import cn.daxpay.single.code.PayOrderAllocStatusEnum; -import cn.daxpay.single.code.PayChannelEnum; -import cn.daxpay.single.code.PayOrderRefundStatusEnum; -import cn.daxpay.single.code.PayStatusEnum; +import cn.bootx.table.modify.annotation.DbColumn; +import cn.bootx.table.modify.annotation.DbTable; +import cn.bootx.table.modify.mysql.annotation.DbMySqlIndex; +import cn.daxpay.single.code.*; import cn.daxpay.single.param.channel.AliPayParam; import cn.daxpay.single.param.channel.WalletPayParam; import cn.daxpay.single.param.channel.WeChatPayParam; import cn.daxpay.single.service.core.order.pay.convert.PayOrderConvert; import cn.daxpay.single.service.dto.order.pay.PayOrderDto; -import cn.bootx.table.modify.annotation.DbColumn; -import cn.bootx.table.modify.annotation.DbTable; -import cn.bootx.table.modify.mysql.annotation.DbMySqlIndex; -import cn.bootx.table.modify.mysql.constants.MySqlIndexType; import com.baomidou.mybatisplus.annotation.FieldStrategy; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableName; @@ -39,25 +34,27 @@ import java.util.Objects; public class PayOrder extends MpBaseEntity implements EntityBaseFunction { /** 商户订单号 */ - @DbMySqlIndex(comment = "商户订单号索引",type = MySqlIndexType.UNIQUE) - @DbColumn(comment = "商户订单号") + @DbMySqlIndex(comment = "商户订单号索引") + @DbColumn(comment = "商户订单号", length = 100, isNull = false) private String bizOrderNo; - @DbColumn(comment = "支付订单号") + @DbMySqlIndex(comment = "支付订单号索引") + @DbColumn(comment = "支付订单号", length = 32, isNull = false) private String orderNo; /** * 通道系统交易号 */ - @DbColumn(comment = "通道支付订单号") + @DbMySqlIndex(comment = "通道支付订单索引") + @DbColumn(comment = "通道支付订单号", length = 150) private String outOrderNo; /** 标题 */ - @DbColumn(comment = "标题") + @DbColumn(comment = "标题", length = 100, isNull = false) private String title; /** 描述 */ - @DbColumn(comment = "描述") + @DbColumn(comment = "描述",length = 500) private String description; /** 是否支持分账 */ @@ -71,36 +68,36 @@ public class PayOrder extends MpBaseEntity implements EntityBaseFunction { +public class ReconcileOrder extends MpBaseEntity implements EntityBaseFunction { /** 对账号 */ - @DbColumn(comment = "对账号") + @DbMySqlIndex(comment = "对账号索引") + @DbColumn(comment = "对账号", length = 32, isNull = false) private String reconcileNo; /** 日期 */ - @DbColumn(comment = "日期") + @DbColumn(comment = "日期", isNull = false) private LocalDate date; /** * 通道 * @see PayChannelEnum */ - @DbColumn(comment = "通道") + @DbColumn(comment = "通道", length = 20, isNull = false) private String channel; /** 交易对账文件是否下载成功 */ - @DbColumn(comment = "明细对账单下载") + @DbColumn(comment = "明细对账单下载", isNull = false) private boolean downOrUpload; /** 交易对账文件是否比对完成 */ - @DbColumn(comment = "明细对账单比对") + @DbColumn(comment = "明细对账单比对", isNull = false) private boolean compare; /** * 交易对账结果 * @see ReconcileResultEnum */ - @DbColumn(comment = "对账结果") + @DbColumn(comment = "对账结果", length = 20) private String result; /** 错误码 */ - @DbColumn(comment = "错误码") + @DbColumn(comment = "错误码", length = 10) @TableField(updateStrategy = FieldStrategy.ALWAYS) private String errorCode; /** 错误信息 */ - @DbColumn(comment = "错误信息") + @DbColumn(comment = "错误信息", length = 150) @TableField(updateStrategy = FieldStrategy.ALWAYS) private String errorMsg; diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/refund/entity/RefundOrder.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/refund/entity/RefundOrder.java index 6d1e35502..de6b6924f 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/refund/entity/RefundOrder.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/refund/entity/RefundOrder.java @@ -2,6 +2,9 @@ package cn.daxpay.single.service.core.order.refund.entity; import cn.bootx.platform.common.core.function.EntityBaseFunction; import cn.bootx.platform.common.mybatisplus.base.MpBaseEntity; +import cn.bootx.table.modify.annotation.DbColumn; +import cn.bootx.table.modify.annotation.DbTable; +import cn.bootx.table.modify.mysql.annotation.DbMySqlIndex; import cn.daxpay.single.code.PayChannelEnum; import cn.daxpay.single.code.RefundStatusEnum; import cn.daxpay.single.param.channel.AliPayParam; @@ -9,8 +12,6 @@ import cn.daxpay.single.param.channel.WalletPayParam; import cn.daxpay.single.param.channel.WeChatPayParam; import cn.daxpay.single.service.core.order.refund.convert.RefundOrderConvert; import cn.daxpay.single.service.dto.order.refund.RefundOrderDto; -import cn.bootx.table.modify.annotation.DbColumn; -import cn.bootx.table.modify.annotation.DbTable; import com.baomidou.mybatisplus.annotation.FieldStrategy; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableName; @@ -33,54 +34,61 @@ import java.time.LocalDateTime; public class RefundOrder extends MpBaseEntity implements EntityBaseFunction { /** 支付订单ID */ - @DbColumn(comment = "支付订单ID") + @DbMySqlIndex(comment = "支付订单ID索引") + @DbColumn(comment = "支付订单ID", isNull = false) private Long orderId; /** 支付订单号 */ - @DbColumn(comment = "支付订单号") + @DbMySqlIndex(comment = "支付订单号索引") + @DbColumn(comment = "支付订单号", length = 32, isNull = false) private String orderNo; /** 商户支付订单号 */ - @DbColumn(comment = "商户支付订单号") + @DbMySqlIndex(comment = "商户支付订单号索引") + @DbColumn(comment = "商户支付订单号", length = 100, isNull = false) private String bizOrderNo; /** 通道支付订单号 */ - @DbColumn(comment = "通道支付订单号") + @DbMySqlIndex(comment = "通道支付订单号索引") + @DbColumn(comment = "通道支付订单号", length = 150, isNull = false) private String outOrderNo; /** 支付标题 */ - @DbColumn(comment = "支付标题") + @DbColumn(comment = "支付标题", length = 100, isNull = false) private String title; /** 退款号 */ - @DbColumn(comment = "退款号") + @DbMySqlIndex(comment = "退款号索引") + @DbColumn(comment = "退款号", length = 32, isNull = false) private String refundNo; /** 商户退款号 */ - @DbColumn(comment = "商户退款号") + @DbMySqlIndex(comment = "商户退款号索引") + @DbColumn(comment = "商户退款号", length = 100, isNull = false) private String bizRefundNo; /** 通道退款交易号 */ - @DbColumn(comment = "通道退款交易号") + @DbMySqlIndex(comment = "通道退款交易号索引") + @DbColumn(comment = "通道退款交易号", length = 150) private String outRefundNo; /** * 退款通道 * @see PayChannelEnum */ - @DbColumn(comment = "支付通道") + @DbColumn(comment = "支付通道", length = 20, isNull = false) private String channel; /** 订单金额 */ - @DbColumn(comment = "订单金额") + @DbColumn(comment = "订单金额", length = 15, isNull = false) private Integer orderAmount; /** 退款金额 */ - @DbColumn(comment = "退款金额") + @DbColumn(comment = "退款金额", length = 15, isNull = false) private Integer amount; /** 退款原因 */ - @DbColumn(comment = "退款原因") + @DbColumn(comment = "退款原因", length = 150) private String reason; /** 退款完成时间 */ @@ -91,16 +99,16 @@ public class RefundOrder extends MpBaseEntity implements EntityBaseFunction details = orderAndDetail.getDetails(); + AllocOrder order = orderAndDetail.getOrder(); + List details = orderAndDetail.getDetails(); // 无需进行分账, if (Objects.equals(order.getStatus(),AllocOrderStatusEnum.IGNORE.getCode())){ return new AllocationResult() @@ -147,7 +147,7 @@ public class AllocationService { /** * 重新分账 */ - private AllocationResult retryAllocation(AllocationParam param, AllocationOrder order){ + private AllocationResult retryAllocation(AllocationParam param, AllocOrder order){ LockInfo lock = lockTemplate.lock("payment:allocation:" + order.getOrderId(),10000,200); if (Objects.isNull(lock)){ throw new RepetitiveOperationException("分账发起处理中,请勿重复操作"); @@ -160,7 +160,7 @@ public class AllocationService { if (!list.contains(order.getStatus())){ throw new PayFailureException("分账单状态错误,无法重试"); } - List details = this.getDetails(order.getId()); + List details = this.getDetails(order.getId()); // 创建分账策略并初始化 AbsAllocationStrategy allocationStrategy = PayStrategyFactory.create(order.getChannel(),AbsAllocationStrategy.class); allocationStrategy.initParam(order, details); @@ -194,30 +194,30 @@ public class AllocationService { * 分账完结 */ public AllocationResult finish(AllocFinishParam param) { - AllocationOrder allocationOrder; + AllocOrder allocOrder; if (Objects.nonNull(param.getAllocNo())){ - allocationOrder = allocationOrderManager.findByAllocationNo(param.getAllocNo()) + allocOrder = allocationOrderManager.findByAllocNo(param.getAllocNo()) .orElseThrow(() -> new DataNotExistException("未查询到分账单信息")); } else { - allocationOrder = allocationOrderManager.findByBizAllocationNo(param.getBizAllocNo()) + allocOrder = allocationOrderManager.findByBizAllocNo(param.getBizAllocNo()) .orElseThrow(() -> new DataNotExistException("未查询到分账单信息")); } - return this.finish(allocationOrder); + return this.finish(allocOrder); } /** * 分账完结 */ - public AllocationResult finish(AllocationOrder allocationOrder) { + public AllocationResult finish(AllocOrder allocOrder) { // 只有分账结束后才可以完结 - if (!Arrays.asList(ALLOCATION_END.getCode(),FINISH_FAILED.getCode()).contains(allocationOrder.getStatus())) { + if (!Arrays.asList(ALLOCATION_END.getCode(),FINISH_FAILED.getCode()).contains(allocOrder.getStatus())) { throw new PayFailureException("分账单状态错误"); } - List details = this.getDetails(allocationOrder.getId()); + List details = this.getDetails(allocOrder.getId()); // 创建分账策略并初始化 - AbsAllocationStrategy allocationStrategy = PayStrategyFactory.create(allocationOrder.getChannel(),AbsAllocationStrategy.class); - allocationStrategy.initParam(allocationOrder, details); + AbsAllocationStrategy allocationStrategy = PayStrategyFactory.create(allocOrder.getChannel(),AbsAllocationStrategy.class); + allocationStrategy.initParam(allocOrder, details); // 分账完结预处理 allocationStrategy.doBeforeHandler(); @@ -225,20 +225,20 @@ public class AllocationService { // 完结处理 allocationStrategy.finish(); // 完结状态 - allocationOrder.setStatus(AllocOrderStatusEnum.FINISH.getCode()) + allocOrder.setStatus(AllocOrderStatusEnum.FINISH.getCode()) .setFinishTime(LocalDateTime.now()) .setErrorMsg(null); } catch (Exception e) { log.error("分账完结错误:", e); // 失败 - allocationOrder.setStatus(FINISH_FAILED.getCode()) + allocOrder.setStatus(FINISH_FAILED.getCode()) .setErrorMsg(e.getMessage()); } - allocationOrderManager.updateById(allocationOrder); + allocationOrderManager.updateById(allocOrder); return new AllocationResult() - .setAllocNo(allocationOrder.getAllocNo()) - .setBizAllocNo(allocationOrder.getBizAllocNo()) - .setStatus(allocationOrder.getStatus()); + .setAllocNo(allocOrder.getAllocNo()) + .setBizAllocNo(allocOrder.getBizAllocNo()) + .setStatus(allocOrder.getStatus()); } /** @@ -264,12 +264,12 @@ public class AllocationService { */ public AllocOrderResult queryAllocationOrder(QueryAllocOrderParam param) { // 查询分账单 - AllocationOrder allocationOrder = allocationOrderManager.findByAllocationNo(param.getAllocNo()) + AllocOrder allocOrder = allocationOrderManager.findByAllocNo(param.getAllocNo()) .orElseThrow(() -> new PayFailureException("分账单不存在")); - AllocOrderResult result = AllocationConvert.CONVERT.toResult(allocationOrder); + AllocOrderResult result = AllocOrderConvert.CONVERT.toResult(allocOrder); // 查询分账单明细 - List details = allocationOrderDetailManager.findAllByOrderId(allocationOrder.getId()).stream() - .map(AllocationConvert.CONVERT::toResult) + List details = allocOrderDetailManager.findAllByOrderId(allocOrder.getId()).stream() + .map(AllocOrderConvert.CONVERT::toResult) .collect(Collectors.toList()); result.setDetails(details); return result; @@ -283,7 +283,7 @@ public class AllocationService { OrderAndDetail orderAndDetail; // 判断是否传输了分账接收方列表 if (CollUtil.isNotEmpty(param.getReceivers())) { - orderAndDetail = allocationOrderService.createAndUpdate(param, payOrder); + orderAndDetail = allocOrderService.createAndUpdate(param, payOrder); } else { AllocationGroup allocationGroup; if (Objects.nonNull(param.getGroupNo())){ @@ -299,7 +299,7 @@ public class AllocationService { } List receiversByGroups = allocationGroupService.findReceiversByGroups(allocationGroup.getId()); - orderAndDetail = allocationOrderService.createAndUpdate(param ,payOrder, receiversByGroups); + orderAndDetail = allocOrderService.createAndUpdate(param ,payOrder, receiversByGroups); } return orderAndDetail; } @@ -307,8 +307,8 @@ public class AllocationService { /** * 获取发起分账或完结的明细 */ - private List getDetails(Long allocOrderId){ - List details = allocationOrderDetailManager.findAllByOrderId(allocOrderId); + private List getDetails(Long allocOrderId){ + List details = allocOrderDetailManager.findAllByOrderId(allocOrderId); // 过滤掉忽略的条目 return details.stream() .filter(detail -> !Objects.equals(detail.getResult(), AllocDetailResultEnum.IGNORE.getCode())) diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/allocation/service/AllocationSyncService.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/allocation/service/AllocationSyncService.java index e0387a03d..05ce590c5 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/allocation/service/AllocationSyncService.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/allocation/service/AllocationSyncService.java @@ -9,10 +9,10 @@ import cn.daxpay.single.param.payment.allocation.AllocSyncParam; import cn.daxpay.single.result.sync.AllocSyncResult; import cn.daxpay.single.service.code.PaymentTypeEnum; import cn.daxpay.single.service.common.local.PaymentContextLocal; -import cn.daxpay.single.service.core.order.allocation.dao.AllocationOrderDetailManager; +import cn.daxpay.single.service.core.order.allocation.dao.AllocOrderDetailManager; import cn.daxpay.single.service.core.order.allocation.dao.AllocationOrderManager; -import cn.daxpay.single.service.core.order.allocation.entity.AllocationOrder; -import cn.daxpay.single.service.core.order.allocation.entity.AllocationOrderDetail; +import cn.daxpay.single.service.core.order.allocation.entity.AllocOrder; +import cn.daxpay.single.service.core.order.allocation.entity.AllocOrderDetail; import cn.daxpay.single.service.core.payment.notice.service.ClientNoticeService; import cn.daxpay.single.service.core.payment.sync.result.AllocRemoteSyncResult; import cn.daxpay.single.service.core.record.sync.entity.PaySyncRecord; @@ -45,7 +45,7 @@ public class AllocationSyncService { private final AllocationOrderManager allocationOrderManager; - private final AllocationOrderDetailManager allocationOrderDetailManager; + private final AllocOrderDetailManager allocOrderDetailManager; private final PaySyncRecordService paySyncRecordService; @@ -57,46 +57,46 @@ public class AllocationSyncService { @Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class) public AllocSyncResult sync(AllocSyncParam param) { // 获取分账订单 - AllocationOrder allocationOrder = null; + AllocOrder allocOrder = null; if (Objects.nonNull(param.getAllocNo())){ - allocationOrder = allocationOrderManager.findByAllocationNo(param.getAllocNo()) + allocOrder = allocationOrderManager.findByAllocNo(param.getAllocNo()) .orElseThrow(() -> new DataNotExistException("分账单不存在")); } - if (Objects.isNull(allocationOrder)){ - allocationOrder = allocationOrderManager.findByAllocationNo(param.getBizAllocNo()) + if (Objects.isNull(allocOrder)){ + allocOrder = allocationOrderManager.findByAllocNo(param.getBizAllocNo()) .orElseThrow(() -> new DataNotExistException("分账单不存在")); } // 如果类型为忽略, 不进行同步处理 - if (Objects.equals(allocationOrder.getStatus(), AllocOrderStatusEnum.IGNORE.getCode())){ + if (Objects.equals(allocOrder.getStatus(), AllocOrderStatusEnum.IGNORE.getCode())){ return new AllocSyncResult(); } // 调用同步逻辑 - this.sync(allocationOrder); + this.sync(allocOrder); return new AllocSyncResult(); } /** * 分账同步 */ - public void sync(AllocationOrder allocationOrder){ - LockInfo lock = lockTemplate.lock("payment:allocation:" + allocationOrder.getOrderId(),10000,200); + public void sync(AllocOrder allocOrder){ + LockInfo lock = lockTemplate.lock("payment:allocation:" + allocOrder.getOrderId(),10000,200); if (Objects.isNull(lock)){ throw new RepetitiveOperationException("分账同步中,请勿重复操作"); } try { - List detailList = allocationOrderDetailManager.findAllByOrderId(allocationOrder.getId()); + List detailList = allocOrderDetailManager.findAllByOrderId(allocOrder.getId()); // 获取分账策略 - AbsAllocationStrategy allocationStrategy = PayStrategyFactory.create(allocationOrder.getChannel(),AbsAllocationStrategy.class); - allocationStrategy.initParam(allocationOrder, detailList); + AbsAllocationStrategy allocationStrategy = PayStrategyFactory.create(allocOrder.getChannel(),AbsAllocationStrategy.class); + allocationStrategy.initParam(allocOrder, detailList); // 分账完结预处理 allocationStrategy.doBeforeHandler(); // 执行同步操作, 分账明细的状态变更会在这个里面 AllocRemoteSyncResult allocRemoteSyncResult = allocationStrategy.doSync(); // 保存分账同步记录 - this.saveRecord(allocationOrder, allocRemoteSyncResult,null,null); + this.saveRecord(allocOrder, allocRemoteSyncResult,null,null); // 根据订单明细更新订单的状态和处理结果 - this.updateOrderStatus(allocationOrder, detailList); + this.updateOrderStatus(allocOrder, detailList); } finally { lockTemplate.releaseLock(lock); } @@ -106,50 +106,50 @@ public class AllocationSyncService { * 根据订单明细更新订单的状态和处理结果, 如果订单是分账结束或失败, 不更新状态 * TODO 是否多次同步会产生多次变动, 注意处理多次推送通知的问题, 目前是 */ - private void updateOrderStatus(AllocationOrder allocationOrder, List details){ + private void updateOrderStatus(AllocOrder allocOrder, List details){ // 如果是分账结束或失败, 不更新状态 - String status = allocationOrder.getStatus(); + String status = allocOrder.getStatus(); // 如果是分账结束或失败, 不进行对订单进行处理 List list = Arrays.asList(AllocOrderStatusEnum.FINISH.getCode(), AllocOrderStatusEnum.FINISH_FAILED.getCode()); if (!list.contains(status)){ // 判断明细状态. 获取成功和失败的 long successCount = details.stream() - .map(AllocationOrderDetail::getResult) + .map(AllocOrderDetail::getResult) .filter(AllocDetailResultEnum.SUCCESS.getCode()::equals) .count(); long failCount = details.stream() - .map(AllocationOrderDetail::getResult) + .map(AllocOrderDetail::getResult) .filter(AllocDetailResultEnum.FAIL.getCode()::equals) .count(); // 成功和失败都为0 表示进行中 if (successCount == 0 && failCount == 0){ - allocationOrder.setStatus(AllocOrderStatusEnum.ALLOCATION_PROCESSING.getCode()) + allocOrder.setStatus(AllocOrderStatusEnum.ALLOCATION_PROCESSING.getCode()) .setResult(AllocOrderResultEnum.ALL_PENDING.getCode()); } else { if (failCount == details.size()){ // 全部失败 - allocationOrder.setStatus(AllocOrderStatusEnum.ALLOCATION_END.getCode()) + allocOrder.setStatus(AllocOrderStatusEnum.ALLOCATION_END.getCode()) .setResult(AllocOrderResultEnum.ALL_FAILED.getCode()); } else if (successCount == details.size()){ // 全部成功 - allocationOrder.setStatus(AllocOrderStatusEnum.ALLOCATION_END.getCode()) + allocOrder.setStatus(AllocOrderStatusEnum.ALLOCATION_END.getCode()) .setResult(AllocOrderResultEnum.ALL_SUCCESS.getCode()); } else { // 部分成功 - allocationOrder.setStatus(AllocOrderStatusEnum.ALLOCATION_END.getCode()) + allocOrder.setStatus(AllocOrderStatusEnum.ALLOCATION_END.getCode()) .setResult(AllocOrderResultEnum.PART_SUCCESS.getCode()); } } } - allocationOrderDetailManager.updateAllById(details); - allocationOrderManager.updateById(allocationOrder); + allocOrderDetailManager.updateAllById(details); + allocationOrderManager.updateById(allocOrder); // 如果状态为完成, 发送通知 - if (Objects.equals(AllocOrderStatusEnum.ALLOCATION_END.getCode(), allocationOrder.getStatus())){ + if (Objects.equals(AllocOrderStatusEnum.ALLOCATION_END.getCode(), allocOrder.getStatus())){ // 发送通知 - clientNoticeService.registerAllocNotice(allocationOrder, details); + clientNoticeService.registerAllocNotice(allocOrder, details); } } @@ -157,7 +157,7 @@ public class AllocationSyncService { /** * 保存同步记录 */ - private void saveRecord(AllocationOrder order, AllocRemoteSyncResult syncResult, String errorCode, String errorMsg){ + private void saveRecord(AllocOrder order, AllocRemoteSyncResult syncResult, String errorCode, String errorMsg){ PaySyncRecord paySyncRecord = new PaySyncRecord() .setBizTradeNo(order.getBizAllocNo()) .setTradeNo(order.getAllocNo()) diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/allocation/strategy/allocation/AliPayAllocationStrategy.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/allocation/strategy/allocation/AliPayAllocationStrategy.java index 107eca305..b94c72115 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/allocation/strategy/allocation/AliPayAllocationStrategy.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/allocation/strategy/allocation/AliPayAllocationStrategy.java @@ -60,7 +60,7 @@ public class AliPayAllocationStrategy extends AbsAllocationStrategy { */ @Override public void allocation() { - aliPayAllocationService.allocation(this.getAllocationOrder(), this.getAllocationOrderDetails()); + aliPayAllocationService.allocation(this.getAllocOrder(), this.getAllocOrderDetails()); } /** @@ -68,7 +68,7 @@ public class AliPayAllocationStrategy extends AbsAllocationStrategy { */ @Override public void finish() { - aliPayAllocationService.finish(this.getAllocationOrder(), this.getAllocationOrderDetails()); + aliPayAllocationService.finish(this.getAllocOrder(), this.getAllocOrderDetails()); } /** @@ -76,7 +76,7 @@ public class AliPayAllocationStrategy extends AbsAllocationStrategy { */ @Override public AllocRemoteSyncResult doSync() { - return aliPayAllocationService.sync(this.getAllocationOrder(), this.getAllocationOrderDetails()); + return aliPayAllocationService.sync(this.getAllocOrder(), this.getAllocOrderDetails()); } } diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/allocation/strategy/allocation/WeChatPayAllocationStrategy.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/allocation/strategy/allocation/WeChatPayAllocationStrategy.java index 721c6769b..6ad445a65 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/allocation/strategy/allocation/WeChatPayAllocationStrategy.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/allocation/strategy/allocation/WeChatPayAllocationStrategy.java @@ -52,7 +52,7 @@ public class WeChatPayAllocationStrategy extends AbsAllocationStrategy { throw new PayFailureException("微信支付配置不支持分账"); } // 如果分账金额为0, 不发起分账 - if (getAllocationOrder().getAmount() == 0){ + if (getAllocOrder().getAmount() == 0){ throw new PayFailureException("微信订单的分账比例不正确或订单金额太小, 无法进行分账"); } } @@ -62,7 +62,7 @@ public class WeChatPayAllocationStrategy extends AbsAllocationStrategy { */ @Override public void allocation() { - weChatPayAllocationService.allocation(getAllocationOrder(), this.getAllocationOrderDetails(), weChatPayConfig); + weChatPayAllocationService.allocation(getAllocOrder(), this.getAllocOrderDetails(), weChatPayConfig); } /** @@ -70,7 +70,7 @@ public class WeChatPayAllocationStrategy extends AbsAllocationStrategy { */ @Override public void finish() { - weChatPayAllocationService.finish(getAllocationOrder(), weChatPayConfig); + weChatPayAllocationService.finish(getAllocOrder(), weChatPayConfig); } /** @@ -78,7 +78,7 @@ public class WeChatPayAllocationStrategy extends AbsAllocationStrategy { */ @Override public AllocRemoteSyncResult doSync() { - return weChatPayAllocationService.sync(this.getAllocationOrder(),this.getAllocationOrderDetails(),weChatPayConfig); + return weChatPayAllocationService.sync(this.getAllocOrder(),this.getAllocOrderDetails(),weChatPayConfig); } } diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/notice/result/PayNoticeResult.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/notice/result/PayNoticeResult.java index 84f842cfa..0570a0618 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/notice/result/PayNoticeResult.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/notice/result/PayNoticeResult.java @@ -56,7 +56,7 @@ public class PayNoticeResult extends PaymentCommonResult { * 支付通道 * @see PayChannelEnum */ - @Schema(description = "异步支付通道") + @Schema(description = "支付通道") private String channel; /** diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/notice/service/ClientNoticeAssistService.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/notice/service/ClientNoticeAssistService.java index e779025ca..487cc45d1 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/notice/service/ClientNoticeAssistService.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/notice/service/ClientNoticeAssistService.java @@ -3,9 +3,9 @@ package cn.daxpay.single.service.core.payment.notice.service; import cn.bootx.platform.common.jackson.util.JacksonUtil; import cn.daxpay.single.service.code.ClientNoticeTypeEnum; import cn.daxpay.single.service.core.notice.entity.ClientNoticeTask; -import cn.daxpay.single.service.core.order.allocation.convert.AllocationConvert; -import cn.daxpay.single.service.core.order.allocation.entity.AllocationOrder; -import cn.daxpay.single.service.core.order.allocation.entity.AllocationOrderDetail; +import cn.daxpay.single.service.core.order.allocation.convert.AllocOrderConvert; +import cn.daxpay.single.service.core.order.allocation.entity.AllocOrder; +import cn.daxpay.single.service.core.order.allocation.entity.AllocOrderDetail; import cn.daxpay.single.service.core.order.pay.convert.PayOrderConvert; import cn.daxpay.single.service.core.order.pay.entity.PayOrder; import cn.daxpay.single.service.core.order.refund.convert.RefundOrderConvert; @@ -75,12 +75,12 @@ public class ClientNoticeAssistService { /** * 构建分账通知 */ - public ClientNoticeTask buildAllocTask(AllocationOrder order, List list){ + public ClientNoticeTask buildAllocTask(AllocOrder order, List list){ // 分账 - AllocNoticeResult allocOrderResult = AllocationConvert.CONVERT.toNotice(order); + AllocNoticeResult allocOrderResult = AllocOrderConvert.CONVERT.toNotice(order); // 分账详情 List details = list.stream() - .map(AllocationConvert.CONVERT::toNotice) + .map(AllocOrderConvert.CONVERT::toNotice) .collect(Collectors.toList()); // 分账扩展和明细 allocOrderResult.setAttach(order.getAttach()) diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/notice/service/ClientNoticeService.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/notice/service/ClientNoticeService.java index 042cf8b5c..d7f7852b2 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/notice/service/ClientNoticeService.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/notice/service/ClientNoticeService.java @@ -8,8 +8,8 @@ import cn.daxpay.single.service.core.notice.dao.ClientNoticeTaskManager; import cn.daxpay.single.service.core.notice.entity.ClientNoticeRecord; import cn.daxpay.single.service.core.notice.entity.ClientNoticeTask; import cn.daxpay.single.service.core.notice.service.ClientNoticeRecordService; -import cn.daxpay.single.service.core.order.allocation.entity.AllocationOrder; -import cn.daxpay.single.service.core.order.allocation.entity.AllocationOrderDetail; +import cn.daxpay.single.service.core.order.allocation.entity.AllocOrder; +import cn.daxpay.single.service.core.order.allocation.entity.AllocOrderDetail; import cn.daxpay.single.service.core.order.pay.entity.PayOrder; import cn.daxpay.single.service.core.order.refund.entity.RefundOrder; import cn.hutool.core.util.StrUtil; @@ -128,7 +128,7 @@ public class ClientNoticeService { * 注册分账消息通知任务 */ @Async("bigExecutor") - public void registerAllocNotice(AllocationOrder order, List list) { + public void registerAllocNotice(AllocOrder order, List list) { // 判断是否需要进行通知 if (StrUtil.isBlank(order.getNotifyUrl())){ log.info("分账订单无需通知,订单ID:{}",order.getId()); diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/pay/service/PayService.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/pay/service/PayService.java index 50c5c7477..f29c63d30 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/pay/service/PayService.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/pay/service/PayService.java @@ -53,8 +53,6 @@ public class PayService { public PayResult pay(PayParam payParam){ // 创建返回类 PayResult payResult = new PayResult(); - // 支付参数检查 - PayUtil.validation(payParam); // 校验支付限额 payAssistService.validationLimitAmount(payParam); // 获取商户订单号 diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/refund/service/RefundService.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/refund/service/RefundService.java index cc93d38ea..4762e3721 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/refund/service/RefundService.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/refund/service/RefundService.java @@ -1,7 +1,6 @@ package cn.daxpay.single.service.core.payment.refund.service; import cn.bootx.platform.common.core.exception.DataNotExistException; -import cn.bootx.platform.common.core.util.CollUtil; import cn.bootx.platform.common.core.util.ValidationUtil; import cn.daxpay.single.code.PayOrderRefundStatusEnum; import cn.daxpay.single.code.RefundStatusEnum; @@ -20,7 +19,6 @@ import cn.daxpay.single.service.core.record.flow.service.TradeFlowRecordService; import cn.daxpay.single.service.func.AbsRefundStrategy; import cn.daxpay.single.service.util.PayStrategyFactory; import cn.hutool.extra.spring.SpringUtil; -import cn.hutool.json.JSONUtil; import com.baomidou.lock.LockInfo; import com.baomidou.lock.LockTemplate; import lombok.RequiredArgsConstructor; @@ -182,10 +180,8 @@ public class RefundService { order.setAttach(param.getAttach()) .setClientIp(param.getClientIp()) .setNotifyUrl(param.getNotifyUrl()) - .setReqTime(param.getReqTime()); - if (CollUtil.isNotEmpty(param.getExtraParam())){ - order.setExtraParam(JSONUtil.toJsonStr(param.getExtraParam())); - } + .setReqTime(param.getReqTime()) + .setExtraParam(param.getExtraParam()); refundOrderManager.updateById(order); } diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/dto/order/allocation/AllocationOrderDto.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/dto/order/allocation/AllocOrderDto.java similarity index 98% rename from daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/dto/order/allocation/AllocationOrderDto.java rename to daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/dto/order/allocation/AllocOrderDto.java index 849679fda..f50e43f1a 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/dto/order/allocation/AllocationOrderDto.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/dto/order/allocation/AllocOrderDto.java @@ -19,7 +19,7 @@ import java.time.LocalDateTime; @Data @Accessors(chain = true) @Schema(title = "分账订单") -public class AllocationOrderDto extends BaseDto { +public class AllocOrderDto extends BaseDto { /** * 分账订单号 diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/func/AbsAllocationStrategy.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/func/AbsAllocationStrategy.java index 67218b73e..de8dde4e0 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/func/AbsAllocationStrategy.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/func/AbsAllocationStrategy.java @@ -1,7 +1,7 @@ package cn.daxpay.single.service.func; -import cn.daxpay.single.service.core.order.allocation.entity.AllocationOrder; -import cn.daxpay.single.service.core.order.allocation.entity.AllocationOrderDetail; +import cn.daxpay.single.service.core.order.allocation.entity.AllocOrder; +import cn.daxpay.single.service.core.order.allocation.entity.AllocOrderDetail; import cn.daxpay.single.service.core.payment.sync.result.AllocRemoteSyncResult; import lombok.Getter; import lombok.Setter; @@ -19,16 +19,16 @@ import java.util.List; @Setter public abstract class AbsAllocationStrategy implements PayStrategy{ - private AllocationOrder allocationOrder; + private AllocOrder allocOrder; - private List allocationOrderDetails; + private List allocOrderDetails; /** * 初始化参数 */ - public void initParam(AllocationOrder allocationOrder, List allocationOrderDetails) { - this.allocationOrder = allocationOrder; - this.allocationOrderDetails = allocationOrderDetails; + public void initParam(AllocOrder allocOrder, List allocOrderDetails) { + this.allocOrder = allocOrder; + this.allocOrderDetails = allocOrderDetails; } /** diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/param/order/AllocationOrderQuery.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/param/order/AllocOrderQuery.java similarity index 94% rename from daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/param/order/AllocationOrderQuery.java rename to daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/param/order/AllocOrderQuery.java index 7ad532b50..cedb9f68a 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/param/order/AllocationOrderQuery.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/param/order/AllocOrderQuery.java @@ -12,7 +12,7 @@ import lombok.experimental.Accessors; @Data @Accessors(chain = true) @Schema(title = "分账订单查询参数") -public class AllocationOrderQuery { +public class AllocOrderQuery { @Schema(description = "分账订单号") private String orderNo; diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/task/AllocationSyncTask.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/task/AllocationSyncTask.java index fbb2ac618..cad5efd34 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/task/AllocationSyncTask.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/task/AllocationSyncTask.java @@ -2,7 +2,7 @@ package cn.daxpay.single.service.task; import cn.daxpay.single.code.AllocOrderStatusEnum; import cn.daxpay.single.service.core.order.allocation.dao.AllocationOrderManager; -import cn.daxpay.single.service.core.order.allocation.entity.AllocationOrder; +import cn.daxpay.single.service.core.order.allocation.entity.AllocOrder; import cn.daxpay.single.service.core.payment.allocation.service.AllocationService; import cn.daxpay.single.service.core.payment.allocation.service.AllocationSyncService; import lombok.RequiredArgsConstructor; @@ -32,18 +32,18 @@ public class AllocationSyncTask implements Job { */ @Override public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException { - for (AllocationOrder allocationOrder : allocationOrderManager.findSyncOrder()) { + for (AllocOrder allocOrder : allocationOrderManager.findSyncOrder()) { try { // 分账中走同步逻辑 - if (allocationOrder.getStatus().equals(AllocOrderStatusEnum.ALLOCATION_PROCESSING.getCode())) { - allocationSyncService.sync(allocationOrder); + if (allocOrder.getStatus().equals(AllocOrderStatusEnum.ALLOCATION_PROCESSING.getCode())) { + allocationSyncService.sync(allocOrder); } // 如果分账结束, 调用自动完结逻辑 - if (allocationOrder.getStatus().equals(AllocOrderStatusEnum.ALLOCATION_END.getCode())) { - allocationService.finish(allocationOrder); + if (allocOrder.getStatus().equals(AllocOrderStatusEnum.ALLOCATION_END.getCode())) { + allocationService.finish(allocOrder); } } catch (Exception e) { - log.warn("分账同步或完结失败, 分账号:{}", allocationOrder.getAllocNo()); + log.warn("分账同步或完结失败, 分账号:{}", allocOrder.getAllocNo()); log.warn("分账同步或完结失败", e); } }