From ec4a901d860a5a527b953cc79365a0d29cf284d0 Mon Sep 17 00:00:00 2001 From: bootx Date: Mon, 22 Jan 2024 23:52:04 +0800 Subject: [PATCH] =?UTF-8?q?feat=20=E5=AF=B9=E8=B4=A6=E6=98=8E=E7=BB=86?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E6=9F=A5=E7=9C=8B=E5=92=8C=E9=80=9A=E7=94=A8?= =?UTF-8?q?=E5=AF=B9=E8=B4=A6=E5=AD=97=E6=AE=B5=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bootx/platform/daxpay/util/PayUtil.java | 3 +- .../service/AliPayReconcileService.java | 4 +- .../wechat/entity/WxReconcileBillDetail.java | 2 +- .../service/WechatPayReconcileService.java | 5 ++- .../reconcile/entity/PayReconcileDetail.java | 33 +++++++++------- .../service/PayReconcileService.java | 2 +- .../reconcile/PayReconcileDetailDto.java | 39 +++++++++---------- .../param/reconcile/ReconcileDetailQuery.java | 12 +++--- 8 files changed, 52 insertions(+), 48 deletions(-) diff --git a/daxpay-single/daxpay-single-core/src/main/java/cn/bootx/platform/daxpay/util/PayUtil.java b/daxpay-single/daxpay-single-core/src/main/java/cn/bootx/platform/daxpay/util/PayUtil.java index 0d81f40c9..5aa4cee9c 100644 --- a/daxpay-single/daxpay-single-core/src/main/java/cn/bootx/platform/daxpay/util/PayUtil.java +++ b/daxpay-single/daxpay-single-core/src/main/java/cn/bootx/platform/daxpay/util/PayUtil.java @@ -104,6 +104,7 @@ public class PayUtil { * 生成退款号 */ public String getRefundNo(){ - return "R" + IdUtil.getSnowflakeNextIdStr(); +// return "R" + IdUtil.getSnowflakeNextIdStr(); + return IdUtil.getSnowflakeNextIdStr(); } } diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/channel/alipay/service/AliPayReconcileService.java b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/channel/alipay/service/AliPayReconcileService.java index 90e2010ae..918935550 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/channel/alipay/service/AliPayReconcileService.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/channel/alipay/service/AliPayReconcileService.java @@ -137,14 +137,14 @@ public class AliPayReconcileService { // 默认为支付对账记录 PayReconcileDetail payReconcileDetail = new PayReconcileDetail() .setRecordOrderId(billDetail.getRecordOrderId()) - .setOrderId(billDetail.getOutTradeNo()) + .setPaymentId(billDetail.getOutTradeNo()) .setType("pay") .setAmount(amount) .setTitle(billDetail.getSubject()) .setGatewayOrderNo(billDetail.getTradeNo()); // 退款覆盖更新对应的字段 if (Objects.equals(billDetail.getTradeType(), "退款")){ - payReconcileDetail.setOrderId(billDetail.getBatchNo()) + payReconcileDetail.setRefundId(billDetail.getBatchNo()) .setType("refund"); } diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/channel/wechat/entity/WxReconcileBillDetail.java b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/channel/wechat/entity/WxReconcileBillDetail.java index 21104dbde..822ce2760 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/channel/wechat/entity/WxReconcileBillDetail.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/channel/wechat/entity/WxReconcileBillDetail.java @@ -80,7 +80,7 @@ public class WxReconcileBillDetail extends MpIdEntity { @Alias("微信退款单号") @DbColumn(comment = "微信退款单号") - private String name; + private String wxRefundNo; @Alias("商户退款单号") @DbColumn(comment = "商户退款单号") diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/channel/wechat/service/WechatPayReconcileService.java b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/channel/wechat/service/WechatPayReconcileService.java index 2a8cb6054..627da665d 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/channel/wechat/service/WechatPayReconcileService.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/channel/wechat/service/WechatPayReconcileService.java @@ -117,7 +117,7 @@ public class WechatPayReconcileService{ // 默认为支付对账记录 PayReconcileDetail payReconcileDetail = new PayReconcileDetail() .setRecordOrderId(billDetail.getRecordOrderId()) - .setOrderId(billDetail.getMchOrderNo()) + .setPaymentId(billDetail.getMchOrderNo()) .setTitle(billDetail.getSubject()) .setGatewayOrderNo(billDetail.getWeiXinOrderNo()); // 支付 @@ -136,7 +136,8 @@ public class WechatPayReconcileService{ double v = Double.parseDouble(refundAmount) * 100; int amount = Math.abs(((int) v)); payReconcileDetail.setType("refund") - .setAmount(amount); + .setAmount(amount) + .setRefundId(billDetail.getMchRefundNo()); } // TODO 已撤销, 暂时未处理 if (Objects.equals(billDetail.getStatus(), "REVOKED")){ diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/order/reconcile/entity/PayReconcileDetail.java b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/order/reconcile/entity/PayReconcileDetail.java index 61043a26f..9ed1e84da 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/order/reconcile/entity/PayReconcileDetail.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/order/reconcile/entity/PayReconcileDetail.java @@ -27,25 +27,30 @@ public class PayReconcileDetail extends MpCreateEntity implements EntityBaseFunc @DbColumn(comment = "关联对账订单ID") private Long recordOrderId; - /** 交易类型 支付/退款 */ - @DbColumn(comment = "交易类型") - private String type; - - /** 订单id - 支付ID/退款ID等 */ - @DbColumn(comment = "订单id") - private String orderId; - - /** 网关订单号 - 支付宝/微信的订单号 */ - @DbColumn(comment = "网关订单号") - private String gatewayOrderNo; + /** 商品名称 */ + @DbColumn(comment = "商品名称") + private String title; /** 交易金额 */ @DbColumn(comment = "交易金额") private Integer amount; - /** 商品名称 */ - @DbColumn(comment = "商品名称") - private String title; + /** 交易类型 pay/refund */ + @DbColumn(comment = "交易类型") + private String type; + + /** 本地订单ID */ + @DbColumn(comment = "本地订单ID") + private String paymentId; + + /** 本地退款ID */ + @DbColumn(comment = "本地退款ID") + private String refundId; + + /** 网关订单号 - 支付宝/微信的订单号 */ + @DbColumn(comment = "网关订单号") + private String gatewayOrderNo; + @Override public PayReconcileDetailDto toDto() { diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/payment/reconcile/service/PayReconcileService.java b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/payment/reconcile/service/PayReconcileService.java index df19ed163..7112d3da6 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/payment/reconcile/service/PayReconcileService.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/payment/reconcile/service/PayReconcileService.java @@ -52,7 +52,7 @@ public class PayReconcileService { reconcileOrderService.update(recordOrder); } catch (Exception e) { log.error("下载对账单异常", e); - recordOrder.setErrorMsg("错误原因: " + e.getMessage()); + recordOrder.setErrorMsg("原因: " + e.getMessage()); reconcileOrderService.update(recordOrder); throw new RuntimeException(e); } diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/dto/order/reconcile/PayReconcileDetailDto.java b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/dto/order/reconcile/PayReconcileDetailDto.java index 891693929..4a577e132 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/dto/order/reconcile/PayReconcileDetailDto.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/dto/order/reconcile/PayReconcileDetailDto.java @@ -17,32 +17,31 @@ import lombok.experimental.Accessors; @Schema(title = "对账订单详情") public class PayReconcileDetailDto extends BaseDto { + /** 关联对账订单ID */ @Schema(description = "关联对账订单ID") private Long recordOrderId; - /** - * @see cn.bootx.platform.daxpay.code.PayStatusEnum - */ - @Schema(description = "交易状态") - private String status; - - /** 交易类型 支付/退款 */ - @Schema(description = "交易类型") - private String type; - - /** 订单id - 支付ID/退款ID等 */ - @Schema(description = "订单id") - private String orderId; - - /** 网关订单号 - 支付宝/微信的订单号 */ - @Schema(description = "网关订单号") - private String gatewayOrderNo; + /** 商品名称 */ + @Schema(description = "商品名称") + private String title; /** 交易金额 */ @Schema(description = "交易金额") private Integer amount; - /** 商品名称 */ - @Schema(description = "商品名称") - private String title; + /** 交易类型 pay/refund */ + @Schema(description = "交易类型") + private String type; + + /** 本地订单ID */ + @Schema(description = "本地订单ID") + private String paymentId; + + /** 本地退款ID */ + @Schema(description = "本地退款ID") + private String refundId; + + /** 网关订单号 - 支付宝/微信的订单号 */ + @Schema(description = "网关订单号") + private String gatewayOrderNo; } diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/param/reconcile/ReconcileDetailQuery.java b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/param/reconcile/ReconcileDetailQuery.java index 2bec1a5be..c3776174e 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/param/reconcile/ReconcileDetailQuery.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/param/reconcile/ReconcileDetailQuery.java @@ -19,19 +19,17 @@ public class ReconcileDetailQuery { @Schema(description = "关联对账订单ID") private Long recordOrderId; - /** - * @see cn.bootx.platform.daxpay.code.PayStatusEnum - */ - @Schema(description = "交易状态") - private String status; - /** 交易类型 支付/退款 */ @Schema(description = "交易类型") private String type; /** 订单id - 支付ID/退款ID等 */ @Schema(description = "订单id") - private String orderId; + private String paymentId; + + /** 本地退款ID */ + @Schema(description = "本地退款ID") + private String refundId; /** 网关订单号 - 支付宝/微信的订单号 */ @Schema(description = "网关订单号")