diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index 01e4abe..27941aa 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -1,13 +1,21 @@
+# 相当于脚本用途的一个声明
name: Maven Central Repo Deployment
+# 触发脚本的事件 这里为发布release之后触发
on:
release:
types: [released]
+# 定义一个发行任务
jobs:
publish:
+# 任务运行的环境
runs-on: ubuntu-latest
+# 任务的步骤
steps:
- - name: Checkout
+# 1. 声明 checkout 仓库代码到工作区
+ - name: Checkout Git Repo
uses: actions/checkout@v2
+# 2. 安装Java 环境 这里会用到的参数就是 Git Action secrets中配置的,
+# 取值要在key前面加 secrets.
- name: Set up Maven Central Repo
uses: actions/setup-java@v1
with:
@@ -16,7 +24,9 @@ jobs:
server-username: ${{ secrets.OSSRH_USER }}
server-password: ${{ secrets.OSSRH_PASSWORD }}
gpg-passphrase: ${{ secrets.GPG_PASSWORD }}
+# 3. 发布到Maven中央仓库
- name: Publish to Maven Central Repo
+# 这里用到了其他人写的action脚本,详细可以去看他的文档。
uses: samuelmeuli/action-maven-publish@v1
with:
gpg_private_key: ${{ secrets.GPG_SECRET }}
diff --git a/README.md b/README.md
index dd9fc9c..6212053 100644
--- a/README.md
+++ b/README.md
@@ -11,7 +11,7 @@
+ *
+ * @since 1.0.10.RELEASE
+ */
+@Slf4j
+public class WechatAllocationApi {
+ /**
+ * The constant MAPPER.
+ */
+ private static final ObjectMapper MAPPER = new ObjectMapper();
+
+ static {
+ MAPPER.setPropertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE)
+ .setSerializationInclusion(JsonInclude.Include.NON_NULL)
+ .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
+ .configure(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT, true)
+ .registerModule(new JavaTimeModule());
+ }
+
+ private final WechatV2Client wechatV2Client;
+
+ /**
+ * Instantiates a new Wechat allocation api.
+ *
+ * @param wechatV2Client the wechat v 2 client
+ */
+ public WechatAllocationApi(WechatV2Client wechatV2Client) {
+ this.wechatV2Client = wechatV2Client;
+ }
+
+ /**
+ * 请求单次分账
+ *
+ * @param profitSharingModel the profit sharing model
+ * @return json node
+ */
+ @SneakyThrows
+ public JsonNode profitSharing(ProfitSharingModel profitSharingModel) {
+ ProfitSharingSModel profitSharingSModel = new ProfitSharingSModel();
+ List
+ * 微信支付分配的商户号
+ */
+ private String mchId;
+ private String appid;
+ private String transactionId;
+ private String outOrderNo;
+
+}
diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v2/model/allocation/BaseProfitSharingReceiverModel.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v2/model/allocation/BaseProfitSharingReceiverModel.java
new file mode 100644
index 0000000..7a235f3
--- /dev/null
+++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v2/model/allocation/BaseProfitSharingReceiverModel.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2019-2021 felord.cn
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ * Website:
+ * https://felord.cn
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package cn.felord.payment.wechat.v2.model.allocation;
+
+import cn.felord.payment.wechat.v2.model.BaseModel;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * The type Base profit sharing receiver model.
+ *
+ * @author wangzecheng
+ * @since 1.0.10.RELEASE
+ */
+@EqualsAndHashCode(callSuper = true)
+@Data
+public class BaseProfitSharingReceiverModel extends BaseModel {
+ /**
+ * 商户号.
+ *
+ * 微信支付分配的商户号
+ */
+ private String mchId;
+
+ /**
+ * 公众账号ID.
+ *
+ * 微信分配的公众账号ID
+ */
+ private String appid;
+
+}
diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v2/model/allocation/MultiProfitSharingModel.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v2/model/allocation/MultiProfitSharingModel.java
new file mode 100644
index 0000000..8718017
--- /dev/null
+++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v2/model/allocation/MultiProfitSharingModel.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2019-2021 felord.cn
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ * Website:
+ * https://felord.cn
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package cn.felord.payment.wechat.v2.model.allocation;
+
+/**
+ * The type Multi profit sharing model.
+ *
+ * @author wangzecheng
+ * @since 1.0.10.RELEASE
+ */
+public class MultiProfitSharingModel extends ProfitSharingModel {
+
+}
diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v2/model/allocation/MultiProfitSharingSModel.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v2/model/allocation/MultiProfitSharingSModel.java
new file mode 100644
index 0000000..af5f404
--- /dev/null
+++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v2/model/allocation/MultiProfitSharingSModel.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2019-2021 felord.cn
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ * Website:
+ * https://felord.cn
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package cn.felord.payment.wechat.v2.model.allocation;
+
+/**
+ * The type Multi profit sharing s model.
+ *
+ * @author wangzecheng
+ * @since 1.0.10.RELEASE
+ */
+public class MultiProfitSharingSModel extends ProfitSharingSModel {
+
+}
diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v2/model/allocation/ProfitSharingAddReceiverModel.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v2/model/allocation/ProfitSharingAddReceiverModel.java
new file mode 100644
index 0000000..34d31d4
--- /dev/null
+++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v2/model/allocation/ProfitSharingAddReceiverModel.java
@@ -0,0 +1,95 @@
+/*
+ * Copyright 2019-2021 felord.cn
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ * Website:
+ * https://felord.cn
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package cn.felord.payment.wechat.v2.model.allocation;
+
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * The type Profit sharing add receiver model.
+ *
+ * @author wangzecheng
+ * @since 1.0.10.RELEASE
+ */
+@EqualsAndHashCode(callSuper = true)
+@Data
+public class ProfitSharingAddReceiverModel extends BaseProfitSharingReceiverModel {
+
+ private Receiver receiver;
+
+ /**
+ * The type Receiver.
+ */
+ @Data
+ public static class Receiver {
+
+ /**
+ * 分账接收方类型.
+ *
+ * MERCHANT_ID:商户号(mch_id或者sub_mch_id)
+ * PERSONAL_OPENID:个人openid
+ */
+ private Type type;
+
+ /**
+ * 分账接收方帐号.
+ *
+ * 类型是MERCHANT_ID时,是商户号(mch_id或者sub_mch_id)
+ * 类型是PERSONAL_OPENID时,是个人openid
+ */
+ private String account;
+
+ /**
+ * 分账接收方全称.
+ *
+ * 分账接收方类型是MERCHANT_ID时,是商户全称(必传),当商户是小微商户或个体户时,是开户人姓名
+ * 分账接收方类型是PERSONAL_OPENID时,是个人姓名(选传,传则校验)
+ */
+ private String name;
+
+ /**
+ * 与分账方的关系类型.
+ *
+ * 子商户与接收方的关系。
+ * 本字段值为枚举:
+ * SERVICE_PROVIDER:服务商
+ * STORE:门店
+ * STAFF:员工
+ * STORE_OWNER:店主
+ * PARTNER:合作伙伴
+ * HEADQUARTER:总部
+ * BRAND:品牌方
+ * DISTRIBUTOR:分销商
+ * USER:用户
+ * SUPPLIER:供应商
+ * CUSTOM:自定义
+ */
+ private RelationType relationType;
+
+ /**
+ * 自定义的分账关系.
+ *
+ * 子商户与接收方具体的关系,本字段最多10个字。
+ * 当字段relation_type的值为CUSTOM时,本字段必填
+ * 当字段relation_type的值不为CUSTOM时,本字段无需填写
+ */
+ private String customRelation;
+
+ }
+
+}
diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v2/model/allocation/ProfitSharingAddReceiverSModel.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v2/model/allocation/ProfitSharingAddReceiverSModel.java
new file mode 100644
index 0000000..ba8ef1b
--- /dev/null
+++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v2/model/allocation/ProfitSharingAddReceiverSModel.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2019-2021 felord.cn
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ * Website:
+ * https://felord.cn
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package cn.felord.payment.wechat.v2.model.allocation;
+
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * The type Profit sharing add receiver s model.
+ *
+ * @author wangzecheng
+ * @since 1.0.10.RELEASE
+ */
+@EqualsAndHashCode(callSuper = true)
+@Data
+public class ProfitSharingAddReceiverSModel extends BaseProfitSharingReceiverModel {
+
+ private String receiver;
+
+}
diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v2/model/allocation/ProfitSharingFinishModel.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v2/model/allocation/ProfitSharingFinishModel.java
new file mode 100644
index 0000000..4d046f3
--- /dev/null
+++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v2/model/allocation/ProfitSharingFinishModel.java
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2019-2021 felord.cn
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ * Website:
+ * https://felord.cn
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package cn.felord.payment.wechat.v2.model.allocation;
+
+import cn.felord.payment.wechat.v2.model.BaseModel;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * The type Profit sharing finish model.
+ *
+ * @author wangzecheng
+ * @since 1.0.10.RELEASE
+ */
+@EqualsAndHashCode(callSuper = true)
+@Data
+public class ProfitSharingFinishModel extends BaseModel {
+
+ /**
+ * 商户号.
+ *
+ * 微信支付分配的商户号
+ */
+ private String mchId;
+
+ /**
+ * 公众账号ID.
+ *
+ * 微信分配的公众账号ID
+ */
+ private String appid;
+
+ /**
+ * 微信订单号.
+ *
+ * 微信支付订单号
+ */
+ private String transactionId;
+
+ /**
+ * 商户分账单号.
+ *
+ * 查询分账结果,输入申请分账时的商户分账单号; 查询分账完结执行的结果,输入发起分账完结时的商户分账单号
+ */
+ private String outOrderNo;
+
+ /**
+ * 分账完结描述.
+ *
+ * 分账完结的原因描述
+ */
+ private String description;
+
+}
diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v2/model/allocation/ProfitSharingModel.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v2/model/allocation/ProfitSharingModel.java
new file mode 100644
index 0000000..638ff68
--- /dev/null
+++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v2/model/allocation/ProfitSharingModel.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2019-2021 felord.cn
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ * Website:
+ * https://felord.cn
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package cn.felord.payment.wechat.v2.model.allocation;
+
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.util.List;
+
+/**
+ * 单次分账请求按照传入的分账接收方账号和资金进行分账,同时会将订单剩余的待分账金额解冻给本商户。
+ * 故操作成功后,订单不能再进行分账,也不能进行分账完结。
+ *
+ * @author wangzecheng
+ * @since 1.0.10.RELEASE
+ */
+@EqualsAndHashCode(callSuper = true)
+@Data
+public class ProfitSharingModel extends BaseProfitSharingModel {
+
+ /**
+ * 分账接收方列表,不超过50个json对象,不能设置分账方作为分账接受方
+ */
+ private List
+ * 微信支付分配的商户号
+ */
+ private String mchId;
+
+ /**
+ * 微信订单号.
+ *
+ * 微信支付订单号
+ */
+ private String transactionId;
+
+}
diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v2/model/allocation/ProfitSharingQueryModel.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v2/model/allocation/ProfitSharingQueryModel.java
new file mode 100644
index 0000000..1f7584d
--- /dev/null
+++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v2/model/allocation/ProfitSharingQueryModel.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2019-2021 felord.cn
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ * Website:
+ * https://felord.cn
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package cn.felord.payment.wechat.v2.model.allocation;
+
+import cn.felord.payment.wechat.v2.model.BaseModel;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * The type Profit sharing query model.
+ *
+ * @author wangzecheng
+ * @since 1.0.10.RELEASE
+ */
+@EqualsAndHashCode(callSuper = true)
+@Data
+public class ProfitSharingQueryModel extends BaseModel {
+
+ /**
+ * 商户号.
+ *
+ * 微信支付分配的商户号
+ */
+ private String mchId;
+
+ /**
+ * 微信订单号.
+ *
+ * 微信支付订单号
+ */
+ private String transactionId;
+
+ /**
+ * 商户分账单号.
+ *
+ * 查询分账结果,输入申请分账时的商户分账单号; 查询分账完结执行的结果,输入发起分账完结时的商户分账单号
+ */
+ private String outOrderNo;
+
+}
diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v2/model/allocation/ProfitSharingRemoveReceiverModel.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v2/model/allocation/ProfitSharingRemoveReceiverModel.java
new file mode 100644
index 0000000..b97c49e
--- /dev/null
+++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v2/model/allocation/ProfitSharingRemoveReceiverModel.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2019-2021 felord.cn
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ * Website:
+ * https://felord.cn
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package cn.felord.payment.wechat.v2.model.allocation;
+
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * The type Profit sharing remove receiver model.
+ *
+ * @author wangzecheng
+ * @since 1.0.10.RELEASE
+ */
+@EqualsAndHashCode(callSuper = true)
+@Data
+public class ProfitSharingRemoveReceiverModel extends BaseProfitSharingReceiverModel {
+
+ private Receiver receiver;
+
+ /**
+ * The type Receiver.
+ */
+ @Data
+ public static class Receiver {
+
+ private Type type;
+ private String account;
+
+ }
+
+}
diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v2/model/allocation/ProfitSharingRemoveReceiverSModel.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v2/model/allocation/ProfitSharingRemoveReceiverSModel.java
new file mode 100644
index 0000000..39ef4d3
--- /dev/null
+++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v2/model/allocation/ProfitSharingRemoveReceiverSModel.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2019-2021 felord.cn
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ * Website:
+ * https://felord.cn
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package cn.felord.payment.wechat.v2.model.allocation;
+
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * The type Profit sharing remove receiver s model.
+ *
+ * @author wangzecheng
+ * @since 1.0.10.RELEASE
+ */
+@EqualsAndHashCode(callSuper = true)
+@Data
+public class ProfitSharingRemoveReceiverSModel extends BaseProfitSharingReceiverModel {
+
+ private String receiver;
+
+}
diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v2/model/allocation/ProfitSharingReturnModel.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v2/model/allocation/ProfitSharingReturnModel.java
new file mode 100644
index 0000000..6a7f021
--- /dev/null
+++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v2/model/allocation/ProfitSharingReturnModel.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2019-2021 felord.cn
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ * Website:
+ * https://felord.cn
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package cn.felord.payment.wechat.v2.model.allocation;
+
+import cn.felord.payment.wechat.v2.model.BaseModel;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * The type Profit sharing return model.
+ *
+ * @author wangzecheng
+ * @since 1.0.10.RELEASE
+ */
+@EqualsAndHashCode(callSuper = true)
+@Data
+public class ProfitSharingReturnModel extends BaseModel {
+
+ /**
+ * 商户号.
+ *
+ * 微信支付分配的商户号
+ */
+ private String mchId;
+
+ /**
+ * 公众账号ID.
+ *
+ * 微信分配的公众账号ID
+ */
+ private String appid;
+ private String orderId;
+ private String outOrderNo;
+ private String outReturnNo;
+ private String returnAccountType;
+ private String returnAccount;
+ private String returnAmount;
+ private String description;
+
+}
diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v2/model/allocation/ProfitSharingReturnQueryModel.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v2/model/allocation/ProfitSharingReturnQueryModel.java
new file mode 100644
index 0000000..40669db
--- /dev/null
+++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v2/model/allocation/ProfitSharingReturnQueryModel.java
@@ -0,0 +1,71 @@
+/*
+ * Copyright 2019-2021 felord.cn
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ * Website:
+ * https://felord.cn
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package cn.felord.payment.wechat.v2.model.allocation;
+
+import cn.felord.payment.wechat.v2.model.BaseModel;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * The type Profit sharing return query model.
+ *
+ * @author wangzecheng
+ * @since 1.0.10.RELEASE
+ */
+@EqualsAndHashCode(callSuper = true)
+@Data
+public class ProfitSharingReturnQueryModel extends BaseModel {
+
+ /**
+ * 商户号.
+ *
+ * 微信支付分配的商户号
+ */
+ private String mchId;
+
+ /**
+ * 公众账号ID.
+ *
+ * 微信分配的公众账号ID
+ */
+ private String appid;
+
+ /**
+ * 微信分账订单号.
+ *
+ * 原发起分账请求时,微信返回的微信分账单号,与商户分账单号一一对应。
+ * 微信分账单号与商户分账单号二选一填写
+ */
+ private String orderId;
+
+ /**
+ * 商户分账单号.
+ *
+ * 原发起分账请求时使用的商户系统内部的分账单号。
+ * 微信分账单号与商户分账单号二选一填写
+ */
+ private String outOrderNo;
+
+ /**
+ * 商户回退单号.
+ *
+ * 调用回退接口提供的商户系统内部的回退单号
+ */
+ private String outReturnNo;
+
+}
diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v2/model/allocation/ProfitSharingSModel.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v2/model/allocation/ProfitSharingSModel.java
new file mode 100644
index 0000000..99df912
--- /dev/null
+++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v2/model/allocation/ProfitSharingSModel.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2019-2021 felord.cn
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ * Website:
+ * https://felord.cn
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package cn.felord.payment.wechat.v2.model.allocation;
+
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * The type Profit sharing s model.
+ *
+ * @author wangzecheng
+ * @since 1.0.10.RELEASE
+ */
+@EqualsAndHashCode(callSuper = true)
+@Data
+public class ProfitSharingSModel extends BaseProfitSharingModel {
+
+ /**
+ * 分账接收方列表,不超过50个json对象,不能设置分账方作为分账接受方。
+ */
+ private String receivers;
+
+}
diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v2/model/allocation/Receiver.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v2/model/allocation/Receiver.java
new file mode 100644
index 0000000..352b822
--- /dev/null
+++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v2/model/allocation/Receiver.java
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2019-2021 felord.cn
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ * Website:
+ * https://felord.cn
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package cn.felord.payment.wechat.v2.model.allocation;
+
+import lombok.Data;
+
+/**
+ * The type Receiver.
+ *
+ * @author wangzecheng
+ * @since 1.0.10.RELEASE
+ */
+@Data
+public class Receiver {
+
+ /**
+ * 分账接收方类型.
+ *
+ * MERCHANT_ID:商户号(mch_id或者sub_mch_id)
+ * PERSONAL_OPENID:个人openid
+ */
+ private Type type;
+
+ /**
+ * 分账接收方帐号.
+ *
+ * 类型是MERCHANT_ID时,是商户号(mch_id或者sub_mch_id)
+ * 类型是PERSONAL_OPENID时,是个人openid
+ */
+ private String account;
+
+ /**
+ * 分账金额.
+ *
+ * 单位为分,只能为整数,不能超过原订单支付金额及最大分账比例金额
+ */
+ private Integer amount;
+
+ /**
+ * 分账描述.
+ *
+ * 分账的原因描述,分账账单中需要体现
+ */
+ private String description;
+
+ /**
+ * 分账个人接收方姓名.
+ *
+ * 可选项,在接收方类型为个人的时可选填,若有值,会检查与 name 是否实名匹配,不匹配会拒绝分账请求.
+ * 1、分账接收方类型是PERSONAL_OPENID时,是个人姓名(选传,传则校验)
+ */
+ private String name;
+
+}
diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v2/model/allocation/RelationType.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v2/model/allocation/RelationType.java
new file mode 100644
index 0000000..319abc1
--- /dev/null
+++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v2/model/allocation/RelationType.java
@@ -0,0 +1,72 @@
+/*
+ * Copyright 2019-2021 felord.cn
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ * Website:
+ * https://felord.cn
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package cn.felord.payment.wechat.v2.model.allocation;
+
+/**
+ * The enum Relation type.
+ * @author wangzecheng
+ * @since 1.0.10.RELEASE
+ */
+public enum RelationType {
+
+ /**
+ * Service provider relation type.
+ */
+ SERVICE_PROVIDER,
+ /**
+ * Store relation type.
+ */
+ STORE,
+ /**
+ * Staff relation type.
+ */
+ STAFF,
+ /**
+ * Store owner relation type.
+ */
+ STORE_OWNER,
+ /**
+ * Partner relation type.
+ */
+ PARTNER,
+ /**
+ * Headquarter relation type.
+ */
+ HEADQUARTER,
+ /**
+ * Brand relation type.
+ */
+ BRAND,
+ /**
+ * Distributor relation type.
+ */
+ DISTRIBUTOR,
+ /**
+ * User relation type.
+ */
+ USER,
+ /**
+ * Supplier relation type.
+ */
+ SUPPLIER,
+ /**
+ * Custom relation type.
+ */
+ CUSTOM
+
+}
diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v2/model/allocation/Type.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v2/model/allocation/Type.java
new file mode 100644
index 0000000..1a0b7be
--- /dev/null
+++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v2/model/allocation/Type.java
@@ -0,0 +1,20 @@
+package cn.felord.payment.wechat.v2.model.allocation;
+
+/**
+ * The enum Type.
+ *
+ * @author wangzecheng
+ * @since 1.0.10.RELEASE
+ */
+public enum Type {
+
+ /**
+ * 商户号(mch_id或者sub_mch_id)
+ */
+ MERCHANT_ID,
+
+ /**
+ * 个人openid
+ */
+ PERSONAL_OPENID
+}
diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/AbstractApi.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/AbstractApi.java
index 546c453..50615ec 100644
--- a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/AbstractApi.java
+++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/AbstractApi.java
@@ -202,6 +202,21 @@ public abstract class AbstractApi {
.build();
}
+ /**
+ * 构建Post请求对象.
+ *
+ * @param uri the uri
+ * @param params the params
+ * @return the request entity
+ */
+ protected RequestEntity> Patch(URI uri, Object params) {
+ try {
+ return RequestEntity.patch(uri).header("Pay-TenantId", tenantId)
+ .body(mapper.writeValueAsString(params));
+ } catch (JsonProcessingException e) {
+ throw new PayException("wechat app pay json failed");
+ }
+ }
/**
* 对账单内容下载,非流文件。
*
diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/KeyPairFactory.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/KeyPairFactory.java
index 839245f..c6a3547 100644
--- a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/KeyPairFactory.java
+++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/KeyPairFactory.java
@@ -22,10 +22,7 @@ package cn.felord.payment.wechat.v3;
import cn.felord.payment.PayException;
import org.springframework.core.io.ClassPathResource;
-import java.security.KeyPair;
-import java.security.KeyStore;
-import java.security.PrivateKey;
-import java.security.PublicKey;
+import java.security.*;
import java.security.cert.X509Certificate;
/**
@@ -36,9 +33,16 @@ import java.security.cert.X509Certificate;
**/
public class KeyPairFactory {
- private KeyStore store;
+ private static final KeyStore PKCS12_KEY_STORE;
+
+ static {
+ try {
+ PKCS12_KEY_STORE = KeyStore.getInstance("PKCS12");
+ } catch (KeyStoreException e) {
+ throw new PayException(" wechat pay keystore initialization failed");
+ }
+ }
- private final Object lock = new Object();
/**
* 获取公私钥.
@@ -48,23 +52,16 @@ public class KeyPairFactory {
* @param keyPass password
* @return the key pair
*/
- public WechatMetaBean createPKCS12(String keyPath, String keyAlias, String keyPass) {
+ public WechatMetaBean initWechatMetaBean(String keyPath, String keyAlias, String keyPass) {
ClassPathResource resource = new ClassPathResource(keyPath);
char[] pem = keyPass.toCharArray();
try {
- synchronized (lock) {
- if (store == null) {
- synchronized (lock) {
- store = KeyStore.getInstance("PKCS12");
- store.load(resource.getInputStream(), pem);
- }
- }
- }
- X509Certificate certificate = (X509Certificate) store.getCertificate(keyAlias);
+ PKCS12_KEY_STORE.load(resource.getInputStream(), pem);
+ X509Certificate certificate = (X509Certificate) PKCS12_KEY_STORE.getCertificate(keyAlias);
certificate.checkValidity();
String serialNumber = certificate.getSerialNumber().toString(16).toUpperCase();
PublicKey publicKey = certificate.getPublicKey();
- PrivateKey storeKey = (PrivateKey) store.getKey(keyAlias, pem);
+ PrivateKey storeKey = (PrivateKey) PKCS12_KEY_STORE.getKey(keyAlias, pem);
WechatMetaBean wechatMetaBean = new WechatMetaBean();
wechatMetaBean.setKeyPair(new KeyPair(publicKey, storeKey));
wechatMetaBean.setSerialNumber(serialNumber);
diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/WechatApiProvider.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/WechatApiProvider.java
index bab8d0e..b7c9778 100644
--- a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/WechatApiProvider.java
+++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/WechatApiProvider.java
@@ -18,6 +18,7 @@
*/
package cn.felord.payment.wechat.v3;
+import cn.felord.payment.wechat.v2.WechatAllocationApi;
import cn.felord.payment.wechat.v2.WechatPayRedpackApi;
import cn.felord.payment.wechat.v2.WechatPayTransfersApi;
import cn.felord.payment.wechat.v2.WechatV2Client;
@@ -177,4 +178,19 @@ public class WechatApiProvider {
return new WechatPayTransfersApi(wechatV2Client);
}
+ /**
+ * 微信支付分账,基于V2
+ *
+ * @param tenantId the tenant id
+ * @return wechat allocation api
+ * @since 1.0.10.RELEASE
+ */
+ public WechatAllocationApi allocationApi(String tenantId) {
+ WechatMetaBean wechatMeta = wechatPayClient.signatureProvider()
+ .wechatMetaContainer()
+ .getWechatMeta(tenantId);
+ WechatV2Client wechatV2Client = new WechatV2Client(wechatMeta);
+ return new WechatAllocationApi(wechatV2Client);
+ }
+
}
diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/WechatMarketingBusiFavorApi.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/WechatMarketingBusiFavorApi.java
index 9fd4018..b29e50f 100644
--- a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/WechatMarketingBusiFavorApi.java
+++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/WechatMarketingBusiFavorApi.java
@@ -384,7 +384,7 @@ public class WechatMarketingBusiFavorApi extends AbstractApi {
.expand(updateParams.getStockId())
.toUri();
updateParams.setStockId(null);
- return Post(uri, updateParams);
+ return Patch(uri, updateParams);
})
.consumer(wechatResponseEntity::convert)
.request();
diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/WechatPayCallback.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/WechatPayCallback.java
index 77d41df..f6789a8 100644
--- a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/WechatPayCallback.java
+++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/WechatPayCallback.java
@@ -91,6 +91,27 @@ public class WechatPayCallback {
}
+ /**
+ * 微信支付分账回调.
+ *
+ * @param params the params
+ * @param consumeDataConsumer the consume data consumer
+ * @return the map
+ * @since 1.0.10.RELEASE
+ */
+ @SneakyThrows
+ public Map
+ * 直连模式分账发起和出资商户
+ */
+ private String mchid;
+
+ /**
+ * 微信订单号.
+ *
+ * 微信支付订单号
+ */
+ private String transactionId;
+
+ /**
+ * 微信分账/回退单号.
+ */
+ private String orderId;
+
+ /**
+ * 商户分账/回退单号.
+ *
+ * 分账方系统内部的分账/回退单号
+ */
+ private String outOrderNo;
+
+ /**
+ * 分账接收方.
+ *
+ * 分账接收方对象
+ */
+ private Receiver receiver;
+
+ /**
+ * 成功时间.
+ *
+ * Rfc3339标准
+ */
+ @JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ssXXX", timezone = "GMT+8")
+ private LocalDateTime successTime;
+
+}
diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/RefundConsumeData.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/RefundConsumeData.java
index a9a942f..f983733 100644
--- a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/RefundConsumeData.java
+++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/RefundConsumeData.java
@@ -22,7 +22,7 @@ import cn.felord.payment.wechat.enumeration.RefundStatus;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
-import java.time.OffsetDateTime;
+import java.time.LocalDateTime;
/**
* 微信支付退款结果通知解密
@@ -60,7 +60,7 @@ public class RefundConsumeData {
* 退款成功时间
*/
@JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ssXXX", timezone = "GMT+8")
- private OffsetDateTime successTime;
+ private LocalDateTime successTime;
/**
* 退款入账账户
*/
diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/TransactionConsumeData.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/TransactionConsumeData.java
index a9fe1f7..8d070a9 100644
--- a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/TransactionConsumeData.java
+++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/TransactionConsumeData.java
@@ -23,7 +23,7 @@ import cn.felord.payment.wechat.enumeration.TradeType;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
-import java.time.OffsetDateTime;
+import java.time.LocalDateTime;
import java.util.List;
/**
@@ -91,7 +91,7 @@ public class TransactionConsumeData {
* 支付完成时间 YYYY-MM-DDTHH:mm:ss+TIMEZONE
*/
@JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ssXXX", timezone = "GMT+8")
- private OffsetDateTime successTime;
+ private LocalDateTime successTime;
/**
* 在 1.0.0.RELEASE 直接返回了枚举字符串,1.0.2.RELEASE 中变更为枚举
*
diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/busifavor/BusiFavorReceiveConsumeData.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/busifavor/BusiFavorReceiveConsumeData.java
index 2560165..bdd250b 100644
--- a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/busifavor/BusiFavorReceiveConsumeData.java
+++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/busifavor/BusiFavorReceiveConsumeData.java
@@ -20,7 +20,7 @@ package cn.felord.payment.wechat.v3.model.busifavor;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
-import java.time.OffsetDateTime;
+import java.time.LocalDateTime;
/**
* 商家券领券事件回调通知解密
@@ -50,7 +50,7 @@ public class BusiFavorReceiveConsumeData {
* 发放时间 rfc 3339 yyyy-MM-ddTHH:mm:ss+TIMEZONE
*/
@JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ssXXX", timezone = "GMT+8")
- private OffsetDateTime sendTime;
+ private LocalDateTime sendTime;
/**
* 微信用户在appid下的唯一标识。
*/
diff --git a/payment-spring-boot-starter/pom.xml b/payment-spring-boot-starter/pom.xml
index 2a817cd..dd4975d 100644
--- a/payment-spring-boot-starter/pom.xml
+++ b/payment-spring-boot-starter/pom.xml
@@ -5,11 +5,11 @@