From 42cfd24558ea6e36f92ec9a5ec5f430fbcd0ca11 Mon Sep 17 00:00:00 2001 From: DaxPay Date: Wed, 5 Jun 2024 20:05:25 +0800 Subject: [PATCH 01/34] =?UTF-8?q?feat=20=E6=96=B0=E5=A2=9E=E6=94=AF?= =?UTF-8?q?=E4=BB=98=E6=92=A4=E9=94=80,=20=E6=94=AF=E4=BB=98=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E5=A2=9E=E5=8A=A0=E6=92=A4=E9=94=80=E7=8A=B6=E6=80=81?= =?UTF-8?q?,=20=E5=88=A0=E9=99=A4=E6=97=A0=E5=85=B3=E5=9F=BA=E7=A1=80?= =?UTF-8?q?=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _doc/Task.md | 24 ++-- .../baseapi/dto/chinaword/ChinaWordDto.java | 30 ----- .../dto/chinaword/ChinaWordVerifyResult.java | 27 ----- .../param/chinaword/ChinaWordImportParam.java | 19 --- .../param/chinaword/ChinaWordParam.java | 31 ----- .../param/chinaword/ChinaWordVerifyParam.java | 24 ---- .../single/sdk/model/pay/PayCancelModel.java | 17 +++ .../single/sdk/param/pay/PayCancelParam.java | 41 +++++++ .../single/sdk/param/pay/PayCloseParam.java | 9 +- .../daxpay/single/sdk/param/pay/PayParam.java | 2 - .../single/sdk/payment/PayCloseOrderTest.java | 11 ++ .../cn/daxpay/single/code/PayStatusEnum.java | 1 + .../cn/daxpay/single/code/PaymentApiCode.java | 2 + .../daxpay/single/entity/RefundableInfo.java | 25 ---- .../param/payment/pay/PayCancelParam.java | 2 + .../param/payment/pay/PayCloseParam.java | 2 +- .../single/result/pay/PayCancelResult.java | 19 +++ .../gateway/controller/UniPayController.java | 12 ++ .../single/service/code/PayCloseTypeEnum.java | 25 ++++ .../alipay/service/AliPayCloseService.java | 46 +++++-- .../wechat/service/WeChatPayCloseService.java | 31 ++++- .../core/order/pay/entity/PayOrder.java | 2 + .../order/pay/service/PayOrderService.java | 5 +- .../factory/PayCancelStrategyFactory.java | 38 ++++++ .../cancel/service/PayCancelService.java | 113 ++++++++++++++++++ .../cancel/strategy/AliPayCancelStrategy.java | 51 ++++++++ .../strategy/WeChatPayCancelStrategy.java | 58 +++++++++ .../close/service/PayCloseService.java | 5 +- .../payment/pay/service/PayAssistService.java | 2 +- .../refund/service/RefundAssistService.java | 1 + .../repair/service/PayRepairService.java | 14 +-- .../payment/sync/service/PaySyncService.java | 3 +- .../record/close/entity/PayCloseRecord.java | 8 ++ .../dto/record/close/PayCloseRecordDto.java | 8 ++ .../service/func/AbsPayCancelStrategy.java | 28 +++++ .../param/record/PayCloseRecordQuery.java | 2 +- 36 files changed, 528 insertions(+), 210 deletions(-) delete mode 100644 bootx-platform/bootx-services/service-baseapi/src/main/java/cn/bootx/platform/baseapi/dto/chinaword/ChinaWordDto.java delete mode 100644 bootx-platform/bootx-services/service-baseapi/src/main/java/cn/bootx/platform/baseapi/dto/chinaword/ChinaWordVerifyResult.java delete mode 100644 bootx-platform/bootx-services/service-baseapi/src/main/java/cn/bootx/platform/baseapi/param/chinaword/ChinaWordImportParam.java delete mode 100644 bootx-platform/bootx-services/service-baseapi/src/main/java/cn/bootx/platform/baseapi/param/chinaword/ChinaWordParam.java delete mode 100644 bootx-platform/bootx-services/service-baseapi/src/main/java/cn/bootx/platform/baseapi/param/chinaword/ChinaWordVerifyParam.java create mode 100644 daxpay-single-sdk/src/main/java/cn/daxpay/single/sdk/model/pay/PayCancelModel.java create mode 100644 daxpay-single-sdk/src/main/java/cn/daxpay/single/sdk/param/pay/PayCancelParam.java delete mode 100644 daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/entity/RefundableInfo.java create mode 100644 daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/result/pay/PayCancelResult.java create mode 100644 daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/code/PayCloseTypeEnum.java create mode 100644 daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/cancel/factory/PayCancelStrategyFactory.java create mode 100644 daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/cancel/service/PayCancelService.java create mode 100644 daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/cancel/strategy/AliPayCancelStrategy.java create mode 100644 daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/cancel/strategy/WeChatPayCancelStrategy.java create mode 100644 daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/func/AbsPayCancelStrategy.java diff --git a/_doc/Task.md b/_doc/Task.md index ea2506bb9..9917ac51e 100644 --- a/_doc/Task.md +++ b/_doc/Task.md @@ -1,28 +1,22 @@ ## 单商户 2.0.8: 对账完善和系统优化 -- [ ] 细分各种支付异常类和编码 -- [ ] 修复功能支付/退款/对账 +- [ ] 支持撤销接口 - [ ] 增加转账接口功能 +- [ ] 细分各种支付异常类和编码 +- [ ] 增加对账修复功能拆 - [ ] DEMO增加获取微信OpenID和支付宝OpenId功能 - [ ] 管理端界面支持扫码绑定对账接收方功能 -- [ ] 对账提供外部接口调用 - - [ ] 下载系统账单 -- [ ] 分账结果通知处理 - - [ ] 支付宝通知 - - [ ] 微信通知 - - [ ] 通知记录保存 - [ ] 增加收单收银台功能 - [ ] 增加资金对账单功能 - [ ] 支付通道两个独立的配置进行合并为一个 -- [ ] 支持撤销接口 -- [ ] 支付和退款达到终态不可以再回退回之前的状态, 只能添加差错单进行处理 - -2.0.8: 转账和功能功能优化 -- [ ] 支持转账操作, 通过支付通道专有参数进行实现, 转账时只能单个通道进行操作 +- [ ] 支付和退款达到终态不可以再回退回之前的状态 +- [x] 修复支付关闭参数名称不正确问题 +2.0.9: 消息通知和功能功能优化 +- [ ] 将系统通知消息重构为类似支付宝应用通知的方式 - [ ] 支付成功回调后, 如果订单已超时, 则进入待退款订单中,提示进行退款,或者自动退款 -- [ ] 新增支付单预警功能, 处理支付单与网关状态不一致且无法自动修复的情况 -2.1.x 版本内容 + 2.1.x 版本内容 +- [ ] 新增支付单预警功能, 处理支付单与网关状态不一致且无法自动修复的情况 - [ ] 差错单据处理 - [ ] 特殊退款接口 - [ ] 统计报表功能 diff --git a/bootx-platform/bootx-services/service-baseapi/src/main/java/cn/bootx/platform/baseapi/dto/chinaword/ChinaWordDto.java b/bootx-platform/bootx-services/service-baseapi/src/main/java/cn/bootx/platform/baseapi/dto/chinaword/ChinaWordDto.java deleted file mode 100644 index f31a395b9..000000000 --- a/bootx-platform/bootx-services/service-baseapi/src/main/java/cn/bootx/platform/baseapi/dto/chinaword/ChinaWordDto.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.bootx.platform.baseapi.dto.chinaword; - -import cn.bootx.platform.common.core.rest.dto.BaseDto; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.experimental.Accessors; - -/** - * 敏感词 - * @author xxm - * @since 2023-08-09 - */ -@EqualsAndHashCode(callSuper = true) -@Data -@Schema(title = "敏感词") -@Accessors(chain = true) -public class ChinaWordDto extends BaseDto { - - @Schema(description = "敏感词") - private String word; - @Schema(description = "分类") - private String type; - @Schema(description = "描述") - private String description; - @Schema(description = "是否启用") - private Boolean enable; - @Schema(description = "是否是白名单名词") - private Boolean white; -} diff --git a/bootx-platform/bootx-services/service-baseapi/src/main/java/cn/bootx/platform/baseapi/dto/chinaword/ChinaWordVerifyResult.java b/bootx-platform/bootx-services/service-baseapi/src/main/java/cn/bootx/platform/baseapi/dto/chinaword/ChinaWordVerifyResult.java deleted file mode 100644 index dc8887f59..000000000 --- a/bootx-platform/bootx-services/service-baseapi/src/main/java/cn/bootx/platform/baseapi/dto/chinaword/ChinaWordVerifyResult.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.bootx.platform.baseapi.dto.chinaword; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.experimental.Accessors; - -import java.util.Set; - -/** - * 敏感词验证结果 - * @author xxm - * @since 2023/8/9 - */ -@Data -@Accessors(chain = true) -@Schema(title = "敏感词验证结果") -public class ChinaWordVerifyResult { - - @Schema(description = "是否敏感") - private boolean sensitive; - @Schema(description = "敏感词数量") - private int count; - @Schema(description = "去重后的敏感词列表") - private Set sensitiveWords; - @Schema(description = "脱敏后的文本") - private String text; -} diff --git a/bootx-platform/bootx-services/service-baseapi/src/main/java/cn/bootx/platform/baseapi/param/chinaword/ChinaWordImportParam.java b/bootx-platform/bootx-services/service-baseapi/src/main/java/cn/bootx/platform/baseapi/param/chinaword/ChinaWordImportParam.java deleted file mode 100644 index 5edd178b8..000000000 --- a/bootx-platform/bootx-services/service-baseapi/src/main/java/cn/bootx/platform/baseapi/param/chinaword/ChinaWordImportParam.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.bootx.platform.baseapi.param.chinaword; - -import com.alibaba.excel.annotation.ExcelProperty; -import lombok.Data; - -/** - * 敏感词导入参数 - * @author xxm - * @since 2023/8/12 - */ -@Data -public class ChinaWordImportParam { - @ExcelProperty(value = "类型") - private String type; - @ExcelProperty("黑/白名单") - private String whiteOrBlack; - @ExcelProperty("敏感词") - private String word; -} diff --git a/bootx-platform/bootx-services/service-baseapi/src/main/java/cn/bootx/platform/baseapi/param/chinaword/ChinaWordParam.java b/bootx-platform/bootx-services/service-baseapi/src/main/java/cn/bootx/platform/baseapi/param/chinaword/ChinaWordParam.java deleted file mode 100644 index 3e5c1fc78..000000000 --- a/bootx-platform/bootx-services/service-baseapi/src/main/java/cn/bootx/platform/baseapi/param/chinaword/ChinaWordParam.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.bootx.platform.baseapi.param.chinaword; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.experimental.Accessors; - -/** - * 敏感词 - * @author xxm - * @since 2023-08-09 - */ -@Data -@Schema(title = "敏感词") -@Accessors(chain = true) -public class ChinaWordParam { - - @Schema(description= "主键") - private Long id; - - @Schema(description = "敏感词") - private String word; - @Schema(description = "分类") - private String type; - @Schema(description = "描述") - private String description; - @Schema(description = "是否启用") - private Boolean enable; - @Schema(description = "白名单名词") - private Boolean white; - -} diff --git a/bootx-platform/bootx-services/service-baseapi/src/main/java/cn/bootx/platform/baseapi/param/chinaword/ChinaWordVerifyParam.java b/bootx-platform/bootx-services/service-baseapi/src/main/java/cn/bootx/platform/baseapi/param/chinaword/ChinaWordVerifyParam.java deleted file mode 100644 index 46d2465a6..000000000 --- a/bootx-platform/bootx-services/service-baseapi/src/main/java/cn/bootx/platform/baseapi/param/chinaword/ChinaWordVerifyParam.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.bootx.platform.baseapi.param.chinaword; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.experimental.Accessors; - -/** - * 敏感词验证参数类 - * @author xxm - * @since 2023/8/10 - */ -@Data -@Accessors(chain = true) -@Schema(title = "敏感词验证参数类") -public class ChinaWordVerifyParam { - @Schema(description = "文本") - private String text; - - @Schema(description = "间隔距离") - private int skip = 0; - - @Schema(description = "替换字符") - private char symbol = '*'; -} diff --git a/daxpay-single-sdk/src/main/java/cn/daxpay/single/sdk/model/pay/PayCancelModel.java b/daxpay-single-sdk/src/main/java/cn/daxpay/single/sdk/model/pay/PayCancelModel.java new file mode 100644 index 000000000..427cd572e --- /dev/null +++ b/daxpay-single-sdk/src/main/java/cn/daxpay/single/sdk/model/pay/PayCancelModel.java @@ -0,0 +1,17 @@ +package cn.daxpay.single.sdk.model.pay; + +import cn.daxpay.single.sdk.net.DaxPayResponseModel; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +/** + * 支付撤销 + * @author xxm + * @since 2024/2/2 + */ +@Getter +@Setter +@ToString(callSuper = true) +public class PayCancelModel extends DaxPayResponseModel { +} diff --git a/daxpay-single-sdk/src/main/java/cn/daxpay/single/sdk/param/pay/PayCancelParam.java b/daxpay-single-sdk/src/main/java/cn/daxpay/single/sdk/param/pay/PayCancelParam.java new file mode 100644 index 000000000..089994a1f --- /dev/null +++ b/daxpay-single-sdk/src/main/java/cn/daxpay/single/sdk/param/pay/PayCancelParam.java @@ -0,0 +1,41 @@ +package cn.daxpay.single.sdk.param.pay; + +import cn.daxpay.single.sdk.model.pay.PayCancelModel; +import cn.daxpay.single.sdk.net.DaxPayRequest; +import cn.daxpay.single.sdk.response.DaxPayResult; +import cn.hutool.core.lang.TypeReference; +import cn.hutool.json.JSONUtil; +import lombok.Getter; +import lombok.Setter; + +/** + * 支付撤销参数 + * @author xxm + * @since 2023/12/17 + */ +@Getter +@Setter +public class PayCancelParam extends DaxPayRequest { + + /** 订单号 */ + private String orderNo; + + /** 商户订单号 */ + private String bizOrderNo; + + /** + * 方法请求路径 + */ + @Override + public String path() { + return "/unipay/cancel"; + } + + /** + * 将请求返回结果反序列化为实体类 + */ + @Override + public DaxPayResult toModel(String json) { + return JSONUtil.toBean(json, new TypeReference>() {}, false); + } +} diff --git a/daxpay-single-sdk/src/main/java/cn/daxpay/single/sdk/param/pay/PayCloseParam.java b/daxpay-single-sdk/src/main/java/cn/daxpay/single/sdk/param/pay/PayCloseParam.java index f08834584..7d6e752e5 100644 --- a/daxpay-single-sdk/src/main/java/cn/daxpay/single/sdk/param/pay/PayCloseParam.java +++ b/daxpay-single-sdk/src/main/java/cn/daxpay/single/sdk/param/pay/PayCloseParam.java @@ -5,23 +5,22 @@ import cn.daxpay.single.sdk.response.DaxPayResult; import cn.hutool.core.lang.TypeReference; import cn.hutool.json.JSONUtil; -import lombok.Data; -import lombok.EqualsAndHashCode; +import lombok.*; /** * 支付关闭参数 * @author xxm * @since 2023/12/17 */ -@EqualsAndHashCode(callSuper = true) -@Data +@Getter +@Setter public class PayCloseParam extends DaxPayRequest { /** 订单号 */ private String orderNo; /** 商户订单号 */ - private String bizTradeNo; + private String bizOrderNo; /** * 方法请求路径 diff --git a/daxpay-single-sdk/src/main/java/cn/daxpay/single/sdk/param/pay/PayParam.java b/daxpay-single-sdk/src/main/java/cn/daxpay/single/sdk/param/pay/PayParam.java index 10f5555c9..1f275bdca 100644 --- a/daxpay-single-sdk/src/main/java/cn/daxpay/single/sdk/param/pay/PayParam.java +++ b/daxpay-single-sdk/src/main/java/cn/daxpay/single/sdk/param/pay/PayParam.java @@ -13,7 +13,6 @@ import cn.hutool.json.JSONUtil; import lombok.Getter; import lombok.Setter; -import lombok.ToString; import java.time.LocalDateTime; @@ -24,7 +23,6 @@ */ @Getter @Setter -@ToString(callSuper = true) public class PayParam extends DaxPayRequest { /** 商户订单号 */ diff --git a/daxpay-single-sdk/src/test/java/cn/daxpay/single/sdk/payment/PayCloseOrderTest.java b/daxpay-single-sdk/src/test/java/cn/daxpay/single/sdk/payment/PayCloseOrderTest.java index 51592947b..8cb86723c 100644 --- a/daxpay-single-sdk/src/test/java/cn/daxpay/single/sdk/payment/PayCloseOrderTest.java +++ b/daxpay-single-sdk/src/test/java/cn/daxpay/single/sdk/payment/PayCloseOrderTest.java @@ -1,9 +1,11 @@ package cn.daxpay.single.sdk.payment; import cn.daxpay.single.sdk.code.SignTypeEnum; +import cn.daxpay.single.sdk.model.pay.PayCancelModel; import cn.daxpay.single.sdk.model.pay.PayCloseModel; import cn.daxpay.single.sdk.net.DaxPayConfig; import cn.daxpay.single.sdk.net.DaxPayKit; +import cn.daxpay.single.sdk.param.pay.PayCancelParam; import cn.daxpay.single.sdk.param.pay.PayCloseParam; import cn.daxpay.single.sdk.response.DaxPayResult; import cn.hutool.json.JSONUtil; @@ -37,4 +39,13 @@ public void close(){ DaxPayResult execute = DaxPayKit.execute(param); System.out.println(JSONUtil.toJsonStr(execute)); } + + @Test + public void cancel(){ + PayCancelParam param = new PayCancelParam(); + param.setOrderNo("DEVP24060518083863000001"); + param.setClientIp("127.0.0.1"); + DaxPayResult execute = DaxPayKit.execute(param); + System.out.println(JSONUtil.toJsonStr(execute)); + } } diff --git a/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/code/PayStatusEnum.java b/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/code/PayStatusEnum.java index 87946d9d7..92da52189 100644 --- a/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/code/PayStatusEnum.java +++ b/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/code/PayStatusEnum.java @@ -18,6 +18,7 @@ public enum PayStatusEnum { PROGRESS("progress","支付中"), SUCCESS("success","成功"), CLOSE("close","支付关闭"), + CANCEL("cancel","支付撤销"), REFUNDING("refunding","退款中"), PARTIAL_REFUND("partial_refund","部分退款"), REFUNDED("refunded","全部退款"), diff --git a/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/code/PaymentApiCode.java b/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/code/PaymentApiCode.java index fbe8bd278..d0d7e9308 100644 --- a/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/code/PaymentApiCode.java +++ b/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/code/PaymentApiCode.java @@ -12,6 +12,8 @@ public interface PaymentApiCode { String REFUND = "refund"; /** 关闭订单 */ String CLOSE = "close"; + /** 撤销订单 */ + String CANCEL = "cancel"; /** 分账 */ String ALLOCATION = "allocation"; /** 转账 */ diff --git a/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/entity/RefundableInfo.java b/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/entity/RefundableInfo.java deleted file mode 100644 index 450bcfeb3..000000000 --- a/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/entity/RefundableInfo.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.daxpay.single.entity; - -import cn.daxpay.single.code.PayChannelEnum; -import lombok.Data; -import lombok.experimental.Accessors; - -/** - * 可退款信息(不持久化,直接保存为json) - * @author xxm - * @since 2023/12/18 - */ -@Data -@Accessors(chain = true) -public class RefundableInfo { - /** - * 通道 - * @see PayChannelEnum#getCode() - */ - private String channel; - - /** - * 可退款金额 - */ - private Integer amount; -} diff --git a/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/param/payment/pay/PayCancelParam.java b/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/param/payment/pay/PayCancelParam.java index d06882294..e1ebcbb98 100644 --- a/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/param/payment/pay/PayCancelParam.java +++ b/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/param/payment/pay/PayCancelParam.java @@ -16,9 +16,11 @@ @Schema(title = "支付订单撤销") public class PayCancelParam extends PaymentCommonParam { + /** 订单号 */ @Schema(description = "订单号") private String orderNo; + /** 商户订单号 */ @Schema(description = "商户订单号") private String bizOrderNo; } diff --git a/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/param/payment/pay/PayCloseParam.java b/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/param/payment/pay/PayCloseParam.java index d372aae50..35eda5c9b 100644 --- a/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/param/payment/pay/PayCloseParam.java +++ b/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/param/payment/pay/PayCloseParam.java @@ -21,5 +21,5 @@ public class PayCloseParam extends PaymentCommonParam { /** 商户订单号 */ @Schema(description = "商户订单号") - private String bizTradeNo; + private String bizOrderNo; } diff --git a/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/result/pay/PayCancelResult.java b/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/result/pay/PayCancelResult.java new file mode 100644 index 000000000..769fc2bbf --- /dev/null +++ b/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/result/pay/PayCancelResult.java @@ -0,0 +1,19 @@ +package cn.daxpay.single.result.pay; + +import cn.daxpay.single.result.PaymentCommonResult; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + * 支付关闭响应参数 + * @author xxm + * @since 2024/4/23 + */ +@EqualsAndHashCode(callSuper = true) +@Data +@Accessors(chain = true) +@Schema(title = "支付撤销响应参数") +public class PayCancelResult extends PaymentCommonResult { +} diff --git a/daxpay-single/daxpay-single-gateway/src/main/java/cn/daxpay/single/gateway/controller/UniPayController.java b/daxpay-single/daxpay-single-gateway/src/main/java/cn/daxpay/single/gateway/controller/UniPayController.java index 697c9fbfa..51b581d9d 100644 --- a/daxpay-single/daxpay-single-gateway/src/main/java/cn/daxpay/single/gateway/controller/UniPayController.java +++ b/daxpay-single/daxpay-single-gateway/src/main/java/cn/daxpay/single/gateway/controller/UniPayController.java @@ -2,16 +2,19 @@ import cn.bootx.platform.common.core.annotation.IgnoreAuth; import cn.daxpay.single.code.PaymentApiCode; +import cn.daxpay.single.param.payment.pay.PayCancelParam; import cn.daxpay.single.param.payment.pay.PayCloseParam; import cn.daxpay.single.param.payment.pay.PayParam; import cn.daxpay.single.param.payment.refund.RefundParam; import cn.daxpay.single.param.payment.transfer.TransferParam; import cn.daxpay.single.result.DaxResult; +import cn.daxpay.single.result.pay.PayCancelResult; import cn.daxpay.single.result.pay.PayCloseResult; import cn.daxpay.single.result.pay.PayResult; import cn.daxpay.single.result.pay.RefundResult; import cn.daxpay.single.service.annotation.PaymentSign; import cn.daxpay.single.service.annotation.InitPaymentContext; +import cn.daxpay.single.service.core.payment.cancel.service.PayCancelService; import cn.daxpay.single.service.core.payment.close.service.PayCloseService; import cn.daxpay.single.service.core.payment.pay.service.PayService; import cn.daxpay.single.service.core.payment.refund.service.RefundService; @@ -38,6 +41,7 @@ public class UniPayController { private final PayService payService; private final RefundService refundService; private final PayCloseService payCloseService; + private final PayCancelService payCancelService; @PaymentSign @InitPaymentContext(PaymentApiCode.PAY) @@ -55,6 +59,14 @@ public DaxResult close(@RequestBody PayCloseParam param){ return DaxRes.ok(payCloseService.close(param)); } + @PaymentSign + @InitPaymentContext(PaymentApiCode.CANCEL) + @Operation(summary = "支付撤销接口") + @PostMapping("/cancel") + public DaxResult cancel(@RequestBody PayCancelParam param){ + return DaxRes.ok(payCancelService.cancel(param)); + } + @PaymentSign @InitPaymentContext(PaymentApiCode.REFUND) @Operation(summary = "统一退款接口") diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/code/PayCloseTypeEnum.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/code/PayCloseTypeEnum.java new file mode 100644 index 000000000..629186d7c --- /dev/null +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/code/PayCloseTypeEnum.java @@ -0,0 +1,25 @@ +package cn.daxpay.single.service.code; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * 订单关闭类型 + * @author xxm + * @since 2024/6/5 + */ +@Getter +@AllArgsConstructor +public enum PayCloseTypeEnum { + /** + * 订单关闭 + */ + CLOSE("close", "订单关闭"), + /** + * 订单撤销 + */ + CANCEL("cancel", "订单撤销"), + ; + final String code; + final String name; +} diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/channel/alipay/service/AliPayCloseService.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/channel/alipay/service/AliPayCloseService.java index 2d936af92..501438990 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/channel/alipay/service/AliPayCloseService.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/channel/alipay/service/AliPayCloseService.java @@ -1,24 +1,24 @@ package cn.daxpay.single.service.core.channel.alipay.service; -import cn.bootx.platform.common.spring.exception.RetryableException; import cn.daxpay.single.code.PaySyncStatusEnum; +import cn.daxpay.single.exception.pay.PayFailureException; import cn.daxpay.single.service.code.AliPayCode; -import cn.daxpay.single.service.core.payment.sync.result.PayRemoteSyncResult; import cn.daxpay.single.service.core.order.pay.entity.PayOrder; -import cn.daxpay.single.exception.pay.PayFailureException; +import cn.daxpay.single.service.core.payment.sync.result.PayRemoteSyncResult; import com.alipay.api.AlipayApiException; +import com.alipay.api.domain.AlipayTradeCancelModel; import com.alipay.api.domain.AlipayTradeCloseModel; +import com.alipay.api.response.AlipayTradeCancelResponse; import com.alipay.api.response.AlipayTradeCloseResponse; import com.ijpay.alipay.AliPayApi; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.springframework.retry.annotation.Retryable; import org.springframework.stereotype.Service; import java.util.Objects; /** - * 支付宝支付取消和支付关闭 + * 支付宝支付撤销和支付关闭 * * @author xxm * @since 2021/4/20 @@ -30,15 +30,13 @@ public class AliPayCloseService { private final AliPaySyncService aliPaySyncService; /** - * 关闭支付 此处使用交易关闭接口, 支付宝支持 交易关闭 和 交易撤销 两种关闭订单的方式, 区别如下 + * 关闭支付 此处使用交易关闭接口 * 交易关闭: 只有订单在未支付的状态下才可以进行关闭, 商户不需要额外申请就有此接口的权限 - * 交易撤销: 如果用户支付成功,会将此订单资金退还给用户. 限制时间为1天,过了24小时,该接口无法再使用。可以视为一个特殊的接口, 需要专门签约这个接口的权限 *

* 1. 如果未查询到支付单,视为支付关闭, * 2. 如果返回"当前交易状态不支持此操作", 同步网关支付状态, 判断网关是否已经被关闭 * */ - @Retryable(value = RetryableException.class) public void close(PayOrder payOrder) { AlipayTradeCloseModel model = new AlipayTradeCloseModel(); model.setOutTradeNo(payOrder.getOrderNo()); @@ -65,6 +63,38 @@ public void close(PayOrder payOrder) { } } + /** + * 交易撤销: 如果用户支付成功,会将此订单资金退还给用户. 限制时间为1天,过了24小时,该接口无法再使用。 + * 可以视为一个特殊的接口, 需要专门签约这个接口的权限 + */ + public void cancel(PayOrder payOrder) { + AlipayTradeCancelModel model = new AlipayTradeCancelModel(); + model.setOutTradeNo(payOrder.getOrderNo()); + + try { + AlipayTradeCancelResponse response = AliPayApi.tradeCancelToResponse(model); + if (!Objects.equals(AliPayCode.SUCCESS, response.getCode())) { + if (!Objects.equals(AliPayCode.SUCCESS, response.getCode())) { + // 如果返回"当前交易状态不支持此操作", 同步网关支付状态, 判断网关是否已经被关闭 + if (Objects.equals(response.getSubCode(),AliPayCode.ACQ_TRADE_STATUS_ERROR)){ + if (this.syncStatus(payOrder)){ + return; + } + } + // 返回"交易不存在"视同关闭成功 + if (Objects.equals(response.getSubCode(),AliPayCode.ACQ_TRADE_NOT_EXIST)){ + return; + } + log.error("网关返回关闭失败: {}", response.getSubMsg()); + throw new PayFailureException(response.getSubMsg()); + } + } + } catch (AlipayApiException e) { + log.error("关闭订单失败:", e); + throw new PayFailureException("关闭订单失败"); + } + } + /** * 关闭失败后, 获取支付网关的状态, 如果是关闭返回true, 其他情况抛出异常 diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/channel/wechat/service/WeChatPayCloseService.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/channel/wechat/service/WeChatPayCloseService.java index b14142df7..7be1efbe3 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/channel/wechat/service/WeChatPayCloseService.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/channel/wechat/service/WeChatPayCloseService.java @@ -1,10 +1,10 @@ package cn.daxpay.single.service.core.channel.wechat.service; -import cn.bootx.platform.common.spring.exception.RetryableException; 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.pay.entity.PayOrder; +import cn.hutool.core.codec.Base64; import cn.hutool.core.util.StrUtil; import com.ijpay.core.enums.SignType; import com.ijpay.core.kit.WxPayKit; @@ -12,9 +12,9 @@ import com.ijpay.wxpay.model.CloseOrderModel; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.springframework.retry.annotation.Retryable; import org.springframework.stereotype.Service; +import java.io.ByteArrayInputStream; import java.util.Map; /** @@ -31,7 +31,6 @@ public class WeChatPayCloseService { /** * 关闭支付, 微信对已经关闭的支付单也可以重复关闭 */ - @Retryable(value = RetryableException.class) public void close(PayOrder payOrder, WeChatPayConfig weChatPayConfig) { // 只有部分需要调用微信网关进行关闭 Map params = CloseOrderModel.builder() @@ -47,6 +46,32 @@ public void close(PayOrder payOrder, WeChatPayConfig weChatPayConfig) { this.verifyErrorMsg(result); } + /** + * 撤销接口 + */ + public void cancel(PayOrder payOrder, WeChatPayConfig weChatPayConfig){ + // 只有部分需要调用微信网关进行关闭 + Map params = CloseOrderModel.builder() + .appid(weChatPayConfig.getWxAppId()) + .mch_id(weChatPayConfig.getWxMchId()) + .out_trade_no(payOrder.getOrderNo()) + .nonce_str(WxPayKit.generateStr()) + .build() + .createSign(weChatPayConfig.getApiKeyV2(), SignType.HMACSHA256); + + // 获取证书文件 + if (StrUtil.isBlank(weChatPayConfig.getP12())){ + String errorMsg = "微信p.12证书未配置,无法进行退款"; + throw new PayFailureException(errorMsg); + } + byte[] fileBytes = Base64.decode(weChatPayConfig.getP12()); + ByteArrayInputStream inputStream = new ByteArrayInputStream(fileBytes); + // 证书密码为 微信商户号 + String xmlResult = WxPayApi.orderReverse(params,inputStream,weChatPayConfig.getWxMchId()); + Map result = WxPayKit.xmlToMap(xmlResult); + this.verifyErrorMsg(result); + } + /** * 验证错误信息 */ 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 6bb7e72ff..0e4d56441 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,6 +2,7 @@ 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.PayStatusEnum; @@ -71,6 +72,7 @@ public class PayOrder extends MpBaseEntity implements EntityBaseFunction ORDER_FINISH = Arrays.asList(PayStatusEnum.CLOSE.getCode(), PayStatusEnum.SUCCESS.getCode()); + private final List ORDER_FINISH = Arrays.asList( + PayStatusEnum.CLOSE.getCode(), + PayStatusEnum.CANCEL.getCode(), + PayStatusEnum.SUCCESS.getCode()); /** * 查询 diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/cancel/factory/PayCancelStrategyFactory.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/cancel/factory/PayCancelStrategyFactory.java new file mode 100644 index 000000000..1ed871cd7 --- /dev/null +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/cancel/factory/PayCancelStrategyFactory.java @@ -0,0 +1,38 @@ +package cn.daxpay.single.service.core.payment.cancel.factory; + +import cn.daxpay.single.code.PayChannelEnum; +import cn.daxpay.single.exception.pay.PayUnsupportedMethodException; +import cn.daxpay.single.service.core.payment.cancel.strategy.AliPayCancelStrategy; +import cn.daxpay.single.service.core.payment.cancel.strategy.WeChatPayCancelStrategy; +import cn.daxpay.single.service.func.AbsPayCancelStrategy; +import cn.hutool.extra.spring.SpringUtil; +import lombok.experimental.UtilityClass; + +/** + * 订单撤销策略工厂 + * @author xxm + * @since 2024/6/5 + */ +@UtilityClass +public class PayCancelStrategyFactory { + + /** + * 根据传入的支付通道创建策略 + * @return 支付策略 + */ + public static AbsPayCancelStrategy create(String channel) { + PayChannelEnum channelEnum = PayChannelEnum.findByCode(channel); + AbsPayCancelStrategy strategy; + switch (channelEnum) { + case ALI: + strategy = SpringUtil.getBean(AliPayCancelStrategy.class); + break; + case WECHAT: + strategy = SpringUtil.getBean(WeChatPayCancelStrategy.class); + break; + default: + throw new PayUnsupportedMethodException(); + } + return strategy; + } +} diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/cancel/service/PayCancelService.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/cancel/service/PayCancelService.java new file mode 100644 index 000000000..ebcc7158b --- /dev/null +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/cancel/service/PayCancelService.java @@ -0,0 +1,113 @@ +package cn.daxpay.single.service.core.payment.cancel.service; + +import cn.bootx.platform.common.core.exception.RepetitiveOperationException; +import cn.daxpay.single.code.PayStatusEnum; +import cn.daxpay.single.exception.pay.PayFailureException; +import cn.daxpay.single.param.payment.pay.PayCancelParam; +import cn.daxpay.single.result.pay.PayCancelResult; +import cn.daxpay.single.service.code.PayCloseTypeEnum; +import cn.daxpay.single.service.common.local.PaymentContextLocal; +import cn.daxpay.single.service.core.order.pay.entity.PayOrder; +import cn.daxpay.single.service.core.order.pay.service.PayOrderQueryService; +import cn.daxpay.single.service.core.order.pay.service.PayOrderService; +import cn.daxpay.single.service.core.payment.cancel.factory.PayCancelStrategyFactory; +import cn.daxpay.single.service.core.payment.notice.service.ClientNoticeService; +import cn.daxpay.single.service.core.record.close.entity.PayCloseRecord; +import cn.daxpay.single.service.core.record.close.service.PayCloseRecordService; +import cn.daxpay.single.service.func.AbsPayCancelStrategy; +import com.baomidou.lock.LockInfo; +import com.baomidou.lock.LockTemplate; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +import java.time.LocalDateTime; +import java.util.Objects; + +/** + * 支付关闭和撤销服务 + * @author xxm + * @since 2023/12/18 + */ +@Slf4j +@Service +@RequiredArgsConstructor +public class PayCancelService { + private final PayOrderService payOrderService; + private final PayOrderQueryService payOrderQueryService; + private final PayCloseRecordService payCloseRecordService; + private final ClientNoticeService clientsService;; + + private final LockTemplate lockTemplate; + + /** + * 撤销支付 + */ + public PayCancelResult cancel(PayCancelParam param){ + PayOrder payOrder = payOrderQueryService.findByBizOrOrderNo(param.getOrderNo(), param.getBizOrderNo()) + .orElseThrow(() -> new PayFailureException("支付订单不存在")); + LockInfo lock = lockTemplate.lock("payment:cancel:" + payOrder.getId(),10000, 50); + if (Objects.isNull(lock)){ + throw new RepetitiveOperationException("支付订单已在撤销中,请勿重复发起"); + } + try { + PayCancelResult result = new PayCancelResult(); + // 状态检查, 只有支付中可以进行撤销支付 + if (!Objects.equals(payOrder.getStatus(), PayStatusEnum.PROGRESS.getCode())) { + throw new PayFailureException("订单不是支付中, 无法进行撤销订单"); + } + try { + AbsPayCancelStrategy strategy = PayCancelStrategyFactory.create(payOrder.getChannel()); + // 设置支付订单 + strategy.setOrder(payOrder); + // 撤销前准备 + strategy.doBeforeCancelHandler(); + // 执行撤销策略 + strategy.doCancelHandler(); + // 成功处理 + this.successHandler(payOrder); + // 返回结果 + return result; + } catch (Exception e) { + log.error("撤销订单失败, id: {}:", payOrder.getId()); + log.error("撤销订单失败:", e); + // 记录撤销失败的记录 + this.saveRecord(payOrder, false, e.getMessage()); + throw new PayFailureException("撤销订单失败"); + } + } finally { + lockTemplate.releaseLock(lock); + } + } + + /** + * 成功后处理方法 + */ + private void successHandler(PayOrder payOrder){ + // 撤销订单 + payOrder.setStatus(PayStatusEnum.CANCEL.getCode()) + .setCloseTime(LocalDateTime.now()); + payOrderService.updateById(payOrder); + // 发送通知 + clientsService.registerPayNotice(payOrder,null); + this.saveRecord(payOrder,true,null); + } + + /** + * 保存撤销记录 + */ + private void saveRecord(PayOrder payOrder, boolean closed, String errMsg){ + String clientIp = PaymentContextLocal.get() + .getRequestInfo() + .getClientIp(); + PayCloseRecord record = new PayCloseRecord() + .setOrderNo(payOrder.getOrderNo()) + .setBizOrderNo(payOrder.getBizOrderNo()) + .setChannel(payOrder.getChannel()) + .setCloseType(PayCloseTypeEnum.CANCEL.getCode()) + .setClosed(closed) + .setErrorMsg(errMsg) + .setClientIp(clientIp); + payCloseRecordService.saveRecord(record); + } +} diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/cancel/strategy/AliPayCancelStrategy.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/cancel/strategy/AliPayCancelStrategy.java new file mode 100644 index 000000000..75865b439 --- /dev/null +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/cancel/strategy/AliPayCancelStrategy.java @@ -0,0 +1,51 @@ +package cn.daxpay.single.service.core.payment.cancel.strategy; + +import cn.daxpay.single.code.PayChannelEnum; +import cn.daxpay.single.service.core.channel.alipay.entity.AliPayConfig; +import cn.daxpay.single.service.core.channel.alipay.service.AliPayCloseService; +import cn.daxpay.single.service.core.channel.alipay.service.AliPayConfigService; +import cn.daxpay.single.service.func.AbsPayCancelStrategy; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Service; + +import static org.springframework.beans.factory.config.BeanDefinition.SCOPE_PROTOTYPE; + +/** + * 支付宝撤销策略 + * @author xxm + * @since 2024/6/5 + */ +@Slf4j +@Scope(SCOPE_PROTOTYPE) +@Service +@RequiredArgsConstructor +public class AliPayCancelStrategy extends AbsPayCancelStrategy { + + private final AliPayConfigService alipayConfigService; + + private final AliPayCloseService aliPayCloseService; + + @Override + public PayChannelEnum getChannel() { + return PayChannelEnum.ALI; + } + + /** + * 关闭前的处理方式 + */ + @Override + public void doBeforeCancelHandler() { + AliPayConfig config = alipayConfigService.getConfig(); + alipayConfigService.initConfig(config); + } + + /** + * 关闭操作 + */ + @Override + public void doCancelHandler() { + aliPayCloseService.cancel(this.getOrder()); + } +} diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/cancel/strategy/WeChatPayCancelStrategy.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/cancel/strategy/WeChatPayCancelStrategy.java new file mode 100644 index 000000000..df91dde08 --- /dev/null +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/cancel/strategy/WeChatPayCancelStrategy.java @@ -0,0 +1,58 @@ +package cn.daxpay.single.service.core.payment.cancel.strategy; + +import cn.daxpay.single.code.PayChannelEnum; +import cn.daxpay.single.code.PayMethodEnum; +import cn.daxpay.single.service.core.channel.wechat.entity.WeChatPayConfig; +import cn.daxpay.single.service.core.channel.wechat.service.WeChatPayCloseService; +import cn.daxpay.single.service.core.channel.wechat.service.WeChatPayConfigService; +import cn.daxpay.single.service.func.AbsPayCancelStrategy; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Service; + +import java.util.Objects; + +import static org.springframework.beans.factory.config.BeanDefinition.SCOPE_PROTOTYPE; + +/** + * 微信支付关闭策略 + * @author xxm + * @since 2023/12/30 + */ +@Slf4j +@Scope(SCOPE_PROTOTYPE) +@Service +@RequiredArgsConstructor +public class WeChatPayCancelStrategy extends AbsPayCancelStrategy { + + private final WeChatPayConfigService weChatPayConfigService; + private final WeChatPayCloseService weChatPayCloseService; + + private WeChatPayConfig weChatPayConfig; + + @Override + public PayChannelEnum getChannel() { + return PayChannelEnum.WECHAT; + } + + /** + * 关闭前的处理方式 + */ + @Override + public void doBeforeCancelHandler() { + // 非当面付订单不可以关闭 + if (!Objects.equals(this.getOrder().getMethod(), PayMethodEnum.BARCODE.getCode())) { + throw new RuntimeException("微信当面付订单才可以被撤销"); + } + this.weChatPayConfig = weChatPayConfigService.getConfig(); + } + + /** + * 关闭操作 + */ + @Override + public void doCancelHandler() { + weChatPayCloseService.cancel(this.getOrder(), weChatPayConfig); + } +} diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/close/service/PayCloseService.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/close/service/PayCloseService.java index 3ebce3a2b..75e13c798 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/close/service/PayCloseService.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/close/service/PayCloseService.java @@ -5,6 +5,7 @@ import cn.daxpay.single.exception.pay.PayFailureException; import cn.daxpay.single.param.payment.pay.PayCloseParam; import cn.daxpay.single.result.pay.PayCloseResult; +import cn.daxpay.single.service.code.PayCloseTypeEnum; import cn.daxpay.single.service.common.local.PaymentContextLocal; import cn.daxpay.single.service.core.order.pay.entity.PayOrder; import cn.daxpay.single.service.core.order.pay.service.PayOrderQueryService; @@ -43,7 +44,7 @@ public class PayCloseService { * 关闭支付 */ public PayCloseResult close(PayCloseParam param){ - PayOrder payOrder = payOrderQueryService.findByBizOrOrderNo(param.getOrderNo(), param.getBizTradeNo()) + PayOrder payOrder = payOrderQueryService.findByBizOrOrderNo(param.getOrderNo(), param.getBizOrderNo()) .orElseThrow(() -> new PayFailureException("支付订单不存在")); LockInfo lock = lockTemplate.lock("payment:close:" + payOrder.getId(),10000, 50); if (Objects.isNull(lock)){ @@ -83,7 +84,6 @@ private PayCloseResult close(PayOrder payOrder) { // 记录关闭失败的记录 this.saveRecord(payOrder, false, e.getMessage()); throw new PayFailureException("关闭订单失败"); - } } @@ -111,6 +111,7 @@ private void saveRecord(PayOrder payOrder, boolean closed, String errMsg){ .setOrderNo(payOrder.getOrderNo()) .setBizOrderNo(payOrder.getBizOrderNo()) .setChannel(payOrder.getChannel()) + .setCloseType(PayCloseTypeEnum.CLOSE.getCode()) .setClosed(closed) .setErrorMsg(errMsg) .setClientIp(clientIp); diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/pay/service/PayAssistService.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/pay/service/PayAssistService.java index 443af4892..a863f50be 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/pay/service/PayAssistService.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/pay/service/PayAssistService.java @@ -200,7 +200,7 @@ public PayOrder getOrderAndCheck(String bizOrderNo) { throw new PayFailureException("已经支付成功,请勿重新支付"); } // 支付失败类型状态 - List tradesStatus = Arrays.asList(FAIL.getCode(), CLOSE.getCode()); + List tradesStatus = Arrays.asList(FAIL.getCode(), CLOSE.getCode(), CANCEL.getCode()); if (tradesStatus.contains(payOrder.getStatus())) { throw new PayFailureException("支付失败或已经被关闭"); } diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/refund/service/RefundAssistService.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/refund/service/RefundAssistService.java index 8d0116621..7bf7de3af 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/refund/service/RefundAssistService.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/refund/service/RefundAssistService.java @@ -83,6 +83,7 @@ public void checkAndParam(RefundParam param, PayOrder payOrder){ List tradesStatus = Arrays.asList( PayStatusEnum.PROGRESS.getCode(), PayStatusEnum.CLOSE.getCode(), + PayStatusEnum.CANCEL.getCode(), PayStatusEnum.REFUNDED.getCode(), PayStatusEnum.REFUNDING.getCode(), PayStatusEnum.FAIL.getCode()); diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/repair/service/PayRepairService.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/repair/service/PayRepairService.java index c9f1a866e..7a8a03ea2 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/repair/service/PayRepairService.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/repair/service/PayRepairService.java @@ -74,8 +74,7 @@ public PayRepairResult repair(PayOrder order, PayRepairWayEnum repairType){ repairResult.setAfterPayStatus(PayStatusEnum.CLOSE); break; case PROGRESS: - this.waitPay(order); - repairResult.setAfterPayStatus(PayStatusEnum.PROGRESS); + // TODO 保存为异常订单 break; case CLOSE_GATEWAY: this.closeRemote(order, repairStrategy); @@ -93,17 +92,6 @@ public PayRepairResult repair(PayOrder order, PayRepairWayEnum repairType){ return repairResult; } - /** - * 变更未待支付 - * TODO 后期保存为异常订单 - */ - private void waitPay(PayOrder order) { - // 修改订单支付状态为待支付 - order.setStatus(PayStatusEnum.PROGRESS.getCode()) - .setPayTime(null) - .setCloseTime(null); - payOrderService.updateById(order); - } /** * 变更为已支付 diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/sync/service/PaySyncService.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/sync/service/PaySyncService.java index a26d371e7..29e18b604 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/sync/service/PaySyncService.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/sync/service/PaySyncService.java @@ -33,7 +33,6 @@ import java.time.LocalDateTime; import java.util.Arrays; -import java.util.Collections; import java.util.List; import java.util.Objects; @@ -163,7 +162,7 @@ private boolean checkAndAdjustSyncStatus(PayRemoteSyncResult payRemoteSyncResult 未找到订单可能是发起支付用户未操作、支付已关闭、交易未找到三种情况 所以需要根据本地订单不同的状态进行特殊处理, 此处视为支付已关闭、交易未找到这两种, 处理方式相同, 都作为支付关闭处理 */ - List payCloseEnums = Collections.singletonList(PayStatusEnum.CLOSE.getCode()); + List payCloseEnums = Arrays.asList(PayStatusEnum.CLOSE.getCode(), PayStatusEnum.CANCEL.getCode()); List syncClose = Arrays.asList(CLOSED, NOT_FOUND, NOT_FOUND_UNKNOWN); if (payCloseEnums.contains(orderStatus) && syncClose.contains(syncStatus)){ return true; diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/record/close/entity/PayCloseRecord.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/record/close/entity/PayCloseRecord.java index b4e1adf2e..f96ac5ec6 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/record/close/entity/PayCloseRecord.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/record/close/entity/PayCloseRecord.java @@ -3,6 +3,7 @@ import cn.bootx.platform.common.core.function.EntityBaseFunction; import cn.bootx.platform.common.mybatisplus.base.MpCreateEntity; import cn.daxpay.single.code.PayChannelEnum; +import cn.daxpay.single.service.code.PayCloseTypeEnum; import cn.daxpay.single.service.core.record.close.convert.PayCloseRecordConvert; import cn.daxpay.single.service.dto.record.close.PayCloseRecordDto; import cn.bootx.table.modify.annotation.DbColumn; @@ -39,6 +40,13 @@ public class PayCloseRecord extends MpCreateEntity implements EntityBaseFunction @DbColumn(comment = "关闭的支付通道") private String channel; + /** + * 关闭类型 关闭/撤销 + * @see PayCloseTypeEnum + */ + @DbColumn(comment = "关闭类型") + private String closeType; + /** * 是否关闭成功 */ diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/dto/record/close/PayCloseRecordDto.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/dto/record/close/PayCloseRecordDto.java index 0659b3068..b165e89ac 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/dto/record/close/PayCloseRecordDto.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/dto/record/close/PayCloseRecordDto.java @@ -3,6 +3,7 @@ import cn.bootx.platform.common.core.rest.dto.BaseDto; import cn.daxpay.single.code.PayChannelEnum; import cn.bootx.table.modify.annotation.DbColumn; +import cn.daxpay.single.service.code.PayCloseTypeEnum; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import lombok.EqualsAndHashCode; @@ -34,6 +35,13 @@ public class PayCloseRecordDto extends BaseDto { @DbColumn(comment = "关闭的异步支付通道") private String channel; + /** + * 关闭类型 关闭/撤销 + * @see PayCloseTypeEnum + */ + @DbColumn(comment = "关闭类型") + private String closeType; + /** * 是否关闭成功 */ diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/func/AbsPayCancelStrategy.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/func/AbsPayCancelStrategy.java new file mode 100644 index 000000000..7ef7848d4 --- /dev/null +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/func/AbsPayCancelStrategy.java @@ -0,0 +1,28 @@ +package cn.daxpay.single.service.func; + +import cn.daxpay.single.service.core.order.pay.entity.PayOrder; +import lombok.Getter; +import lombok.Setter; + +/** + * 支付订单撤销接口 + * @author xxm + * @since 2024/6/5 + */ +@Getter +@Setter +public abstract class AbsPayCancelStrategy implements PayStrategy { + /** 支付订单 */ + private PayOrder order = null; + + + /** + * 撤销前的处理方式 + */ + public void doBeforeCancelHandler() {} + + /** + * 撤销操作 + */ + public abstract void doCancelHandler(); +} diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/param/record/PayCloseRecordQuery.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/param/record/PayCloseRecordQuery.java index 2fbdface8..686a991ce 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/param/record/PayCloseRecordQuery.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/param/record/PayCloseRecordQuery.java @@ -38,7 +38,7 @@ public class PayCloseRecordQuery extends QueryOrder { * 是否关闭成功 */ @DbColumn(comment = "是否关闭成功") - private boolean closed; + private Boolean closed; /** 错误码 */ @DbColumn(comment = "错误码") From 848c55d13c9d64fa4fe2974ae4ebc822724b4a4e Mon Sep 17 00:00:00 2001 From: DaxPay Date: Thu, 6 Jun 2024 20:35:37 +0800 Subject: [PATCH 02/34] =?UTF-8?q?feat=20=E8=BD=AC=E8=B4=A6=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E5=BC=80=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _doc/Task.md | 25 +++++---- .../single/code/AllocReceiverTypeEnum.java | 2 +- .../single/code/TransferPayeeTypeEnum.java | 51 +++++++++++++++++++ .../daxpay/single/code/TransferTypeEnum.java | 26 ++++++++++ .../param/payment/transfer/TransferParam.java | 51 +++++++++++++++++++ .../result/transfer/TransferResult.java | 19 +++++++ .../gateway/controller/TestController.java | 3 ++ .../gateway/controller/UniPayController.java | 7 ++- .../alipay/service/AliPayTransferService.java | 13 ++++- .../refund/service/RefundOrderService.java | 1 - .../dao/TransferOrderExtraManager.java | 16 ++++++ .../dao/TransferOrderExtraMapper.java | 14 +++++ .../order/transfer/entity/TransferOrder.java | 44 +++++++++++++--- .../transfer/entity/TransferOrderExtra.java | 43 ++++++++++++++++ .../service/TransferOrderService.java | 4 ++ .../sync/factory/PaySyncStrategyFactory.java | 6 ++- .../transfer/factory/TransferFactory.java | 23 +++++++++ .../service/TransferAssistService.java | 44 ++++++++++++++++ .../transfer/service/TransferService.java | 48 +++++++++++++++++ .../strategy/AliPayTransferStrategy.java | 4 ++ .../service/func/AbsRefundStrategy.java | 1 - .../service/func/AbsTransferStrategy.java | 12 +++++ 22 files changed, 431 insertions(+), 26 deletions(-) create mode 100644 daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/code/TransferPayeeTypeEnum.java create mode 100644 daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/code/TransferTypeEnum.java create mode 100644 daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/result/transfer/TransferResult.java create mode 100644 daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/transfer/dao/TransferOrderExtraManager.java create mode 100644 daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/transfer/dao/TransferOrderExtraMapper.java create mode 100644 daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/transfer/entity/TransferOrderExtra.java create mode 100644 daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/transfer/service/TransferAssistService.java diff --git a/_doc/Task.md b/_doc/Task.md index 9917ac51e..19dc88920 100644 --- a/_doc/Task.md +++ b/_doc/Task.md @@ -1,31 +1,34 @@ ## 单商户 2.0.8: 对账完善和系统优化 -- [ ] 支持撤销接口 +- [x] 支持撤销接口 - [ ] 增加转账接口功能 -- [ ] 细分各种支付异常类和编码 -- [ ] 增加对账修复功能拆 +- [ ] 细分各种支付异常类和编码(完成部分) +- [ ] 增加分账修复功能 - [ ] DEMO增加获取微信OpenID和支付宝OpenId功能 - [ ] 管理端界面支持扫码绑定对账接收方功能 -- [ ] 增加收单收银台功能 -- [ ] 增加资金对账单功能 - [ ] 支付通道两个独立的配置进行合并为一个 -- [ ] 支付和退款达到终态不可以再回退回之前的状态 +- [ ] 支付宝拆分退款状态为单独的字段 +- [ ] 工厂支持自适应 +- [x] 支付和退款达到终态不可以再回退回之前的状态 - [x] 修复支付关闭参数名称不正确问题 -2.0.9: 消息通知和功能功能优化 -- [ ] 将系统通知消息重构为类似支付宝应用通知的方式 -- [ ] 支付成功回调后, 如果订单已超时, 则进入待退款订单中,提示进行退款,或者自动退款 +2.0.9: 消息通知改版和功能优化 +- [ ] 增加类似支付宝应用通知的方式, 先支持http方式通信 +- [ ] 平台配置和接口配置删除回调地址配置, 只保留接口参数设置 +- [ ] 增加支付宝和微信通知回调地址一键生成功能 2.1.x 版本内容 +- [ ] 增加收单收银台功能 +- [ ] 增加资金对账单功能 - [ ] 新增支付单预警功能, 处理支付单与网关状态不一致且无法自动修复的情况 - [ ] 差错单据处理 + - [ ] 支付成功回调订单已超时 + - [ ] 对账单据不平 - [ ] 特殊退款接口 - [ ] 统计报表功能 - [ ] 微信新增V3版本接口 - [ ] 支付宝新增V3版本接口 - [ ] 增加各类日志记录,例如钱包的各项操作 -- [ ] 增加撤销功能,用于处理线下支付订单的情况 - [ ] 数据库表进行规则, 字段设置长度, 增加索引 -- [ ] 订单超时支持数据表级别触发 - [ ] 针对同步/对账等出现脏数据导致阻塞的问题, 进行优化 - [ ] 同步接口 - [ ] 对账接口 diff --git a/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/code/AllocReceiverTypeEnum.java b/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/code/AllocReceiverTypeEnum.java index 944a3280a..9b7559875 100644 --- a/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/code/AllocReceiverTypeEnum.java +++ b/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/code/AllocReceiverTypeEnum.java @@ -24,7 +24,7 @@ public enum AllocReceiverTypeEnum { ALI_USER_ID("ali_user_id","userId", "用户ID"), /** openId */ ALI_OPEN_ID("ali_open_id","openId", "openId"), - /** 账号 */ + /** 账号 支持邮箱和手机号格式 */ ALI_LOGIN_NAME("ali_login_name","loginName", "账号"); /** 编码 */ diff --git a/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/code/TransferPayeeTypeEnum.java b/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/code/TransferPayeeTypeEnum.java new file mode 100644 index 000000000..06cc8934d --- /dev/null +++ b/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/code/TransferPayeeTypeEnum.java @@ -0,0 +1,51 @@ +package cn.daxpay.single.code; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +/** + * 转账接收方类型 + * @author xxm + * @since 2024/4/1 + */ +@Getter +@AllArgsConstructor +public enum TransferPayeeTypeEnum { + /** 个人 */ + WX_PERSONAL("wx_personal","openid", "个人"), + + + /** userId 以2088开头的纯16位数字 */ + ALI_USER_ID("ali_user_id","ALIPAY_USERID", "用户ID"), + /** openId */ + ALI_OPEN_ID("ali_open_id","ALIPAY_OPENID", "openId"), + /** 账号 支持邮箱和手机号格式 */ + ALI_LOGIN_NAME("ali_login_name","ALIPAY_LOGONID", "账号"); + + /** 编码 */ + private final String code; + /** 外部编码, 三方支付系统使用的编码 */ + private final String outCode; + /** 名称 */ + private final String name; + + /** + * 根据编码查找 + */ + public static TransferPayeeTypeEnum findByCode(String code) { + return Arrays.stream(TransferPayeeTypeEnum.values()) + .filter(e -> e.getCode().equals(code)) + .findFirst() + .orElseThrow(() -> new IllegalArgumentException("未找到对应的分账接收方类型")); + } + + /** 微信支持类型 */ + public static final List WECHAT_LIST = Collections.singletonList(WX_PERSONAL); + /** 支付宝支持类型 */ + public static final List ALI_LIST = Collections.unmodifiableList(Arrays.asList(ALI_OPEN_ID, ALI_USER_ID, ALI_LOGIN_NAME)); + +} diff --git a/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/code/TransferTypeEnum.java b/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/code/TransferTypeEnum.java new file mode 100644 index 000000000..2f97d3ca2 --- /dev/null +++ b/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/code/TransferTypeEnum.java @@ -0,0 +1,26 @@ +package cn.daxpay.single.code; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * 转账类型注解 + * @author xxm + * @since 2024/6/6 + */ +@Getter +@AllArgsConstructor +public enum TransferTypeEnum { + /** 转账给用户 */ + USER("user", "转账给用户"), + /** 转账给员工 */ + EMPLOYEE("employee", "转账给员工"), + /** 转账给合作伙 */ + PARTNER("partner", "转账给合作伙"), + /** 转账给其他对象 */ + OTHER("other", "转账给其他对象"),; + + private final String code; + private final String name; + +} 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 99f50633b..2951b0ed5 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 @@ -1,5 +1,8 @@ package cn.daxpay.single.param.payment.transfer; +import cn.daxpay.single.code.PayChannelEnum; +import cn.daxpay.single.code.TransferPayeeTypeEnum; +import cn.daxpay.single.code.TransferTypeEnum; import cn.daxpay.single.param.PaymentCommonParam; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; @@ -16,4 +19,52 @@ @Accessors(chain = true) @Schema(title = "转账参数") public class TransferParam extends PaymentCommonParam { + + /** 商户转账号 */ + @Schema(description = "商户转账号") + private String bizTransferNo; + + /** + * 支付通道 + * @see PayChannelEnum + */ + @Schema(description = "支付通道") + private String channel; + + /** 转账金额 */ + @Schema(description = "转账金额") + private Integer amount; + + /** 标题 */ + @Schema(description = "标题") + private String title; + + /** 转账原因/备注 */ + @Schema(description = "转账原因/备注") + private String reason; + + /** + * 转账类型, 微信使用 + * @see TransferTypeEnum + */ + @Schema(description = "转账类型, 微信使用") + private String transferType; + + /** 付款方显示名称 */ + private String payerShowName; + + /** + * 收款人账号类型 + * @see TransferPayeeTypeEnum + */ + @Schema(description = "收款人账号类型") + private String payeeType; + + /** 收款人账号 */ + @Schema(description = "收款人账号") + private String payeeAccount; + + /** 收款人姓名 */ + @Schema(description = "收款人姓名") + private String payeeName; } diff --git a/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/result/transfer/TransferResult.java b/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/result/transfer/TransferResult.java new file mode 100644 index 000000000..8bb46932b --- /dev/null +++ b/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/result/transfer/TransferResult.java @@ -0,0 +1,19 @@ +package cn.daxpay.single.result.transfer; + +import cn.daxpay.single.result.PaymentCommonResult; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + * 转账结果 + * @author xxm + * @since 2024/6/6 + */ +@EqualsAndHashCode(callSuper = true) +@Data +@Accessors(chain = true) +@Schema(title = "转账结果") +public class TransferResult extends PaymentCommonResult { +} diff --git a/daxpay-single/daxpay-single-gateway/src/main/java/cn/daxpay/single/gateway/controller/TestController.java b/daxpay-single/daxpay-single-gateway/src/main/java/cn/daxpay/single/gateway/controller/TestController.java index 12c2c58ba..9dccf823a 100644 --- a/daxpay-single/daxpay-single-gateway/src/main/java/cn/daxpay/single/gateway/controller/TestController.java +++ b/daxpay-single/daxpay-single-gateway/src/main/java/cn/daxpay/single/gateway/controller/TestController.java @@ -3,6 +3,7 @@ import cn.bootx.platform.common.core.exception.BizException; import cn.bootx.platform.common.core.rest.Res; import cn.bootx.platform.common.core.rest.ResResult; +import cn.daxpay.single.service.core.payment.transfer.service.TransferService; import cn.hutool.core.thread.ThreadUtil; import com.baomidou.lock.LockInfo; import com.baomidou.lock.LockTemplate; @@ -27,6 +28,8 @@ public class TestController { private final LockTemplate lockTemplate; + private final TransferService transferService; + @Operation(summary = "锁测试1") @GetMapping("/lock1") // @Lock4j(keys = "#name", acquireTimeout = 50) diff --git a/daxpay-single/daxpay-single-gateway/src/main/java/cn/daxpay/single/gateway/controller/UniPayController.java b/daxpay-single/daxpay-single-gateway/src/main/java/cn/daxpay/single/gateway/controller/UniPayController.java index 51b581d9d..dffe9409b 100644 --- a/daxpay-single/daxpay-single-gateway/src/main/java/cn/daxpay/single/gateway/controller/UniPayController.java +++ b/daxpay-single/daxpay-single-gateway/src/main/java/cn/daxpay/single/gateway/controller/UniPayController.java @@ -12,12 +12,14 @@ import cn.daxpay.single.result.pay.PayCloseResult; import cn.daxpay.single.result.pay.PayResult; import cn.daxpay.single.result.pay.RefundResult; +import cn.daxpay.single.result.transfer.TransferResult; import cn.daxpay.single.service.annotation.PaymentSign; import cn.daxpay.single.service.annotation.InitPaymentContext; import cn.daxpay.single.service.core.payment.cancel.service.PayCancelService; import cn.daxpay.single.service.core.payment.close.service.PayCloseService; import cn.daxpay.single.service.core.payment.pay.service.PayService; import cn.daxpay.single.service.core.payment.refund.service.RefundService; +import cn.daxpay.single.service.core.payment.transfer.service.TransferService; import cn.daxpay.single.util.DaxRes; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; @@ -42,6 +44,7 @@ public class UniPayController { private final RefundService refundService; private final PayCloseService payCloseService; private final PayCancelService payCancelService; + private final TransferService transferService; @PaymentSign @InitPaymentContext(PaymentApiCode.PAY) @@ -79,8 +82,8 @@ public DaxResult refund(@RequestBody RefundParam param){ @InitPaymentContext(PaymentApiCode.TRANSFER) @Operation(summary = "统一转账接口") @PostMapping("/transfer") - public DaxResult transfer(@RequestBody TransferParam param){ - return DaxRes.ok(); + public DaxResult transfer(@RequestBody TransferParam param){ + return DaxRes.ok(transferService.transfer(param)); } } diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/channel/alipay/service/AliPayTransferService.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/channel/alipay/service/AliPayTransferService.java index 0d02f272b..3cf3381a9 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/channel/alipay/service/AliPayTransferService.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/channel/alipay/service/AliPayTransferService.java @@ -1,6 +1,8 @@ package cn.daxpay.single.service.core.channel.alipay.service; import cn.daxpay.single.service.core.channel.alipay.entity.AliPayConfig; +import cn.daxpay.single.service.core.order.transfer.entity.TransferOrder; +import cn.hutool.core.util.IdUtil; import com.alipay.api.domain.AlipayFundAccountQueryModel; import com.alipay.api.domain.AlipayFundTransToaccountTransferModel; import com.alipay.api.response.AlipayFundAccountQueryResponse; @@ -36,8 +38,17 @@ public void queryAccountAmount(AliPayConfig config) { * 转账接口 */ @SneakyThrows - public void transfer() { + public void transfer(TransferOrder order) { AlipayFundTransToaccountTransferModel model = new AlipayFundTransToaccountTransferModel(); +// model.setAmount(PayUtil.conversionAmount(order.getAmount()).toString()); + model.setAmount("1.00"); + model.setOutBizNo(IdUtil.getSnowflakeNextIdStr()); + model.setPayeeType("ALIPAY_USERID"); + model.setPayeeAccount("2088722032251651"); + model.setPayerShowName("易杯光年"); + model.setExtParam("{order_title: '订单标题'}"); + model.setRemark("易杯光年的备注"); AlipayFundTransToaccountTransferResponse response = AliPayApi.transferToResponse(model); + System.out.println(response); } } diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/refund/service/RefundOrderService.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/refund/service/RefundOrderService.java index ad20a1306..2b0484b41 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/refund/service/RefundOrderService.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/refund/service/RefundOrderService.java @@ -40,7 +40,6 @@ public class RefundOrderService { /** * 手动发起退款 - * 退款涉及到回调通知, 索所以需要手动初始化一下上下文 */ public void refund(PayOrderRefundParam param) { diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/transfer/dao/TransferOrderExtraManager.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/transfer/dao/TransferOrderExtraManager.java new file mode 100644 index 000000000..73462d30a --- /dev/null +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/transfer/dao/TransferOrderExtraManager.java @@ -0,0 +1,16 @@ +package cn.daxpay.single.service.core.order.transfer.dao; + +import cn.bootx.platform.common.mybatisplus.impl.BaseManager; +import cn.daxpay.single.service.core.order.transfer.entity.TransferOrderExtra; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Repository; + +/** + * 转账订单扩展数据 + * @author xxm + * @since 2024/6/6 + */ +@Slf4j +@Repository +public class TransferOrderExtraManager extends BaseManager { +} diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/transfer/dao/TransferOrderExtraMapper.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/transfer/dao/TransferOrderExtraMapper.java new file mode 100644 index 000000000..74eca265d --- /dev/null +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/transfer/dao/TransferOrderExtraMapper.java @@ -0,0 +1,14 @@ +package cn.daxpay.single.service.core.order.transfer.dao; + +import cn.daxpay.single.service.core.order.transfer.entity.TransferOrderExtra; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Mapper; + +/** + * 转账订单扩展 + * @author xxm + * @since 2024/6/6 + */ +@Mapper +public interface TransferOrderExtraMapper extends BaseMapper { +} diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/transfer/entity/TransferOrder.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/transfer/entity/TransferOrder.java index 005fd2856..a3758e60f 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/transfer/entity/TransferOrder.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/transfer/entity/TransferOrder.java @@ -3,6 +3,7 @@ import cn.bootx.platform.common.mybatisplus.base.MpBaseEntity; import cn.daxpay.single.code.PayChannelEnum; import cn.bootx.table.modify.annotation.DbTable; +import cn.daxpay.single.code.TransferPayeeTypeEnum; import com.baomidou.mybatisplus.annotation.TableName; import lombok.Data; import lombok.EqualsAndHashCode; @@ -22,8 +23,14 @@ @TableName("pay_transfer_order") public class TransferOrder extends MpBaseEntity { - /** 业务号 */ - private String outTradeNo; + /** 商户转账号 */ + private String bizTransferNo; + + /** 转账号 */ + private String transferNo; + + /** 通道转账号 */ + private String outTransferNo; /** * 支付通道 @@ -31,17 +38,40 @@ public class TransferOrder extends MpBaseEntity { */ private String channel; - /** 金额 */ + /** 转账金额 */ private Integer amount; - /** 状态 */ - private String status; + /** 标题 */ + private String title; + + /** 转账原因/备注 */ + private String reason; + + /** + * 转账类型, 微信使用 + */ + private String transferType; /** 付款方 */ private String payer; - /** 收款方 */ - private String payee; + /** 付款方显示名称 */ + private String payerShowName; + + /** + * 收款人类型 + * @see TransferPayeeTypeEnum + */ + private String payeeType; + + /** 收款人账号 */ + private String payeeAccount; + + /** 收款人姓名 */ + private String payeeName; + + /** 状态 */ + private String status; /** 成功时间 */ private LocalDateTime successTime; diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/transfer/entity/TransferOrderExtra.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/transfer/entity/TransferOrderExtra.java new file mode 100644 index 000000000..1092179d2 --- /dev/null +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/transfer/entity/TransferOrderExtra.java @@ -0,0 +1,43 @@ +package cn.daxpay.single.service.core.order.transfer.entity; + +import cn.bootx.platform.common.mybatisplus.base.MpBaseEntity; +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; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +import java.time.LocalDateTime; + +/** + * 转账订单扩展数据 + * @author xxm + * @since 2024/6/6 + */ +@EqualsAndHashCode(callSuper = true) +@Data +@Accessors(chain = true) +@DbTable(comment = "转账订单扩展数据") +@TableName("pay_transfer_order_extra") +public class TransferOrderExtra extends MpBaseEntity { + + /** 异步通知地址 */ + @DbColumn(comment = "异步通知地址") + @TableField(updateStrategy = FieldStrategy.ALWAYS) + private String notifyUrl; + + /** 商户扩展参数,回调时会原样返回, 以最后一次为准 */ + @DbColumn(comment = "商户扩展参数") + private String attach; + + /** 请求时间,时间戳转时间 */ + @DbColumn(comment = "请求时间,传输时间戳") + private LocalDateTime reqTime; + + /** 终端ip */ + @DbColumn(comment = "支付终端ip") + private String clientIp; +} diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/transfer/service/TransferOrderService.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/transfer/service/TransferOrderService.java index 3ff3bf119..055b18a29 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/transfer/service/TransferOrderService.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/transfer/service/TransferOrderService.java @@ -13,4 +13,8 @@ @Service @RequiredArgsConstructor public class TransferOrderService { + + /** + * 创建订单 + */ } diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/sync/factory/PaySyncStrategyFactory.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/sync/factory/PaySyncStrategyFactory.java index 5030cb2f7..fb6cc8c55 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/sync/factory/PaySyncStrategyFactory.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/sync/factory/PaySyncStrategyFactory.java @@ -8,19 +8,21 @@ import cn.daxpay.single.service.core.payment.sync.strategy.pay.WeChatPaySyncStrategy; import cn.daxpay.single.service.func.AbsPaySyncStrategy; import cn.hutool.extra.spring.SpringUtil; +import lombok.experimental.UtilityClass; /** * 支付同步策略工厂类 * @author xxm * @since 2023/7/14 */ +@UtilityClass public class PaySyncStrategyFactory { /** - * 获取支付同步策略, 只有异步支付方式才需要这个功能 + * 获取支付同步策略 * @param channelCode 支付通道编码 * @return 支付同步策略类 */ - public static AbsPaySyncStrategy create(String channelCode) { + public AbsPaySyncStrategy create(String channelCode) { AbsPaySyncStrategy strategy; PayChannelEnum channelEnum = PayChannelEnum.findByCode(channelCode); switch (channelEnum) { diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/transfer/factory/TransferFactory.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/transfer/factory/TransferFactory.java index 9cde56acf..ca6ed388d 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/transfer/factory/TransferFactory.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/transfer/factory/TransferFactory.java @@ -1,5 +1,10 @@ package cn.daxpay.single.service.core.payment.transfer.factory; +import cn.daxpay.single.code.PayChannelEnum; +import cn.daxpay.single.exception.pay.PayUnsupportedMethodException; +import cn.daxpay.single.service.core.payment.transfer.strategy.AliPayTransferStrategy; +import cn.daxpay.single.service.func.AbsTransferStrategy; +import cn.hutool.extra.spring.SpringUtil; import lombok.experimental.UtilityClass; /** @@ -9,4 +14,22 @@ */ @UtilityClass public class TransferFactory { + + /** + * 获取转账策略 + * @param channelCode 支付通道编码 + * @return 支付同步策略类 + */ + public AbsTransferStrategy create(String channelCode) { + AbsTransferStrategy strategy; + PayChannelEnum channelEnum = PayChannelEnum.findByCode(channelCode); + switch (channelEnum) { + case ALI: + strategy = SpringUtil.getBean(AliPayTransferStrategy.class); + break; + default: + throw new PayUnsupportedMethodException(); + } + return strategy; + } } diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/transfer/service/TransferAssistService.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/transfer/service/TransferAssistService.java new file mode 100644 index 000000000..fa4a9222f --- /dev/null +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/transfer/service/TransferAssistService.java @@ -0,0 +1,44 @@ +package cn.daxpay.single.service.core.payment.transfer.service; + +import cn.daxpay.single.param.payment.transfer.TransferParam; +import cn.daxpay.single.result.transfer.TransferResult; +import cn.daxpay.single.service.core.order.transfer.entity.TransferOrder; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +/** + * 转账辅助服务 + * @author xxm + * @since 2024/6/6 + */ +@Slf4j +@Service +@RequiredArgsConstructor +public class TransferAssistService { + + /** + * 创建转账订单 + */ + public TransferOrder createOrder(TransferParam param) { + // 1. 创建转账订单 + + return null; + } + + /** + * 更新转账订单错误信息 + */ + public void updateOrderByError(TransferOrder order) { + + } + + /** + * 构造 + * @param order + */ + public TransferResult buildResult(TransferOrder order) { + + return null; + } +} diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/transfer/service/TransferService.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/transfer/service/TransferService.java index acf7e17ee..f5f154226 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/transfer/service/TransferService.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/transfer/service/TransferService.java @@ -1,5 +1,14 @@ package cn.daxpay.single.service.core.payment.transfer.service; +import cn.daxpay.single.code.PayChannelEnum; +import cn.daxpay.single.code.RefundStatusEnum; +import cn.daxpay.single.param.payment.transfer.TransferParam; +import cn.daxpay.single.result.transfer.TransferResult; +import cn.daxpay.single.service.common.local.PaymentContextLocal; +import cn.daxpay.single.service.core.order.transfer.entity.TransferOrder; +import cn.daxpay.single.service.core.payment.transfer.factory.TransferFactory; +import cn.daxpay.single.service.func.AbsTransferStrategy; +import cn.hutool.extra.spring.SpringUtil; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; @@ -13,4 +22,43 @@ @Service @RequiredArgsConstructor public class TransferService { + + private final TransferAssistService transferAssistService; + + /** + * 转账 + */ + public TransferResult transfer(TransferParam transferParam){ + + // 获取策略 + AbsTransferStrategy transferStrategy = TransferFactory.create(PayChannelEnum.ALI.getCode()); + // 检查转账参数 + transferStrategy.doValidateParam(transferParam); + // 创建转账订单并设置 + TransferOrder order = transferAssistService.createOrder(transferParam); + transferStrategy.setTransferOrder(order); + // 执行预处理 + transferStrategy.doBeforeHandler(); + try { + // 执行转账策略 + transferStrategy.doTransferHandler(); + } catch (Exception e) { + log.error("转账出现错误", e); + // 记录处理失败状态 + PaymentContextLocal.get().getRefundInfo().setStatus(RefundStatusEnum.FAIL); + // 更新退款失败的记录 + transferAssistService.updateOrderByError(order); + return transferAssistService.buildResult(order); + } + SpringUtil.getBean(this.getClass()).successHandler(order); + return transferAssistService.buildResult(order); + } + + /** + * 成功处理 + */ + public void successHandler(TransferOrder order){ + } + + } diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/transfer/strategy/AliPayTransferStrategy.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/transfer/strategy/AliPayTransferStrategy.java index 244e45b48..0e88b877b 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/transfer/strategy/AliPayTransferStrategy.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/transfer/strategy/AliPayTransferStrategy.java @@ -46,4 +46,8 @@ public void doBeforeHandler() { payConfigService.initConfig(this.config); } + @Override + public void doTransferHandler() { + aliPayTransferService.transfer(this.getTransferOrder()); + } } diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/func/AbsRefundStrategy.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/func/AbsRefundStrategy.java index 845b8483e..c471c9a83 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/func/AbsRefundStrategy.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/func/AbsRefundStrategy.java @@ -17,7 +17,6 @@ public abstract class AbsRefundStrategy implements PayStrategy{ /** 退款订单 */ private RefundOrder refundOrder = null; - /** * 退款前对处理, 主要进行配置的加载和检查 */ diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/func/AbsTransferStrategy.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/func/AbsTransferStrategy.java index 13a67aeaf..6e597d090 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/func/AbsTransferStrategy.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/func/AbsTransferStrategy.java @@ -1,5 +1,6 @@ package cn.daxpay.single.service.func; +import cn.daxpay.single.param.payment.transfer.TransferParam; import cn.daxpay.single.service.core.order.transfer.entity.TransferOrder; import lombok.Getter; import lombok.Setter; @@ -15,9 +16,20 @@ public abstract class AbsTransferStrategy implements PayStrategy{ /** 转账订单 */ private TransferOrder transferOrder; + /** + * 校验参数 + */ + public void doValidateParam(TransferParam transferParam) { + } + /** * 转账前操作 */ public void doBeforeHandler(){} + /** + * 转账操作 + */ + public abstract void doTransferHandler(); + } From ce8dee8afe48110faa34045f218681feec631520 Mon Sep 17 00:00:00 2001 From: DaxPay Date: Fri, 7 Jun 2024 17:21:02 +0800 Subject: [PATCH 03/34] =?UTF-8?q?feat=20=E6=94=AF=E4=BB=98=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E6=8B=86=E5=88=86=E9=80=80=E6=AC=BE=E7=8A=B6=E6=80=81?= =?UTF-8?q?=E4=B8=BA=E5=8D=95=E7=8B=AC=E7=9A=84=E5=AD=97=E6=AE=B5,=20?= =?UTF-8?q?=E7=AD=96=E7=95=A5=E5=B7=A5=E5=8E=82=E4=BF=AE=E6=94=B9=E4=B8=BA?= =?UTF-8?q?=E9=80=9A=E7=94=A8=E7=AD=96=E7=95=A5=E5=B7=A5=E5=8E=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _doc/Task.md | 4 +- .../single/code/PayOrderAllocStatusEnum.java | 2 +- .../single/code/PayOrderRefundStatusEnum.java | 36 ++++++++++++++ .../cn/daxpay/single/code/PayStatusEnum.java | 3 -- .../core/order/pay/builder/PayBuilder.java | 2 + .../core/order/pay/dao/PayOrderManager.java | 23 ++------- .../core/order/pay/entity/PayOrder.java | 9 ++++ .../allocation/AliPayAllocationStrategy.java | 4 +- .../WeChatPayAllocationStrategy.java | 4 +- .../AliPayAllocationReceiverStrategy.java | 4 +- .../WeChatPayAllocationReceiverStrategy.java | 4 +- .../factory/PayCancelStrategyFactory.java | 38 --------------- .../cancel/service/PayCancelService.java | 5 +- .../cancel/strategy/AliPayCancelStrategy.java | 4 +- .../strategy/WeChatPayCancelStrategy.java | 4 +- .../factory/PayCloseStrategyFactory.java | 42 ---------------- .../close/service/PayCloseService.java | 5 +- .../close/strategy/AliPayCloseStrategy.java | 4 +- .../close/strategy/UnionPayCloseStrategy.java | 4 +- .../strategy/WeChatPayCloseStrategy.java | 4 +- .../pay/factory/PayStrategyFactory.java | 48 ------------------- .../payment/pay/service/PayAssistService.java | 4 +- .../core/payment/pay/service/PayService.java | 22 +++++++-- .../payment/pay/strategy/AliPayStrategy.java | 6 +-- .../pay/strategy/UnionPayStrategy.java | 4 +- .../pay/strategy/WalletPayStrategy.java | 4 +- .../pay/strategy/WeChatPayStrategy.java | 4 +- .../factory/ReconcileStrategyFactory.java | 32 ------------- .../reconcile/service/ReconcileService.java | 10 ++-- .../strategy/AlipayReconcileStrategy.java | 6 +-- .../strategy/UnionPayReconcileStrategy.java | 4 +- .../strategy/WechatPayReconcileStrategy.java | 4 +- .../refund/factory/RefundStrategyFactory.java | 47 ------------------ .../refund/service/RefundAssistService.java | 23 ++++----- .../payment/refund/service/RefundService.java | 16 +++---- .../refund/strategy/AliRefundStrategy.java | 6 +-- .../refund/strategy/UnionRefundStrategy.java | 4 +- .../refund/strategy/WalletRefundStrategy.java | 4 +- .../refund/strategy/WeChatRefundStrategy.java | 4 +- .../factory/PayRepairStrategyFactory.java | 42 ---------------- .../repair/result/RefundRepairResult.java | 6 +-- .../repair/service/PayRepairService.java | 7 +-- .../repair/service/RefundRepairService.java | 22 +++++---- .../strategy/pay/AliPayRepairStrategy.java | 6 +-- .../strategy/pay/UnionPayRepairStrategy.java | 4 +- .../strategy/pay/WeChatPayRepairStrategy.java | 4 +- .../sync/factory/PaySyncStrategyFactory.java | 44 ----------------- .../factory/RefundSyncStrategyFactory.java | 43 ----------------- .../payment/sync/service/PaySyncService.java | 21 ++++---- .../sync/service/RefundSyncService.java | 8 +++- .../Refund/AliRefundSyncStrategy.java | 6 +-- .../Refund/UnionRefundSyncStrategy.java | 4 +- .../Refund/WeChatRefundSyncStrategy.java | 4 +- .../sync/strategy/pay/AliPaySyncStrategy.java | 6 +-- .../strategy/pay/UnionPaySyncStrategy.java | 4 +- .../strategy/pay/WeChatPaySyncStrategy.java | 4 +- .../strategy/AliPayTransferStrategy.java | 6 +-- .../single/service/func/PayStrategy.java | 5 +- .../service/util/PayStrategyFactory.java | 31 ++++++++++++ 59 files changed, 241 insertions(+), 493 deletions(-) create mode 100644 daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/code/PayOrderRefundStatusEnum.java delete mode 100644 daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/cancel/factory/PayCancelStrategyFactory.java delete mode 100644 daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/close/factory/PayCloseStrategyFactory.java delete mode 100644 daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/pay/factory/PayStrategyFactory.java delete mode 100644 daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/reconcile/factory/ReconcileStrategyFactory.java delete mode 100644 daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/refund/factory/RefundStrategyFactory.java delete mode 100644 daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/repair/factory/PayRepairStrategyFactory.java delete mode 100644 daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/sync/factory/PaySyncStrategyFactory.java delete mode 100644 daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/sync/factory/RefundSyncStrategyFactory.java create mode 100644 daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/util/PayStrategyFactory.java diff --git a/_doc/Task.md b/_doc/Task.md index 19dc88920..a8363a129 100644 --- a/_doc/Task.md +++ b/_doc/Task.md @@ -7,8 +7,8 @@ - [ ] DEMO增加获取微信OpenID和支付宝OpenId功能 - [ ] 管理端界面支持扫码绑定对账接收方功能 - [ ] 支付通道两个独立的配置进行合并为一个 -- [ ] 支付宝拆分退款状态为单独的字段 -- [ ] 工厂支持自适应 +- [x] 支付订单拆分退款状态为单独的字段 +- [x] 策略工厂修改为通用策略工厂 - [x] 支付和退款达到终态不可以再回退回之前的状态 - [x] 修复支付关闭参数名称不正确问题 2.0.9: 消息通知改版和功能优化 diff --git a/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/code/PayOrderAllocStatusEnum.java b/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/code/PayOrderAllocStatusEnum.java index 9cd556834..29646632a 100644 --- a/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/code/PayOrderAllocStatusEnum.java +++ b/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/code/PayOrderAllocStatusEnum.java @@ -4,7 +4,7 @@ import lombok.Getter; /** - * 支付订单分账状态 + * 支付订单的分账状态 * @author xxm * @since 2024/4/16 */ diff --git a/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/code/PayOrderRefundStatusEnum.java b/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/code/PayOrderRefundStatusEnum.java new file mode 100644 index 000000000..7785b2885 --- /dev/null +++ b/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/code/PayOrderRefundStatusEnum.java @@ -0,0 +1,36 @@ +package cn.daxpay.single.code; + +import cn.bootx.platform.common.core.exception.DataNotExistException; +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.util.Arrays; +import java.util.Objects; + +/** + * 支付订单的退款状态 + * @author xxm + * @since 2024/6/7 + */ +@Getter +@AllArgsConstructor +public enum PayOrderRefundStatusEnum { + NO_REFUND("no_refund","未退款"), + REFUNDING("refunding","退款中"), + PARTIAL_REFUND("partial_refund","部分退款"), + REFUNDED("refunded","全部退款"), + ; + private final String code; + private final String name; + + /** + * 根据编码获取枚举 + */ + public static PayOrderRefundStatusEnum findByCode(String code){ + return Arrays.stream(values()) + .filter(payStatusEnum -> Objects.equals(payStatusEnum.getCode(), code)) + .findFirst() + .orElseThrow(() -> new DataNotExistException("该枚举不存在")); + } + +} diff --git a/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/code/PayStatusEnum.java b/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/code/PayStatusEnum.java index 92da52189..0d1b0f754 100644 --- a/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/code/PayStatusEnum.java +++ b/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/code/PayStatusEnum.java @@ -19,9 +19,6 @@ public enum PayStatusEnum { SUCCESS("success","成功"), CLOSE("close","支付关闭"), CANCEL("cancel","支付撤销"), - REFUNDING("refunding","退款中"), - PARTIAL_REFUND("partial_refund","部分退款"), - REFUNDED("refunded","全部退款"), FAIL("fail","失败"); /** 编码 */ diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/pay/builder/PayBuilder.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/pay/builder/PayBuilder.java index f6ae4a65b..85e6a34a1 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/pay/builder/PayBuilder.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/pay/builder/PayBuilder.java @@ -1,6 +1,7 @@ package cn.daxpay.single.service.core.order.pay.builder; import cn.daxpay.single.code.PayOrderAllocStatusEnum; +import cn.daxpay.single.code.PayOrderRefundStatusEnum; import cn.daxpay.single.code.PayStatusEnum; import cn.daxpay.single.param.payment.pay.PayParam; import cn.daxpay.single.service.common.context.NoticeLocal; @@ -38,6 +39,7 @@ public PayOrder buildPayOrder(PayParam payParam) { .setTitle(payParam.getTitle()) .setDescription(payParam.getDescription()) .setStatus(PayStatusEnum.PROGRESS.getCode()) + .setRefundStatus(PayOrderRefundStatusEnum.NO_REFUND.getCode()) .setAllocation(payParam.getAllocation()) .setAmount(payParam.getAmount()) .setChannel(payParam.getChannel()) diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/pay/dao/PayOrderManager.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/pay/dao/PayOrderManager.java index 2c36ca5e0..6f6cae729 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/pay/dao/PayOrderManager.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/pay/dao/PayOrderManager.java @@ -15,7 +15,6 @@ import org.springframework.stereotype.Repository; import java.time.LocalDateTime; -import java.util.Arrays; import java.util.List; import java.util.Optional; @@ -58,14 +57,10 @@ public Page page(PageParam pageParam, PayOrderQuery query){ * 查询对账用订单记录(指定时间和状态的订单) */ public List findReconcile(String channel, LocalDateTime startTime, LocalDateTime endTime) { - List status = Arrays.asList(PayStatusEnum.SUCCESS.getCode(), - PayStatusEnum.PARTIAL_REFUND.getCode(), - PayStatusEnum.REFUNDING.getCode(), - PayStatusEnum.REFUNDED.getCode()); return this.lambdaQuery() .eq(PayOrder::getChannel, channel) .between(PayOrder::getPayTime, startTime, endTime) - .in(PayOrder::getStatus, status) + .eq(PayOrder::getStatus, PayStatusEnum.SUCCESS.getCode()) .list(); } @@ -73,15 +68,11 @@ public List findReconcile(String channel, LocalDateTime startTime, Loc * 查询自动分账的订单记录(指定时间和状态的订单) */ public List findAutoAllocation() { - List status = Arrays.asList(PayStatusEnum.SUCCESS.getCode(), - PayStatusEnum.PARTIAL_REFUND.getCode(), - PayStatusEnum.REFUNDING.getCode(), - PayStatusEnum.REFUNDED.getCode()); return this.lambdaQuery() .eq(PayOrder::getAllocation, true) .eq(PayOrder::getAutoAllocation, true) .eq(PayOrder::getAllocationStatus, PayOrderAllocStatusEnum.WAITING.getCode()) - .in(PayOrder::getStatus, status) + .eq(PayOrder::getStatus, PayStatusEnum.SUCCESS.getCode()) .list(); } @@ -90,13 +81,7 @@ public List findAutoAllocation() { */ public Integer getTalAmount(PayOrderQuery query){ QueryWrapper generator = QueryGenerator.generator(query); - // 成功, 退款相关都算 - generator.in(MpUtil.getColumnName(PayOrder::getStatus), - PayStatusEnum.SUCCESS.getCode(), - PayStatusEnum.REFUNDED.getCode(), - PayStatusEnum.REFUNDING.getCode(), - PayStatusEnum.PARTIAL_REFUND.getCode() - ); + generator.eq(MpUtil.getColumnName(PayOrder::getStatus), PayStatusEnum.SUCCESS.getCode()); return baseMapper.getTalAmount(generator); } @@ -105,7 +90,7 @@ public Integer getTalAmount(PayOrderQuery query){ */ public List queryExpiredOrder() { return lambdaQuery() - .eq(PayOrder::getStatus, PayStatusEnum.REFUNDING.getCode()) + .eq(PayOrder::getStatus, PayStatusEnum.PROGRESS.getCode()) .lt(PayOrder::getExpiredTime, LocalDateTime.now()) .list(); } 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 0e4d56441..df3fa2440 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 @@ -5,6 +5,7 @@ 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.daxpay.single.service.core.order.pay.convert.PayOrderConvert; import cn.daxpay.single.service.dto.order.pay.PayOrderDto; @@ -92,6 +93,14 @@ public class PayOrder extends MpBaseEntity implements EntityBaseFunction strategy.getChannel().equals(channel)) + .findFirst() + .orElseThrow(PayUnsupportedMethodException::new); + } } diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/pay/strategy/AliPayStrategy.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/pay/strategy/AliPayStrategy.java index ae4aaba2d..36bbb47c0 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/pay/strategy/AliPayStrategy.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/pay/strategy/AliPayStrategy.java @@ -37,9 +37,9 @@ public class AliPayStrategy extends AbsPayStrategy { private AliPayParam aliPayParam; - @Override - public PayChannelEnum getChannel() { - return PayChannelEnum.ALI; + @Override + public String getChannel() { + return PayChannelEnum.ALI.getCode(); } /** diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/pay/strategy/UnionPayStrategy.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/pay/strategy/UnionPayStrategy.java index 16690df5f..70744a495 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/pay/strategy/UnionPayStrategy.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/pay/strategy/UnionPayStrategy.java @@ -41,8 +41,8 @@ public class UnionPayStrategy extends AbsPayStrategy { private UnionPayConfig unionPayConfig; @Override - public PayChannelEnum getChannel() { - return PayChannelEnum.UNION_PAY; + public String getChannel() { + return PayChannelEnum.UNION_PAY.getCode(); } /** * 支付前操作 diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/pay/strategy/WalletPayStrategy.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/pay/strategy/WalletPayStrategy.java index 87a0867e2..8d3a9f8e6 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/pay/strategy/WalletPayStrategy.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/pay/strategy/WalletPayStrategy.java @@ -44,8 +44,8 @@ public class WalletPayStrategy extends AbsPayStrategy { private Wallet wallet; @Override - public PayChannelEnum getChannel() { - return PayChannelEnum.WALLET; + public String getChannel() { + return PayChannelEnum.WALLET.getCode(); } /** diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/pay/strategy/WeChatPayStrategy.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/pay/strategy/WeChatPayStrategy.java index 5f1a93b7a..684e14f00 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/pay/strategy/WeChatPayStrategy.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/pay/strategy/WeChatPayStrategy.java @@ -39,8 +39,8 @@ public class WeChatPayStrategy extends AbsPayStrategy { * 类型 */ @Override - public PayChannelEnum getChannel() { - return PayChannelEnum.WECHAT; + public String getChannel() { + return PayChannelEnum.WECHAT.getCode(); } /** diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/reconcile/factory/ReconcileStrategyFactory.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/reconcile/factory/ReconcileStrategyFactory.java deleted file mode 100644 index 1f9fb8c5e..000000000 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/reconcile/factory/ReconcileStrategyFactory.java +++ /dev/null @@ -1,32 +0,0 @@ -package cn.daxpay.single.service.core.payment.reconcile.factory; - -import cn.daxpay.single.code.PayChannelEnum; -import cn.daxpay.single.exception.pay.PayUnsupportedMethodException; -import cn.daxpay.single.service.func.AbsReconcileStrategy; -import cn.hutool.extra.spring.SpringUtil; -import lombok.experimental.UtilityClass; - -import java.util.Map; -import java.util.Objects; - -/** - * 支付对账工厂类 - * @author xxm - * @since 2024/1/18 - */ -@UtilityClass -public class ReconcileStrategyFactory { - - /** - * 根据传入的支付类型批量创建策略 - */ - public AbsReconcileStrategy create(String channel) { - PayChannelEnum channelEnum = PayChannelEnum.findByCode(channel); - Map beansOfType = SpringUtil.getBeansOfType(AbsReconcileStrategy.class); - return beansOfType.values().stream() - .filter(strategy -> Objects.equals(strategy.getChannel(), channelEnum)) - .findFirst() - .orElseThrow(PayUnsupportedMethodException::new); - } - -} diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/reconcile/service/ReconcileService.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/reconcile/service/ReconcileService.java index a115b1e83..089b8de20 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/reconcile/service/ReconcileService.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/reconcile/service/ReconcileService.java @@ -12,17 +12,17 @@ import cn.daxpay.single.service.core.order.reconcile.dao.ReconcileFileManager; import cn.daxpay.single.service.core.order.reconcile.dao.ReconcileOrderManager; import cn.daxpay.single.service.core.order.reconcile.dao.ReconcileOutTradeManager; -import cn.daxpay.single.service.core.order.reconcile.entity.ReconcileOutTrade; import cn.daxpay.single.service.core.order.reconcile.entity.ReconcileDiff; import cn.daxpay.single.service.core.order.reconcile.entity.ReconcileFile; import cn.daxpay.single.service.core.order.reconcile.entity.ReconcileOrder; +import cn.daxpay.single.service.core.order.reconcile.entity.ReconcileOutTrade; import cn.daxpay.single.service.core.order.reconcile.service.ReconcileOrderService; import cn.daxpay.single.service.core.payment.reconcile.domain.GeneralTradeInfo; -import cn.daxpay.single.service.core.payment.reconcile.factory.ReconcileStrategyFactory; import cn.daxpay.single.service.dto.order.reconcile.ReconcileDiffExcel; import cn.daxpay.single.service.dto.order.reconcile.ReconcileTradeDetailExcel; import cn.daxpay.single.service.func.AbsReconcileStrategy; import cn.daxpay.single.service.param.reconcile.ReconcileUploadParam; +import cn.daxpay.single.service.util.PayStrategyFactory; import cn.daxpay.single.util.OrderNoGenerateUtil; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.date.DatePattern; @@ -106,7 +106,7 @@ public void downAndSave(ReconcileOrder reconcileOrder) { // 将对账订单写入到上下文中 PaymentContextLocal.get().getReconcileInfo().setReconcileOrder(reconcileOrder); // 构建对账策略 - AbsReconcileStrategy reconcileStrategy = ReconcileStrategyFactory.create(reconcileOrder.getChannel()); + AbsReconcileStrategy reconcileStrategy = PayStrategyFactory.create(reconcileOrder.getChannel(), AbsReconcileStrategy.class); reconcileStrategy.setRecordOrder(reconcileOrder); reconcileStrategy.doBeforeHandler(); try { @@ -136,7 +136,7 @@ public void upload(ReconcileUploadParam param, MultipartFile file) { .orElseThrow(() -> new DataNotExistException("未找到对账订单")); // 将对账订单写入到上下文中 PaymentContextLocal.get().getReconcileInfo().setReconcileOrder(reconcileOrder); - AbsReconcileStrategy reconcileStrategy = ReconcileStrategyFactory.create(reconcileOrder.getChannel()); + AbsReconcileStrategy reconcileStrategy = PayStrategyFactory.create(reconcileOrder.getChannel(), AbsReconcileStrategy.class); reconcileStrategy.setRecordOrder(reconcileOrder); reconcileStrategy.doBeforeHandler(); @@ -183,7 +183,7 @@ public void compare(ReconcileOrder reconcileOrder){ // 查询对账单 List reconcileTradeDetails = reconcileOutTradeManager.findAllByReconcileId(reconcileOrder.getId()); // 构建对账策略 - AbsReconcileStrategy reconcileStrategy = ReconcileStrategyFactory.create(reconcileOrder.getChannel()); + AbsReconcileStrategy reconcileStrategy =PayStrategyFactory.create(reconcileOrder.getChannel(), AbsReconcileStrategy.class); // 初始化参数 reconcileStrategy.setRecordOrder(reconcileOrder); diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/reconcile/strategy/AlipayReconcileStrategy.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/reconcile/strategy/AlipayReconcileStrategy.java index 64711fc09..3b66275f3 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/reconcile/strategy/AlipayReconcileStrategy.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/reconcile/strategy/AlipayReconcileStrategy.java @@ -37,9 +37,9 @@ public class AlipayReconcileStrategy extends AbsReconcileStrategy { * * @see PayChannelEnum */ - @Override - public PayChannelEnum getChannel() { - return PayChannelEnum.ALI; + @Override + public String getChannel() { + return PayChannelEnum.ALI.getCode(); } /** diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/reconcile/strategy/UnionPayReconcileStrategy.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/reconcile/strategy/UnionPayReconcileStrategy.java index 58d4b3852..5390d7dc7 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/reconcile/strategy/UnionPayReconcileStrategy.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/reconcile/strategy/UnionPayReconcileStrategy.java @@ -40,8 +40,8 @@ public class UnionPayReconcileStrategy extends AbsReconcileStrategy { * 策略标识 */ @Override - public PayChannelEnum getChannel() { - return PayChannelEnum.UNION_PAY; + public String getChannel() { + return PayChannelEnum.UNION_PAY.getCode(); } /** diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/reconcile/strategy/WechatPayReconcileStrategy.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/reconcile/strategy/WechatPayReconcileStrategy.java index 34e5d04fe..7044206ca 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/reconcile/strategy/WechatPayReconcileStrategy.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/reconcile/strategy/WechatPayReconcileStrategy.java @@ -40,8 +40,8 @@ public class WechatPayReconcileStrategy extends AbsReconcileStrategy { * @see PayChannelEnum */ @Override - public PayChannelEnum getChannel() { - return PayChannelEnum.WECHAT; + public String getChannel() { + return PayChannelEnum.WECHAT.getCode(); } /** diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/refund/factory/RefundStrategyFactory.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/refund/factory/RefundStrategyFactory.java deleted file mode 100644 index c4662efb1..000000000 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/refund/factory/RefundStrategyFactory.java +++ /dev/null @@ -1,47 +0,0 @@ -package cn.daxpay.single.service.core.payment.refund.factory; - -import cn.daxpay.single.code.PayChannelEnum; -import cn.daxpay.single.exception.pay.PayUnsupportedMethodException; -import cn.daxpay.single.service.core.payment.refund.strategy.AliRefundStrategy; -import cn.daxpay.single.service.core.payment.refund.strategy.UnionRefundStrategy; -import cn.daxpay.single.service.core.payment.refund.strategy.WalletRefundStrategy; -import cn.daxpay.single.service.core.payment.refund.strategy.WeChatRefundStrategy; -import cn.daxpay.single.service.func.AbsRefundStrategy; -import cn.hutool.extra.spring.SpringUtil; - -/** - * 退款策略工厂 - * @author xxm - * @since 2023/7/4 - */ -public class RefundStrategyFactory { - - - /** - * 根据传入的支付通道创建策略 - * @return 支付策略 - */ - public static AbsRefundStrategy create(String channel) { - - AbsRefundStrategy strategy; - PayChannelEnum channelEnum = PayChannelEnum.findByCode(channel); - switch (channelEnum) { - case ALI: - strategy = SpringUtil.getBean(AliRefundStrategy.class); - break; - case WECHAT: - strategy = SpringUtil.getBean(WeChatRefundStrategy.class); - break; - case UNION_PAY: - strategy = SpringUtil.getBean(UnionRefundStrategy.class); - break; - case WALLET: - strategy = SpringUtil.getBean(WalletRefundStrategy.class); - break; - default: - throw new PayUnsupportedMethodException(); - } - return strategy; - } - -} diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/refund/service/RefundAssistService.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/refund/service/RefundAssistService.java index 7bf7de3af..d5400fe2f 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/refund/service/RefundAssistService.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/refund/service/RefundAssistService.java @@ -1,5 +1,6 @@ package cn.daxpay.single.service.core.payment.refund.service; +import cn.daxpay.single.code.PayOrderRefundStatusEnum; import cn.daxpay.single.code.PaySignTypeEnum; import cn.daxpay.single.code.PayStatusEnum; import cn.daxpay.single.code.RefundStatusEnum; @@ -21,6 +22,7 @@ import cn.hutool.core.util.StrUtil; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import lombok.val; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; @@ -78,20 +80,19 @@ private void initNotice(RefundParam param) { * 检查并处理退款参数 */ public void checkAndParam(RefundParam param, PayOrder payOrder){ - - // 状态判断, 支付中/失败/取消等不能进行退款 - List tradesStatus = Arrays.asList( - PayStatusEnum.PROGRESS.getCode(), - PayStatusEnum.CLOSE.getCode(), - PayStatusEnum.CANCEL.getCode(), - PayStatusEnum.REFUNDED.getCode(), - PayStatusEnum.REFUNDING.getCode(), - PayStatusEnum.FAIL.getCode()); - if (tradesStatus.contains(payOrder.getStatus())) { + // 非支付完成的不能进行退款 + if (!Objects.equals(SUCCESS.getCode(), payOrder.getStatus())) { PayStatusEnum statusEnum = PayStatusEnum.findByCode(payOrder.getStatus()); throw new PayFailureException("当前支付单订状态["+statusEnum.getName()+"]不允许发起退款操作"); } - + // 退款中和退款完成不能退款 + List tradesStatus = Arrays.asList( + PayOrderRefundStatusEnum.REFUNDED.getCode(), + PayOrderRefundStatusEnum.REFUNDING.getCode()); + if (tradesStatus.contains(payOrder.getRefundStatus())){ + val statusEnum = PayOrderRefundStatusEnum.findByCode(payOrder.getRefundStatus()); + throw new PayFailureException("当前支付单退款状态["+statusEnum.getName()+"]不允许发起退款操作"); + } // 退款号唯一校验 if (StrUtil.isNotBlank(param.getBizRefundNo()) && refundOrderManager.existsByRefundNo(param.getBizRefundNo())){ throw new PayFailureException("退款单号已存在"); 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 3f15365b4..f8e13051b 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 @@ -3,7 +3,7 @@ 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.PayStatusEnum; +import cn.daxpay.single.code.PayOrderRefundStatusEnum; import cn.daxpay.single.code.RefundStatusEnum; import cn.daxpay.single.exception.pay.PayFailureException; import cn.daxpay.single.param.payment.refund.RefundParam; @@ -18,9 +18,9 @@ import cn.daxpay.single.service.core.order.refund.entity.RefundOrder; import cn.daxpay.single.service.core.order.refund.entity.RefundOrderExtra; import cn.daxpay.single.service.core.payment.notice.service.ClientNoticeService; -import cn.daxpay.single.service.core.payment.refund.factory.RefundStrategyFactory; 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; @@ -106,7 +106,7 @@ public RefundResult firstRefund(RefundParam param){ // 检查退款参数 refundAssistService.checkAndParam(param, payOrder); // 通过退款参数获取退款策略 - AbsRefundStrategy refundStrategy = RefundStrategyFactory.create(payOrder.getChannel()); + AbsRefundStrategy refundStrategy = PayStrategyFactory.create(payOrder.getChannel(), AbsRefundStrategy.class); // 进行退款前预处理 refundStrategy.doBeforeRefundHandler(); // 退款操作的预处理, 对支付订单进行预扣款, 返回创建成功的退款订单, 成功后才可以进行下一阶段的操作 @@ -136,7 +136,7 @@ public RefundOrder preRefundMethod(RefundParam refundParam, PayOrder payOrder) { // 预扣支付订单要退款的金额并进行更新 int orderRefundableBalance = payOrder.getRefundableBalance() - refundParam.getAmount(); payOrder.setRefundableBalance(orderRefundableBalance) - .setStatus(PayStatusEnum.REFUNDING.getCode()); + .setRefundStatus(PayOrderRefundStatusEnum.REFUNDING.getCode()); payOrderService.updateById(payOrder); // ----------------------- 退款订单创建 ------------------------- return refundAssistService.createOrder(refundParam, payOrder); @@ -158,7 +158,7 @@ public RefundResult repeatRefund(RefundOrder refundOrder, RefundParam param){ .orElseThrow(() -> new DataNotExistException("支付订单不存在")); RefundOrderExtra refundOrderExtra = refundOrderExtraManager.findById(refundOrder.getId()) .orElseThrow(() -> new DataNotExistException("退款订单扩展信息不存在")); - AbsRefundStrategy refundStrategy = RefundStrategyFactory.create(refundOrder.getChannel()); + AbsRefundStrategy refundStrategy = PayStrategyFactory.create(refundOrder.getChannel(), AbsRefundStrategy.class); // 设置退款订单对象 refundStrategy.setRefundOrder(refundOrder); // 退款前准备操作 @@ -208,14 +208,14 @@ public void successHandler(RefundOrder refundOrder, PayOrder payOrder) { int refundableBalance = payOrder.getRefundableBalance(); // 退款状态为退款中 if (refundInfo.getStatus() == RefundStatusEnum.PROGRESS) { - payOrder.setStatus(PayStatusEnum.REFUNDING.getCode()); + payOrder.setRefundStatus(PayOrderRefundStatusEnum.REFUNDING.getCode()); } // 退款状态为成功 else { if (refundableBalance == 0) { - payOrder.setStatus(PayStatusEnum.REFUNDED.getCode()); + payOrder.setRefundStatus(PayOrderRefundStatusEnum.REFUNDED.getCode()); } else { - payOrder.setStatus(PayStatusEnum.PARTIAL_REFUND.getCode()); + payOrder.setRefundStatus(PayOrderRefundStatusEnum.PARTIAL_REFUND.getCode()); } // 记录流水 tradeFlowRecordService.saveRefund(refundOrder); diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/refund/strategy/AliRefundStrategy.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/refund/strategy/AliRefundStrategy.java index 8c7dcb3d4..b84427d80 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/refund/strategy/AliRefundStrategy.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/refund/strategy/AliRefundStrategy.java @@ -28,9 +28,9 @@ public class AliRefundStrategy extends AbsRefundStrategy { * * @see PayChannelEnum */ - @Override - public PayChannelEnum getChannel() { - return PayChannelEnum.ALI; + @Override + public String getChannel() { + return PayChannelEnum.ALI.getCode(); } diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/refund/strategy/UnionRefundStrategy.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/refund/strategy/UnionRefundStrategy.java index db5f53e19..320a39a27 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/refund/strategy/UnionRefundStrategy.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/refund/strategy/UnionRefundStrategy.java @@ -34,8 +34,8 @@ public class UnionRefundStrategy extends AbsRefundStrategy { * @see PayChannelEnum */ @Override - public PayChannelEnum getChannel() { - return PayChannelEnum.UNION_PAY; + public String getChannel() { + return PayChannelEnum.UNION_PAY.getCode(); } /** diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/refund/strategy/WalletRefundStrategy.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/refund/strategy/WalletRefundStrategy.java index 0e232475e..be3cdafd1 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/refund/strategy/WalletRefundStrategy.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/refund/strategy/WalletRefundStrategy.java @@ -36,8 +36,8 @@ public class WalletRefundStrategy extends AbsRefundStrategy { * @see PayChannelEnum */ @Override - public PayChannelEnum getChannel() { - return PayChannelEnum.WALLET; + public String getChannel() { + return PayChannelEnum.WALLET.getCode(); } diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/refund/strategy/WeChatRefundStrategy.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/refund/strategy/WeChatRefundStrategy.java index 1433ece8a..d34a9a9d5 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/refund/strategy/WeChatRefundStrategy.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/refund/strategy/WeChatRefundStrategy.java @@ -33,8 +33,8 @@ public class WeChatRefundStrategy extends AbsRefundStrategy { * @see PayChannelEnum */ @Override - public PayChannelEnum getChannel() { - return PayChannelEnum.WECHAT; + public String getChannel() { + return PayChannelEnum.WECHAT.getCode(); } /** diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/repair/factory/PayRepairStrategyFactory.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/repair/factory/PayRepairStrategyFactory.java deleted file mode 100644 index 4914805d5..000000000 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/repair/factory/PayRepairStrategyFactory.java +++ /dev/null @@ -1,42 +0,0 @@ -package cn.daxpay.single.service.core.payment.repair.factory; - -import cn.daxpay.single.code.PayChannelEnum; -import cn.daxpay.single.exception.pay.PayUnsupportedMethodException; -import cn.daxpay.single.service.core.payment.repair.strategy.pay.AliPayRepairStrategy; -import cn.daxpay.single.service.core.payment.repair.strategy.pay.UnionPayRepairStrategy; -import cn.daxpay.single.service.core.payment.repair.strategy.pay.WeChatPayRepairStrategy; -import cn.daxpay.single.service.func.AbsPayRepairStrategy; -import cn.hutool.extra.spring.SpringUtil; -import lombok.experimental.UtilityClass; - -/** - * 支付修复策略工厂类 - * @author xxm - * @since 2023/12/29 - */ -@UtilityClass -public class PayRepairStrategyFactory { - /** - * 根据传入的支付通道创建策略 - * @return 支付修复策略 - */ - public static AbsPayRepairStrategy create(String channel) { - PayChannelEnum channelEnum = PayChannelEnum.findByCode(channel); - AbsPayRepairStrategy strategy; - switch (channelEnum) { - case ALI: - strategy = SpringUtil.getBean(AliPayRepairStrategy.class); - break; - case WECHAT: - strategy = SpringUtil.getBean(WeChatPayRepairStrategy.class); - break; - case UNION_PAY: - strategy = SpringUtil.getBean(UnionPayRepairStrategy.class); - break; - default: - throw new PayUnsupportedMethodException(); - } - return strategy; - } - -} diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/repair/result/RefundRepairResult.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/repair/result/RefundRepairResult.java index 2c8d8a5d4..2ac681bf9 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/repair/result/RefundRepairResult.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/repair/result/RefundRepairResult.java @@ -1,7 +1,7 @@ package cn.daxpay.single.service.core.payment.repair.result; +import cn.daxpay.single.code.PayOrderRefundStatusEnum; import cn.daxpay.single.code.RefundStatusEnum; -import cn.daxpay.single.code.PayStatusEnum; import lombok.Data; import lombok.experimental.Accessors; @@ -21,7 +21,7 @@ public class RefundRepairResult { /** 退款修复后状态 */ private RefundStatusEnum afterRefundStatus; /** 支付修复前状态 */ - private PayStatusEnum beforePayStatus; + private PayOrderRefundStatusEnum beforePayStatus; /** 支付修复后状态 */ - private PayStatusEnum afterPayStatus; + private PayOrderRefundStatusEnum afterPayStatus; } diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/repair/service/PayRepairService.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/repair/service/PayRepairService.java index 7a8a03ea2..1bd37df19 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/repair/service/PayRepairService.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/repair/service/PayRepairService.java @@ -8,12 +8,12 @@ import cn.daxpay.single.service.core.order.pay.entity.PayOrder; import cn.daxpay.single.service.core.order.pay.service.PayOrderService; import cn.daxpay.single.service.core.payment.notice.service.ClientNoticeService; -import cn.daxpay.single.service.core.payment.repair.factory.PayRepairStrategyFactory; import cn.daxpay.single.service.core.payment.repair.result.PayRepairResult; import cn.daxpay.single.service.core.record.flow.service.TradeFlowRecordService; import cn.daxpay.single.service.core.record.repair.entity.PayRepairRecord; import cn.daxpay.single.service.core.record.repair.service.PayRepairRecordService; import cn.daxpay.single.service.func.AbsPayRepairStrategy; +import cn.daxpay.single.service.util.PayStrategyFactory; import cn.hutool.core.util.IdUtil; import com.baomidou.lock.LockInfo; import com.baomidou.lock.LockTemplate; @@ -23,7 +23,8 @@ import org.springframework.transaction.annotation.Transactional; import java.time.LocalDateTime; -import java.util.*; +import java.util.Objects; +import java.util.Optional; /** * 支付修复服务 @@ -57,7 +58,7 @@ public PayRepairResult repair(PayOrder order, PayRepairWayEnum repairType){ } // 2.1 初始化修复参数 - AbsPayRepairStrategy repairStrategy = PayRepairStrategyFactory.create(order.getChannel()); + AbsPayRepairStrategy repairStrategy = PayStrategyFactory.create(order.getChannel(),AbsPayRepairStrategy.class); repairStrategy.setOrder(order); // 2.2 执行前置处理 repairStrategy.doBeforeHandler(); diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/repair/service/RefundRepairService.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/repair/service/RefundRepairService.java index a6563fe4a..6f4b980c7 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/repair/service/RefundRepairService.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/repair/service/RefundRepairService.java @@ -1,5 +1,6 @@ package cn.daxpay.single.service.core.payment.repair.service; +import cn.daxpay.single.code.PayOrderRefundStatusEnum; import cn.daxpay.single.code.PayStatusEnum; import cn.daxpay.single.code.RefundStatusEnum; import cn.daxpay.single.service.code.PaymentTypeEnum; @@ -100,20 +101,20 @@ public RefundRepairResult repair(RefundOrder refundOrder, RefundRepairWayEnum re private RefundRepairResult success(RefundOrder refundOrder, PayOrder payOrder) { RepairLocal repairInfo = PaymentContextLocal.get().getRepairInfo(); // 订单相关状态 - PayStatusEnum beforePayStatus = PayStatusEnum.findByCode(payOrder.getStatus()); - PayStatusEnum afterPayRefundStatus; + PayOrderRefundStatusEnum beforePayStatus = PayOrderRefundStatusEnum.findByCode(payOrder.getRefundStatus()); + PayOrderRefundStatusEnum afterPayRefundStatus; RefundStatusEnum beforeRefundStatus = RefundStatusEnum.findByCode(refundOrder.getStatus()); // 判断订单全部退款还是部分退款 if (Objects.equals(payOrder.getRefundableBalance(),0)){ - afterPayRefundStatus = PayStatusEnum.REFUNDED; + afterPayRefundStatus = PayOrderRefundStatusEnum.REFUNDED; } else { - afterPayRefundStatus = PayStatusEnum.PARTIAL_REFUND; + afterPayRefundStatus = PayOrderRefundStatusEnum.PARTIAL_REFUND; } // 设置退款为完成状态和完成时间 refundOrder.setStatus(RefundStatusEnum.SUCCESS.getCode()) .setFinishTime(repairInfo.getFinishTime()); - payOrder.setStatus(afterPayRefundStatus.getCode()); + payOrder.setRefundStatus(afterPayRefundStatus.getCode()); // 更新订单和退款相关订单 payOrderService.updateById(payOrder); @@ -144,7 +145,7 @@ private RefundRepairResult close(RefundOrder refundOrder, PayOrder payOrder) { RefundRepairResult repairResult = new RefundRepairResult(); // 订单修复前状态 - PayStatusEnum beforePayStatus = PayStatusEnum.findByCode(refundOrder.getStatus()); + PayOrderRefundStatusEnum beforePayStatus = PayOrderRefundStatusEnum.findByCode(payOrder.getRefundStatus()); RefundStatusEnum beforeRefundStatus = RefundStatusEnum.findByCode(refundOrder.getStatus()); repairResult.setBeforePayStatus(beforePayStatus) .setBeforeRefundStatus(beforeRefundStatus); @@ -154,11 +155,11 @@ private RefundRepairResult close(RefundOrder refundOrder, PayOrder payOrder) { // 退款失败返还后的余额+可退余额 == 订单金额 支付订单回退为为支付成功状态 if (payOrderAmount == payOrder.getAmount()){ payOrder.setStatus(PayStatusEnum.SUCCESS.getCode()); - repairResult.setAfterPayStatus(PayStatusEnum.SUCCESS); + repairResult.setAfterPayStatus(PayOrderRefundStatusEnum.NO_REFUND); } else { // 回归部分退款状态 - payOrder.setStatus(PayStatusEnum.PARTIAL_REFUND.getCode()); - repairResult.setAfterPayStatus(PayStatusEnum.PARTIAL_REFUND); + payOrder.setRefundStatus(PayOrderRefundStatusEnum.PARTIAL_REFUND.getCode()); + repairResult.setAfterPayStatus(PayOrderRefundStatusEnum.PARTIAL_REFUND); } // 更新支付订单相关的可退款金额 @@ -179,7 +180,8 @@ private RefundRepairResult close(RefundOrder refundOrder, PayOrder payOrder) { */ private PayRepairRecord payRepairRecord(PayOrder order, RefundRepairWayEnum repairType, RefundRepairResult repairResult){ // 修复前的状态 - String beforeStatus = Optional.ofNullable(repairResult.getBeforePayStatus()).map(PayStatusEnum::getCode).orElse(null); + String beforeStatus = Optional.ofNullable(repairResult.getBeforePayStatus()) + .map(PayOrderRefundStatusEnum::getCode).orElse(null); // 修复发起来源 String source = PaymentContextLocal.get() .getRepairInfo() diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/repair/strategy/pay/AliPayRepairStrategy.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/repair/strategy/pay/AliPayRepairStrategy.java index c6f2e76e2..1722c07fa 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/repair/strategy/pay/AliPayRepairStrategy.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/repair/strategy/pay/AliPayRepairStrategy.java @@ -29,9 +29,9 @@ public class AliPayRepairStrategy extends AbsPayRepairStrategy { /** * 策略标识 */ - @Override - public PayChannelEnum getChannel() { - return PayChannelEnum.ALI; + @Override + public String getChannel() { + return PayChannelEnum.ALI.getCode(); } /** diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/repair/strategy/pay/UnionPayRepairStrategy.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/repair/strategy/pay/UnionPayRepairStrategy.java index 58cae03ae..2d655eb92 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/repair/strategy/pay/UnionPayRepairStrategy.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/repair/strategy/pay/UnionPayRepairStrategy.java @@ -24,8 +24,8 @@ public class UnionPayRepairStrategy extends AbsPayRepairStrategy { * 策略标识 */ @Override - public PayChannelEnum getChannel() { - return PayChannelEnum.UNION_PAY; + public String getChannel() { + return PayChannelEnum.UNION_PAY.getCode(); } /** diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/repair/strategy/pay/WeChatPayRepairStrategy.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/repair/strategy/pay/WeChatPayRepairStrategy.java index afdfd7803..1ec19e5c9 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/repair/strategy/pay/WeChatPayRepairStrategy.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/repair/strategy/pay/WeChatPayRepairStrategy.java @@ -32,8 +32,8 @@ public class WeChatPayRepairStrategy extends AbsPayRepairStrategy { * 策略标识 */ @Override - public PayChannelEnum getChannel() { - return PayChannelEnum.WECHAT; + public String getChannel() { + return PayChannelEnum.WECHAT.getCode(); } diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/sync/factory/PaySyncStrategyFactory.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/sync/factory/PaySyncStrategyFactory.java deleted file mode 100644 index fb6cc8c55..000000000 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/sync/factory/PaySyncStrategyFactory.java +++ /dev/null @@ -1,44 +0,0 @@ -package cn.daxpay.single.service.core.payment.sync.factory; - - -import cn.daxpay.single.code.PayChannelEnum; -import cn.daxpay.single.exception.pay.PayUnsupportedMethodException; -import cn.daxpay.single.service.core.payment.sync.strategy.pay.AliPaySyncStrategy; -import cn.daxpay.single.service.core.payment.sync.strategy.pay.UnionPaySyncStrategy; -import cn.daxpay.single.service.core.payment.sync.strategy.pay.WeChatPaySyncStrategy; -import cn.daxpay.single.service.func.AbsPaySyncStrategy; -import cn.hutool.extra.spring.SpringUtil; -import lombok.experimental.UtilityClass; - -/** - * 支付同步策略工厂类 - * @author xxm - * @since 2023/7/14 - */ -@UtilityClass -public class PaySyncStrategyFactory { - /** - * 获取支付同步策略 - * @param channelCode 支付通道编码 - * @return 支付同步策略类 - */ - public AbsPaySyncStrategy create(String channelCode) { - AbsPaySyncStrategy strategy; - PayChannelEnum channelEnum = PayChannelEnum.findByCode(channelCode); - switch (channelEnum) { - case ALI: - strategy = SpringUtil.getBean(AliPaySyncStrategy.class); - break; - case WECHAT: - strategy = SpringUtil.getBean(WeChatPaySyncStrategy.class); - break; - case UNION_PAY: - strategy = SpringUtil.getBean(UnionPaySyncStrategy.class); - break; - default: - throw new PayUnsupportedMethodException(); - } - // noinspection ConstantConditions - return strategy; - } -} diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/sync/factory/RefundSyncStrategyFactory.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/sync/factory/RefundSyncStrategyFactory.java deleted file mode 100644 index ce839bd21..000000000 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/sync/factory/RefundSyncStrategyFactory.java +++ /dev/null @@ -1,43 +0,0 @@ -package cn.daxpay.single.service.core.payment.sync.factory; - -import cn.daxpay.single.code.PayChannelEnum; -import cn.daxpay.single.exception.pay.PayUnsupportedMethodException; -import cn.daxpay.single.service.core.payment.sync.strategy.Refund.AliRefundSyncStrategy; -import cn.daxpay.single.service.core.payment.sync.strategy.Refund.UnionRefundSyncStrategy; -import cn.daxpay.single.service.core.payment.sync.strategy.Refund.WeChatRefundSyncStrategy; -import cn.daxpay.single.service.func.AbsRefundSyncStrategy; -import cn.hutool.extra.spring.SpringUtil; -import lombok.experimental.UtilityClass; - -/** - * 支付退款同步策略工厂 - * @author xxm - * @since 2024/1/29 - */ -@UtilityClass -public class RefundSyncStrategyFactory { - /** - * 获取支付同步策略, 只有异步支付方式才需要这个功能 - * @param channelCode 支付通道编码 - * @return 支付同步策略类 - */ - public static AbsRefundSyncStrategy create(String channelCode) { - AbsRefundSyncStrategy strategy; - PayChannelEnum channelEnum = PayChannelEnum.findByCode(channelCode); - switch (channelEnum) { - case ALI: - strategy = SpringUtil.getBean(AliRefundSyncStrategy.class); - break; - case UNION_PAY: - strategy = SpringUtil.getBean(UnionRefundSyncStrategy.class); - break; - case WECHAT: - strategy = SpringUtil.getBean(WeChatRefundSyncStrategy.class); - break; - default: - throw new PayUnsupportedMethodException(); - } - // noinspection ConstantConditions - return strategy; - } -} diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/sync/service/PaySyncService.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/sync/service/PaySyncService.java index 29e18b604..0a17e6ccd 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/sync/service/PaySyncService.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/sync/service/PaySyncService.java @@ -3,6 +3,7 @@ import cn.bootx.platform.common.core.exception.RepetitiveOperationException; import cn.bootx.platform.common.core.util.LocalDateTimeUtil; import cn.daxpay.single.code.PayChannelEnum; +import cn.daxpay.single.code.PayOrderRefundStatusEnum; import cn.daxpay.single.code.PayStatusEnum; import cn.daxpay.single.code.PaySyncStatusEnum; import cn.daxpay.single.exception.pay.PayFailureException; @@ -18,11 +19,11 @@ import cn.daxpay.single.service.core.order.pay.service.PayOrderService; import cn.daxpay.single.service.core.payment.repair.result.PayRepairResult; import cn.daxpay.single.service.core.payment.repair.service.PayRepairService; -import cn.daxpay.single.service.core.payment.sync.factory.PaySyncStrategyFactory; import cn.daxpay.single.service.core.payment.sync.result.PayRemoteSyncResult; import cn.daxpay.single.service.core.record.sync.entity.PaySyncRecord; import cn.daxpay.single.service.core.record.sync.service.PaySyncRecordService; import cn.daxpay.single.service.func.AbsPaySyncStrategy; +import cn.daxpay.single.service.util.PayStrategyFactory; import com.baomidou.lock.LockInfo; import com.baomidou.lock.LockTemplate; import lombok.RequiredArgsConstructor; @@ -64,9 +65,10 @@ public class PaySyncService { public PaySyncResult sync(PaySyncParam param) { PayOrder payOrder = payOrderQueryService.findByBizOrOrderNo(param.getOrderNo(), param.getBizOrderNo()) .orElseThrow(() -> new PayFailureException("支付订单不存在")); - // 钱包支付钱包不需要 + + // 钱包支付钱包不需要同步 if (PayChannelEnum.WALLET.getCode().equals(payOrder.getChannel())){ - throw new PayFailureException("订单没有异步支付方式,不需要同步"); + throw new PayFailureException("支付订单不需要同步"); } // 执行订单同步逻辑 return this.syncPayOrder(payOrder); @@ -84,10 +86,9 @@ public PaySyncResult syncPayOrder(PayOrder payOrder) { if (Objects.isNull(lock)){ throw new RepetitiveOperationException("支付同步处理中,请勿重复操作"); } - try { // 获取支付同步策略类 - AbsPaySyncStrategy syncPayStrategy = PaySyncStrategyFactory.create(payOrder.getChannel()); + AbsPaySyncStrategy syncPayStrategy = PayStrategyFactory.create(payOrder.getChannel(), AbsPaySyncStrategy.class); syncPayStrategy.initPayParam(payOrder); // 执行操作, 获取支付网关同步的结果 PayRemoteSyncResult payRemoteSyncResult = syncPayStrategy.doSyncStatus(); @@ -168,12 +169,9 @@ private boolean checkAndAdjustSyncStatus(PayRemoteSyncResult payRemoteSyncResult return true; } - // 退款比对状态不做额外处理, 需要通过退款接口进行处理 - List orderClose = Arrays.asList( - PayStatusEnum.REFUNDED.getCode(), - PayStatusEnum.REFUNDING.getCode(), - PayStatusEnum.PARTIAL_REFUND.getCode()); - if (orderClose.contains(orderStatus) || syncStatus.equals(PaySyncStatusEnum.REFUND)){ + // 退款状态不做额外处理, 需要通过退款接口进行处理 + if (!Objects.equals(order.getRefundStatus(),PayOrderRefundStatusEnum.NO_REFUND.getCode()) + || syncStatus.equals(PaySyncStatusEnum.REFUND)){ return true; } return false; @@ -248,4 +246,5 @@ private void saveRecord(PayOrder payOrder, PayRemoteSyncResult payRemoteSyncResu .setClientIp(PaymentContextLocal.get().getRequestInfo().getClientIp()); paySyncRecordService.saveRecord(paySyncRecord); } + } diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/sync/service/RefundSyncService.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/sync/service/RefundSyncService.java index eff3f96b3..d5f9c0070 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/sync/service/RefundSyncService.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/sync/service/RefundSyncService.java @@ -5,6 +5,7 @@ import cn.daxpay.single.code.RefundStatusEnum; import cn.daxpay.single.code.RefundSyncStatusEnum; import cn.daxpay.single.exception.pay.PayFailureException; +import cn.daxpay.single.exception.pay.PayUnsupportedMethodException; import cn.daxpay.single.param.payment.refund.RefundSyncParam; import cn.daxpay.single.result.sync.RefundSyncResult; import cn.daxpay.single.service.code.PayRepairSourceEnum; @@ -17,15 +18,17 @@ import cn.daxpay.single.service.core.order.refund.service.RefundOrderQueryService; import cn.daxpay.single.service.core.payment.repair.result.RefundRepairResult; import cn.daxpay.single.service.core.payment.repair.service.RefundRepairService; -import cn.daxpay.single.service.core.payment.sync.factory.RefundSyncStrategyFactory; import cn.daxpay.single.service.core.payment.sync.result.RefundRemoteSyncResult; import cn.daxpay.single.service.core.record.sync.entity.PaySyncRecord; import cn.daxpay.single.service.core.record.sync.service.PaySyncRecordService; import cn.daxpay.single.service.func.AbsRefundSyncStrategy; +import cn.daxpay.single.service.util.PayStrategyFactory; +import cn.hutool.extra.spring.SpringUtil; import com.baomidou.lock.LockInfo; import com.baomidou.lock.LockTemplate; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import lombok.val; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; @@ -78,7 +81,7 @@ public RefundSyncResult syncRefundOrder(RefundOrder refundOrder) { } try { // 获取支付同步策略类 - AbsRefundSyncStrategy syncPayStrategy = RefundSyncStrategyFactory.create(refundOrder.getChannel()); + AbsRefundSyncStrategy syncPayStrategy = PayStrategyFactory.create(refundOrder.getChannel(),AbsRefundSyncStrategy.class); syncPayStrategy.setRefundOrder(refundOrder); // 同步前处理, 主要预防请求过于迅速 syncPayStrategy.doBeforeHandler(); @@ -203,4 +206,5 @@ private void saveRecord(RefundOrder refundOrder, RefundRemoteSyncResult syncResu .setClientIp(PaymentContextLocal.get().getRequestInfo().getClientIp()); paySyncRecordService.saveRecord(paySyncRecord); } + } diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/sync/strategy/Refund/AliRefundSyncStrategy.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/sync/strategy/Refund/AliRefundSyncStrategy.java index 4b55e3a34..cca9d89d9 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/sync/strategy/Refund/AliRefundSyncStrategy.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/sync/strategy/Refund/AliRefundSyncStrategy.java @@ -30,9 +30,9 @@ public class AliRefundSyncStrategy extends AbsRefundSyncStrategy { /** * 策略标识 */ - @Override - public PayChannelEnum getChannel() { - return PayChannelEnum.ALI; + @Override + public String getChannel() { + return PayChannelEnum.ALI.getCode(); } /** diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/sync/strategy/Refund/UnionRefundSyncStrategy.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/sync/strategy/Refund/UnionRefundSyncStrategy.java index a2ab97061..752175458 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/sync/strategy/Refund/UnionRefundSyncStrategy.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/sync/strategy/Refund/UnionRefundSyncStrategy.java @@ -43,7 +43,7 @@ public RefundRemoteSyncResult doSyncStatus() { * 策略标识 */ @Override - public PayChannelEnum getChannel() { - return PayChannelEnum.UNION_PAY; + public String getChannel() { + return PayChannelEnum.UNION_PAY.getCode(); } } diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/sync/strategy/Refund/WeChatRefundSyncStrategy.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/sync/strategy/Refund/WeChatRefundSyncStrategy.java index 328aa49e3..b2d2b25b2 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/sync/strategy/Refund/WeChatRefundSyncStrategy.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/sync/strategy/Refund/WeChatRefundSyncStrategy.java @@ -28,8 +28,8 @@ public class WeChatRefundSyncStrategy extends AbsRefundSyncStrategy { * 策略标识 */ @Override - public PayChannelEnum getChannel() { - return PayChannelEnum.WECHAT; + public String getChannel() { + return PayChannelEnum.WECHAT.getCode(); } /** diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/sync/strategy/pay/AliPaySyncStrategy.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/sync/strategy/pay/AliPaySyncStrategy.java index eec17a41d..f43457a56 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/sync/strategy/pay/AliPaySyncStrategy.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/sync/strategy/pay/AliPaySyncStrategy.java @@ -30,9 +30,9 @@ public class AliPaySyncStrategy extends AbsPaySyncStrategy { /** * 策略标识 */ - @Override - public PayChannelEnum getChannel() { - return PayChannelEnum.ALI; + @Override + public String getChannel() { + return PayChannelEnum.ALI.getCode(); } /** diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/sync/strategy/pay/UnionPaySyncStrategy.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/sync/strategy/pay/UnionPaySyncStrategy.java index b9cb54505..c7d60c2db 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/sync/strategy/pay/UnionPaySyncStrategy.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/sync/strategy/pay/UnionPaySyncStrategy.java @@ -44,7 +44,7 @@ public PayRemoteSyncResult doSyncStatus() { * 策略标识 */ @Override - public PayChannelEnum getChannel() { - return PayChannelEnum.UNION_PAY; + public String getChannel() { + return PayChannelEnum.UNION_PAY.getCode(); } } diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/sync/strategy/pay/WeChatPaySyncStrategy.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/sync/strategy/pay/WeChatPaySyncStrategy.java index b1413c213..ba804e890 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/sync/strategy/pay/WeChatPaySyncStrategy.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/sync/strategy/pay/WeChatPaySyncStrategy.java @@ -32,8 +32,8 @@ public class WeChatPaySyncStrategy extends AbsPaySyncStrategy { * 策略标识 */ @Override - public PayChannelEnum getChannel() { - return PayChannelEnum.WECHAT; + public String getChannel() { + return PayChannelEnum.WECHAT.getCode(); } /** diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/transfer/strategy/AliPayTransferStrategy.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/transfer/strategy/AliPayTransferStrategy.java index 0e88b877b..8124c2d02 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/transfer/strategy/AliPayTransferStrategy.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/transfer/strategy/AliPayTransferStrategy.java @@ -32,9 +32,9 @@ public class AliPayTransferStrategy extends AbsTransferStrategy { /** * 策略标识 */ - @Override - public PayChannelEnum getChannel() { - return PayChannelEnum.ALI; + @Override + public String getChannel() { + return PayChannelEnum.ALI.getCode(); } /** diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/func/PayStrategy.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/func/PayStrategy.java index 2ee80f4e7..9c5475f1b 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/func/PayStrategy.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/func/PayStrategy.java @@ -1,7 +1,5 @@ package cn.daxpay.single.service.func; -import cn.daxpay.single.code.PayChannelEnum; - /** * 支付相关策略标识接口 * @author xxm @@ -11,6 +9,7 @@ public interface PayStrategy { /** * 策略标识 + * @see cn.daxpay.single.param.payment.pay.PayCancelParam */ - PayChannelEnum getChannel(); + String getChannel(); } diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/util/PayStrategyFactory.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/util/PayStrategyFactory.java new file mode 100644 index 000000000..c2f1cf7c9 --- /dev/null +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/util/PayStrategyFactory.java @@ -0,0 +1,31 @@ +package cn.daxpay.single.service.util; + +import cn.daxpay.single.exception.pay.PayUnsupportedMethodException; +import cn.daxpay.single.service.func.PayStrategy; +import cn.hutool.extra.spring.SpringUtil; +import lombok.experimental.UtilityClass; +import lombok.val; + +/** + * 策略工厂工具类 + * @author xxm + * @since 2024/6/7 + */ +@UtilityClass +public class PayStrategyFactory { + + /** + * 获取策略 + * @param channel 通道编码 + * @param clazz 策略类型 + * @return 策略类 + * @param 需要为 PayStrategy 的子类 + */ + public T create(String channel, Class clazz) { + val beansOfType = SpringUtil.getBeansOfType(clazz); + return beansOfType.values().stream() + .filter(strategy -> strategy.getChannel().equals(channel)) + .findFirst() + .orElseThrow(PayUnsupportedMethodException::new); + } +} From 91b2b3d9614190d8ebe1bef74b528e9ee229c7e8 Mon Sep 17 00:00:00 2001 From: bootx Date: Sat, 8 Jun 2024 23:22:46 +0800 Subject: [PATCH 04/34] =?UTF-8?q?ref=20=E5=88=86=E8=B4=A6=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=E7=BB=9F=E4=B8=80=E4=B8=BAAlloc,=20=E4=B8=8D=E5=8C=85?= =?UTF-8?q?=E6=8B=AC=E6=8E=A5=E5=8F=A3=E5=90=8D=E7=A7=B0,=20=E6=94=AF?= =?UTF-8?q?=E4=BB=98=E8=AE=A2=E5=8D=95=E6=8B=86=E5=88=86=E9=80=80=E6=AC=BE?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E4=B8=BA=E5=8D=95=E7=8B=AC=E7=9A=84=E5=AD=97?= =?UTF-8?q?=E6=AE=B5,=20=E7=AD=96=E7=95=A5=E5=B7=A5=E5=8E=82=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E4=B8=BA=E9=80=9A=E7=94=A8=E7=AD=96=E7=95=A5=E5=B7=A5?= =?UTF-8?q?=E5=8E=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _doc/Task.md | 4 +- .../single/sdk/code/PayChannelEnum.java | 14 ------- .../sdk/code/PayOrderRefundStatusEnum.java | 21 ++++++++++ .../sdk/model/allocation/AllocOrderModel.java | 6 +-- .../sdk/model/allocation/AllocationModel.java | 4 +- .../sdk/model/notice/AllocNoticeModel.java | 6 +-- .../sdk/model/notice/PayNoticeModel.java | 10 ++++- .../single/sdk/model/pay/PayOrderModel.java | 10 ++++- .../param/allocation/AllocFinishParam.java | 8 ++-- .../sdk/param/allocation/AllocSyncParam.java | 4 +- .../allocation/QueryAllocOrderParam.java | 4 +- .../single/sdk/allocation/AllocationTest.java | 4 +- .../single/sdk/query/QueryAllocOrderTest.java | 2 +- .../allocation/AllocationOrderController.java | 6 +-- .../payment/allocation/AllocFinishParam.java | 4 +- .../payment/allocation/AllocSyncParam.java | 4 +- .../allocation/QueryAllocOrderParam.java | 4 +- .../result/allocation/AllocationResult.java | 4 +- .../single/result/order/AllocOrderResult.java | 6 +-- .../single/result/order/PayOrderResult.java | 10 ++++- .../service/AliPayAllocationService.java | 6 +-- .../service/AliPayReconcileService.java | 3 +- .../service/UnionPayReconcileService.java | 3 +- .../service/WeChatPayAllocationService.java | 6 +-- .../service/WechatPayReconcileService.java | 3 +- .../dao/AllocationOrderManager.java | 4 +- .../allocation/entity/AllocationOrder.java | 6 +-- .../service/AllocationOrderService.java | 6 +-- .../core/order/pay/builder/PayBuilder.java | 2 +- .../core/order/pay/dao/PayOrderManager.java | 2 +- .../core/order/pay/entity/PayOrder.java | 2 +- .../allocation/factory/AllocationFactory.java | 39 ------------------- .../factory/AllocationReceiverFactory.java | 38 ------------------ .../service/AllocationCallbackService.java | 2 +- .../service/AllocationGroupService.java | 1 - .../service/AllocationReceiverService.java | 8 ++-- .../allocation/service/AllocationService.java | 38 +++++++++--------- .../service/AllocationSyncService.java | 16 ++++---- .../notice/result/AllocNoticeResult.java | 6 +-- .../notice/result/PayNoticeResult.java | 10 ++++- .../service/ClientNoticeAssistService.java | 2 +- .../payment/pay/service/PayAssistService.java | 2 +- .../reconcile/service/ReconcileService.java | 5 ++- .../transfer/factory/TransferFactory.java | 35 ----------------- .../transfer/service/TransferService.java | 5 +-- .../order/allocation/AllocationOrderDto.java | 6 +-- .../service/dto/order/pay/PayOrderDto.java | 10 ++++- .../handler/excel/PayChannelConvert.java | 1 + .../param/order/AllocationOrderQuery.java | 2 +- .../service/param/order/PayOrderQuery.java | 10 ++++- .../service/task/AllocationSyncTask.java | 2 +- 51 files changed, 177 insertions(+), 239 deletions(-) create mode 100644 daxpay-single-sdk/src/main/java/cn/daxpay/single/sdk/code/PayOrderRefundStatusEnum.java delete mode 100644 daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/allocation/factory/AllocationFactory.java delete mode 100644 daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/allocation/factory/AllocationReceiverFactory.java delete mode 100644 daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/transfer/factory/TransferFactory.java diff --git a/_doc/Task.md b/_doc/Task.md index a8363a129..5e085a915 100644 --- a/_doc/Task.md +++ b/_doc/Task.md @@ -7,13 +7,15 @@ - [ ] DEMO增加获取微信OpenID和支付宝OpenId功能 - [ ] 管理端界面支持扫码绑定对账接收方功能 - [ ] 支付通道两个独立的配置进行合并为一个 +- [ ] 平台配置和接口配置删除回调地址配置, 只保留接口参数设置 +- [ ] 接口配置删除验签配置, 放到平台配置进行统一处理 +- [x] 分账字段统一为Alloc, 不包括接口名称 - [x] 支付订单拆分退款状态为单独的字段 - [x] 策略工厂修改为通用策略工厂 - [x] 支付和退款达到终态不可以再回退回之前的状态 - [x] 修复支付关闭参数名称不正确问题 2.0.9: 消息通知改版和功能优化 - [ ] 增加类似支付宝应用通知的方式, 先支持http方式通信 -- [ ] 平台配置和接口配置删除回调地址配置, 只保留接口参数设置 - [ ] 增加支付宝和微信通知回调地址一键生成功能 2.1.x 版本内容 diff --git a/daxpay-single-sdk/src/main/java/cn/daxpay/single/sdk/code/PayChannelEnum.java b/daxpay-single-sdk/src/main/java/cn/daxpay/single/sdk/code/PayChannelEnum.java index 51e1f56c6..214e140d5 100644 --- a/daxpay-single-sdk/src/main/java/cn/daxpay/single/sdk/code/PayChannelEnum.java +++ b/daxpay-single-sdk/src/main/java/cn/daxpay/single/sdk/code/PayChannelEnum.java @@ -3,9 +3,6 @@ import lombok.Getter; import lombok.RequiredArgsConstructor; -import java.util.Arrays; -import java.util.Objects; - /** * 支付通道枚举 * @@ -26,15 +23,4 @@ public enum PayChannelEnum { /** 支付通道名称 */ private final String name; - - /** - * 根据编码获取枚举 - */ - public static PayChannelEnum findByCode(String code){ - return Arrays.stream(values()) - .filter(o -> Objects.equals(o.getCode(), code)) - .findFirst() - .orElseThrow(() -> new IllegalArgumentException("该枚举不存在")); - } - } diff --git a/daxpay-single-sdk/src/main/java/cn/daxpay/single/sdk/code/PayOrderRefundStatusEnum.java b/daxpay-single-sdk/src/main/java/cn/daxpay/single/sdk/code/PayOrderRefundStatusEnum.java new file mode 100644 index 000000000..b3edddb31 --- /dev/null +++ b/daxpay-single-sdk/src/main/java/cn/daxpay/single/sdk/code/PayOrderRefundStatusEnum.java @@ -0,0 +1,21 @@ +package cn.daxpay.single.sdk.code; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * 支付订单的退款状态 + * @author xxm + * @since 2024/6/7 + */ +@Getter +@AllArgsConstructor +public enum PayOrderRefundStatusEnum { + NO_REFUND("no_refund","未退款"), + REFUNDING("refunding","退款中"), + PARTIAL_REFUND("partial_refund","部分退款"), + REFUNDED("refunded","全部退款"), + ; + private final String code; + private final String name; +} diff --git a/daxpay-single-sdk/src/main/java/cn/daxpay/single/sdk/model/allocation/AllocOrderModel.java b/daxpay-single-sdk/src/main/java/cn/daxpay/single/sdk/model/allocation/AllocOrderModel.java index 36b0e4ba1..996aabf0a 100644 --- a/daxpay-single-sdk/src/main/java/cn/daxpay/single/sdk/model/allocation/AllocOrderModel.java +++ b/daxpay-single-sdk/src/main/java/cn/daxpay/single/sdk/model/allocation/AllocOrderModel.java @@ -22,13 +22,13 @@ public class AllocOrderModel extends DaxPayResponseModel { /** 分账单号 */ - private String allocationNo; + private String allocNo; /** 商户分账单号 */ - private String bizAllocationNo; + private String bizAllocNo; /** 通道分账号 */ - private String outAllocationNo; + private String outAllocNo; /** 支付订单号 */ private String orderNo; diff --git a/daxpay-single-sdk/src/main/java/cn/daxpay/single/sdk/model/allocation/AllocationModel.java b/daxpay-single-sdk/src/main/java/cn/daxpay/single/sdk/model/allocation/AllocationModel.java index 96ffbe808..ecd65e636 100644 --- a/daxpay-single-sdk/src/main/java/cn/daxpay/single/sdk/model/allocation/AllocationModel.java +++ b/daxpay-single-sdk/src/main/java/cn/daxpay/single/sdk/model/allocation/AllocationModel.java @@ -17,10 +17,10 @@ public class AllocationModel extends DaxPayResponseModel { /** 分账订单号 */ - private String allocationNo; + private String allocNo; /** 分账订单号 */ - private String bizAllocationNo; + private String bizAllocNo; /** * 分账状态 diff --git a/daxpay-single-sdk/src/main/java/cn/daxpay/single/sdk/model/notice/AllocNoticeModel.java b/daxpay-single-sdk/src/main/java/cn/daxpay/single/sdk/model/notice/AllocNoticeModel.java index 0f0492a4a..7b289e0aa 100644 --- a/daxpay-single-sdk/src/main/java/cn/daxpay/single/sdk/model/notice/AllocNoticeModel.java +++ b/daxpay-single-sdk/src/main/java/cn/daxpay/single/sdk/model/notice/AllocNoticeModel.java @@ -22,17 +22,17 @@ public class AllocNoticeModel extends DaxPayResponseModel { /** * 分账单号 */ - private String allocationNo; + private String allocNo; /** * 商户分账单号 */ - private String bizAllocationNo; + private String bizAllocNo; /** * 通道分账号 */ - private String outAllocationNo; + private String outAllocNo; /** * 支付订单号 diff --git a/daxpay-single-sdk/src/main/java/cn/daxpay/single/sdk/model/notice/PayNoticeModel.java b/daxpay-single-sdk/src/main/java/cn/daxpay/single/sdk/model/notice/PayNoticeModel.java index e17653e05..f01747ef9 100644 --- a/daxpay-single-sdk/src/main/java/cn/daxpay/single/sdk/model/notice/PayNoticeModel.java +++ b/daxpay-single-sdk/src/main/java/cn/daxpay/single/sdk/model/notice/PayNoticeModel.java @@ -2,6 +2,7 @@ import cn.daxpay.single.sdk.code.PayChannelEnum; import cn.daxpay.single.sdk.code.PayOrderAllocStatusEnum; +import cn.daxpay.single.sdk.code.PayOrderRefundStatusEnum; import cn.daxpay.single.sdk.code.PayStatusEnum; import cn.daxpay.single.sdk.net.DaxPayResponseModel; import lombok.Getter; @@ -56,11 +57,18 @@ public class PayNoticeModel extends DaxPayResponseModel { */ private String status; + + /** + * 退款状态 + * @see PayOrderRefundStatusEnum + */ + private String refundStatus; + /** * 分账状态 * @see PayOrderAllocStatusEnum */ - private String allocationStatus; + private String allocStatus; /** 支付成功时间 */ private Long payTime; diff --git a/daxpay-single-sdk/src/main/java/cn/daxpay/single/sdk/model/pay/PayOrderModel.java b/daxpay-single-sdk/src/main/java/cn/daxpay/single/sdk/model/pay/PayOrderModel.java index decf9c4ac..e035de888 100644 --- a/daxpay-single-sdk/src/main/java/cn/daxpay/single/sdk/model/pay/PayOrderModel.java +++ b/daxpay-single-sdk/src/main/java/cn/daxpay/single/sdk/model/pay/PayOrderModel.java @@ -2,6 +2,7 @@ import cn.daxpay.single.sdk.code.PayChannelEnum; import cn.daxpay.single.sdk.code.PayOrderAllocStatusEnum; +import cn.daxpay.single.sdk.code.PayOrderRefundStatusEnum; import cn.daxpay.single.sdk.code.PayStatusEnum; import cn.daxpay.single.sdk.net.DaxPayResponseModel; import lombok.Getter; @@ -18,7 +19,6 @@ @ToString(callSuper = true) public class PayOrderModel extends DaxPayResponseModel { - /** 订单号 */ private String orderNo; @@ -63,11 +63,17 @@ public class PayOrderModel extends DaxPayResponseModel { */ private String status; + /** + * 退款状态 + * @see PayOrderRefundStatusEnum + */ + private String refundStatus; + /** * 分账状态 * @see PayOrderAllocStatusEnum */ - private String allocationStatus; + private String allocStatus; /** 支付时间 */ diff --git a/daxpay-single-sdk/src/main/java/cn/daxpay/single/sdk/param/allocation/AllocFinishParam.java b/daxpay-single-sdk/src/main/java/cn/daxpay/single/sdk/param/allocation/AllocFinishParam.java index bb7e887c5..37253cf47 100644 --- a/daxpay-single-sdk/src/main/java/cn/daxpay/single/sdk/param/allocation/AllocFinishParam.java +++ b/daxpay-single-sdk/src/main/java/cn/daxpay/single/sdk/param/allocation/AllocFinishParam.java @@ -17,11 +17,11 @@ @Data public class AllocFinishParam extends DaxPayRequest { - /** 商户分账单号 */ - private String bizAllocationNo; - /** 分账单号 */ - private String allocationNo; + private String allocNo; + + /** 商户分账单号 */ + private String bizAllocNo; /** * 方法请求路径 diff --git a/daxpay-single-sdk/src/main/java/cn/daxpay/single/sdk/param/allocation/AllocSyncParam.java b/daxpay-single-sdk/src/main/java/cn/daxpay/single/sdk/param/allocation/AllocSyncParam.java index efda2cb37..b61b37ab4 100644 --- a/daxpay-single-sdk/src/main/java/cn/daxpay/single/sdk/param/allocation/AllocSyncParam.java +++ b/daxpay-single-sdk/src/main/java/cn/daxpay/single/sdk/param/allocation/AllocSyncParam.java @@ -18,10 +18,10 @@ public class AllocSyncParam extends DaxPayRequest { /** 分账号 */ - private String allocationNo; + private String allocNo; /** 商户分账号 */ - private String bizAllocationNo; + private String bizAllocNo; @Override public String path() { diff --git a/daxpay-single-sdk/src/main/java/cn/daxpay/single/sdk/param/allocation/QueryAllocOrderParam.java b/daxpay-single-sdk/src/main/java/cn/daxpay/single/sdk/param/allocation/QueryAllocOrderParam.java index ff482e8de..d8f3efddc 100644 --- a/daxpay-single-sdk/src/main/java/cn/daxpay/single/sdk/param/allocation/QueryAllocOrderParam.java +++ b/daxpay-single-sdk/src/main/java/cn/daxpay/single/sdk/param/allocation/QueryAllocOrderParam.java @@ -18,10 +18,10 @@ public class QueryAllocOrderParam extends DaxPayRequest { /** 分账单号 */ - private String allocationNo; + private String allocNo; /** 商户分账单号 */ - private String bizAllocationNo; + private String bizAllocNo; /** * 方法请求路径 diff --git a/daxpay-single-sdk/src/test/java/cn/daxpay/single/sdk/allocation/AllocationTest.java b/daxpay-single-sdk/src/test/java/cn/daxpay/single/sdk/allocation/AllocationTest.java index 4e9c6fdd3..d4ccfc36b 100644 --- a/daxpay-single-sdk/src/test/java/cn/daxpay/single/sdk/allocation/AllocationTest.java +++ b/daxpay-single-sdk/src/test/java/cn/daxpay/single/sdk/allocation/AllocationTest.java @@ -149,7 +149,7 @@ public void allocationOpenByReceivers() { public void allocationFinish() { // 分账完结参数 AllocFinishParam param = new AllocFinishParam(); - param.setAllocationNo("DEVA24060117191963000003"); + param.setAllocNo("DEVA24060117191963000003"); DaxPayResult execute = DaxPayKit.execute(param); System.out.println(JSONUtil.toJsonStr(execute)); @@ -162,7 +162,7 @@ public void allocationFinish() { public void allocationSync() { // 分账同步参数 AllocSyncParam param = new AllocSyncParam(); - param.setAllocationNo("DEVA24060117191963000003"); + param.setAllocNo("DEVA24060117191963000003"); DaxPayResult execute = DaxPayKit.execute(param); System.out.println(JSONUtil.toJsonStr(execute)); diff --git a/daxpay-single-sdk/src/test/java/cn/daxpay/single/sdk/query/QueryAllocOrderTest.java b/daxpay-single-sdk/src/test/java/cn/daxpay/single/sdk/query/QueryAllocOrderTest.java index d7c98c2c9..3ce113a53 100644 --- a/daxpay-single-sdk/src/test/java/cn/daxpay/single/sdk/query/QueryAllocOrderTest.java +++ b/daxpay-single-sdk/src/test/java/cn/daxpay/single/sdk/query/QueryAllocOrderTest.java @@ -37,7 +37,7 @@ public void init() { @Test public void queryAllocOrder() { QueryAllocOrderParam param = new QueryAllocOrderParam(); - param.setAllocationNo("DEVA240602000243630000101"); + param.setAllocNo("DEVA240602000243630000101"); param.setClientIp("127.0.0.1"); DaxPayResult execute = DaxPayKit.execute(param); System.out.println(JSONUtil.toJsonStr(execute)); 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 11aad17e9..11842d430 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 @@ -88,9 +88,9 @@ public ResResult> findChannels(){ @InitPaymentContext(PaymentApiCode.SYNC_ALLOCATION) @Operation(summary = "同步分账结果") @PostMapping("/sync") - public ResResult sync(String allocationNo){ + public ResResult sync(String allocNo){ AllocSyncParam param = new AllocSyncParam(); - param.setAllocationNo(allocationNo); + param.setAllocNo(allocNo); allocationSyncService.sync(param); return Res.ok(); } @@ -100,7 +100,7 @@ public ResResult sync(String allocationNo){ @PostMapping("/finish") public ResResult finish(String allocationNo){ AllocFinishParam param = new AllocFinishParam(); - param.setAllocationNo(allocationNo); + param.setAllocNo(allocationNo); allocationService.finish(param); return Res.ok(); } diff --git a/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/param/payment/allocation/AllocFinishParam.java b/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/param/payment/allocation/AllocFinishParam.java index 57b9bfe26..4ad4cd625 100644 --- a/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/param/payment/allocation/AllocFinishParam.java +++ b/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/param/payment/allocation/AllocFinishParam.java @@ -16,8 +16,8 @@ public class AllocFinishParam extends PaymentCommonParam { @Schema(description = "商户分账单号") - private String bizAllocationNo; + private String bizAllocNo; @Schema(description = "分账单号") - private String allocationNo; + private String allocNo; } diff --git a/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/param/payment/allocation/AllocSyncParam.java b/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/param/payment/allocation/AllocSyncParam.java index b01508a00..9b863f4b0 100644 --- a/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/param/payment/allocation/AllocSyncParam.java +++ b/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/param/payment/allocation/AllocSyncParam.java @@ -16,8 +16,8 @@ public class AllocSyncParam extends PaymentCommonParam { @Schema(description = "分账号") - private String allocationNo; + private String allocNo; @Schema(description = "商户分账号") - private String bizAllocationNo; + private String bizAllocNo; } diff --git a/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/param/payment/allocation/QueryAllocOrderParam.java b/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/param/payment/allocation/QueryAllocOrderParam.java index 6ba1a7886..f43aa85c4 100644 --- a/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/param/payment/allocation/QueryAllocOrderParam.java +++ b/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/param/payment/allocation/QueryAllocOrderParam.java @@ -16,8 +16,8 @@ public class QueryAllocOrderParam extends PaymentCommonParam { @Schema(description = "分账单号") - private String allocationNo; + private String allocNo; @Schema(description = "商户分账单号") - private String bizAllocationNo; + private String bizAllocNo; } diff --git a/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/result/allocation/AllocationResult.java b/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/result/allocation/AllocationResult.java index ca0444cca..832e528e7 100644 --- a/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/result/allocation/AllocationResult.java +++ b/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/result/allocation/AllocationResult.java @@ -20,11 +20,11 @@ public class AllocationResult extends PaymentCommonResult { /** 分账订单号 */ @Schema(description = "分账订单号") - private String allocationNo; + private String allocNo; /** 商户分账订单号 */ @Schema(description = "商户分账订单号") - private String bizAllocationNo; + private String bizAllocNo; /** * 分账状态 diff --git a/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/result/order/AllocOrderResult.java b/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/result/order/AllocOrderResult.java index 2ab85ea4b..a9b1014f9 100644 --- a/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/result/order/AllocOrderResult.java +++ b/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/result/order/AllocOrderResult.java @@ -25,15 +25,15 @@ public class AllocOrderResult extends PaymentCommonResult { /** 分账单号 */ @Schema(description = "分账单号") - private String allocationNo; + private String allocNo; /** 商户分账单号 */ @Schema(description = "商户分账单号") - private String bizAllocationNo; + private String bizAllocNo; /** 通道分账号 */ @Schema(description = "通道分账号") - private String outAllocationNo; + private String outAllocNo; /** * 支付订单号 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 d7bdbb577..a73c460fb 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 @@ -2,6 +2,7 @@ import cn.daxpay.single.code.PayChannelEnum; import cn.daxpay.single.code.PayOrderAllocStatusEnum; +import cn.daxpay.single.code.PayOrderRefundStatusEnum; import cn.daxpay.single.code.PayStatusEnum; import cn.daxpay.single.result.PaymentCommonResult; import cn.daxpay.single.serializer.LocalDateTimeToTimestampSerializer; @@ -79,12 +80,19 @@ public class PayOrderResult extends PaymentCommonResult { @Schema(description = "支付状态") private String status; + /** + * 退款状态 + * @see PayOrderRefundStatusEnum + */ + @Schema(description = "退款状态") + private String refundStatus; + /** * 分账状态 * @see PayOrderAllocStatusEnum */ @Schema(description = "分账状态") - private String allocationStatus; + private String allocStatus; /** 支付时间 */ @Schema(description = "支付时间") 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 314b22c63..dd2985a5c 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 @@ -49,7 +49,7 @@ public class AliPayAllocationService { public void allocation(AllocationOrder allocationOrder, List orderDetails){ // 分账主体参数 AlipayTradeOrderSettleModel model = new AlipayTradeOrderSettleModel(); - model.setOutRequestNo(allocationOrder.getAllocationNo()); + model.setOutRequestNo(allocationOrder.getAllocNo()); model.setTradeNo(allocationOrder.getOutOrderNo()); model.setRoyaltyMode(AliPayCode.ALLOC_ASYNC); @@ -79,7 +79,7 @@ public void allocation(AllocationOrder allocationOrder, List orderDetails ){ // 分账主体参数 AlipayTradeOrderSettleModel model = new AlipayTradeOrderSettleModel(); - model.setOutRequestNo(String.valueOf(allocationOrder.getAllocationNo())); + model.setOutRequestNo(String.valueOf(allocationOrder.getAllocNo())); model.setTradeNo(allocationOrder.getOutOrderNo()); model.setRoyaltyMode(AliPayCode.ALLOC_ASYNC); // 分账完结参数 @@ -109,7 +109,7 @@ public void finish(AllocationOrder allocationOrder, List public AllocRemoteSyncResult sync(AllocationOrder allocationOrder, List allocationOrderDetails){ AlipayTradeOrderSettleQueryModel model = new AlipayTradeOrderSettleQueryModel(); model.setTradeNo(allocationOrder.getOutOrderNo()); - model.setOutRequestNo(allocationOrder.getAllocationNo()); + model.setOutRequestNo(allocationOrder.getAllocNo()); AlipayTradeOrderSettleQueryRequest request = new AlipayTradeOrderSettleQueryRequest(); request.setBizModel(model); AlipayTradeOrderSettleQueryResponse response = AliPayApi.execute(request); diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/channel/alipay/service/AliPayReconcileService.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/channel/alipay/service/AliPayReconcileService.java index 0d71396d0..aaeb7be97 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/channel/alipay/service/AliPayReconcileService.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/channel/alipay/service/AliPayReconcileService.java @@ -239,10 +239,9 @@ private List parseTotal(List list){ */ private void saveOriginalFile(ReconcileOrder reconcileOrder, byte[] bytes) { // 将原始文件进行保存 - PayChannelEnum channelEnum = PayChannelEnum.findByCode(reconcileOrder.getChannel()); String date = LocalDateTimeUtil.format(reconcileOrder.getDate(), DatePattern.PURE_DATE_PATTERN); // 将原始文件进行保存 通道-日期 - String fileName = StrUtil.format("交易对账单-{}-{}.csv", channelEnum.getName(),date); + String fileName = StrUtil.format("交易对账单-支付宝-{}.csv",date); UploadPretreatment uploadPretreatment = fileStorageService.of(bytes); if (StrUtil.isNotBlank(fileName)) { uploadPretreatment.setOriginalFilename(fileName); diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/channel/union/service/UnionPayReconcileService.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/channel/union/service/UnionPayReconcileService.java index 169c56af3..44722bc43 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/channel/union/service/UnionPayReconcileService.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/channel/union/service/UnionPayReconcileService.java @@ -210,10 +210,9 @@ private void save(List billDetails){ * 保存下载的原始对账文件 */ private void saveOriginalFile(ReconcileOrder reconcileOrder, byte[] bytes) { - PayChannelEnum channelEnum = PayChannelEnum.findByCode(reconcileOrder.getChannel()); String date = LocalDateTimeUtil.format(reconcileOrder.getDate(), DatePattern.PURE_DATE_PATTERN); // 将原始文件进行保存 通道-日期 - String fileName = StrUtil.format("交易对账单-{}-{}.txt", channelEnum.getName(),date); + String fileName = StrUtil.format("交易对账单-云闪付-{}.txt",date); UploadPretreatment uploadPretreatment = fileStorageService.of(bytes); if (StrUtil.isNotBlank(fileName)) { uploadPretreatment.setOriginalFilename(fileName); 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 ab0e47b6b..c27a9d2df 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 @@ -75,7 +75,7 @@ public void allocation(AllocationOrder allocationOrder, List findByAllocationNo(String allocationNo){ - return findByField(AllocationOrder::getAllocationNo, allocationNo); + return findByField(AllocationOrder::getAllocNo, allocationNo); } /** * 根据商户分账号查询 */ public Optional findByBizAllocationNo(String bizAllocationNo){ - return findByField(AllocationOrder::getBizAllocationNo, bizAllocationNo); + return findByField(AllocationOrder::getBizAllocNo, bizAllocationNo); } /** 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/AllocationOrder.java index e5b900b5f..879e6ae8c 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/AllocationOrder.java @@ -34,19 +34,19 @@ public class AllocationOrder extends MpBaseEntity implements EntityBaseFunction< * 分账单号 */ @DbColumn(comment = "分账单号") - private String allocationNo; + private String allocNo; /** * 商户分账单号 */ @DbColumn(comment = "商户分账单号") - private String bizAllocationNo; + private String bizAllocNo; /** * 通道分账号 */ @DbColumn(comment = "通道分账号") - private String outAllocationNo; + private String outAllocNo; /** 支付订单ID */ @DbColumn(comment = "支付订单ID") 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/AllocationOrderService.java index c6cf4b27c..7692b5a95 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/AllocationOrderService.java @@ -164,8 +164,8 @@ private OrderAndDetail saveAllocOrder(AllocationParam param, PayOrder payOrder, .setBizOrderNo(payOrder.getBizOrderNo()) .setOutOrderNo(payOrder.getOutOrderNo()) .setTitle(payOrder.getTitle()) - .setAllocationNo(OrderNoGenerateUtil.allocation()) - .setBizAllocationNo(param.getBizAllocationNo()) + .setAllocNo(OrderNoGenerateUtil.allocation()) + .setBizAllocNo(param.getBizAllocationNo()) .setChannel(payOrder.getChannel()) .setDescription(param.getDescription()) .setStatus(AllocOrderStatusEnum.ALLOCATION_PROCESSING.getCode()) @@ -187,7 +187,7 @@ private OrderAndDetail saveAllocOrder(AllocationParam param, PayOrder payOrder, extend.setId(allocId); // 更新支付订单分账状态 - payOrder.setAllocationStatus(PayOrderAllocStatusEnum.ALLOCATION.getCode()); + payOrder.setAllocStatus(PayOrderAllocStatusEnum.ALLOCATION.getCode()); payOrderManager.updateById(payOrder); allocationOrderDetailManager.saveAll(details); allocationOrderExtraManager.save(extend); diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/pay/builder/PayBuilder.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/pay/builder/PayBuilder.java index 85e6a34a1..2a1d37414 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/pay/builder/PayBuilder.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/pay/builder/PayBuilder.java @@ -48,7 +48,7 @@ public PayOrder buildPayOrder(PayParam payParam) { .setRefundableBalance(payParam.getAmount()); // 如果支持分账, 设置分账状态为代分账 if (payOrder.getAllocation()) { - payOrder.setAllocationStatus(PayOrderAllocStatusEnum.WAITING.getCode()); + payOrder.setAllocStatus(PayOrderAllocStatusEnum.WAITING.getCode()); } return payOrder; } diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/pay/dao/PayOrderManager.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/pay/dao/PayOrderManager.java index 6f6cae729..58d734c08 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/pay/dao/PayOrderManager.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/pay/dao/PayOrderManager.java @@ -71,7 +71,7 @@ public List findAutoAllocation() { return this.lambdaQuery() .eq(PayOrder::getAllocation, true) .eq(PayOrder::getAutoAllocation, true) - .eq(PayOrder::getAllocationStatus, PayOrderAllocStatusEnum.WAITING.getCode()) + .eq(PayOrder::getAllocStatus, PayOrderAllocStatusEnum.WAITING.getCode()) .eq(PayOrder::getStatus, PayStatusEnum.SUCCESS.getCode()) .list(); } 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 df3fa2440..f4a99e2bb 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 @@ -106,7 +106,7 @@ public class PayOrder extends MpBaseEntity implements EntityBaseFunction findReceiversByGroups(Long groupId){ * 创建分账组 */ public void create(AllocationGroupParam param){ - PayChannelEnum.findByCode(param.getChannel()); AllocationGroup group = AllocationGroupConvert.CONVERT.convert(param); group.setTotalRate(0); groupManager.save(group); diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/allocation/service/AllocationReceiverService.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/allocation/service/AllocationReceiverService.java index 0ebf81850..8b9473e32 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/allocation/service/AllocationReceiverService.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/allocation/service/AllocationReceiverService.java @@ -20,10 +20,10 @@ import cn.daxpay.single.service.core.payment.allocation.dao.AllocationGroupReceiverManager; import cn.daxpay.single.service.core.payment.allocation.dao.AllocationReceiverManager; import cn.daxpay.single.service.core.payment.allocation.entity.AllocationReceiver; -import cn.daxpay.single.service.core.payment.allocation.factory.AllocationReceiverFactory; import cn.daxpay.single.service.dto.allocation.AllocationReceiverDto; import cn.daxpay.single.service.func.AbsAllocationReceiverStrategy; import cn.daxpay.single.service.param.allocation.receiver.AllocationReceiverQuery; +import cn.daxpay.single.service.util.PayStrategyFactory; import cn.hutool.core.util.StrUtil; import com.baomidou.lock.LockInfo; import com.baomidou.lock.LockTemplate; @@ -120,8 +120,7 @@ public AllocReceiverAddResult addAndSync(AllocReceiverAddParam param){ } AllocationReceiver receiver = AllocationReceiverConvert.CONVERT.convert(param); // 获取策略 - PayChannelEnum channelEnum = PayChannelEnum.findByCode(param.getChannel()); - AbsAllocationReceiverStrategy receiverStrategy = AllocationReceiverFactory.create(channelEnum); + AbsAllocationReceiverStrategy receiverStrategy = PayStrategyFactory.create(param.getChannel(), AbsAllocationReceiverStrategy.class); // 校验 receiverStrategy.setAllocationReceiver(receiver); if (!receiverStrategy.validation()){ @@ -148,8 +147,7 @@ public AllocReceiverRemoveResult remove(AllocReceiverRemoveParam param){ throw new PayFailureException("该接收方已被使用,无法被删除"); } // 获取策略 - PayChannelEnum channelEnum = PayChannelEnum.findByCode(receiver.getChannel()); - AbsAllocationReceiverStrategy receiverStrategy = AllocationReceiverFactory.create(channelEnum); + AbsAllocationReceiverStrategy receiverStrategy = PayStrategyFactory.create(receiver.getChannel(), AbsAllocationReceiverStrategy.class); LockInfo lock = lockTemplate.lock("payment:receiver:" + param.getReceiverNo(),10000,200); if (Objects.isNull(lock)){ throw new PayFailureException("分账方处理中,请勿重复操作"); diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/allocation/service/AllocationService.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/allocation/service/AllocationService.java index e0d037851..0c12a9c43 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/allocation/service/AllocationService.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/allocation/service/AllocationService.java @@ -11,9 +11,9 @@ import cn.daxpay.single.param.payment.allocation.AllocFinishParam; import cn.daxpay.single.param.payment.allocation.AllocationParam; import cn.daxpay.single.param.payment.allocation.QueryAllocOrderParam; +import cn.daxpay.single.result.allocation.AllocationResult; import cn.daxpay.single.result.order.AllocOrderDetailResult; import cn.daxpay.single.result.order.AllocOrderResult; -import cn.daxpay.single.result.allocation.AllocationResult; import cn.daxpay.single.service.common.local.PaymentContextLocal; import cn.daxpay.single.service.core.order.allocation.convert.AllocationConvert; import cn.daxpay.single.service.core.order.allocation.dao.AllocationOrderDetailManager; @@ -28,9 +28,9 @@ import cn.daxpay.single.service.core.order.pay.service.PayOrderQueryService; import cn.daxpay.single.service.core.payment.allocation.dao.AllocationGroupManager; import cn.daxpay.single.service.core.payment.allocation.entity.AllocationGroup; -import cn.daxpay.single.service.core.payment.allocation.factory.AllocationFactory; import cn.daxpay.single.service.dto.allocation.AllocationGroupReceiverResult; import cn.daxpay.single.service.func.AbsAllocationStrategy; +import cn.daxpay.single.service.util.PayStrategyFactory; import com.baomidou.lock.LockInfo; import com.baomidou.lock.LockTemplate; import lombok.RequiredArgsConstructor; @@ -111,13 +111,13 @@ public AllocationResult allocation(AllocationParam param, PayOrder payOrder) { // 无需进行分账, if (Objects.equals(order.getStatus(),AllocOrderStatusEnum.IGNORE.getCode())){ return new AllocationResult() - .setAllocationNo(order.getAllocationNo()) - .setBizAllocationNo(order.getBizAllocationNo()) + .setAllocNo(order.getAllocNo()) + .setBizAllocNo(order.getBizAllocNo()) .setStatus(order.getStatus()); } // 创建分账策略并初始化 - AbsAllocationStrategy allocationStrategy = AllocationFactory.create(payOrder.getChannel()); + AbsAllocationStrategy allocationStrategy = PayStrategyFactory.create(payOrder.getChannel(),AbsAllocationStrategy.class); allocationStrategy.initParam(order, details); try { // 分账预处理 @@ -139,11 +139,11 @@ public AllocationResult allocation(AllocationParam param, PayOrder payOrder) { String outAllocationNo = PaymentContextLocal.get() .getAllocationInfo() .getOutAllocationNo(); - order.setOutAllocationNo(outAllocationNo); + order.setOutAllocNo(outAllocationNo); allocationOrderManager.updateById(order); return new AllocationResult() - .setAllocationNo(order.getAllocationNo()) - .setBizAllocationNo(order.getBizAllocationNo()) + .setAllocNo(order.getAllocNo()) + .setBizAllocNo(order.getBizAllocNo()) .setStatus(order.getStatus()); } finally { lockTemplate.releaseLock(lock); @@ -168,7 +168,7 @@ private AllocationResult retryAllocation(AllocationParam param, AllocationOrder } List details = this.getDetails(order.getId()); // 创建分账策略并初始化 - AbsAllocationStrategy allocationStrategy = AllocationFactory.create(order.getChannel()); + AbsAllocationStrategy allocationStrategy = PayStrategyFactory.create(order.getChannel(),AbsAllocationStrategy.class); allocationStrategy.initParam(order, details); // 分账预处理 allocationStrategy.doBeforeHandler(); @@ -191,8 +191,8 @@ private AllocationResult retryAllocation(AllocationParam param, AllocationOrder } allocationOrderManager.updateById(order); return new AllocationResult() - .setAllocationNo(order.getAllocationNo()) - .setBizAllocationNo(order.getBizAllocationNo()) + .setAllocNo(order.getAllocNo()) + .setBizAllocNo(order.getBizAllocNo()) .setStatus(order.getStatus()); } finally { lockTemplate.releaseLock(lock); @@ -204,11 +204,11 @@ private AllocationResult retryAllocation(AllocationParam param, AllocationOrder */ public AllocationResult finish(AllocFinishParam param) { AllocationOrder allocationOrder; - if (Objects.nonNull(param.getAllocationNo())){ - allocationOrder = allocationOrderManager.findByAllocationNo(param.getAllocationNo()) + if (Objects.nonNull(param.getAllocNo())){ + allocationOrder = allocationOrderManager.findByAllocationNo(param.getAllocNo()) .orElseThrow(() -> new DataNotExistException("未查询到分账单信息")); } else { - allocationOrder = allocationOrderManager.findByBizAllocationNo(param.getBizAllocationNo()) + allocationOrder = allocationOrderManager.findByBizAllocationNo(param.getBizAllocNo()) .orElseThrow(() -> new DataNotExistException("未查询到分账单信息")); } return this.finish(allocationOrder); @@ -225,7 +225,7 @@ public AllocationResult finish(AllocationOrder allocationOrder) { List details = this.getDetails(allocationOrder.getId()); // 创建分账策略并初始化 - AbsAllocationStrategy allocationStrategy = AllocationFactory.create(allocationOrder.getChannel()); + AbsAllocationStrategy allocationStrategy = PayStrategyFactory.create(allocationOrder.getChannel(),AbsAllocationStrategy.class); allocationStrategy.initParam(allocationOrder, details); // 分账完结预处理 @@ -245,8 +245,8 @@ public AllocationResult finish(AllocationOrder allocationOrder) { } allocationOrderManager.updateById(allocationOrder); return new AllocationResult() - .setAllocationNo(allocationOrder.getAllocationNo()) - .setBizAllocationNo(allocationOrder.getBizAllocationNo()) + .setAllocNo(allocationOrder.getAllocNo()) + .setBizAllocNo(allocationOrder.getBizAllocNo()) .setStatus(allocationOrder.getStatus()); } @@ -262,7 +262,7 @@ private PayOrder getAndCheckPayOrder(AllocationParam param) { throw new PayFailureException("该订单不允许分账"); } // 判断分账状态 - if (Objects.equals(PayOrderAllocStatusEnum.ALLOCATION.getCode(), payOrder.getAllocationStatus())){ + if (Objects.equals(PayOrderAllocStatusEnum.ALLOCATION.getCode(), payOrder.getAllocStatus())){ throw new PayFailureException("该订单已分账完成"); } return payOrder; @@ -273,7 +273,7 @@ private PayOrder getAndCheckPayOrder(AllocationParam param) { */ public AllocOrderResult queryAllocationOrder(QueryAllocOrderParam param) { // 查询分账单 - AllocationOrder allocationOrder = allocationOrderManager.findByAllocationNo(param.getAllocationNo()) + AllocationOrder allocationOrder = allocationOrderManager.findByAllocationNo(param.getAllocNo()) .orElseThrow(() -> new PayFailureException("分账单不存在")); AllocOrderResult result = AllocationConvert.CONVERT.toResult(allocationOrder); // 查询分账单明细 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 c4dd93084..1ac347f21 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 @@ -13,12 +13,12 @@ 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.payment.allocation.factory.AllocationFactory; 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; import cn.daxpay.single.service.core.record.sync.service.PaySyncRecordService; import cn.daxpay.single.service.func.AbsAllocationStrategy; +import cn.daxpay.single.service.util.PayStrategyFactory; import com.baomidou.lock.LockInfo; import com.baomidou.lock.LockTemplate; import lombok.RequiredArgsConstructor; @@ -58,12 +58,12 @@ public class AllocationSyncService { public AllocSyncResult sync(AllocSyncParam param) { // 获取分账订单 AllocationOrder allocationOrder = null; - if (Objects.nonNull(param.getAllocationNo())){ - allocationOrder = allocationOrderManager.findByAllocationNo(param.getAllocationNo()) + if (Objects.nonNull(param.getAllocNo())){ + allocationOrder = allocationOrderManager.findByAllocationNo(param.getAllocNo()) .orElseThrow(() -> new DataNotExistException("分账单不存在")); } if (Objects.isNull(allocationOrder)){ - allocationOrder = allocationOrderManager.findByAllocationNo(param.getBizAllocationNo()) + allocationOrder = allocationOrderManager.findByAllocationNo(param.getBizAllocNo()) .orElseThrow(() -> new DataNotExistException("分账单不存在")); } // 如果类型为忽略, 不进行同步处理 @@ -87,7 +87,7 @@ public void sync(AllocationOrder allocationOrder){ try { List detailList = allocationOrderDetailManager.findAllByOrderId(allocationOrder.getId()); // 获取分账策略 - AbsAllocationStrategy allocationStrategy = AllocationFactory.create(allocationOrder.getChannel()); + AbsAllocationStrategy allocationStrategy = PayStrategyFactory.create(allocationOrder.getChannel(),AbsAllocationStrategy.class); allocationStrategy.initParam(allocationOrder, detailList); // 分账完结预处理 allocationStrategy.doBeforeHandler(); @@ -159,9 +159,9 @@ private void updateOrderStatus(AllocationOrder allocationOrder, List downOriginal2Csv(Long id){ // 设置header信息 HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.APPLICATION_OCTET_STREAM); - + // TODO 后续使用数据库中数据 PayChannelEnum channelEnum = PayChannelEnum.findByCode(reconcileOrder.getChannel()); String date = LocalDateTimeUtil.format(reconcileOrder.getDate(), DatePattern.PURE_DATE_PATTERN); // 将原始文件进行保存 通道-日期 @@ -284,7 +284,7 @@ public ResponseEntity downLocalCsv(Long id){ byte[] bytes = byteArrayOutputStream.toByteArray();// 设置header信息 HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.APPLICATION_OCTET_STREAM); - + // TODO 后续使用数据库中数据 PayChannelEnum channelEnum = PayChannelEnum.findByCode(reconcileOrder.getChannel()); String date = LocalDateTimeUtil.format(reconcileOrder.getDate(), DatePattern.PURE_DATE_PATTERN); // 将原始文件进行保存 通道-日期 @@ -316,6 +316,7 @@ public ResponseEntity downDiffCsv(Long id){ HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.APPLICATION_OCTET_STREAM); + // TODO 后续使用数据库中数据 PayChannelEnum channelEnum = PayChannelEnum.findByCode(reconcileOrder.getChannel()); String date = LocalDateTimeUtil.format(reconcileOrder.getDate(), DatePattern.PURE_DATE_PATTERN); // 将原始文件进行保存 通道-日期 diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/transfer/factory/TransferFactory.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/transfer/factory/TransferFactory.java deleted file mode 100644 index ca6ed388d..000000000 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/transfer/factory/TransferFactory.java +++ /dev/null @@ -1,35 +0,0 @@ -package cn.daxpay.single.service.core.payment.transfer.factory; - -import cn.daxpay.single.code.PayChannelEnum; -import cn.daxpay.single.exception.pay.PayUnsupportedMethodException; -import cn.daxpay.single.service.core.payment.transfer.strategy.AliPayTransferStrategy; -import cn.daxpay.single.service.func.AbsTransferStrategy; -import cn.hutool.extra.spring.SpringUtil; -import lombok.experimental.UtilityClass; - -/** - * 转账工具类 - * @author xxm - * @since 2024/3/21 - */ -@UtilityClass -public class TransferFactory { - - /** - * 获取转账策略 - * @param channelCode 支付通道编码 - * @return 支付同步策略类 - */ - public AbsTransferStrategy create(String channelCode) { - AbsTransferStrategy strategy; - PayChannelEnum channelEnum = PayChannelEnum.findByCode(channelCode); - switch (channelEnum) { - case ALI: - strategy = SpringUtil.getBean(AliPayTransferStrategy.class); - break; - default: - throw new PayUnsupportedMethodException(); - } - return strategy; - } -} diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/transfer/service/TransferService.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/transfer/service/TransferService.java index f5f154226..179b410a8 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/transfer/service/TransferService.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/transfer/service/TransferService.java @@ -1,13 +1,12 @@ package cn.daxpay.single.service.core.payment.transfer.service; -import cn.daxpay.single.code.PayChannelEnum; import cn.daxpay.single.code.RefundStatusEnum; import cn.daxpay.single.param.payment.transfer.TransferParam; import cn.daxpay.single.result.transfer.TransferResult; import cn.daxpay.single.service.common.local.PaymentContextLocal; import cn.daxpay.single.service.core.order.transfer.entity.TransferOrder; -import cn.daxpay.single.service.core.payment.transfer.factory.TransferFactory; import cn.daxpay.single.service.func.AbsTransferStrategy; +import cn.daxpay.single.service.util.PayStrategyFactory; import cn.hutool.extra.spring.SpringUtil; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -31,7 +30,7 @@ public class TransferService { public TransferResult transfer(TransferParam transferParam){ // 获取策略 - AbsTransferStrategy transferStrategy = TransferFactory.create(PayChannelEnum.ALI.getCode()); + AbsTransferStrategy transferStrategy = PayStrategyFactory.create(transferParam.getChannel(),AbsTransferStrategy.class); // 检查转账参数 transferStrategy.doValidateParam(transferParam); // 创建转账订单并设置 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/AllocationOrderDto.java index f30c28172..e3aff1010 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/AllocationOrderDto.java @@ -23,18 +23,18 @@ public class AllocationOrderDto extends BaseDto { * 分账订单号 */ @Schema(description = "分账订单号") - private String allocationNo; + private String allocNo; /** * 商户分账单号 */ @Schema(description = "商户分账单号") - private String bizAllocationNo; + private String bizAllocNo; /** * 通道分账单号 */ @Schema(description = "通道分账单号") - private String outAllocationNo; + private String outAllocNo; /** * 支付订单ID diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/dto/order/pay/PayOrderDto.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/dto/order/pay/PayOrderDto.java index 7b37b0eff..912c3ad8f 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/dto/order/pay/PayOrderDto.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/dto/order/pay/PayOrderDto.java @@ -3,6 +3,7 @@ import cn.bootx.platform.common.core.rest.dto.BaseDto; import cn.daxpay.single.code.PayChannelEnum; import cn.daxpay.single.code.PayOrderAllocStatusEnum; +import cn.daxpay.single.code.PayOrderRefundStatusEnum; import cn.daxpay.single.code.PayStatusEnum; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; @@ -78,12 +79,19 @@ public class PayOrderDto extends BaseDto { @Schema(description = "支付状态") private String status; + /** + * 退款状态 + * @see PayOrderRefundStatusEnum + */ + @Schema(description = "退款状态") + private String refundStatus; + /** * 分账状态 * @see PayOrderAllocStatusEnum */ @Schema(description = "分账状态") - private String allocationStatus; + private String allocStatus; /** 支付时间 */ @Schema(description = "支付时间") diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/handler/excel/PayChannelConvert.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/handler/excel/PayChannelConvert.java index 3d0d7c8dc..2a604db99 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/handler/excel/PayChannelConvert.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/handler/excel/PayChannelConvert.java @@ -8,6 +8,7 @@ /** * 支付通道转换 + * TODO 改为读取数据库 * @author xxm * @since 2024/5/6 */ 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/AllocationOrderQuery.java index 5bcf0d1cd..7ad532b50 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/AllocationOrderQuery.java @@ -24,7 +24,7 @@ public class AllocationOrderQuery { private String title; @Schema(description = "分账业务号") - private String allocationNo; + private String allocNo; @Schema(description = "分账通道") private String channel; diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/param/order/PayOrderQuery.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/param/order/PayOrderQuery.java index 831f03257..8c8a39dda 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/param/order/PayOrderQuery.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/param/order/PayOrderQuery.java @@ -4,6 +4,7 @@ import cn.bootx.platform.common.core.rest.param.QueryOrder; import cn.daxpay.single.code.PayChannelEnum; import cn.daxpay.single.code.PayOrderAllocStatusEnum; +import cn.daxpay.single.code.PayOrderRefundStatusEnum; import cn.daxpay.single.code.PayStatusEnum; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; @@ -71,12 +72,19 @@ public class PayOrderQuery extends QueryOrder { @Schema(description = "支付状态") private String status; + /** + * 退款状态 + * @see PayOrderRefundStatusEnum + */ + @Schema(description = "退款状态") + private String refundStatus; + /** * 分账状态 * @see PayOrderAllocStatusEnum */ @Schema(description = "分账状态") - private String allocationStatus; + private String allocStatus; /** 错误码 */ @Schema(description = "错误码") 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 9ba89cd2f..fbb2ac618 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 @@ -43,7 +43,7 @@ public void execute(JobExecutionContext jobExecutionContext) throws JobExecution allocationService.finish(allocationOrder); } } catch (Exception e) { - log.warn("分账同步或完结失败, 分账号:{}", allocationOrder.getAllocationNo()); + log.warn("分账同步或完结失败, 分账号:{}", allocationOrder.getAllocNo()); log.warn("分账同步或完结失败", e); } } From 5b49ff70dc7588c27646ae19a8a5e21f0f7065ce Mon Sep 17 00:00:00 2001 From: bootx Date: Sun, 9 Jun 2024 18:36:27 +0800 Subject: [PATCH 05/34] =?UTF-8?q?ref=20=E5=B9=B3=E5=8F=B0=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E6=94=B9=E7=89=88.=20=E6=8E=A5=E5=8F=A3=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E6=94=B9=E7=89=88.=20=E8=84=9A=E6=89=8B=E6=9E=B6?= =?UTF-8?q?=E7=B2=BE=E7=AE=80,=20=E5=88=A0=E9=99=A4=E6=97=A0=E5=85=B3?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _doc/Task.md | 24 +- .../common-starter-dingtalk/pom.xml | 29 -- .../dingtalk/DingTalkAutoConfiguration.java | 21 -- .../starter/dingtalk/code/DingTalkCode.java | 123 ------- .../dingtalk/code/DingTalkNoticeCode.java | 36 -- .../configuration/DingTalkProperties.java | 27 -- .../controller/DingRobotConfigController.java | 78 ----- .../core/base/result/AccessTokenResult.java | 23 -- .../core/base/result/DingTalkResult.java | 34 -- .../core/base/result/MediaResult.java | 39 --- .../core/base/service/DingAccessService.java | 97 ------ .../core/media/dao/DingMediaMd5Manager.java | 29 -- .../core/media/dao/DingMediaMd5Mapper.java | 14 - .../core/media/entity/DingMediaMd5.java | 31 -- .../media/service/DingMediaMd5Service.java | 19 -- .../core/media/service/DingMediaService.java | 91 ----- .../core/notice/result/ChatNoticeResult.java | 28 -- .../core/notice/result/CorpNoticeResult.java | 35 -- .../notice/service/DingNoticeService.java | 101 ------ .../core/robot/convert/DingRobotConvert.java | 24 -- .../robot/dao/DingRobotConfigManager.java | 47 --- .../core/robot/dao/DingRobotConfigMapper.java | 16 - .../core/robot/entity/DingRobotConfig.java | 52 --- .../robot/service/DingRobotConfigService.java | 102 ------ .../robot/service/DingRobotSendService.java | 68 ---- .../core/user/entity/UserIdResult.java | 25 -- .../core/user/service/DingUserService.java | 60 ---- .../dto/robot/DingRobotConfigDto.java | 40 --- .../dingtalk/param/notice/ChatNotice.java | 39 --- .../dingtalk/param/notice/CorpNotice.java | 55 --- .../param/notice/RecallCorpNotice.java | 36 -- .../param/notice/UpdateCorpNotice.java | 40 --- .../param/notice/msg/ActionCardMsg.java | 70 ---- .../starter/dingtalk/param/notice/msg/At.java | 59 ---- .../dingtalk/param/notice/msg/DingMedia.java | 27 -- .../dingtalk/param/notice/msg/FileMsg.java | 37 -- .../dingtalk/param/notice/msg/ImageMsg.java | 37 -- .../dingtalk/param/notice/msg/LinkMsg.java | 78 ----- .../param/notice/msg/MarkdownMsg.java | 70 ---- .../dingtalk/param/notice/msg/Msg.java | 50 --- .../dingtalk/param/notice/msg/OaMsg.java | 139 -------- .../dingtalk/param/notice/msg/TextMsg.java | 51 --- .../dingtalk/param/notice/msg/VoiceMsg.java | 55 --- .../param/robot/DingRobotConfigParam.java | 41 --- .../starter/dingtalk/util/DingTalkUtil.java | 41 --- ...ot.autoconfigure.AutoConfiguration.imports | 1 - .../common-starter-wechat/pom.xml | 81 ----- .../wechat/WeChatAutoConfiguration.java | 21 -- .../starter/wechat/code/WeChatCode.java | 28 -- .../configuration/WeChatAppletProperties.java | 24 -- .../configuration/WeChatConfiguration.java | 64 ---- .../WeChatMessageRouterConfiguration.java | 48 --- .../configuration/WeChatProperties.java | 30 -- .../controller/WeChatArticleController.java | 34 -- .../controller/WeChatMediaController.java | 55 --- .../controller/WeChatMenuController.java | 91 ----- .../controller/WeChatPortalController.java | 55 --- .../controller/WeChatQrLoginController.java | 43 --- .../controller/WeChatTemplateController.java | 62 ---- .../article/service/WeChatArticleService.java | 43 --- .../login/service/WeChatQrLoginService.java | 99 ------ .../media/service/WeChatMediaService.java | 103 ------ .../core/menu/convert/WeChatMenuConvert.java | 30 -- .../core/menu/dao/WeChatMenuManager.java | 42 --- .../core/menu/dao/WeChatMenuMapper.java | 16 - .../core/menu/domin/WeChatMenuInfo.java | 164 --------- .../wechat/core/menu/entity/WeChatMenu.java | 54 --- .../core/menu/service/WeChatMenuService.java | 130 -------- .../notice/convert/WeChatTemplateConvert.java | 27 -- .../notice/dao/WeChatTemplateManager.java | 55 --- .../core/notice/dao/WeChatTemplateMapper.java | 14 - .../core/notice/entity/WeChatTemplate.java | 76 ----- .../notice/service/WeChatTemplateService.java | 125 ------- .../notice/service/WechatNoticeService.java | 61 ---- .../portal/service/WeChatPortalService.java | 90 ----- .../core/user/convert/WechatFansConvert.java | 24 -- .../core/user/dao/WechatFansManager.java | 45 --- .../core/user/dao/WechatFansMapper.java | 16 - .../wechat/core/user/entity/WechatFans.java | 56 ---- .../core/user/service/WeChatUserService.java | 86 ----- .../wechat/dto/article/WeChatArticleDto.java | 48 --- .../wechat/dto/login/WeChatLoginQrCode.java | 26 -- .../wechat/dto/media/WeChatMediaDto.java | 39 --- .../wechat/dto/menu/WeChatMenuDto.java | 34 -- .../wechat/dto/notice/WeChatTemplateDto.java | 48 --- .../wechat/dto/user/WechatFansDto.java | 56 ---- .../wechat/event/WeChatQrScanEvent.java | 27 -- .../handler/WeChatMpMessageHandler.java | 30 -- .../wechat/handler/WeChatMsgHandler.java | 38 --- .../wechat/handler/WeChatQrScanHandler.java | 64 ---- .../handler/WeChatSubscribeHandler.java | 59 ---- .../handler/WeChatUnSubscribeHandler.java | 37 -- .../wechat/handler/WechatMenuHandler.java | 36 -- .../handler/qrscene/WeChatQrLoginHandler.java | 56 ---- .../qrscene/WeChatQrSceneMsgHandler.java | 29 -- .../wechat/param/menu/WeChatMenuParam.java | 34 -- .../param/notice/WeChatTemplateParam.java | 48 --- .../param/portal/WeChatPortalParam.java | 11 - .../wechat/param/user/WechatFansParam.java | 56 ---- .../starter/wechat/util/WeChatUtil.java | 22 -- ...ot.autoconfigure.AutoConfiguration.imports | 1 - .../common-starter-wecom/pom.xml | 40 --- .../starter/wecom/WeComAutoConfiguration.java | 21 -- .../starter/wecom/code/WeComCode.java | 38 --- .../configuration/WeComConfiguration.java | 45 --- .../wecom/configuration/WeComProperties.java | 33 -- .../WecomRobotConfigController.java | 80 ----- .../notice/domain/WxCpRecallNoticeResult.java | 5 - .../executor/RecallNoticeRequestExecutor.java | 45 --- .../notice/service/WeComNoticeService.java | 71 ---- .../convert/WecomRobotConfigConvert.java | 24 -- .../robot/dao/WecomRobotConfigManager.java | 53 --- .../robot/dao/WecomRobotConfigMapper.java | 16 - .../wecom/core/robot/domin/UploadMedia.java | 29 -- .../core/robot/entity/WecomRobotConfig.java | 57 ---- .../RobotMediaFileUploadRequestExecutor.java | 47 --- .../service/WeComRobotNoticeService.java | 132 -------- .../service/WecomRobotConfigService.java | 94 ------ .../wecom/dto/robot/WecomRobotConfigDto.java | 35 -- .../param/robot/WecomRobotConfigParam.java | 33 -- ...ot.autoconfigure.AutoConfiguration.imports | 1 - bootx-platform/bootx-common-starters/pom.xml | 3 - bootx-platform/bootx-services/pom.xml | 2 - .../region/ChinaRegionInitSqlHandler.java | 31 -- .../bootx-services/service-iam/pom.xml | 10 - .../core/auth/login/DingTalkLoginHandler.java | 146 -------- .../auth/login/WeChatAppletLoginHandler.java | 98 ------ .../core/auth/login/WeChatLoginHandler.java | 92 ----- .../bootx-services/service-notice/pom.xml | 83 ----- .../platform/notice/NoticeApplication.java | 17 - .../bootx/platform/notice/code/MailCode.java | 26 -- .../notice/code/MessageTemplateCode.java | 23 -- .../notice/code/NoticeCenterErrorCode.java | 61 ---- .../platform/notice/code/SiteMessageCode.java | 32 -- .../notice/code/SmsChannelStatusCode.java | 14 - .../controller/MailConfigController.java | 83 ----- .../controller/MessageTemplateController.java | 80 ----- .../controller/SiteMessageController.java | 99 ------ .../SmsChannelConfigController.java | 60 ---- .../controller/SmsTemplateController.java | 67 ---- .../entity/chat/DingChatNoticeParam.java | 30 -- .../entity/corp/DingCorpNoticeParam.java | 40 --- .../entity/corp/DingCorpNoticeReceive.java | 36 -- .../entity/corp/DingCorpNoticeUpdate.java | 35 -- .../entity/msg/DingActionCardMsg.java | 76 ----- .../core/dingtalk/entity/msg/DingFileMsg.java | 35 -- .../dingtalk/entity/msg/DingImageMsg.java | 35 -- .../core/dingtalk/entity/msg/DingLinkMsg.java | 40 --- .../dingtalk/entity/msg/DingMarkDownMsg.java | 29 -- .../core/dingtalk/entity/msg/DingMsg.java | 18 - .../core/dingtalk/entity/msg/DingOaMsg.java | 51 --- .../core/dingtalk/entity/msg/DingTextMsg.java | 34 -- .../dingtalk/entity/msg/DingVoiceMsg.java | 38 --- .../service/DingRobotNoticeSenderImpl.java | 46 --- .../service/DingTalkNoticeSenderImpl.java | 315 ------------------ .../notice/core/mail/convert/MailConvert.java | 26 -- .../core/mail/dao/MailConfigManager.java | 55 --- .../core/mail/dao/MailConfigMapper.java | 16 - .../notice/core/mail/entity/MailConfig.java | 69 ---- .../mail/service/EmailNoticeSenderImpl.java | 242 -------------- .../core/mail/service/MailConfigService.java | 119 ------- .../core/site/convert/SiteMessageConvert.java | 21 -- .../core/site/dao/SiteMessageManager.java | 112 ------- .../core/site/dao/SiteMessageMapper.java | 26 -- .../core/site/dao/SiteMessageUserManager.java | 47 --- .../core/site/dao/SiteMessageUserMapper.java | 14 - .../core/site/domain/SiteMessageInfo.java | 59 ---- .../site/domain/SiteMessageInfoMapper.java | 15 - .../notice/core/site/entity/SiteMessage.java | 68 ---- .../core/site/entity/SiteMessageUser.java | 35 -- .../core/site/service/SiteMessageService.java | 235 ------------- .../sms/convert/SmsChannelConfigConvert.java | 22 -- .../core/sms/convert/SmsTemplateConvert.java | 22 -- .../core/sms/dao/SmsChannelConfigManager.java | 27 -- .../core/sms/dao/SmsChannelConfigMapper.java | 13 - .../core/sms/dao/SmsTemplateManager.java | 35 -- .../core/sms/dao/SmsTemplateMapper.java | 14 - .../core/sms/entity/SmsChannelConfig.java | 91 ----- .../notice/core/sms/entity/SmsTemplate.java | 43 --- .../sms/service/SmsChannelConfigService.java | 246 -------------- .../core/sms/service/SmsTemplateService.java | 75 ----- .../convert/MessageTemplateConvert.java | 26 -- .../template/dao/MessageTemplateManager.java | 48 --- .../template/dao/MessageTemplateMapper.java | 14 - .../core/template/entity/MessageTemplate.java | 47 --- .../service/MessageTemplateService.java | 110 ------ .../core/wecom/entity/WeComNoticeParam.java | 39 --- .../core/wecom/entity/WeComNoticeReceive.java | 52 --- .../core/wecom/entity/msg/WeComFileMsg.java | 25 -- .../core/wecom/entity/msg/WeComImageMsg.java | 29 -- .../wecom/entity/msg/WeComMarkdownMsg.java | 29 -- .../core/wecom/entity/msg/WeComMpNewsMsg.java | 37 -- .../core/wecom/entity/msg/WeComMsg.java | 19 -- .../core/wecom/entity/msg/WeComNewsMsg.java | 37 -- .../wecom/entity/msg/WeComRobotReceive.java | 24 -- .../wecom/entity/msg/WeComTextCardMsg.java | 34 -- .../core/wecom/entity/msg/WeComTextMsg.java | 29 -- .../core/wecom/entity/msg/WeComVideoMsg.java | 35 -- .../core/wecom/entity/msg/WeComVoiceMsg.java | 29 -- .../wecom/service/WeComNoticeSenderImpl.java | 139 -------- .../service/WeComRobotNoticeSenderImpl.java | 101 ------ .../notice/dto/mail/BaseMailParam.java | 20 -- .../notice/dto/mail/MailConfigDto.java | 60 ---- .../notice/dto/mail/MailFileParam.java | 36 -- .../notice/dto/mail/MailTemplateDto.java | 30 -- .../notice/dto/mail/NoticeReceiverDto.java | 42 --- .../notice/dto/mail/SendMailParam.java | 54 --- .../dto/mail/ToUserRequiredMailParam.java | 20 -- .../notice/dto/site/SiteMessageDto.java | 58 ---- .../notice/dto/sms/SmsChannelConfigDto.java | 39 --- .../notice/dto/sms/SmsTemplateDto.java | 29 -- .../dto/template/MessageTemplateDto.java | 44 --- .../dto/wechat/WeChatNoticeConfigDto.java | 25 -- .../notice/event/sms/SmsChannelAddEvent.java | 20 -- .../sms/SmsChannelDisableEnableEvent.java | 19 -- .../event/sms/SmsChannelEnableEvent.java | 19 -- .../event/sms/SmsChannelUpdateEvent.java | 20 -- .../CodeTemplateExistedException.java | 23 -- ...aultMailConfigAlreadyExistedException.java | 23 -- ...MailConfigCodeAlreadyExistedException.java | 23 -- .../MailConfigNotExistException.java | 16 - .../MailTemplateNotExistException.java | 19 -- .../notice/param/mail/MailConfigParam.java | 52 --- .../notice/param/mail/MailTemplateParam.java | 37 -- .../param/site/SendSiteMessageParam.java | 65 ---- .../param/sms/SmsChannelConfigParam.java | 39 --- .../notice/param/sms/SmsTemplateParam.java | 29 -- .../param/template/MessageTemplateParam.java | 49 --- .../notice/service/DingRobotNoticeSender.java | 35 -- .../notice/service/DingTalkNoticeSender.java | 155 --------- .../notice/service/EmailNoticeSender.java | 26 -- .../notice/service/SmsNoticeSender.java | 11 - .../notice/service/WeChatNoticeSender.java | 11 - .../notice/service/WeComNoticeSender.java | 76 ----- .../service/WeComRobotNoticeSender.java | 57 ---- ...ot.autoconfigure.AutoConfiguration.imports | 1 - .../resources/mapper/SiteMessageMapper.xml | 31 -- bootx-platform/pom.xml | 18 - daxpay-single/daxpay-single-admin/pom.xml | 7 - .../system/PayChannelConfigController.java | 12 +- .../system/WechatNoticeConfigController.java | 37 -- .../service/code/TradeNotifyTypeEnum.java | 24 ++ .../service/common/context/ApiInfoLocal.java | 5 - .../service/common/context/NoticeLocal.java | 32 -- .../common/context/PaymentContext.java | 6 - .../service/common/context/PlatformLocal.java | 12 +- .../service/common/context/RequestLocal.java | 8 - .../alipay/service/AliPayConfigService.java | 6 - .../channel/alipay/service/AliPayService.java | 4 - .../union/service/UnionPayConfigService.java | 7 - .../wallet/service/WalletConfigService.java | 6 - .../service/WeChatPayConfigService.java | 8 +- .../service/AllocationOrderService.java | 5 +- .../core/order/pay/builder/PayBuilder.java | 6 +- .../service/AllocationAssistService.java | 36 +- .../allocation/service/AllocationService.java | 2 - .../common/aop/InitPlatformInfoAop.java | 5 - .../common/service/PaymentAssistService.java | 4 +- .../common/service/PaymentSignService.java | 5 +- .../payment/pay/service/PayAssistService.java | 45 +-- .../refund/service/RefundAssistService.java | 35 +- .../payment/refund/service/RefundService.java | 2 - .../convert/WechatNoticeConfigConvert.java | 18 - .../config/dao/WechatNoticeConfigManager.java | 19 -- .../config/dao/WechatNoticeConfigMapper.java | 14 - .../config/entity/PayApiCallRecord.java | 20 -- .../system/config/entity/PayApiConfig.java | 22 +- .../config/entity/PayChannelConfig.java | 12 - .../system/config/entity/PlatformConfig.java | 19 +- .../config/entity/WechatNoticeConfig.java | 52 --- .../config/service/PayApiConfigService.java | 16 - .../service/PayChannelConfigService.java | 22 -- .../config/service/PlatformConfigService.java | 3 +- .../service/WechatNoticeConfigService.java | 41 --- .../dto/system/config/PayApiConfigDto.java | 17 - .../system/config/PayChannelConfigDto.java | 13 - .../dto/system/config/PlatformConfigDto.java | 19 +- .../system/config/WechatNoticeConfigDto.java | 16 - .../system/config/PayApiConfigParam.java | 9 - .../system/config/PlatformConfigParam.java | 16 +- .../config/WechatNoticeConfigParam.java | 16 - 281 files changed, 118 insertions(+), 12360 deletions(-) delete mode 100644 bootx-platform/bootx-common-starters/common-starter-dingtalk/pom.xml delete mode 100644 bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/DingTalkAutoConfiguration.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/code/DingTalkCode.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/code/DingTalkNoticeCode.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/configuration/DingTalkProperties.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/controller/DingRobotConfigController.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/core/base/result/AccessTokenResult.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/core/base/result/DingTalkResult.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/core/base/result/MediaResult.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/core/base/service/DingAccessService.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/core/media/dao/DingMediaMd5Manager.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/core/media/dao/DingMediaMd5Mapper.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/core/media/entity/DingMediaMd5.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/core/media/service/DingMediaMd5Service.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/core/media/service/DingMediaService.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/core/notice/result/ChatNoticeResult.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/core/notice/result/CorpNoticeResult.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/core/notice/service/DingNoticeService.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/core/robot/convert/DingRobotConvert.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/core/robot/dao/DingRobotConfigManager.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/core/robot/dao/DingRobotConfigMapper.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/core/robot/entity/DingRobotConfig.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/core/robot/service/DingRobotConfigService.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/core/robot/service/DingRobotSendService.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/core/user/entity/UserIdResult.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/core/user/service/DingUserService.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/dto/robot/DingRobotConfigDto.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/param/notice/ChatNotice.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/param/notice/CorpNotice.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/param/notice/RecallCorpNotice.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/param/notice/UpdateCorpNotice.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/param/notice/msg/ActionCardMsg.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/param/notice/msg/At.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/param/notice/msg/DingMedia.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/param/notice/msg/FileMsg.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/param/notice/msg/ImageMsg.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/param/notice/msg/LinkMsg.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/param/notice/msg/MarkdownMsg.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/param/notice/msg/Msg.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/param/notice/msg/OaMsg.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/param/notice/msg/TextMsg.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/param/notice/msg/VoiceMsg.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/param/robot/DingRobotConfigParam.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/util/DingTalkUtil.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports delete mode 100644 bootx-platform/bootx-common-starters/common-starter-wechat/pom.xml delete mode 100644 bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/WeChatAutoConfiguration.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/code/WeChatCode.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/configuration/WeChatAppletProperties.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/configuration/WeChatConfiguration.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/configuration/WeChatMessageRouterConfiguration.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/configuration/WeChatProperties.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/controller/WeChatArticleController.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/controller/WeChatMediaController.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/controller/WeChatMenuController.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/controller/WeChatPortalController.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/controller/WeChatQrLoginController.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/controller/WeChatTemplateController.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/core/article/service/WeChatArticleService.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/core/login/service/WeChatQrLoginService.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/core/media/service/WeChatMediaService.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/core/menu/convert/WeChatMenuConvert.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/core/menu/dao/WeChatMenuManager.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/core/menu/dao/WeChatMenuMapper.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/core/menu/domin/WeChatMenuInfo.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/core/menu/entity/WeChatMenu.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/core/menu/service/WeChatMenuService.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/core/notice/convert/WeChatTemplateConvert.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/core/notice/dao/WeChatTemplateManager.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/core/notice/dao/WeChatTemplateMapper.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/core/notice/entity/WeChatTemplate.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/core/notice/service/WeChatTemplateService.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/core/notice/service/WechatNoticeService.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/core/portal/service/WeChatPortalService.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/core/user/convert/WechatFansConvert.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/core/user/dao/WechatFansManager.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/core/user/dao/WechatFansMapper.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/core/user/entity/WechatFans.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/core/user/service/WeChatUserService.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/dto/article/WeChatArticleDto.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/dto/login/WeChatLoginQrCode.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/dto/media/WeChatMediaDto.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/dto/menu/WeChatMenuDto.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/dto/notice/WeChatTemplateDto.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/dto/user/WechatFansDto.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/event/WeChatQrScanEvent.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/handler/WeChatMpMessageHandler.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/handler/WeChatMsgHandler.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/handler/WeChatQrScanHandler.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/handler/WeChatSubscribeHandler.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/handler/WeChatUnSubscribeHandler.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/handler/WechatMenuHandler.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/handler/qrscene/WeChatQrLoginHandler.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/handler/qrscene/WeChatQrSceneMsgHandler.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/param/menu/WeChatMenuParam.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/param/notice/WeChatTemplateParam.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/param/portal/WeChatPortalParam.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/param/user/WechatFansParam.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/util/WeChatUtil.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-wechat/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports delete mode 100644 bootx-platform/bootx-common-starters/common-starter-wecom/pom.xml delete mode 100644 bootx-platform/bootx-common-starters/common-starter-wecom/src/main/java/cn/bootx/platform/starter/wecom/WeComAutoConfiguration.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-wecom/src/main/java/cn/bootx/platform/starter/wecom/code/WeComCode.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-wecom/src/main/java/cn/bootx/platform/starter/wecom/configuration/WeComConfiguration.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-wecom/src/main/java/cn/bootx/platform/starter/wecom/configuration/WeComProperties.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-wecom/src/main/java/cn/bootx/platform/starter/wecom/controller/WecomRobotConfigController.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-wecom/src/main/java/cn/bootx/platform/starter/wecom/core/notice/domain/WxCpRecallNoticeResult.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-wecom/src/main/java/cn/bootx/platform/starter/wecom/core/notice/executor/RecallNoticeRequestExecutor.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-wecom/src/main/java/cn/bootx/platform/starter/wecom/core/notice/service/WeComNoticeService.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-wecom/src/main/java/cn/bootx/platform/starter/wecom/core/robot/convert/WecomRobotConfigConvert.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-wecom/src/main/java/cn/bootx/platform/starter/wecom/core/robot/dao/WecomRobotConfigManager.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-wecom/src/main/java/cn/bootx/platform/starter/wecom/core/robot/dao/WecomRobotConfigMapper.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-wecom/src/main/java/cn/bootx/platform/starter/wecom/core/robot/domin/UploadMedia.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-wecom/src/main/java/cn/bootx/platform/starter/wecom/core/robot/entity/WecomRobotConfig.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-wecom/src/main/java/cn/bootx/platform/starter/wecom/core/robot/executor/RobotMediaFileUploadRequestExecutor.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-wecom/src/main/java/cn/bootx/platform/starter/wecom/core/robot/service/WeComRobotNoticeService.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-wecom/src/main/java/cn/bootx/platform/starter/wecom/core/robot/service/WecomRobotConfigService.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-wecom/src/main/java/cn/bootx/platform/starter/wecom/dto/robot/WecomRobotConfigDto.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-wecom/src/main/java/cn/bootx/platform/starter/wecom/param/robot/WecomRobotConfigParam.java delete mode 100644 bootx-platform/bootx-common-starters/common-starter-wecom/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports delete mode 100644 bootx-platform/bootx-services/service-baseapi/src/main/java/cn/bootx/platform/baseapi/handler/region/ChinaRegionInitSqlHandler.java delete mode 100644 bootx-platform/bootx-services/service-iam/src/main/java/cn/bootx/platform/iam/core/auth/login/DingTalkLoginHandler.java delete mode 100644 bootx-platform/bootx-services/service-iam/src/main/java/cn/bootx/platform/iam/core/auth/login/WeChatAppletLoginHandler.java delete mode 100644 bootx-platform/bootx-services/service-iam/src/main/java/cn/bootx/platform/iam/core/auth/login/WeChatLoginHandler.java delete mode 100644 bootx-platform/bootx-services/service-notice/pom.xml delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/NoticeApplication.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/code/MailCode.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/code/MessageTemplateCode.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/code/NoticeCenterErrorCode.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/code/SiteMessageCode.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/code/SmsChannelStatusCode.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/controller/MailConfigController.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/controller/MessageTemplateController.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/controller/SiteMessageController.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/controller/SmsChannelConfigController.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/controller/SmsTemplateController.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/core/dingtalk/entity/chat/DingChatNoticeParam.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/core/dingtalk/entity/corp/DingCorpNoticeParam.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/core/dingtalk/entity/corp/DingCorpNoticeReceive.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/core/dingtalk/entity/corp/DingCorpNoticeUpdate.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/core/dingtalk/entity/msg/DingActionCardMsg.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/core/dingtalk/entity/msg/DingFileMsg.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/core/dingtalk/entity/msg/DingImageMsg.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/core/dingtalk/entity/msg/DingLinkMsg.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/core/dingtalk/entity/msg/DingMarkDownMsg.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/core/dingtalk/entity/msg/DingMsg.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/core/dingtalk/entity/msg/DingOaMsg.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/core/dingtalk/entity/msg/DingTextMsg.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/core/dingtalk/entity/msg/DingVoiceMsg.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/core/dingtalk/service/DingRobotNoticeSenderImpl.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/core/dingtalk/service/DingTalkNoticeSenderImpl.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/core/mail/convert/MailConvert.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/core/mail/dao/MailConfigManager.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/core/mail/dao/MailConfigMapper.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/core/mail/entity/MailConfig.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/core/mail/service/EmailNoticeSenderImpl.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/core/mail/service/MailConfigService.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/core/site/convert/SiteMessageConvert.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/core/site/dao/SiteMessageManager.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/core/site/dao/SiteMessageMapper.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/core/site/dao/SiteMessageUserManager.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/core/site/dao/SiteMessageUserMapper.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/core/site/domain/SiteMessageInfo.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/core/site/domain/SiteMessageInfoMapper.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/core/site/entity/SiteMessage.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/core/site/entity/SiteMessageUser.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/core/site/service/SiteMessageService.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/core/sms/convert/SmsChannelConfigConvert.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/core/sms/convert/SmsTemplateConvert.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/core/sms/dao/SmsChannelConfigManager.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/core/sms/dao/SmsChannelConfigMapper.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/core/sms/dao/SmsTemplateManager.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/core/sms/dao/SmsTemplateMapper.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/core/sms/entity/SmsChannelConfig.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/core/sms/entity/SmsTemplate.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/core/sms/service/SmsChannelConfigService.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/core/sms/service/SmsTemplateService.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/core/template/convert/MessageTemplateConvert.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/core/template/dao/MessageTemplateManager.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/core/template/dao/MessageTemplateMapper.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/core/template/entity/MessageTemplate.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/core/template/service/MessageTemplateService.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/core/wecom/entity/WeComNoticeParam.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/core/wecom/entity/WeComNoticeReceive.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/core/wecom/entity/msg/WeComFileMsg.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/core/wecom/entity/msg/WeComImageMsg.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/core/wecom/entity/msg/WeComMarkdownMsg.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/core/wecom/entity/msg/WeComMpNewsMsg.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/core/wecom/entity/msg/WeComMsg.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/core/wecom/entity/msg/WeComNewsMsg.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/core/wecom/entity/msg/WeComRobotReceive.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/core/wecom/entity/msg/WeComTextCardMsg.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/core/wecom/entity/msg/WeComTextMsg.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/core/wecom/entity/msg/WeComVideoMsg.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/core/wecom/entity/msg/WeComVoiceMsg.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/core/wecom/service/WeComNoticeSenderImpl.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/core/wecom/service/WeComRobotNoticeSenderImpl.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/dto/mail/BaseMailParam.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/dto/mail/MailConfigDto.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/dto/mail/MailFileParam.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/dto/mail/MailTemplateDto.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/dto/mail/NoticeReceiverDto.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/dto/mail/SendMailParam.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/dto/mail/ToUserRequiredMailParam.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/dto/site/SiteMessageDto.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/dto/sms/SmsChannelConfigDto.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/dto/sms/SmsTemplateDto.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/dto/template/MessageTemplateDto.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/dto/wechat/WeChatNoticeConfigDto.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/event/sms/SmsChannelAddEvent.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/event/sms/SmsChannelDisableEnableEvent.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/event/sms/SmsChannelEnableEvent.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/event/sms/SmsChannelUpdateEvent.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/exception/CodeTemplateExistedException.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/exception/DefaultMailConfigAlreadyExistedException.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/exception/MailConfigCodeAlreadyExistedException.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/exception/MailConfigNotExistException.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/exception/MailTemplateNotExistException.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/param/mail/MailConfigParam.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/param/mail/MailTemplateParam.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/param/site/SendSiteMessageParam.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/param/sms/SmsChannelConfigParam.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/param/sms/SmsTemplateParam.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/param/template/MessageTemplateParam.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/service/DingRobotNoticeSender.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/service/DingTalkNoticeSender.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/service/EmailNoticeSender.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/service/SmsNoticeSender.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/service/WeChatNoticeSender.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/service/WeComNoticeSender.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/java/cn/bootx/platform/notice/service/WeComRobotNoticeSender.java delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports delete mode 100644 bootx-platform/bootx-services/service-notice/src/main/resources/mapper/SiteMessageMapper.xml delete mode 100644 daxpay-single/daxpay-single-admin/src/main/java/cn/daxpay/single/admin/controller/system/WechatNoticeConfigController.java create mode 100644 daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/code/TradeNotifyTypeEnum.java delete mode 100644 daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/common/context/NoticeLocal.java delete mode 100644 daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/system/config/convert/WechatNoticeConfigConvert.java delete mode 100644 daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/system/config/dao/WechatNoticeConfigManager.java delete mode 100644 daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/system/config/dao/WechatNoticeConfigMapper.java delete mode 100644 daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/system/config/entity/PayApiCallRecord.java delete mode 100644 daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/system/config/entity/WechatNoticeConfig.java delete mode 100644 daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/system/config/service/WechatNoticeConfigService.java delete mode 100644 daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/dto/system/config/WechatNoticeConfigDto.java delete mode 100644 daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/param/system/config/WechatNoticeConfigParam.java diff --git a/_doc/Task.md b/_doc/Task.md index 5e085a915..a15d70a54 100644 --- a/_doc/Task.md +++ b/_doc/Task.md @@ -1,22 +1,32 @@ ## 单商户 -2.0.8: 对账完善和系统优化 +2.0.8: 转账/撤销接口和系统优化 - [x] 支持撤销接口 - [ ] 增加转账接口功能 - [ ] 细分各种支付异常类和编码(完成部分) - [ ] 增加分账修复功能 - [ ] DEMO增加获取微信OpenID和支付宝OpenId功能 +- [ ] 支付宝微信等消息通知地址支持一键生成 - [ ] 管理端界面支持扫码绑定对账接收方功能 -- [ ] 支付通道两个独立的配置进行合并为一个 -- [ ] 平台配置和接口配置删除回调地址配置, 只保留接口参数设置 -- [ ] 接口配置删除验签配置, 放到平台配置进行统一处理 +- [x] 支付通道两个独立的配置进行合并为一个 + - [X] 去除有效, icon, 颜色等字段 +- [x] 平台配置改版 + - [x] 平台配置和接口配置删除回调地址配置 + - [X] 删除回调地址配置, 更换为消息通知地址和消息通知类型 +- [X] 接口配置改版 + - [x] 删除是否验签配置和回调地址 + - [x] 去掉上下文相关类 + - [x] 回调通知固定为读取参数传递的数据 - [x] 分账字段统一为Alloc, 不包括接口名称 - [x] 支付订单拆分退款状态为单独的字段 - [x] 策略工厂修改为通用策略工厂 - [x] 支付和退款达到终态不可以再回退回之前的状态 - [x] 修复支付关闭参数名称不正确问题 -2.0.9: 消息通知改版和功能优化 +- [ ] 脚手架优化 + - [ ] 请求权限改版, 使用专用配置类 + - [X] 去除消息通知模块 +2.0.9: 消息通知改版和系统优化 - [ ] 增加类似支付宝应用通知的方式, 先支持http方式通信 -- [ ] 增加支付宝和微信通知回调地址一键生成功能 +- [ ] 优化前端各种状态颜色展示 2.1.x 版本内容 - [ ] 增加收单收银台功能 @@ -34,8 +44,6 @@ - [ ] 针对同步/对账等出现脏数据导致阻塞的问题, 进行优化 - [ ] 同步接口 - [ ] 对账接口 -- [ ] 增加通道开通能力管理,在操作发起前的校验时提前进行拦截 - **任务池** - [ ] 通道费率计算 - [ ] 每日资金流水计算 diff --git a/bootx-platform/bootx-common-starters/common-starter-dingtalk/pom.xml b/bootx-platform/bootx-common-starters/common-starter-dingtalk/pom.xml deleted file mode 100644 index c4b69d151..000000000 --- a/bootx-platform/bootx-common-starters/common-starter-dingtalk/pom.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - bootx-common-starters - cn.bootx.platform - 1.3.6.2 - - 4.0.0 - - common-starter-dingtalk - 钉钉接口 - - - - org.springframework.boot - spring-boot-starter-web - - - cn.bootx.platform - common-mybatis-plus - - - cn.bootx.platform - common-starter-data-perm - - - diff --git a/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/DingTalkAutoConfiguration.java b/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/DingTalkAutoConfiguration.java deleted file mode 100644 index 48cdf45a2..000000000 --- a/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/DingTalkAutoConfiguration.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.bootx.platform.starter.dingtalk; - -import org.apache.ibatis.annotations.Mapper; -import org.mybatis.spring.annotation.MapperScan; -import org.springframework.boot.autoconfigure.AutoConfiguration; -import org.springframework.boot.context.properties.ConfigurationPropertiesScan; -import org.springframework.context.annotation.ComponentScan; - -/** - * 钉钉对接 - * - * @author xxm - * @since 2022/4/2 - */ -@ComponentScan -@ConfigurationPropertiesScan -@AutoConfiguration -@MapperScan(annotationClass = Mapper.class) -public class DingTalkAutoConfiguration { - -} diff --git a/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/code/DingTalkCode.java b/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/code/DingTalkCode.java deleted file mode 100644 index 85f12e81e..000000000 --- a/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/code/DingTalkCode.java +++ /dev/null @@ -1,123 +0,0 @@ -package cn.bootx.platform.starter.dingtalk.code; - -/** - * 钉钉消息类型 - * - * @author xxm - * @since 2020/11/30 - */ -public interface DingTalkCode { - - /** 钉钉Access参数 */ - String ACCESS_TOKEN_PARAM = "?access_token={}"; - - /** 内部应用获取access_token */ - String APP_ACCESS_TOKEN_URL = "https://oapi.dingtalk.com/gettoken?appkey={appKey}&appsecret={appSecret}"; - - /** 带sign的机器人消息发送请求 */ - String ROBOT_SEND_SIGN_URL = "https://oapi.dingtalk.com/robot/send?access_token={accessToken}×tamp={timestamp}&sign={sign}"; - - /** 不带sign的机器人消息发送请求 */ - String ROBOT_SEND_NOT_SIGN_URL = "https://oapi.dingtalk.com/robot/send" + ACCESS_TOKEN_PARAM; - - /** 发送工作通知 */ - String NOTICE_CORP_SEND_URL = "https://oapi.dingtalk.com/topapi/message/corpconversation/asyncsend_v2" - + ACCESS_TOKEN_PARAM; - - /** 更新工作通知(OA消息) */ - String NOTICE_CORP_UPDATE_URL = "https://oapi.dingtalk.com/topapi/message/corpconversation/status_bar/update" - + ACCESS_TOKEN_PARAM; - - /** 撤回工作通知 */ - String NOTICE_CORP_RECALL_URL = "https://oapi.dingtalk.com/topapi/message/corpconversation/recall" - + ACCESS_TOKEN_PARAM; - - /** 发送企业群通知 */ - String NOTICE_CHAT_URL = "https://oapi.dingtalk.com/chat/send" + ACCESS_TOKEN_PARAM; - - /** 发送普通消息通知 */ - String NOTICE_MESSAGE_URL = "https://oapi.dingtalk.com/message/send_to_conversation" + ACCESS_TOKEN_PARAM; - - /** 根据unionid获取用户userid */ - String USER_GET_URL = "https://oapi.dingtalk.com/topapi/user/getbyunionid" + ACCESS_TOKEN_PARAM; - - /** 媒体文件上传 */ - String MEDIA_UPLOAD_URL = "https://oapi.dingtalk.com/media/upload" + ACCESS_TOKEN_PARAM; - - /** 钉钉字段 */ - String ACCESS_TOKEN = "accessToken"; - - String SIGN = "sign"; - - String TIMESTAMP = "timestamp"; - - String APP_KEY = "appKey"; - - String APP_SECRET = "appSecret"; - - /** 应用id */ - String CLIENT_ID = "clientId"; - - // 应用密钥 - String CLIENT_SECRET = "clientSecret"; - - String CODE = "code"; - - // OAuth2.0刷新令牌,从返回结果里面获取。 - String REFRESH_TOKEN = "refreshToken"; - - String GRANT_TYPE = "grantType"; - - String RESPONSE_TYPE = "responseType"; - - String SCOPE = "scope"; - - String REDIRECT_URI = "redirectUri"; - - String STATE = "state"; - - String PROMPT = "prompt"; - - /** 媒体 */ - String MEDIA = "media"; - - /** 类型 */ - String TYPE = "type"; - - /** 请求头参数调用服务端接口的授权凭证 */ - String HEADER_TOKEN = "x-acs-dingtalk-access-token"; - - /* 认证字段 */ - /** 授权码换token */ - String AUTH_AUTHORIZATION_CODE = "authorization_code"; - - /** 刷新token换用户token */ - String AUTH_REFRESH_TOKEN = "refresh_token"; - - /** openid */ - String OPEN_ID = "openid"; - - /** union_id */ - String UNION_ID = "unionid"; - - /* 响应值 */ - /** 成功 */ - int SUCCESS_CODE = 0; - - /** 未找到对应员工 */ - int NOT_FUND_STAFF = 60121; - - /* 媒体类型 */ - /** 图片 */ - String MEDIA_IMAGE = "image"; - - /** 语音 */ - String MEDIA_VOICE = "voice"; - - /** 视频 */ - String MEDIA_VIDEO = "video"; - - /** 普通文件 */ - String MEDIA_FILE = "file"; - -} diff --git a/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/code/DingTalkNoticeCode.java b/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/code/DingTalkNoticeCode.java deleted file mode 100644 index 45e942666..000000000 --- a/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/code/DingTalkNoticeCode.java +++ /dev/null @@ -1,36 +0,0 @@ -package cn.bootx.platform.starter.dingtalk.code; - -/** - * 钉钉通知消息常量 - * - * @author xxm - * @since 2022/4/2 - */ -public interface DingTalkNoticeCode { - - /* 消息类型 */ - /** 文本消息 */ - String MSG_TEXT = "text"; - - /** 图片消息 */ - String MSG_IMAGE = "image"; - - /** 语音消息 */ - String MSG_VOICE = "voice"; - - /** 文件消息 */ - String MSG_FILE = "file"; - - /** 链接消息 */ - String MSG_LINK = "link"; - - /** OA消息 */ - String MSG_OA = "oa"; - - /** markdown消息 */ - String MSG_MARKDOWN = "markdown"; - - /** 卡片消息 */ - String MSG_ACTION_CARD = "action_card"; - -} diff --git a/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/configuration/DingTalkProperties.java b/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/configuration/DingTalkProperties.java deleted file mode 100644 index ee8f4aff7..000000000 --- a/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/configuration/DingTalkProperties.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.bootx.platform.starter.dingtalk.configuration; - -import lombok.Getter; -import lombok.Setter; -import org.springframework.boot.context.properties.ConfigurationProperties; - -/** - * 钉钉应用配置 - * - * @author xxm - * @since 2022/7/15 - */ -@Getter -@Setter -@ConfigurationProperties("bootx.starter.third.ding-talk") -public class DingTalkProperties { - - /** AppKey */ - private String appKey; - - /** AppSecret */ - private String appSecret; - - /** 应用id */ - private Long agentId; - -} diff --git a/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/controller/DingRobotConfigController.java b/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/controller/DingRobotConfigController.java deleted file mode 100644 index 07d8806ba..000000000 --- a/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/controller/DingRobotConfigController.java +++ /dev/null @@ -1,78 +0,0 @@ -package cn.bootx.platform.starter.dingtalk.controller; - -import cn.bootx.platform.common.core.rest.PageResult; -import cn.bootx.platform.common.core.rest.Res; -import cn.bootx.platform.common.core.rest.ResResult; -import cn.bootx.platform.common.core.rest.param.PageParam; -import cn.bootx.platform.starter.dingtalk.core.robot.service.DingRobotConfigService; -import cn.bootx.platform.starter.dingtalk.dto.robot.DingRobotConfigDto; -import cn.bootx.platform.starter.dingtalk.param.robot.DingRobotConfigParam; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.RequiredArgsConstructor; -import org.springframework.web.bind.annotation.*; - -import java.util.List; - -/** - * @author xxm - * @since 2021/9/25 - */ -@Tag(name = "钉钉机器人配置") -@RestController -@RequestMapping("/ding/robot/config") -@RequiredArgsConstructor -public class DingRobotConfigController { - - private final DingRobotConfigService dingRobotConfigService; - - @Operation(summary = "新增机器人配置") - @PostMapping("/add") - public ResResult add(@RequestBody DingRobotConfigParam param) { - return Res.ok(dingRobotConfigService.add(param)); - } - - @Operation(summary = "修改机器人配置") - @PostMapping("/update") - public ResResult update(@RequestBody DingRobotConfigParam param) { - return Res.ok(dingRobotConfigService.update(param)); - } - - @Operation(summary = "分页") - @GetMapping("/page") - public ResResult> page(PageParam pageParam, DingRobotConfigParam param) { - return Res.ok(dingRobotConfigService.page(pageParam, param)); - } - - @Operation(summary = "查询全部") - @GetMapping("/findAll") - public ResResult> findAll() { - return Res.ok(dingRobotConfigService.findAll()); - } - - @Operation(summary = "获取详情") - @GetMapping("/findById") - public ResResult findById(Long id) { - return Res.ok(dingRobotConfigService.findById(id)); - } - - @Operation(summary = "删除") - @DeleteMapping("/delete") - public ResResult delete(Long id) { - dingRobotConfigService.delete(id); - return Res.ok(); - } - - @Operation(summary = "编码是否被使用") - @GetMapping("/existsByCode") - public ResResult existsByCode(String code) { - return Res.ok(dingRobotConfigService.existsByCode(code)); - } - - @Operation(summary = "编码是否被使用(不包含自己)") - @GetMapping("/existsByCodeNotId") - public ResResult existsByCode(String code, Long id) { - return Res.ok(dingRobotConfigService.existsByCode(code, id)); - } - -} diff --git a/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/core/base/result/AccessTokenResult.java b/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/core/base/result/AccessTokenResult.java deleted file mode 100644 index a0b6f2f51..000000000 --- a/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/core/base/result/AccessTokenResult.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.bootx.platform.starter.dingtalk.core.base.result; - -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.experimental.Accessors; - -@EqualsAndHashCode(callSuper = true) -@Data -@Accessors(chain = true) -@Schema(title = "AccessToken响应类") -public class AccessTokenResult extends DingTalkResult { - - @JsonProperty("access_token") - @Schema(description = "访问凭证") - private String accessToken; - - @JsonProperty("expires_in") - @Schema(description = "过期时间") - private Integer expiresIn; - -} diff --git a/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/core/base/result/DingTalkResult.java b/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/core/base/result/DingTalkResult.java deleted file mode 100644 index ceb76aad3..000000000 --- a/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/core/base/result/DingTalkResult.java +++ /dev/null @@ -1,34 +0,0 @@ -package cn.bootx.platform.starter.dingtalk.core.base.result; - -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.experimental.Accessors; - -import java.io.Serializable; - -/** - * 钉钉响应结果 - * - * @author xxm - * @since 2020/11/30 - */ -@Data -@Accessors(chain = true) -@Schema(title = "钉钉发送响应类") -public class DingTalkResult implements Serializable { - - private static final long serialVersionUID = 4298060961428118100L; - - @JsonProperty("errcode") - @Schema(description = "错误码") - private Integer code; - - @Schema(description = "返回数据") - private T result; - - @JsonProperty("errmsg") - @Schema(description = "返回码描述") - private String msg; - -} diff --git a/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/core/base/result/MediaResult.java b/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/core/base/result/MediaResult.java deleted file mode 100644 index c9cc56982..000000000 --- a/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/core/base/result/MediaResult.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.bootx.platform.starter.dingtalk.core.base.result; - -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.experimental.Accessors; - -/** - * 钉钉媒体上传返回类 - * - * @author xxm - * @since 2022/7/25 - */ -@Data -@Accessors(chain = true) -@Schema(title = "钉钉媒体上传返回类") -public class MediaResult { - - @JsonProperty("errcode") - @Schema(description = "错误码") - private Integer code; - - @JsonProperty("errmsg") - @Schema(description = "返回码描述") - private String msg; - - @JsonProperty("type") - @Schema(description = "媒体文件类型") - private String type; - - @JsonProperty("media_id") - @Schema(description = "唯一标识") - private String mediaId; - - @JsonProperty("created_at") - @Schema(description = "媒体文件上传时间戳") - private long createdAt; - -} diff --git a/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/core/base/service/DingAccessService.java b/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/core/base/service/DingAccessService.java deleted file mode 100644 index c5d658d5e..000000000 --- a/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/core/base/service/DingAccessService.java +++ /dev/null @@ -1,97 +0,0 @@ -package cn.bootx.platform.starter.dingtalk.core.base.service; - -import cn.bootx.platform.starter.dingtalk.configuration.DingTalkProperties; -import cn.bootx.platform.common.core.exception.BizException; -import cn.bootx.platform.common.jackson.util.JacksonUtil; -import cn.bootx.platform.common.spring.exception.RetryableException; -import cn.bootx.platform.starter.dingtalk.core.base.result.AccessTokenResult; -import cn.hutool.core.util.StrUtil; -import cn.hutool.extra.spring.SpringUtil; -import cn.hutool.http.HttpException; -import cn.hutool.http.HttpUtil; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.retry.annotation.Retryable; -import org.springframework.stereotype.Service; - -import java.util.HashMap; -import java.util.Map; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.locks.Lock; -import java.util.concurrent.locks.ReentrantLock; - -import static cn.bootx.platform.starter.dingtalk.code.DingTalkCode.*; - -/** - * 钉钉访问凭证 - * - * @author xxm - * @since 2022/4/2 - */ -@Slf4j -@Service -@RequiredArgsConstructor -public class DingAccessService { - - private final DingTalkProperties dingTalkProperties; - - private long expiresTime; - - private String accessToken; - - /** - * 企业内部应用的access_token - */ - public String getAccessToken() { - if (System.currentTimeMillis() < expiresTime) { - return accessToken; - } - Lock lock = new ReentrantLock(); - boolean locked = false; - try { - do { - locked = lock.tryLock(100, TimeUnit.MILLISECONDS); - if (System.currentTimeMillis() < expiresTime) { - return accessToken; - } - } - while (!locked); - SpringUtil.getBean(getClass()) - .getAppAccessToken(dingTalkProperties.getAppKey(), dingTalkProperties.getAppSecret()); - } - catch (InterruptedException e) { - throw new BizException("获取钉钉应用AccessToken失败"); - } - finally { - if (locked) { - lock.unlock(); - } - } - return accessToken; - } - - /** - * 企业内部应用的access_token - */ - @Retryable(value = RetryableException.class) - public void getAppAccessToken(String appKey, String appSecret) { - // 获取accessToken - Map map = new HashMap<>(); - map.put(APP_KEY, appKey); - map.put(APP_SECRET, appSecret); - try { - String responseBody = HttpUtil.createGet(StrUtil.format(APP_ACCESS_TOKEN_URL, map)).execute().body(); - AccessTokenResult dingTalkResult = JacksonUtil.toBean(responseBody, AccessTokenResult.class); - if (StrUtil.isBlank(dingTalkResult.getAccessToken())) { - throw new RetryableException(); - } - this.accessToken = dingTalkResult.getAccessToken(); - // 设置超时时间 - this.expiresTime = System.currentTimeMillis() + (dingTalkResult.getExpiresIn() - 200) * 1000L; - } - catch (HttpException e) { - throw new RetryableException(); - } - } - -} diff --git a/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/core/media/dao/DingMediaMd5Manager.java b/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/core/media/dao/DingMediaMd5Manager.java deleted file mode 100644 index 1ba98a15e..000000000 --- a/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/core/media/dao/DingMediaMd5Manager.java +++ /dev/null @@ -1,29 +0,0 @@ -package cn.bootx.platform.starter.dingtalk.core.media.dao; - -import cn.bootx.platform.starter.dingtalk.core.media.entity.DingMediaMd5; -import cn.bootx.platform.common.mybatisplus.impl.BaseManager; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Repository; - -import java.util.Optional; - -/** - * 钉钉 - * - * @author xxm - * @since 2022/7/26 - */ -@Slf4j -@Repository -@RequiredArgsConstructor -public class DingMediaMd5Manager extends BaseManager { - - /** - * 根据md5查询 - */ - public Optional findByMd5(String md5) { - return findByField(DingMediaMd5::getMd5, md5); - } - -} diff --git a/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/core/media/dao/DingMediaMd5Mapper.java b/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/core/media/dao/DingMediaMd5Mapper.java deleted file mode 100644 index 6d9ae7c6f..000000000 --- a/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/core/media/dao/DingMediaMd5Mapper.java +++ /dev/null @@ -1,14 +0,0 @@ -package cn.bootx.platform.starter.dingtalk.core.media.dao; - -import cn.bootx.platform.starter.dingtalk.core.media.entity.DingMediaMd5; -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import org.apache.ibatis.annotations.Mapper; - -/** - * @author xxm - * @since 2022/7/26 - */ -@Mapper -public interface DingMediaMd5Mapper extends BaseMapper { - -} diff --git a/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/core/media/entity/DingMediaMd5.java b/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/core/media/entity/DingMediaMd5.java deleted file mode 100644 index 6b9800f49..000000000 --- a/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/core/media/entity/DingMediaMd5.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.bootx.platform.starter.dingtalk.core.media.entity; - -import cn.bootx.platform.common.mybatisplus.base.MpCreateEntity; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.RequiredArgsConstructor; -import lombok.experimental.Accessors; - -/** - * 钉钉媒体文件MD5值关联关系 - * - * @author xxm - * @since 2022/7/26 - */ -@EqualsAndHashCode(callSuper = true) -@Data -@Accessors(chain = true) -@AllArgsConstructor -@RequiredArgsConstructor -@TableName("starter_ding_media_md5") -public class DingMediaMd5 extends MpCreateEntity { - - /** 媒体文件id */ - private String mediaId; - - /** 媒体文件的md5值 */ - private String md5; - -} diff --git a/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/core/media/service/DingMediaMd5Service.java b/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/core/media/service/DingMediaMd5Service.java deleted file mode 100644 index cd4c27d11..000000000 --- a/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/core/media/service/DingMediaMd5Service.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.bootx.platform.starter.dingtalk.core.media.service; - -import cn.bootx.platform.starter.dingtalk.core.media.dao.DingMediaMd5Manager; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Service; - -/** - * @author xxm - * @since 2022/7/26 - */ -@Slf4j -@Service -@RequiredArgsConstructor -public class DingMediaMd5Service { - - private final DingMediaMd5Manager dingMediaMd5Manager; - -} diff --git a/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/core/media/service/DingMediaService.java b/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/core/media/service/DingMediaService.java deleted file mode 100644 index 0bd7b1dd2..000000000 --- a/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/core/media/service/DingMediaService.java +++ /dev/null @@ -1,91 +0,0 @@ -package cn.bootx.platform.starter.dingtalk.core.media.service; - -import cn.bootx.platform.common.core.exception.BizException; -import cn.bootx.platform.common.core.util.FileUtil; -import cn.bootx.platform.common.jackson.util.JacksonUtil; -import cn.bootx.platform.starter.dingtalk.code.DingTalkCode; -import cn.bootx.platform.starter.dingtalk.core.base.result.MediaResult; -import cn.bootx.platform.starter.dingtalk.core.base.service.DingAccessService; -import cn.bootx.platform.starter.dingtalk.core.media.dao.DingMediaMd5Manager; -import cn.hutool.core.io.FileTypeUtil; -import cn.hutool.core.io.IoUtil; -import cn.hutool.core.io.file.FileNameUtil; -import cn.hutool.core.util.IdUtil; -import cn.hutool.core.util.StrUtil; -import cn.hutool.http.HttpUtil; -import lombok.RequiredArgsConstructor; -import lombok.SneakyThrows; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Service; - -import java.io.ByteArrayInputStream; -import java.io.File; -import java.io.InputStream; -import java.util.Objects; - -import static cn.bootx.platform.starter.dingtalk.code.DingTalkCode.*; - -/** - * 钉钉媒体文件管理 - * - * @author xxm - * @since 2022/7/25 - */ -@Slf4j -@Service -@RequiredArgsConstructor -public class DingMediaService { - - private final DingAccessService dingAccessService; - - private final DingMediaMd5Manager dingMediaMd5Manager; - - /** - * 文件上传 - */ - @SneakyThrows - public String uploadMedia(InputStream inputStream, String fileName, String mediaType) { - // 判断md5是否是已经上传过的, 上传过的直接使用媒体id( 发现钉钉媒体id只能使用一次, 和文档描述不一致 ) - byte[] bytes = IoUtil.readBytes(inputStream); - String filePrefix = FileNameUtil.mainName(fileName); - String fileType = FileTypeUtil.getType(new ByteArrayInputStream(bytes), fileName); - File tmpFile = FileUtil.createTempFile(new ByteArrayInputStream(bytes), filePrefix, fileType); - String body = HttpUtil - .createPost(StrUtil.format(DingTalkCode.MEDIA_UPLOAD_URL, dingAccessService.getAccessToken())) - .form(MEDIA, tmpFile, fileName) - .form(TYPE, mediaType) - .execute() - .body(); - MediaResult mediaResult = JacksonUtil.toBean(body, MediaResult.class); - if (!Objects.equals(mediaResult.getCode(), SUCCESS_CODE)) { - throw new BizException(mediaResult.getMsg()); - } - String mediaId = mediaResult.getMediaId(); - // dingMediaMd5Manager.save(new DingMediaMd5(mediaId,md5)); - return mediaId; - } - - /** - * 文件上传 - */ - @SneakyThrows - public String uploadMedia(InputStream inputStream, String mediaType) { - byte[] bytes = IoUtil.readBytes(inputStream); - - String fileType = FileTypeUtil.getType(new ByteArrayInputStream(bytes)); - File tmpFile = FileUtil.createTempFile(new ByteArrayInputStream(bytes), IdUtil.getSnowflakeNextIdStr(), - fileType); - String body = HttpUtil - .createPost(StrUtil.format(DingTalkCode.MEDIA_UPLOAD_URL, dingAccessService.getAccessToken())) - .form(MEDIA, tmpFile) - .form(TYPE, mediaType) - .execute() - .body(); - MediaResult mediaResult = JacksonUtil.toBean(body, MediaResult.class); - if (!Objects.equals(mediaResult.getCode(), SUCCESS_CODE)) { - throw new BizException(mediaResult.getMsg()); - } - return mediaResult.getMediaId(); - } - -} diff --git a/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/core/notice/result/ChatNoticeResult.java b/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/core/notice/result/ChatNoticeResult.java deleted file mode 100644 index 6494bc73d..000000000 --- a/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/core/notice/result/ChatNoticeResult.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.bootx.platform.starter.dingtalk.core.notice.result; - -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.experimental.Accessors; - -/** - * @author xxm - * @since 2022/7/20 - */ -@Data -@Accessors(chain = true) -@Schema(title = "通知消息返回值") -public class ChatNoticeResult { - - @JsonProperty("errcode") - @Schema(description = "错误码") - private Integer code; - - @JsonProperty("errmsg") - @Schema(description = "返回码描述") - private String msg; - - @Schema(description = "异步发送任务ID") - private String messageId; - -} diff --git a/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/core/notice/result/CorpNoticeResult.java b/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/core/notice/result/CorpNoticeResult.java deleted file mode 100644 index 89a42eeb3..000000000 --- a/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/core/notice/result/CorpNoticeResult.java +++ /dev/null @@ -1,35 +0,0 @@ -package cn.bootx.platform.starter.dingtalk.core.notice.result; - -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.experimental.Accessors; - -/** - * 钉钉消息响应 - * - * @author xxm - * @since 2022/7/17 - */ -@Data -@Accessors(chain = true) -@Schema(title = "通知消息返回值") -public class CorpNoticeResult { - - @JsonProperty("errcode") - @Schema(description = "错误码") - private Integer code; - - @JsonProperty("errmsg") - @Schema(description = "返回码描述") - private String msg; - - @JsonProperty("task_id") - @Schema(description = "异步发送任务ID") - private Long taskId; - - @JsonProperty("request_id") - @Schema(description = "请求ID") - private String requestId; - -} diff --git a/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/core/notice/service/DingNoticeService.java b/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/core/notice/service/DingNoticeService.java deleted file mode 100644 index 34d689ee3..000000000 --- a/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/core/notice/service/DingNoticeService.java +++ /dev/null @@ -1,101 +0,0 @@ -package cn.bootx.platform.starter.dingtalk.core.notice.service; - -import cn.bootx.platform.starter.dingtalk.param.notice.ChatNotice; -import cn.bootx.platform.starter.dingtalk.param.notice.CorpNotice; -import cn.bootx.platform.starter.dingtalk.param.notice.RecallCorpNotice; -import cn.bootx.platform.starter.dingtalk.param.notice.UpdateCorpNotice; -import cn.bootx.platform.common.jackson.util.JacksonUtil; -import cn.bootx.platform.starter.dingtalk.core.base.service.DingAccessService; -import cn.bootx.platform.starter.dingtalk.core.base.result.DingTalkResult; -import cn.bootx.platform.starter.dingtalk.core.notice.result.ChatNoticeResult; -import cn.bootx.platform.starter.dingtalk.core.notice.result.CorpNoticeResult; -import cn.hutool.core.util.StrUtil; -import cn.hutool.http.HttpUtil; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Service; - -import static cn.bootx.platform.starter.dingtalk.code.DingTalkCode.*; - -/** - * 钉钉通知发送服务 - * - * @author xxm - * @since 2022/7/17 - */ -@Slf4j -@Service -@RequiredArgsConstructor -public class DingNoticeService { - - private final DingAccessService dingAccessService; - - /** - * 发送普通消息, 支持普通群和个人会话 - * - * ... - */ - public void sendNotice() { - } - - /** - * 发送企业群消息 - * - * ... - */ - public ChatNoticeResult sendChatNotice(ChatNotice param) { - String accessToken = dingAccessService.getAccessToken(); - String responseBody = HttpUtil.createPost(StrUtil.format(NOTICE_CHAT_URL, accessToken)) - .body(param.toParam()) - .execute() - .body(); - return JacksonUtil.toBean(responseBody, ChatNoticeResult.class); - } - - /** - * 发送工作通知 - * - * ... - */ - public CorpNoticeResult sendCorpNotice(CorpNotice param) { - String accessToken = dingAccessService.getAccessToken(); - String responseBody = HttpUtil.createPost(StrUtil.format(NOTICE_CORP_SEND_URL, accessToken)) - .body(param.toParam()) - .execute() - .body(); - return JacksonUtil.toBean(responseBody, CorpNoticeResult.class); - } - - /** - * 更新工作通知状态栏 - * @url ... - */ - public CorpNoticeResult updateCorpNotice(UpdateCorpNotice param) { - String accessToken = dingAccessService.getAccessToken(); - String responseBody = HttpUtil.createPost(StrUtil.format(NOTICE_CORP_UPDATE_URL, accessToken)) - .body(param.toParam()) - .execute() - .body(); - return JacksonUtil.toBean(responseBody, CorpNoticeResult.class); - } - - /** - * 撤回工作通知消息 - * @url ... - */ - public DingTalkResult recallCorpNotice(RecallCorpNotice param) { - - String accessToken = dingAccessService.getAccessToken(); - String responseBody = HttpUtil.createPost(StrUtil.format(NOTICE_CORP_RECALL_URL, accessToken)) - .body(param.toParam()) - .execute() - .body(); - return JacksonUtil.toBean(responseBody, DingTalkResult.class); - } - -} diff --git a/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/core/robot/convert/DingRobotConvert.java b/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/core/robot/convert/DingRobotConvert.java deleted file mode 100644 index a6b586b61..000000000 --- a/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/core/robot/convert/DingRobotConvert.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.bootx.platform.starter.dingtalk.core.robot.convert; - -import cn.bootx.platform.starter.dingtalk.param.robot.DingRobotConfigParam; -import cn.bootx.platform.starter.dingtalk.core.robot.entity.DingRobotConfig; -import cn.bootx.platform.starter.dingtalk.dto.robot.DingRobotConfigDto; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -/** - * 钉钉相关类转换 - * - * @author xxm - * @since 2021/8/5 - */ -@Mapper -public interface DingRobotConvert { - - DingRobotConvert CONVERT = Mappers.getMapper(DingRobotConvert.class); - - DingRobotConfig convert(DingRobotConfigParam in); - - DingRobotConfigDto convert(DingRobotConfig in); - -} diff --git a/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/core/robot/dao/DingRobotConfigManager.java b/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/core/robot/dao/DingRobotConfigManager.java deleted file mode 100644 index be0f01b21..000000000 --- a/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/core/robot/dao/DingRobotConfigManager.java +++ /dev/null @@ -1,47 +0,0 @@ -package cn.bootx.platform.starter.dingtalk.core.robot.dao; - -import cn.bootx.platform.starter.dingtalk.core.robot.entity.DingRobotConfig; -import cn.bootx.platform.starter.dingtalk.param.robot.DingRobotConfigParam; -import cn.bootx.platform.common.core.rest.param.PageParam; -import cn.bootx.platform.common.mybatisplus.base.MpIdEntity; -import cn.bootx.platform.common.mybatisplus.impl.BaseManager; -import cn.bootx.platform.common.mybatisplus.util.MpUtil; -import cn.hutool.core.util.StrUtil; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import lombok.RequiredArgsConstructor; -import org.springframework.stereotype.Repository; - -import java.util.Optional; - -/** - * 钉钉机器人 - * - * @author xxm - * @since 2020/11/29 - */ -@Repository -@RequiredArgsConstructor -public class DingRobotConfigManager extends BaseManager { - - public Optional findByCode(String code) { - return findByField(DingRobotConfig::getCode, code); - } - - public boolean existsByCode(String code) { - return existedByField(DingRobotConfig::getCode, code); - } - - public boolean existsByCode(String code, Long id) { - return lambdaQuery().eq(DingRobotConfig::getCode, code).ne(MpIdEntity::getId, id).exists(); - } - - public Page page(PageParam pageParam, DingRobotConfigParam param) { - Page mpPage = MpUtil.getMpPage(pageParam, DingRobotConfig.class); - return lambdaQuery().orderByDesc(MpIdEntity::getId) - .like(StrUtil.isNotBlank(param.getCode()), DingRobotConfig::getCode, param.getCode()) - .like(StrUtil.isNotBlank(param.getName()), DingRobotConfig::getName, param.getName()) - .like(StrUtil.isNotBlank(param.getAccessToken()), DingRobotConfig::getAccessToken, param.getAccessToken()) - .page(mpPage); - } - -} diff --git a/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/core/robot/dao/DingRobotConfigMapper.java b/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/core/robot/dao/DingRobotConfigMapper.java deleted file mode 100644 index f15141791..000000000 --- a/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/core/robot/dao/DingRobotConfigMapper.java +++ /dev/null @@ -1,16 +0,0 @@ -package cn.bootx.platform.starter.dingtalk.core.robot.dao; - -import cn.bootx.platform.starter.dingtalk.core.robot.entity.DingRobotConfig; -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import org.apache.ibatis.annotations.Mapper; - -/** - * 钉钉机器人配置 - * - * @author xxm - * @since 2021/8/5 - */ -@Mapper -public interface DingRobotConfigMapper extends BaseMapper { - -} diff --git a/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/core/robot/entity/DingRobotConfig.java b/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/core/robot/entity/DingRobotConfig.java deleted file mode 100644 index 2532efee0..000000000 --- a/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/core/robot/entity/DingRobotConfig.java +++ /dev/null @@ -1,52 +0,0 @@ -package cn.bootx.platform.starter.dingtalk.core.robot.entity; - -import cn.bootx.platform.starter.dingtalk.core.robot.convert.DingRobotConvert; -import cn.bootx.platform.starter.dingtalk.param.robot.DingRobotConfigParam; -import cn.bootx.platform.common.core.function.EntityBaseFunction; -import cn.bootx.platform.common.mybatisplus.base.MpBaseEntity; -import cn.bootx.platform.starter.dingtalk.dto.robot.DingRobotConfigDto; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.experimental.Accessors; - -/** - * 钉钉机器人配置 - * - * @author xxm - * @since 2020/11/29 - */ -@EqualsAndHashCode(callSuper = true) -@Data -@Accessors(chain = true) -@TableName("starter_ding_robot_config") -public class DingRobotConfig extends MpBaseEntity implements EntityBaseFunction { - - /** 机器人编号编号 */ - private String code; - - /** 机器人配置名称 */ - private String name; - - /** 钉钉机器人的accessToken */ - private String accessToken; - - /** 是否开启验签 */ - private boolean enableSignatureCheck; - - /** 验签秘钥 */ - private String signSecret; - - /** 备注 */ - private String remark; - - public static DingRobotConfig init(DingRobotConfigParam in) { - return DingRobotConvert.CONVERT.convert(in); - } - - @Override - public DingRobotConfigDto toDto() { - return DingRobotConvert.CONVERT.convert(this); - } - -} diff --git a/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/core/robot/service/DingRobotConfigService.java b/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/core/robot/service/DingRobotConfigService.java deleted file mode 100644 index 72d4781e9..000000000 --- a/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/core/robot/service/DingRobotConfigService.java +++ /dev/null @@ -1,102 +0,0 @@ -package cn.bootx.platform.starter.dingtalk.core.robot.service; - -import cn.bootx.platform.starter.dingtalk.param.robot.DingRobotConfigParam; -import cn.bootx.platform.common.core.exception.BizException; -import cn.bootx.platform.common.core.exception.DataNotExistException; -import cn.bootx.platform.common.core.rest.PageResult; -import cn.bootx.platform.common.core.rest.param.PageParam; -import cn.bootx.platform.common.core.util.ResultConvertUtil; -import cn.bootx.platform.common.mybatisplus.util.MpUtil; -import cn.bootx.platform.starter.dingtalk.core.robot.dao.DingRobotConfigManager; -import cn.bootx.platform.starter.dingtalk.core.robot.entity.DingRobotConfig; -import cn.bootx.platform.starter.dingtalk.dto.robot.DingRobotConfigDto; -import cn.hutool.core.bean.BeanUtil; -import cn.hutool.core.bean.copier.CopyOptions; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import java.util.List; - -/** - * 钉钉机器人消息发送 - * - * @author xxm - * @since 2020/11/29 - */ -@Slf4j -@Service -@RequiredArgsConstructor -public class DingRobotConfigService { - - private final DingRobotConfigManager robotConfigManager; - - /** - * 添加新配置 - */ - @Transactional(rollbackFor = Exception.class) - public DingRobotConfigDto add(DingRobotConfigParam param) { - if (robotConfigManager.existsByCode(param.getCode())) { - throw new BizException("code重复"); - } - - DingRobotConfig dingRobotConfig = DingRobotConfig.init(param); - - return robotConfigManager.save(dingRobotConfig).toDto(); - } - - /** - * 更新钉钉机器人配置 - */ - @Transactional(rollbackFor = Exception.class) - public DingRobotConfigDto update(DingRobotConfigParam param) { - DingRobotConfig dingRobotConfig = robotConfigManager.findById(param.getId()) - .orElseThrow(DataNotExistException::new); - BeanUtil.copyProperties(param, dingRobotConfig, CopyOptions.create().ignoreNullValue()); - return robotConfigManager.updateById(dingRobotConfig).toDto(); - } - - /** - * 获取所有配置 - */ - public List findAll() { - return ResultConvertUtil.dtoListConvert(robotConfigManager.findAll()); - } - - /** - * 获取所有配置 - */ - public PageResult page(PageParam pageParam, DingRobotConfigParam param) { - return MpUtil.convert2DtoPageResult(robotConfigManager.page(pageParam, param)); - } - - /** - * 根据 id 获取相应的配置 - */ - public DingRobotConfigDto findById(Long id) { - return ResultConvertUtil.dtoConvert(robotConfigManager.findById(id)); - } - - /** - * 根据 id 删除相应的机器人配置 - */ - public void delete(Long id) { - robotConfigManager.deleteById(id); - } - - /** - * 编码是否已经存在 - */ - public boolean existsByCode(String code) { - return robotConfigManager.existsByCode(code); - } - - /** - * 编码是否已经存在(不包含自身) - */ - public boolean existsByCode(String code, Long id) { - return robotConfigManager.existsByCode(code, id); - } - -} diff --git a/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/core/robot/service/DingRobotSendService.java b/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/core/robot/service/DingRobotSendService.java deleted file mode 100644 index 3cf127843..000000000 --- a/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/core/robot/service/DingRobotSendService.java +++ /dev/null @@ -1,68 +0,0 @@ -package cn.bootx.platform.starter.dingtalk.core.robot.service; - -import cn.bootx.platform.starter.dingtalk.param.notice.msg.Msg; -import cn.bootx.platform.starter.dingtalk.util.DingTalkUtil; -import cn.bootx.platform.common.core.exception.DataNotExistException; -import cn.bootx.platform.common.jackson.util.JacksonUtil; -import cn.bootx.platform.starter.dingtalk.code.DingTalkCode; -import cn.bootx.platform.starter.dingtalk.core.robot.dao.DingRobotConfigManager; -import cn.bootx.platform.starter.dingtalk.core.robot.entity.DingRobotConfig; -import cn.bootx.platform.starter.dingtalk.core.base.result.DingTalkResult; -import cn.hutool.core.util.StrUtil; -import cn.hutool.http.HttpUtil; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Service; - -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -import static cn.bootx.platform.starter.dingtalk.code.DingTalkCode.SUCCESS_CODE; - -/** - * 钉钉机器人消息发送 - * - * @author xxm - * @since 2020/11/29 - */ -@Slf4j -@Service -@RequiredArgsConstructor -public class DingRobotSendService { - - private final DingRobotConfigManager dingRobotConfigManager; - - /** - * 发送钉钉机器人消息 - */ - public void sendNotice(String code, Msg body) { - DingRobotConfig dingRobotConfig = dingRobotConfigManager.findByCode(code) - .orElseThrow(() -> new DataNotExistException("钉钉机器人配置不存在")); - long timestamp = System.currentTimeMillis(); - - Map map = new HashMap<>(3); - map.put(DingTalkCode.ACCESS_TOKEN, dingRobotConfig.getAccessToken()); - String url; - // 验签 - if (dingRobotConfig.isEnableSignatureCheck()) { - url = DingTalkCode.ROBOT_SEND_SIGN_URL; - map.put(DingTalkCode.SIGN, DingTalkUtil.generateSign(timestamp, dingRobotConfig.getSignSecret())); - map.put(DingTalkCode.TIMESTAMP, timestamp); - } - else { - url = DingTalkCode.ROBOT_SEND_NOT_SIGN_URL; - } - - // 请求消息 - String responseBody = HttpUtil.createPost(StrUtil.format(url, map)) - .body(JacksonUtil.toJson(body)) - .execute() - .body(); - DingTalkResult dingTalkResult = JacksonUtil.toBean(responseBody, DingTalkResult.class); - if (!Objects.equals(SUCCESS_CODE, dingTalkResult.getCode())) { - log.error("钉钉机器人发送消息失败: {}", dingTalkResult.getMsg()); - } - } - -} diff --git a/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/core/user/entity/UserIdResult.java b/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/core/user/entity/UserIdResult.java deleted file mode 100644 index 82bb8f864..000000000 --- a/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/core/user/entity/UserIdResult.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.bootx.platform.starter.dingtalk.core.user.entity; - -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.experimental.Accessors; - -/** - * @author xxm - * @since 2022/7/21 - */ -@Data -@Accessors(chain = true) -@Schema(title = "钉钉id消息") -public class UserIdResult { - - @JsonProperty("contact_type") - @Schema(description = "联系类型") - private String contactType; - - @JsonProperty("userid") - @Schema(description = "用户id") - private String userId; - -} diff --git a/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/core/user/service/DingUserService.java b/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/core/user/service/DingUserService.java deleted file mode 100644 index 83a409027..000000000 --- a/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/core/user/service/DingUserService.java +++ /dev/null @@ -1,60 +0,0 @@ -package cn.bootx.platform.starter.dingtalk.core.user.service; - -import cn.bootx.platform.common.core.exception.BizException; -import cn.bootx.platform.common.jackson.util.JacksonUtil; -import cn.bootx.platform.starter.dingtalk.core.base.result.DingTalkResult; -import cn.bootx.platform.starter.dingtalk.core.base.service.DingAccessService; -import cn.bootx.platform.starter.dingtalk.core.user.entity.UserIdResult; -import cn.hutool.core.util.StrUtil; -import cn.hutool.http.HttpUtil; -import com.fasterxml.jackson.core.type.TypeReference; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Service; - -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -import static cn.bootx.platform.starter.dingtalk.code.DingTalkCode.*; - -/** - * 钉钉用户信息 - * - * @author xxm - * @since 2022/7/17 - */ -@Slf4j -@Service -@RequiredArgsConstructor -public class DingUserService { - - private final DingAccessService dingAccessService; - - /** - * 根据unionid获取用户userid ... - */ - public String getUserIdByUnionId(String unionId) { - String accessToken = dingAccessService.getAccessToken(); - Map map = new HashMap<>(1); - map.put(UNION_ID, unionId); - String responseBody = HttpUtil.createPost(StrUtil.format(USER_GET_URL, accessToken)) - .body(JacksonUtil.toJson(map)) - .execute() - .body(); - DingTalkResult dingTalkResult = JacksonUtil.toBean(responseBody, - new TypeReference>() { - }); - // 未找到用户, 返回空 - if (Objects.equals(dingTalkResult.getCode(), NOT_FUND_STAFF)) { - return null; - } - // 错误 - if (!Objects.equals(dingTalkResult.getCode(), SUCCESS_CODE)) { - throw new BizException(dingTalkResult.getMsg()); - } - return dingTalkResult.getResult().getUserId(); - } - -} diff --git a/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/dto/robot/DingRobotConfigDto.java b/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/dto/robot/DingRobotConfigDto.java deleted file mode 100644 index d9042be1e..000000000 --- a/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/dto/robot/DingRobotConfigDto.java +++ /dev/null @@ -1,40 +0,0 @@ -package cn.bootx.platform.starter.dingtalk.dto.robot; - -import cn.bootx.platform.common.core.rest.dto.BaseDto; -import cn.bootx.platform.starter.data.perm.sensitive.SensitiveInfo; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.experimental.Accessors; - -import java.io.Serializable; - -@EqualsAndHashCode(callSuper = true) -@Data -@Accessors(chain = true) -@Schema(title = "钉钉机器人配置") -public class DingRobotConfigDto extends BaseDto implements Serializable { - - private static final long serialVersionUID = -5642207413191556792L; - - @Schema(description = "编号") - private String code; - - @Schema(description = "配置名称") - private String name; - - @Schema(description = "钉钉机器人的AccessToken") - @SensitiveInfo - private String accessToken; - - @Schema(description = "是否开启验签") - private boolean enableSignatureCheck; - - @Schema(description = "验签秘钥") - @SensitiveInfo - private String signSecret; - - @Schema(description = "描述") - private String remark; - -} diff --git a/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/param/notice/ChatNotice.java b/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/param/notice/ChatNotice.java deleted file mode 100644 index 6d8c0e3a5..000000000 --- a/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/param/notice/ChatNotice.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.bootx.platform.starter.dingtalk.param.notice; - -import cn.bootx.platform.starter.dingtalk.param.notice.msg.Msg; -import cn.bootx.platform.common.jackson.util.JacksonUtil; -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; -import lombok.experimental.Accessors; - -/** - * 钉钉发送企业群消息参数 - * - * @author xxm - * @since 2022/7/20 - */ -@Data -@Accessors(chain = true) -@AllArgsConstructor -@NoArgsConstructor -@Schema(title = "钉钉发送企业群消息参数") -public class ChatNotice { - - @JsonProperty("chatid") - @Schema(description = "群Id") - private String chatId; - - @Schema(description = "消息内容") - private Msg msg; - - /** - * 输出参数 - */ - public String toParam() { - return JacksonUtil.toJson(this); - } - -} diff --git a/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/param/notice/CorpNotice.java b/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/param/notice/CorpNotice.java deleted file mode 100644 index 7023a4d40..000000000 --- a/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/param/notice/CorpNotice.java +++ /dev/null @@ -1,55 +0,0 @@ -package cn.bootx.platform.starter.dingtalk.param.notice; - -import cn.bootx.platform.starter.dingtalk.param.notice.msg.Msg; -import cn.bootx.platform.common.jackson.util.JacksonUtil; -import cn.hutool.core.lang.Opt; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.experimental.Accessors; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * 钉钉发送工作通知参数 - * - * @author xxm - * @since 2022/7/17 - */ -@Data -@Accessors(chain = true) -@Schema(title = "钉钉发送工作通知参数") -public class CorpNotice { - - @Schema(description = "发送消息时使用的微应用的AgentID") - private Long agentId; - - @Schema(description = "接收者的userid列表,最大用户列表长度100") - private List useridList; - - @Schema(description = "接收者的部门id列表,最大列表长度20") - private List deptIdList; - - @Schema(description = "是否发送给企业全部用户") - private boolean toAllUser; - - @Schema(description = "消息内容") - private Msg msg; - - /** - * 输出参数 - */ - public String toParam() { - Map map = new HashMap<>(5); - String useridList = Opt.ofEmptyAble(this.useridList).map(list -> String.join(",", list)).orElse(null); - String deptIdList = Opt.ofEmptyAble(this.deptIdList).map(list -> String.join(",", list)).orElse(null); - map.put("agent_id", agentId); - map.put("userid_list", useridList); - map.put("dept_id_list", deptIdList); - map.put("to_all_user", toAllUser); - map.put("msg", msg); - return JacksonUtil.toJson(map); - } - -} diff --git a/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/param/notice/RecallCorpNotice.java b/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/param/notice/RecallCorpNotice.java deleted file mode 100644 index 805cbe728..000000000 --- a/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/param/notice/RecallCorpNotice.java +++ /dev/null @@ -1,36 +0,0 @@ -package cn.bootx.platform.starter.dingtalk.param.notice; - -import cn.bootx.platform.common.jackson.util.JacksonUtil; -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; -import lombok.experimental.Accessors; - -/** - * 钉钉撤回工作通知 - * - * @author xxm - * @since 2022/7/20 - */ -@Data -@Accessors(chain = true) -@AllArgsConstructor -@NoArgsConstructor -@Schema(title = "钉钉撤回工作通知") -public class RecallCorpNotice { - - @JsonProperty("agent_id") - @Schema(description = "发送消息时使用的微应用的AgentID") - private Long agentId; - - @JsonProperty("msg_task_id") - @Schema(description = "发送消息时钉钉返回的任务ID") - private Long taskId; - - public String toParam() { - return JacksonUtil.toJson(this); - } - -} diff --git a/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/param/notice/UpdateCorpNotice.java b/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/param/notice/UpdateCorpNotice.java deleted file mode 100644 index d6e036304..000000000 --- a/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/param/notice/UpdateCorpNotice.java +++ /dev/null @@ -1,40 +0,0 @@ -package cn.bootx.platform.starter.dingtalk.param.notice; - -import cn.bootx.platform.common.jackson.util.JacksonUtil; -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.experimental.Accessors; - -/** - * 钉钉 更新工作通知状态栏 - * - * @author xxm - * @since 2022/7/17 - */ -@Data -@Accessors(chain = true) -@Schema(title = "钉钉更新工作通知状态栏") -public class UpdateCorpNotice { - - @JsonProperty("agent_id") - @Schema(description = "发送消息时使用的微应用的AgentID") - private Long agentId; - - @JsonProperty("task_id") - @Schema(description = "发送消息时使用的微应用的AgentID") - private Long taskId; - - @JsonProperty("status_value") - @Schema(description = "状态栏值") - private String statusValue; - - @JsonProperty("status_bg") - @Schema(description = "状态栏背景色,推荐0xFF加六位颜色值") - private String statusBg; - - public String toParam() { - return JacksonUtil.toJson(this); - } - -} diff --git a/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/param/notice/msg/ActionCardMsg.java b/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/param/notice/msg/ActionCardMsg.java deleted file mode 100644 index 20ee7b85a..000000000 --- a/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/param/notice/msg/ActionCardMsg.java +++ /dev/null @@ -1,70 +0,0 @@ -package cn.bootx.platform.starter.dingtalk.param.notice.msg; - -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.experimental.Accessors; - -import java.util.List; - -/** - * 钉钉卡片消息 - * - * @author xxm - * @since 2022/7/19 - */ -@EqualsAndHashCode(callSuper = true) -@Data -@Accessors(chain = true) -@Schema(title = "钉钉卡片消息") -public class ActionCardMsg extends Msg { - - @Schema(description = "消息内容,支持markdown") - @JsonProperty("action_card") - private ActionCard actionCard; - - @Data - @Accessors(chain = true) - @Schema(title = "消息内容,支持markdown") - public static class ActionCard { - - @Schema(description = "透出到会话列表和通知的文案") - private String title; - - @Schema(description = "消息内容") - private String markdown; - - @JsonProperty("single_title") - @Schema(description = "标题") - private String singleTitle; - - @JsonProperty("single_url") - @Schema(description = "消息点击链接地址") - private String singleUrl; - - @JsonProperty("btn_orientation") - @Schema(description = "使用独立跳转ActionCard样式时的按钮排列方式") - private String btnOrientation; - - @JsonProperty("btn_json_list") - @Schema(description = "使用独立跳转ActionCard样式时的按钮列表") - private List btnJsonList; - - @Data - @Accessors(chain = true) - @Schema(title = "使用独立跳转ActionCard样式时的按钮列表") - public static class BtnJson { - - @Schema(description = "按钮的标题") - private String title; - - @JsonProperty("action_url") - @Schema(description = "跳转链接") - private String actionUrl; - - } - - } - -} diff --git a/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/param/notice/msg/At.java b/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/param/notice/msg/At.java deleted file mode 100644 index 3aef39823..000000000 --- a/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/param/notice/msg/At.java +++ /dev/null @@ -1,59 +0,0 @@ -package cn.bootx.platform.starter.dingtalk.param.notice.msg; - -import cn.hutool.core.collection.CollUtil; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.NoArgsConstructor; -import lombok.experimental.Accessors; - -import java.io.Serializable; -import java.util.List; - -/** - * 钉钉At - * - * @author xxm - * @since 2020/11/29 - */ -@Data -@Accessors(chain = true) -@NoArgsConstructor -@Schema(title = "钉钉@指定用户") -public class At implements Serializable { - - private static final long serialVersionUID = -8677524557109058147L; - - @Schema(description = "@的用户手机号") - private List atMobiles; - - @Schema(description = "@被@人的用户userid") - private List atUserIds; - - @Schema(description = "是否@全体") - private boolean isAtAll = false; - - public At(List atMobiles) { - this.atMobiles = atMobiles; - } - - /** - * 输出@xxx文本 - */ - public String toAtMobiles() { - if (CollUtil.isNotEmpty(atMobiles)) { - return " @" + String.join(" @", atMobiles); - } - return ""; - } - - /** - * 输出@xxx文本 - */ - public String toAtUserIds() { - if (CollUtil.isNotEmpty(atUserIds)) { - return " @" + String.join(" @", atUserIds); - } - return ""; - } - -} diff --git a/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/param/notice/msg/DingMedia.java b/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/param/notice/msg/DingMedia.java deleted file mode 100644 index 28012efd3..000000000 --- a/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/param/notice/msg/DingMedia.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.bootx.platform.starter.dingtalk.param.notice.msg; - -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; -import lombok.experimental.Accessors; - -/** - * 钉钉图片 - * - * @author xxm - * @since 2022/7/17 - */ -@Data -@Accessors(chain = true) -@Schema(title = "钉钉媒体") -@NoArgsConstructor -@AllArgsConstructor -public class DingMedia { - - @JsonProperty("media_id") - @Schema(description = "媒体文件id") - private String mediaId; - -} diff --git a/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/param/notice/msg/FileMsg.java b/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/param/notice/msg/FileMsg.java deleted file mode 100644 index d948b44d5..000000000 --- a/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/param/notice/msg/FileMsg.java +++ /dev/null @@ -1,37 +0,0 @@ -package cn.bootx.platform.starter.dingtalk.param.notice.msg; - -import cn.bootx.platform.starter.dingtalk.code.DingTalkNoticeCode; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.experimental.Accessors; - -import java.io.Serializable; - -/** - * 钉钉图片通知 - * - * @author xxm - * @since 2022/7/17 - */ -@EqualsAndHashCode(callSuper = true) -@Data -@Accessors(chain = true) -@Schema(title = "钉钉文件通知") -public class FileMsg extends Msg implements Serializable { - - private static final long serialVersionUID = -835679566138176L; - - @Schema(description = "钉钉文件") - private DingMedia file; - - public FileMsg() { - super(DingTalkNoticeCode.MSG_FILE); - } - - public FileMsg(String mediaId) { - super(DingTalkNoticeCode.MSG_FILE); - this.file = new DingMedia(mediaId); - } - -} diff --git a/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/param/notice/msg/ImageMsg.java b/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/param/notice/msg/ImageMsg.java deleted file mode 100644 index a1fa6cb82..000000000 --- a/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/param/notice/msg/ImageMsg.java +++ /dev/null @@ -1,37 +0,0 @@ -package cn.bootx.platform.starter.dingtalk.param.notice.msg; - -import cn.bootx.platform.starter.dingtalk.code.DingTalkNoticeCode; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.experimental.Accessors; - -import java.io.Serializable; - -/** - * 钉钉图片通知 - * - * @author xxm - * @since 2022/7/17 - */ -@EqualsAndHashCode(callSuper = true) -@Data -@Accessors(chain = true) -@Schema(title = "钉钉图片通知") -public class ImageMsg extends Msg implements Serializable { - - private static final long serialVersionUID = -835679566138176L; - - @Schema(description = "钉钉图片") - private DingMedia image; - - public ImageMsg() { - super(DingTalkNoticeCode.MSG_IMAGE); - } - - public ImageMsg(String mediaId) { - super(DingTalkNoticeCode.MSG_IMAGE); - this.image = new DingMedia(mediaId); - } - -} diff --git a/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/param/notice/msg/LinkMsg.java b/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/param/notice/msg/LinkMsg.java deleted file mode 100644 index 20b1ab0c7..000000000 --- a/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/param/notice/msg/LinkMsg.java +++ /dev/null @@ -1,78 +0,0 @@ -package cn.bootx.platform.starter.dingtalk.param.notice.msg; - -import cn.bootx.platform.starter.dingtalk.code.DingTalkNoticeCode; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.NoArgsConstructor; -import lombok.experimental.Accessors; - -import java.io.Serializable; - -/** - * 钉钉链接消息 - * - * @author xxm - * @since 2020/11/30 - */ -@EqualsAndHashCode(callSuper = true) -@Data -@Accessors(chain = true) -@Schema(title = "钉钉链接消息") -public class LinkMsg extends Msg implements Serializable { - - private static final long serialVersionUID = -3094638065840434973L; - - @Schema(description = "钉钉link消息体") - private DingLink link; - - public LinkMsg() { - super(DingTalkNoticeCode.MSG_LINK); - } - - public LinkMsg(String title, String msg, String messageUrl) { - super(DingTalkNoticeCode.MSG_LINK); - link = new DingLink(title, msg, messageUrl); - } - - public LinkMsg(String title, String msg, String messageUrl, String picUrl) { - super(DingTalkNoticeCode.MSG_LINK); - link = new DingLink(title, msg, messageUrl, picUrl); - } - - @Data - @Accessors(chain = true) - @Schema(title = "钉钉link") - @NoArgsConstructor - public static class DingLink implements Serializable { - - private static final long serialVersionUID = 8191181631664337904L; - - @Schema(description = "标题") - private String title; - - @Schema(description = "内容") - private String text; - - @Schema(description = "点击消息跳转的URL") - private String messageUrl; - - @Schema(description = "图片URL") - private String picUrl; - - public DingLink(String title, String text, String messageUrl) { - this.title = title; - this.text = text; - this.messageUrl = messageUrl; - } - - public DingLink(String title, String text, String messageUrl, String picUrl) { - this.title = title; - this.text = text; - this.messageUrl = messageUrl; - this.picUrl = picUrl; - } - - } - -} diff --git a/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/param/notice/msg/MarkdownMsg.java b/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/param/notice/msg/MarkdownMsg.java deleted file mode 100644 index 40548c1d5..000000000 --- a/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/param/notice/msg/MarkdownMsg.java +++ /dev/null @@ -1,70 +0,0 @@ -package cn.bootx.platform.starter.dingtalk.param.notice.msg; - -import cn.bootx.platform.starter.dingtalk.code.DingTalkNoticeCode; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.NoArgsConstructor; -import lombok.experimental.Accessors; - -import java.io.Serializable; -import java.util.List; - -/** - * 钉钉markdown消息 - * - * @author xxm - * @since 2020/11/30 - */ -@EqualsAndHashCode(callSuper = true) -@Data -@Accessors(chain = true) -@Schema(title = "钉钉文本消息") -public class MarkdownMsg extends Msg implements Serializable { - - private static final long serialVersionUID = -2724590259000709240L; - - @Schema(description = "markdown消息体") - private DingMarkdown markdown; - - public MarkdownMsg() { - super(DingTalkNoticeCode.MSG_MARKDOWN); - } - - /** - * @param title 标题 - * @param msg 内容 - * @param phones @谁 - */ - public MarkdownMsg(String title, String msg, List phones) { - super(new At(phones), DingTalkNoticeCode.MSG_MARKDOWN); - this.markdown = new DingMarkdown(title, msg); - } - - public MarkdownMsg(String title, String msg) { - super(DingTalkNoticeCode.MSG_MARKDOWN); - this.markdown = new DingMarkdown(title, msg); - } - - @Data - @Accessors(chain = true) - @NoArgsConstructor - @Schema(title = "钉钉markdown格式信息") - public static class DingMarkdown implements Serializable { - - private static final long serialVersionUID = 2353543901449818541L; - - @Schema(description = "标题") - private String title; - - @Schema(description = "内容") - private String text; - - public DingMarkdown(String title, String text) { - this.title = title; - this.text = text; - } - - } - -} diff --git a/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/param/notice/msg/Msg.java b/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/param/notice/msg/Msg.java deleted file mode 100644 index 656371c4b..000000000 --- a/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/param/notice/msg/Msg.java +++ /dev/null @@ -1,50 +0,0 @@ -package cn.bootx.platform.starter.dingtalk.param.notice.msg; - -import cn.bootx.platform.starter.dingtalk.code.DingTalkNoticeCode; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.NoArgsConstructor; -import lombok.experimental.Accessors; - -import java.io.Serializable; - -/** - * 钉钉消息 - * - * @author xxm - * @since 2020/11/30 - */ -@Data -@Accessors(chain = true) -@NoArgsConstructor -@Schema(title = "钉钉消息基础类") -public class Msg implements Serializable { - - private static final long serialVersionUID = -8548175773944126488L; - - /** - * ... - */ - @JsonInclude(JsonInclude.Include.NON_NULL) - @Schema(description = "@谁(机器人消息用)") - private At at; - - /** - * @see DingTalkNoticeCode - */ - @JsonProperty("msgtype") - @Schema(description = "消息类型") - private String msgType; - - public Msg(At at, String msgType) { - this.at = at; - this.msgType = msgType; - } - - public Msg(String msgType) { - this.msgType = msgType; - } - -} diff --git a/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/param/notice/msg/OaMsg.java b/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/param/notice/msg/OaMsg.java deleted file mode 100644 index fbaab9131..000000000 --- a/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/param/notice/msg/OaMsg.java +++ /dev/null @@ -1,139 +0,0 @@ -package cn.bootx.platform.starter.dingtalk.param.notice.msg; - -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.NoArgsConstructor; -import lombok.experimental.Accessors; - -import java.util.List; - -/** - * 钉钉OA消息 - * - * @author xxm - * @since 2022/7/19 - */ -@EqualsAndHashCode(callSuper = true) -@Data -@Accessors(chain = true) -@AllArgsConstructor -@NoArgsConstructor -@Schema(title = "钉钉OA消息") -public class OaMsg extends Msg { - - @Schema(description = "OA消息体") - private Oa oa; - - @Data - @Accessors(chain = true) - @Schema(title = "OA消息体") - public static class Oa { - - @JsonProperty("message_url") - @Schema(description = "消息点击链接地址") - private String messageUrl; - - @JsonProperty("pc_message_url") - @Schema(description = "PC端点击消息时跳转到的地址") - private String pcMessageUrl; - - @Schema(description = "消息头部内容") - private Head head; - - @Schema(description = "消息体") - private Body body; - - @JsonProperty("status_bar") - @Schema(description = "消息状态栏") - private StatusBar statusBar; - - @Data - @Accessors(chain = true) - @Schema(title = "消息头部内容") - public static class Head { - - @JsonProperty("bgcolor") - @Schema(description = "消息头部的背景颜色") - private String bgColor; - - @Schema(description = "消息的头部标题") - private String text; - - } - - @Data - @Accessors(chain = true) - @Schema(title = "消息状态栏") - public static class StatusBar { - - @Schema(description = "状态栏文案") - @JsonProperty("status_value") - private String statusValue; - - @Schema(description = "状态栏背景色") - @JsonProperty("status_bg") - private String statusBg; - - } - - @Data - @Accessors(chain = true) - @Schema(title = "消息体") - public static class Body { - - @Schema(description = "消息体的标题") - private String title; - - @Schema(description = "消息体的表单") - private List

form; - - @Schema(description = "单行富文本信息") - private Rich rich; - - @Schema(description = "消息体的内容") - private String content; - - @Schema(description = "消息体中的图片(媒体id)") - private String image; - - @Schema(description = "自定义的附件数目") - @JsonProperty("file_count") - private String fileCount; - - @Schema(description = "自定义的作者名字") - private String author; - - @Data - @Accessors(chain = true) - @Schema(title = "消息体的表单,最多显示6个,超过会被隐藏") - public static class Form { - - @Schema(description = "消息体的关键字") - private String key; - - @Schema(description = "消息体的关键字对应的值") - private String value; - - } - - @Data - @Accessors(chain = true) - @Schema(title = "单行富文本信息") - public static class Rich { - - @Schema(description = "单行富文本信息的数目") - private String num; - - @Schema(description = "单行富文本信息的单位") - private String unit; - - } - - } - - } - -} diff --git a/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/param/notice/msg/TextMsg.java b/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/param/notice/msg/TextMsg.java deleted file mode 100644 index 72e71d042..000000000 --- a/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/param/notice/msg/TextMsg.java +++ /dev/null @@ -1,51 +0,0 @@ -package cn.bootx.platform.starter.dingtalk.param.notice.msg; - -import cn.bootx.platform.starter.dingtalk.code.DingTalkNoticeCode; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.NoArgsConstructor; -import lombok.experimental.Accessors; - -import java.io.Serializable; - -/** - * @author xxm - * @since 2020/11/29 - */ -@EqualsAndHashCode(callSuper = true) -@Data -@Accessors(chain = true) -@Schema(title = "钉钉文本消息") -public class TextMsg extends Msg implements Serializable { - - private static final long serialVersionUID = 8237431306046852539L; - - @Schema(description = "文本消息体") - private DingText text; - - public TextMsg() { - super(DingTalkNoticeCode.MSG_TEXT); - } - - public TextMsg(String msg) { - super(DingTalkNoticeCode.MSG_TEXT); - text = new DingText(msg); - } - - @Data - @Accessors(chain = true) - @NoArgsConstructor - @AllArgsConstructor - @Schema(title = "钉钉文本") - public static class DingText implements Serializable { - - private static final long serialVersionUID = 3582073816491238620L; - - @Schema(description = "文本") - private String content; - - } - -} diff --git a/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/param/notice/msg/VoiceMsg.java b/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/param/notice/msg/VoiceMsg.java deleted file mode 100644 index d4b95c511..000000000 --- a/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/param/notice/msg/VoiceMsg.java +++ /dev/null @@ -1,55 +0,0 @@ -package cn.bootx.platform.starter.dingtalk.param.notice.msg; - -import cn.bootx.platform.starter.dingtalk.code.DingTalkNoticeCode; -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.NoArgsConstructor; -import lombok.experimental.Accessors; - -import java.io.Serializable; - -/** - * 钉钉语音消息 - * - * @author xxm - * @since 2022/7/17 - */ -@EqualsAndHashCode(callSuper = true) -@Data -@Accessors(chain = true) -@Schema(title = "钉钉语音消息") -public class VoiceMsg extends Msg implements Serializable { - - @Schema(description = "钉钉语音") - private DingVoice voice; - - public VoiceMsg() { - super(DingTalkNoticeCode.MSG_VOICE); - } - - public VoiceMsg(String mediaId, String duration) { - super(DingTalkNoticeCode.MSG_VOICE); - this.voice = new DingVoice(mediaId, duration); - } - - @Data - @Accessors(chain = true) - @Schema(title = "钉钉语音") - @NoArgsConstructor - @AllArgsConstructor - public static class DingVoice { - - @JsonProperty("media_id") - @Schema(description = "媒体文件id") - private String mediaId; - - @JsonProperty("duration") - @Schema(description = "音频时长") - private String duration; - - } - -} diff --git a/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/param/robot/DingRobotConfigParam.java b/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/param/robot/DingRobotConfigParam.java deleted file mode 100644 index 620604d8c..000000000 --- a/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/param/robot/DingRobotConfigParam.java +++ /dev/null @@ -1,41 +0,0 @@ -package cn.bootx.platform.starter.dingtalk.param.robot; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.experimental.Accessors; - -import java.io.Serializable; - -/** - * @author xxm - * @since 2021/8/5 - */ -@Data -@Accessors(chain = true) -@Schema(title = "钉钉机器人配置参数") -public class DingRobotConfigParam implements Serializable { - - private static final long serialVersionUID = -3979174622716815670L; - - @Schema(description = "主键") - private Long id; - - @Schema(description = "编号") - private String code; - - @Schema(description = "配置名称") - private String name; - - @Schema(description = "钉钉机器人的accessToken") - private String accessToken; - - @Schema(description = "是否开启验签") - private boolean enableSignatureCheck; - - @Schema(description = "验签秘钥") - private String signSecret; - - @Schema(description = "描述") - private String remark; - -} diff --git a/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/util/DingTalkUtil.java b/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/util/DingTalkUtil.java deleted file mode 100644 index ba4494ed0..000000000 --- a/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/java/cn/bootx/platform/starter/dingtalk/util/DingTalkUtil.java +++ /dev/null @@ -1,41 +0,0 @@ -package cn.bootx.platform.starter.dingtalk.util; - -import cn.hutool.crypto.digest.HmacAlgorithm; -import lombok.experimental.UtilityClass; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.codec.binary.Base64; - -import javax.crypto.Mac; -import javax.crypto.spec.SecretKeySpec; -import java.nio.charset.StandardCharsets; -import java.security.InvalidKeyException; -import java.security.NoSuchAlgorithmException; - -/** - * 钉钉工具类 - * - * @author xxm - * @since 2022/4/2 - */ -@Slf4j -@UtilityClass -public class DingTalkUtil { - - /** - * 生成sign - */ - public String generateSign(Long timestamp, String sec) { - String combine = String.format("%d\n%s", timestamp, sec); - try { - Mac mac = Mac.getInstance(HmacAlgorithm.HmacSHA256.getValue()); - mac.init(new SecretKeySpec(sec.getBytes(StandardCharsets.UTF_8), HmacAlgorithm.HmacSHA256.getValue())); - byte[] signData = mac.doFinal(combine.getBytes(StandardCharsets.UTF_8)); - return Base64.encodeBase64String(signData); - } - catch (NoSuchAlgorithmException | InvalidKeyException e) { - log.warn(e.getMessage(), e); - } - return null; - } - -} diff --git a/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports deleted file mode 100644 index 73283971c..000000000 --- a/bootx-platform/bootx-common-starters/common-starter-dingtalk/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports +++ /dev/null @@ -1 +0,0 @@ -cn.bootx.platform.starter.dingtalk.DingTalkAutoConfiguration diff --git a/bootx-platform/bootx-common-starters/common-starter-wechat/pom.xml b/bootx-platform/bootx-common-starters/common-starter-wechat/pom.xml deleted file mode 100644 index f2d39d7e1..000000000 --- a/bootx-platform/bootx-common-starters/common-starter-wechat/pom.xml +++ /dev/null @@ -1,81 +0,0 @@ - - - - bootx-common-starters - cn.bootx.platform - 1.3.6.2 - - 4.0.0 - - common-starter-wechat - jar - - - - - org.springframework.boot - spring-boot-starter-web - - - - cn.bootx.platform - common-mybatis-plus - - - - com.github.binarywang - weixin-java-mp - ${wxjava.version} - - - commons-io - commons-io - - - guava - com.google.guava - - - com.thoughtworks.xstream - xstream - - - - - - com.github.binarywang - weixin-java-miniapp - ${wxjava.version} - - - commons-io - commons-io - - - guava - com.google.guava - - - com.thoughtworks.xstream - xstream - - - - - - com.thoughtworks.xstream - xstream - 1.4.20 - - - cn.bootx.platform - common-websocket - - - cn.bootx.platform - common-starter-auth - - - diff --git a/bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/WeChatAutoConfiguration.java b/bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/WeChatAutoConfiguration.java deleted file mode 100644 index 42089c6f8..000000000 --- a/bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/WeChatAutoConfiguration.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.bootx.platform.starter.wechat; - -import org.apache.ibatis.annotations.Mapper; -import org.mybatis.spring.annotation.MapperScan; -import org.springframework.boot.autoconfigure.AutoConfiguration; -import org.springframework.boot.context.properties.ConfigurationPropertiesScan; -import org.springframework.context.annotation.ComponentScan; - -/** - * 微信操作封装 - * - * @author xxm - * @since 2022/7/15 - */ -@ComponentScan -@MapperScan(annotationClass = Mapper.class) -@AutoConfiguration -@ConfigurationPropertiesScan -public class WeChatAutoConfiguration { - -} diff --git a/bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/code/WeChatCode.java b/bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/code/WeChatCode.java deleted file mode 100644 index edf7660ed..000000000 --- a/bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/code/WeChatCode.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.bootx.platform.starter.wechat.code; - -/** - * 微信编码 - * - * @author xxm - * @since 2022/8/5 - */ -public interface WeChatCode { - - /** qrscene_为前缀,后面为二维码的参数值 */ - String EVENT_KEY_QRSCENE = "qrscene_"; - - /* 带参数的扫码事件(qrscene_为前缀)参数前缀, 需要配合 qrscene_ 一起使用 */ - /** 扫码登录 */ - String QRSCENE_LOGIN = "login_"; - - /* 扫码登录状态 */ - /** 已过期 */ - String QR_LOGIN_EXPIRED = "expired"; - - /** 等待中 */ - String QR_LOGIN_WAIT = "wait"; - - /** */ - String QR_LOGIN_OK = "ok"; - -} diff --git a/bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/configuration/WeChatAppletProperties.java b/bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/configuration/WeChatAppletProperties.java deleted file mode 100644 index 1a95ed7d4..000000000 --- a/bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/configuration/WeChatAppletProperties.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.bootx.platform.starter.wechat.configuration; - -import lombok.Getter; -import lombok.Setter; -import org.springframework.boot.context.properties.ConfigurationProperties; - -/** - * 微信公众平台配置 - * - * @author xxm - * @since 2022/7/15 - */ -@Getter -@Setter -@ConfigurationProperties("bootx.starter.third.wechat-applet") -public class WeChatAppletProperties { - - /** AppKey */ - private String appId = "?"; - - /** AppSecret */ - private String appSecret = "?"; - -} diff --git a/bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/configuration/WeChatConfiguration.java b/bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/configuration/WeChatConfiguration.java deleted file mode 100644 index d1bce120a..000000000 --- a/bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/configuration/WeChatConfiguration.java +++ /dev/null @@ -1,64 +0,0 @@ -package cn.bootx.platform.starter.wechat.configuration; - -import cn.binarywang.wx.miniapp.api.WxMaService; -import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl; -import cn.binarywang.wx.miniapp.config.WxMaConfig; -import cn.binarywang.wx.miniapp.config.impl.WxMaDefaultConfigImpl; -import lombok.RequiredArgsConstructor; -import me.chanjar.weixin.mp.api.*; -import me.chanjar.weixin.mp.api.impl.*; -import me.chanjar.weixin.mp.config.WxMpConfigStorage; -import me.chanjar.weixin.mp.config.impl.WxMpDefaultConfigImpl; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -/** - * 微信配置 - * - * @author xxm - * @since 2022/7/15 - */ -@Configuration -@RequiredArgsConstructor -public class WeChatConfiguration { - - private final WeChatProperties weChatProperties; - - private final WeChatAppletProperties weChatAppletProperties; - - /** - * 微信公众号APIService - */ - @Bean - public WxMpService wxMpService(WxMpConfigStorage wxMpConfigStorage) { - WxMpService wxMpService = new WxMpServiceImpl(); - wxMpService.setWxMpConfigStorage(wxMpConfigStorage); - return wxMpService; - } - - /** - * 微信配置 - */ - @Bean - public WxMpConfigStorage wxMpConfigStorage() { - WxMpDefaultConfigImpl config = new WxMpDefaultConfigImpl(); - config.setAppId(weChatProperties.getAppId()); // 设置微信公众号的appid - config.setSecret(weChatProperties.getAppSecret()); // 设置微信公众号的app corpSecret - config.setToken(weChatProperties.getToken()); // 设置微信公众号的Token - config.setAesKey(weChatProperties.getEncodingAesKey()); // 消息加解密密钥 - return config; - } - @Bean - public WxMaService wxMaService(WxMaConfig wxMaConfigStorage) { - WxMaService wxMpService = new WxMaServiceImpl(); - wxMpService.setWxMaConfig(wxMaConfigStorage); - return wxMpService; - } - @Bean - public WxMaConfig wxMaConfigStorage() { - WxMaDefaultConfigImpl config = new WxMaDefaultConfigImpl(); - config.setAppid(weChatAppletProperties.getAppId()); // 设置微信公众号的appid - config.setSecret(weChatAppletProperties.getAppSecret()); // 设置微信公众号的app corpSecret - return config; - } -} diff --git a/bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/configuration/WeChatMessageRouterConfiguration.java b/bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/configuration/WeChatMessageRouterConfiguration.java deleted file mode 100644 index 9799789b4..000000000 --- a/bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/configuration/WeChatMessageRouterConfiguration.java +++ /dev/null @@ -1,48 +0,0 @@ -package cn.bootx.platform.starter.wechat.configuration; - -import cn.bootx.platform.starter.wechat.handler.WeChatMpMessageHandler; -import cn.bootx.platform.starter.wechat.handler.WeChatMsgHandler; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import me.chanjar.weixin.mp.api.WxMpMessageRouter; -import me.chanjar.weixin.mp.api.WxMpService; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -import java.util.List; - -/** - * 微信信息路由配置 - * - * @author xxm - * @since 2022/7/16 - */ -@Slf4j -@Configuration -@RequiredArgsConstructor -public class WeChatMessageRouterConfiguration { - - private final List weChatMpMessageHandlers; - - private final WeChatMsgHandler weChatMsgHandler; - - @Bean - public WxMpMessageRouter wxMpMessageRouter(WxMpService wxMpService) { - WxMpMessageRouter router = new WxMpMessageRouter(wxMpService); - // 记录日志 - - // 消息路由绑定 - for (WeChatMpMessageHandler weChatMpMessageHandler : weChatMpMessageHandlers) { - router.rule() - .async(false) - .msgType(weChatMpMessageHandler.getMsgType()) - .event(weChatMpMessageHandler.getEvent()) - .handler(weChatMpMessageHandler) - .end(); - } - // 默认的 文本消息处理 - router.rule().async(false).handler(weChatMsgHandler).end(); - return router; - } - -} diff --git a/bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/configuration/WeChatProperties.java b/bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/configuration/WeChatProperties.java deleted file mode 100644 index b6246580f..000000000 --- a/bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/configuration/WeChatProperties.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.bootx.platform.starter.wechat.configuration; - -import lombok.Getter; -import lombok.Setter; -import org.springframework.boot.context.properties.ConfigurationProperties; - -/** - * 微信公众平台配置 - * - * @author xxm - * @since 2022/7/15 - */ -@Getter -@Setter -@ConfigurationProperties("bootx.starter.third.wechat") -public class WeChatProperties { - - /** AppKey */ - private String appId = "?"; - - /** AppSecret */ - private String appSecret = "?"; - - /** token */ - private String token = "?"; - - /** 消息加解密密钥 */ - private String encodingAesKey = "?"; - -} diff --git a/bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/controller/WeChatArticleController.java b/bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/controller/WeChatArticleController.java deleted file mode 100644 index 29749eaa6..000000000 --- a/bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/controller/WeChatArticleController.java +++ /dev/null @@ -1,34 +0,0 @@ -package cn.bootx.platform.starter.wechat.controller; - -import cn.bootx.platform.common.core.rest.PageResult; -import cn.bootx.platform.common.core.rest.Res; -import cn.bootx.platform.common.core.rest.ResResult; -import cn.bootx.platform.common.core.rest.param.PageParam; -import cn.bootx.platform.starter.wechat.core.article.service.WeChatArticleService; -import cn.bootx.platform.starter.wechat.dto.article.WeChatArticleDto; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.RequiredArgsConstructor; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * @author xxm - * @since 2022/8/11 - */ -@Tag(name = "微信文章管理") -@RestController -@RequestMapping("/wechat/article") -@RequiredArgsConstructor -public class WeChatArticleController { - - private final WeChatArticleService weChatArticleService; - - @Operation(summary = "分页") - @GetMapping("/page") - public ResResult> page(PageParam pageParam) { - return Res.ok(weChatArticleService.page(pageParam)); - } - -} diff --git a/bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/controller/WeChatMediaController.java b/bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/controller/WeChatMediaController.java deleted file mode 100644 index bfd82f4eb..000000000 --- a/bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/controller/WeChatMediaController.java +++ /dev/null @@ -1,55 +0,0 @@ -package cn.bootx.platform.starter.wechat.controller; - -import cn.bootx.platform.common.core.rest.PageResult; -import cn.bootx.platform.common.core.rest.Res; -import cn.bootx.platform.common.core.rest.ResResult; -import cn.bootx.platform.common.core.rest.param.PageParam; -import cn.bootx.platform.starter.wechat.core.media.service.WeChatMediaService; -import cn.bootx.platform.starter.wechat.dto.media.WeChatMediaDto; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.RequiredArgsConstructor; -import org.springframework.web.bind.annotation.*; -import org.springframework.web.multipart.MultipartFile; - -import static me.chanjar.weixin.mp.bean.material.WxMpMaterialNewsBatchGetResult.WxMaterialNewsBatchGetNewsItem; - -/** - * @author xxm - * @since 2022/8/9 - */ -@Tag(name = "微信素材管理") -@RestController -@RequestMapping("/wechat/media") -@RequiredArgsConstructor -public class WeChatMediaController { - - private final WeChatMediaService weChatMediaService; - - @Operation(summary = "非图文素材分页") - @GetMapping("/pageFile") - public ResResult> pageFile(PageParam pageParam, String type) { - return Res.ok(weChatMediaService.pageFile(pageParam, type)); - } - - @Operation(summary = "图文素材分页") - @GetMapping("/pageNews") - public ResResult> pageNews(PageParam pageParam) { - return Res.ok(weChatMediaService.pageNews(pageParam)); - } - - @Operation(summary = "删除素材") - @DeleteMapping("/deleteFile") - public ResResult deleteFile(String mediaId) { - weChatMediaService.deleteFile(mediaId); - return Res.ok(); - } - - @Operation(summary = "上传素材") - @PostMapping("/uploadFile") - public ResResult uploadFile(String mediaType, MultipartFile file) { - weChatMediaService.uploadFile(mediaType, file); - return Res.ok(); - } - -} diff --git a/bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/controller/WeChatMenuController.java b/bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/controller/WeChatMenuController.java deleted file mode 100644 index 1c556776e..000000000 --- a/bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/controller/WeChatMenuController.java +++ /dev/null @@ -1,91 +0,0 @@ -package cn.bootx.platform.starter.wechat.controller; - -import cn.bootx.platform.common.core.rest.PageResult; -import cn.bootx.platform.common.core.rest.Res; -import cn.bootx.platform.common.core.rest.ResResult; -import cn.bootx.platform.common.core.rest.param.PageParam; -import cn.bootx.platform.starter.wechat.core.menu.service.WeChatMenuService; -import cn.bootx.platform.starter.wechat.dto.menu.WeChatMenuDto; -import cn.bootx.platform.starter.wechat.param.menu.WeChatMenuParam; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.RequiredArgsConstructor; -import org.springframework.web.bind.annotation.*; - -import java.util.List; - -/** - * 微信菜单管理 - * - * @author xxm - * @since 2022/8/6 - */ -@Tag(name = "微信菜单管理") -@RestController -@RequestMapping("/wechat/menu") -@RequiredArgsConstructor -public class WeChatMenuController { - - private final WeChatMenuService weChatMenuService; - - @Operation(summary = "添加") - @PostMapping(value = "/add") - public ResResult add(@RequestBody WeChatMenuParam param) { - weChatMenuService.add(param); - return Res.ok(); - } - - @Operation(summary = "修改") - @PostMapping(value = "/update") - public ResResult update(@RequestBody WeChatMenuParam param) { - weChatMenuService.update(param); - return Res.ok(); - } - - @Operation(summary = "删除") - @DeleteMapping(value = "/delete") - public ResResult delete(Long id) { - weChatMenuService.delete(id); - return Res.ok(); - } - - @Operation(summary = "通过ID查询") - @GetMapping(value = "/findById") - public ResResult findById(Long id) { - return Res.ok(weChatMenuService.findById(id)); - } - - @Operation(summary = "查询所有") - @GetMapping(value = "/findAll") - public ResResult> findAll() { - return Res.ok(weChatMenuService.findAll()); - } - - @Operation(summary = "分页查询") - @GetMapping(value = "/page") - public ResResult> page(PageParam pageParam, WeChatMenuParam weChatMenuParam) { - return Res.ok(weChatMenuService.page(pageParam, weChatMenuParam)); - } - - @Operation(summary = "发布菜单") - @PostMapping("/publish") - public ResResult publish(Long id) { - weChatMenuService.publish(id); - return Res.ok(); - } - - @Operation(summary = "导入微信自定义菜单到系统中") - @PostMapping("/importMenu") - public ResResult importMenu() { - weChatMenuService.importMenu(); - return Res.ok(); - } - - @Operation(summary = "清空微信自定义菜单") - @PostMapping("/clearMenu") - public ResResult clearMenu() { - weChatMenuService.clearMenu(); - return Res.ok(); - } - -} diff --git a/bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/controller/WeChatPortalController.java b/bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/controller/WeChatPortalController.java deleted file mode 100644 index 5028b4a09..000000000 --- a/bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/controller/WeChatPortalController.java +++ /dev/null @@ -1,55 +0,0 @@ -package cn.bootx.platform.starter.wechat.controller; - -import cn.bootx.platform.common.core.annotation.IgnoreAuth; -import cn.bootx.platform.starter.wechat.core.portal.service.WeChatPortalService; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.web.bind.annotation.*; - -/** - * 微信工作台接入入口 - * - * @author xxm - * @since 2022/7/16 - */ -@IgnoreAuth -@Slf4j -@Tag(name = "微信接入入口") -@RestController -@RequestMapping("/wechat/portal") -@RequiredArgsConstructor -public class WeChatPortalController { - - private final WeChatPortalService weChatPortalService; - - /** - * 微信接入校验处理 - * @param signature 微信签名 - * @param timestamp 时间戳 - * @param nonce 随机数 - * @param echostr 随机字符串 - */ - @GetMapping(produces = "text/plain;charset=utf-8") - public String auth(String signature, String timestamp, String nonce, String echostr) { - return weChatPortalService.auth(signature, timestamp, nonce, echostr); - } - - /** - * 微信消息处理 - * @param requestBody 请求报文体 - * @param signature 微信签名 - * @param encType 加签方式 - * @param msgSignature 微信签名 - * @param timestamp 时间戳 - * @param nonce 随机数 - */ - @PostMapping(produces = "application/xml; charset=UTF-8") - public String post(@RequestBody String requestBody, String signature, String timestamp, String nonce, String openid, - @RequestParam(name = "encrypt_type", required = false) String encType, - @RequestParam(name = "msg_signature", required = false) String msgSignature) { - return weChatPortalService.handleMessage(requestBody, signature, timestamp, nonce, openid, encType, - msgSignature); - } - -} diff --git a/bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/controller/WeChatQrLoginController.java b/bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/controller/WeChatQrLoginController.java deleted file mode 100644 index 825f56305..000000000 --- a/bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/controller/WeChatQrLoginController.java +++ /dev/null @@ -1,43 +0,0 @@ -package cn.bootx.platform.starter.wechat.controller; - -import cn.bootx.platform.common.core.annotation.IgnoreAuth; -import cn.bootx.platform.common.core.rest.Res; -import cn.bootx.platform.common.core.rest.ResResult; -import cn.bootx.platform.starter.wechat.core.login.service.WeChatQrLoginService; -import cn.bootx.platform.starter.wechat.dto.login.WeChatLoginQrCode; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.RequiredArgsConstructor; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * 微信 - * - * @author xxm - * @since 2022/8/4 - */ -@IgnoreAuth -@Tag(name = "微信扫码登录") -@RestController -@RequestMapping("/token/wechat/qr") -@RequiredArgsConstructor -public class WeChatQrLoginController { - - private final WeChatQrLoginService weChatQrLoginService; - - @Operation(summary = "申请登录用QR码") - @PostMapping("/applyQrCode") - public ResResult applyQrCode() { - return Res.ok(weChatQrLoginService.applyQrCode()); - } - - @Operation(summary = "获取扫码状态") - @GetMapping("/getStatus") - public ResResult getStatus(String qrCodeKey) { - return Res.ok(weChatQrLoginService.getStatus(qrCodeKey)); - } - -} diff --git a/bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/controller/WeChatTemplateController.java b/bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/controller/WeChatTemplateController.java deleted file mode 100644 index d618de59b..000000000 --- a/bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/controller/WeChatTemplateController.java +++ /dev/null @@ -1,62 +0,0 @@ -package cn.bootx.platform.starter.wechat.controller; - -import cn.bootx.platform.common.core.rest.PageResult; -import cn.bootx.platform.common.core.rest.Res; -import cn.bootx.platform.common.core.rest.ResResult; -import cn.bootx.platform.common.core.rest.param.PageParam; -import cn.bootx.platform.starter.auth.util.SecurityUtil; -import cn.bootx.platform.starter.wechat.core.notice.service.WeChatTemplateService; -import cn.bootx.platform.starter.wechat.dto.notice.WeChatTemplateDto; -import cn.bootx.platform.starter.wechat.param.notice.WeChatTemplateParam; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.RequiredArgsConstructor; -import org.springframework.web.bind.annotation.*; - -/** - * @author xxm - * @since 2022/7/16 - */ -@Tag(name = "微信模板消息") -@RestController -@RequestMapping("/wechat/template") -@RequiredArgsConstructor -public class WeChatTemplateController { - - private final WeChatTemplateService weChatTemplateService; - - @Operation(summary = "修改") - @PostMapping(value = "/update") - public ResResult update(@RequestBody WeChatTemplateParam param) { - weChatTemplateService.update(param); - return Res.ok(); - } - - @Operation(summary = "通过ID查询") - @GetMapping(value = "/findById") - public ResResult findById(Long id) { - return Res.ok(weChatTemplateService.findById(id)); - } - - @Operation(summary = "分页查询") - @GetMapping(value = "/page") - public ResResult> page(PageParam pageParam, WeChatTemplateParam weChatTemplateParam) { - return Res.ok(weChatTemplateService.page(pageParam, weChatTemplateParam)); - } - - @Operation(summary = "编码是否被使用(不包含自己)") - @GetMapping("/existsByCodeNotId") - public ResResult existsByCode(String code, Long id) { - return Res.ok(weChatTemplateService.existsByCode(code, id)); - } - - @Operation(summary = "同步消息模板数据") - @PostMapping("/sync") - public ResResult sync() { - // 为了获取用户生效, 测试用 - SecurityUtil.getUserId(); - weChatTemplateService.sync(); - return Res.ok(); - } - -} diff --git a/bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/core/article/service/WeChatArticleService.java b/bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/core/article/service/WeChatArticleService.java deleted file mode 100644 index ade2a2b15..000000000 --- a/bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/core/article/service/WeChatArticleService.java +++ /dev/null @@ -1,43 +0,0 @@ -package cn.bootx.platform.starter.wechat.core.article.service; - -import cn.bootx.platform.common.core.rest.PageResult; -import cn.bootx.platform.common.core.rest.param.PageParam; -import cn.bootx.platform.starter.wechat.dto.article.WeChatArticleDto; -import lombok.RequiredArgsConstructor; -import lombok.SneakyThrows; -import lombok.extern.slf4j.Slf4j; -import lombok.val; -import me.chanjar.weixin.mp.api.WxMpService; -import org.springframework.stereotype.Service; - -import java.util.stream.Collectors; - -/** - * @author xxm - * @since 2022/8/11 - */ -@Slf4j -@Service -@RequiredArgsConstructor -public class WeChatArticleService { - - private final WxMpService wxMpService; - - /** - * 查询图文 - * @return - */ - @SneakyThrows - public PageResult page(PageParam pageParam) { - val freePublishService = wxMpService.getFreePublishService(); - val result = freePublishService.getPublicationRecords(pageParam.start(), pageParam.getSize()); - val items = result.getItems().stream().map(WeChatArticleDto::init).collect(Collectors.toList()); - PageResult pageResult = new PageResult<>(); - pageResult.setCurrent(pageParam.getCurrent()) - .setRecords(items) - .setSize(pageParam.getSize()) - .setTotal(result.getTotalCount()); - return pageResult; - } - -} diff --git a/bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/core/login/service/WeChatQrLoginService.java b/bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/core/login/service/WeChatQrLoginService.java deleted file mode 100644 index 19af0f274..000000000 --- a/bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/core/login/service/WeChatQrLoginService.java +++ /dev/null @@ -1,99 +0,0 @@ -package cn.bootx.platform.starter.wechat.core.login.service; - -import cn.bootx.platform.starter.auth.exception.LoginFailureException; -import cn.bootx.platform.common.redis.RedisClient; -import cn.bootx.platform.starter.wechat.dto.login.WeChatLoginQrCode; -import cn.hutool.core.util.IdUtil; -import cn.hutool.core.util.StrUtil; -import lombok.RequiredArgsConstructor; -import lombok.SneakyThrows; -import lombok.extern.slf4j.Slf4j; -import me.chanjar.weixin.mp.api.WxMpQrcodeService; -import me.chanjar.weixin.mp.api.WxMpService; -import me.chanjar.weixin.mp.bean.result.WxMpQrCodeTicket; -import org.springframework.stereotype.Service; - -import java.util.Objects; - -import static cn.bootx.platform.starter.wechat.code.WeChatCode.*; - -/** - * 扫码事件 - * - * @author xxm - * @since 2022/8/4 - */ -@Slf4j -@Service -@RequiredArgsConstructor -public class WeChatQrLoginService { - - private final RedisClient redisClient; - - private final WxMpService wxMpService; - - private final String PREFIX_KEY = "third:wechat:login:qr:"; - - /** - * 申请待扫描的二维码 - */ - @SneakyThrows - public WeChatLoginQrCode applyQrCode() { - WxMpQrcodeService qrcodeService = wxMpService.getQrcodeService(); - long timeout = 5 * 60 * 1000; - String qrCodeKey = IdUtil.getSnowflakeNextIdStr(); - // 创建微信临时Key, 需要有指定的前缀 - String wxKey = QRSCENE_LOGIN + qrCodeKey; - WxMpQrCodeTicket wxMpQrCodeTicket = qrcodeService.qrCodeCreateTmpTicket(wxKey, (int) timeout); - String url = wxMpQrCodeTicket.getUrl(); - redisClient.setWithTimeout(PREFIX_KEY + qrCodeKey, "", timeout); - return new WeChatLoginQrCode(qrCodeKey, url); - } - - /** - * 查询二维码状态 等待扫码/登录成功/过期 - */ - public String getStatus(String key) { - String openId = redisClient.get(PREFIX_KEY + key); - // 超时 - if (Objects.isNull(openId)) { - return QR_LOGIN_EXPIRED; - } - // 等待 - else if (StrUtil.isBlank(openId)) { - return QR_LOGIN_WAIT; - } - // 登录成功 - else { - return QR_LOGIN_OK; - } - } - - /** - * 设置微信openId - */ - public void setOpenId(String key, String openId) { - if (redisClient.exists(PREFIX_KEY + key)) { - redisClient.set(PREFIX_KEY + key, openId); - } - } - - /** - * 获取 openId - */ - public String getOpenId(String key) { - String openId = redisClient.get(PREFIX_KEY + key); - if (StrUtil.isBlank(openId)) { - throw new LoginFailureException("数据已过期或不存在"); - } - return openId; - } - - /** - * 清除扫码信息 - */ - public void clear(String key) { - redisClient.deleteKey(PREFIX_KEY + key); - } - -} diff --git a/bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/core/media/service/WeChatMediaService.java b/bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/core/media/service/WeChatMediaService.java deleted file mode 100644 index bfbb2095e..000000000 --- a/bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/core/media/service/WeChatMediaService.java +++ /dev/null @@ -1,103 +0,0 @@ -package cn.bootx.platform.starter.wechat.core.media.service; - -import cn.bootx.platform.common.core.rest.PageResult; -import cn.bootx.platform.common.core.rest.param.PageParam; -import cn.bootx.platform.common.core.util.FileUtil; -import cn.bootx.platform.starter.wechat.dto.media.WeChatMediaDto; -import cn.hutool.core.io.FileTypeUtil; -import cn.hutool.core.io.IoUtil; -import cn.hutool.core.io.file.FileNameUtil; -import lombok.RequiredArgsConstructor; -import lombok.SneakyThrows; -import lombok.extern.slf4j.Slf4j; -import lombok.val; -import me.chanjar.weixin.common.api.WxConsts; -import me.chanjar.weixin.mp.api.WxMpMaterialService; -import me.chanjar.weixin.mp.api.WxMpService; -import me.chanjar.weixin.mp.bean.material.WxMpMaterial; -import me.chanjar.weixin.mp.bean.material.WxMpMaterialNewsBatchGetResult.WxMaterialNewsBatchGetNewsItem; -import org.springframework.stereotype.Service; -import org.springframework.web.multipart.MultipartFile; - -import java.io.ByteArrayInputStream; -import java.io.File; -import java.util.Objects; -import java.util.stream.Collectors; - -/** - * 素材管理 - * - * @author xxm - * @since 2022/8/9 - */ -@Slf4j -@Service -@RequiredArgsConstructor -public class WeChatMediaService { - - private final WxMpService wxMpService; - - /** - * 分页查询 - */ - @SneakyThrows - public PageResult pageFile(PageParam pageParam, String type) { - WxMpMaterialService materialService = wxMpService.getMaterialService(); - val result = materialService.materialFileBatchGet(type, pageParam.start(), pageParam.getSize()); - // val result = new WxMpMaterialFileBatchGetResult(); - val items = result.getItems().stream().map(WeChatMediaDto::init).collect(Collectors.toList()); - PageResult pageResult = new PageResult<>(); - pageResult.setCurrent(pageParam.getCurrent()) - .setRecords(items) - .setSize(pageParam.getSize()) - .setTotal(result.getTotalCount()); - return pageResult; - } - - /** - * 分页查询(图文) - */ - @SneakyThrows - public PageResult pageNews(PageParam pageParam) { - WxMpMaterialService materialService = wxMpService.getMaterialService(); - val result = materialService.materialNewsBatchGet(pageParam.start(), pageParam.getSize()); - val items = result.getItems(); - PageResult pageResult = new PageResult<>(); - pageResult.setCurrent(pageParam.getCurrent()) - .setRecords(items) - .setSize(pageParam.getSize()) - .setTotal(result.getTotalCount()); - return pageResult; - } - - /** - * 删除素材 - */ - @SneakyThrows - public void deleteFile(String mediaId) { - WxMpMaterialService materialService = wxMpService.getMaterialService(); - materialService.materialDelete(mediaId); - } - - /** - * 上传 非图文素材 - * @see WxConsts.MediaFileType - */ - @SneakyThrows - public void uploadFile(String mediaType, MultipartFile multipartFile) { - WxMpMaterialService materialService = wxMpService.getMaterialService(); - byte[] bytes = IoUtil.readBytes(multipartFile.getInputStream()); - String originalFilename = multipartFile.getOriginalFilename(); - String fileName = FileNameUtil.mainName(originalFilename); - String fileType = FileTypeUtil.getType(new ByteArrayInputStream(bytes), originalFilename); - File tempFile = FileUtil.createTempFile(new ByteArrayInputStream(bytes), fileName, fileType); - WxMpMaterial material = new WxMpMaterial(); - material.setFile(tempFile); - if (Objects.equals(mediaType, WxConsts.MediaFileType.VIDEO)) { - material.setVideoTitle(fileName); - material.setVideoIntroduction(fileName); - } - materialService.materialFileUpload(mediaType, material); - } - -} diff --git a/bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/core/menu/convert/WeChatMenuConvert.java b/bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/core/menu/convert/WeChatMenuConvert.java deleted file mode 100644 index 0b27d7196..000000000 --- a/bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/core/menu/convert/WeChatMenuConvert.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.bootx.platform.starter.wechat.core.menu.convert; - -import cn.bootx.platform.starter.wechat.param.menu.WeChatMenuParam; -import cn.bootx.platform.starter.wechat.core.menu.domin.WeChatMenuInfo; -import cn.bootx.platform.starter.wechat.core.menu.entity.WeChatMenu; -import cn.bootx.platform.starter.wechat.dto.menu.WeChatMenuDto; -import me.chanjar.weixin.common.bean.menu.WxMenu; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -/** - * 微信自定义菜单 - * - * @author xxm - * @since 2022-08-08 - */ -@Mapper -public interface WeChatMenuConvert { - - WeChatMenuConvert CONVERT = Mappers.getMapper(WeChatMenuConvert.class); - - WeChatMenu convert(WeChatMenuParam in); - - WeChatMenuDto convert(WeChatMenu in); - - WeChatMenuInfo convert(WxMenu in); - - WxMenu convert(WeChatMenuInfo in); - -} diff --git a/bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/core/menu/dao/WeChatMenuManager.java b/bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/core/menu/dao/WeChatMenuManager.java deleted file mode 100644 index d60b693f8..000000000 --- a/bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/core/menu/dao/WeChatMenuManager.java +++ /dev/null @@ -1,42 +0,0 @@ -package cn.bootx.platform.starter.wechat.core.menu.dao; - -import cn.bootx.platform.starter.wechat.core.menu.entity.WeChatMenu; -import cn.bootx.platform.starter.wechat.param.menu.WeChatMenuParam; -import cn.bootx.platform.common.core.rest.param.PageParam; -import cn.bootx.platform.common.mybatisplus.base.MpIdEntity; -import cn.bootx.platform.common.mybatisplus.impl.BaseManager; -import cn.bootx.platform.common.mybatisplus.util.MpUtil; -import cn.hutool.core.util.StrUtil; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import lombok.RequiredArgsConstructor; -import org.springframework.stereotype.Repository; - -/** - * 微信自定义菜单 - * - * @author xxm - * @since 2022-08-08 - */ -@Repository -@RequiredArgsConstructor -public class WeChatMenuManager extends BaseManager { - - /** - * 分页 - */ - public Page page(PageParam pageParam, WeChatMenuParam param) { - Page mpPage = MpUtil.getMpPage(pageParam, WeChatMenu.class); - return lambdaQuery().select(this.getEntityClass(), MpUtil::excludeBigField) - .like(StrUtil.isNotBlank(param.getName()), WeChatMenu::getName, param.getName()) - .orderByDesc(MpIdEntity::getId) - .page(mpPage); - } - - /** - * 清除其他发布状态 - */ - public void clearPublish() { - lambdaUpdate().eq(WeChatMenu::isPublish, true).set(WeChatMenu::isPublish, false).update(); - } - -} diff --git a/bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/core/menu/dao/WeChatMenuMapper.java b/bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/core/menu/dao/WeChatMenuMapper.java deleted file mode 100644 index 6934ab0e6..000000000 --- a/bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/core/menu/dao/WeChatMenuMapper.java +++ /dev/null @@ -1,16 +0,0 @@ -package cn.bootx.platform.starter.wechat.core.menu.dao; - -import cn.bootx.platform.starter.wechat.core.menu.entity.WeChatMenu; -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import org.apache.ibatis.annotations.Mapper; - -/** - * 微信自定义菜单 - * - * @author xxm - * @since 2022-08-08 - */ -@Mapper -public interface WeChatMenuMapper extends BaseMapper { - -} diff --git a/bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/core/menu/domin/WeChatMenuInfo.java b/bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/core/menu/domin/WeChatMenuInfo.java deleted file mode 100644 index aeb482c91..000000000 --- a/bootx-platform/bootx-common-starters/common-starter-wechat/src/main/java/cn/bootx/platform/starter/wechat/core/menu/domin/WeChatMenuInfo.java +++ /dev/null @@ -1,164 +0,0 @@ -package cn.bootx.platform.starter.wechat.core.menu.domin; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.experimental.Accessors; -import me.chanjar.weixin.common.bean.menu.WxMenu; -import me.chanjar.weixin.common.bean.menu.WxMenuButton; -import me.chanjar.weixin.mp.bean.menu.WxMpMenu; - -import java.util.ArrayList; -import java.util.List; -import java.util.stream.Collectors; - -/** - * 微信自定义菜单 - * - * @author xxm - * @since 2022/8/8 - */ -@Data -@Accessors(chain = true) -@Schema(title = "微信自定义菜单") -public class WeChatMenuInfo { - - private List