From 5941907d7cec58b20fc7e96ea8e257fe6b3f5c28 Mon Sep 17 00:00:00 2001 From: xiafang Date: Wed, 21 Jun 2023 15:15:22 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=94=AF=E4=BB=98=E6=9C=89=E7=A4=BC-?= =?UTF-8?q?=E7=9B=B4=E8=BF=9E=E5=95=86=E6=88=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/wechat_v3_api.md | 15 +- .../wechat/InMemoryWechatTenantService.java | 2 +- .../wechat/enumeration/ActivityStatus.java | 58 +++++ .../payment/wechat/enumeration/AwardType.java | 31 +++ .../wechat/enumeration/DeliveryPurpose.java | 35 +++ .../enumeration/DeliveryUserCategory.java | 33 +++ .../wechat/enumeration/SendContent.java | 35 +++ .../enumeration/WechatPayAlgorithms.java | 2 +- .../wechat/enumeration/WechatPayV3Type.java | 49 ++++ .../payment/wechat/v3/WechatApiProvider.java | 11 + .../v3/WechatMarketingPayGiftActivityApi.java | 232 ++++++++++++++++++ .../ActivitiesListPageRequest.java | 35 +++ .../ActivitiesPageRequest.java | 31 +++ .../paygiftactivity/ActivityBaseInfo.java | 66 +++++ .../paygiftactivity/AdvancedSetting.java | 34 +++ .../paygiftactivity/AvailablePeriods.java | 34 +++ .../v3/model/paygiftactivity/AwardItem.java | 31 +++ .../model/paygiftactivity/AwardSendRule.java | 40 +++ .../DeleteActivityMchRequest.java | 33 +++ .../paygiftactivity/GiftActivityParams.java | 31 +++ .../paygiftactivity/LocalTimePeriods.java | 35 +++ .../NewActivityMchRequest.java | 33 +++ .../OffsetDateTimePeriods.java | 37 +++ .../BrandProfitsharingOrder.java | 19 +- 24 files changed, 957 insertions(+), 5 deletions(-) create mode 100644 payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/enumeration/ActivityStatus.java create mode 100644 payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/enumeration/AwardType.java create mode 100644 payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/enumeration/DeliveryPurpose.java create mode 100644 payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/enumeration/DeliveryUserCategory.java create mode 100644 payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/enumeration/SendContent.java create mode 100644 payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/WechatMarketingPayGiftActivityApi.java create mode 100644 payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/paygiftactivity/ActivitiesListPageRequest.java create mode 100644 payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/paygiftactivity/ActivitiesPageRequest.java create mode 100644 payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/paygiftactivity/ActivityBaseInfo.java create mode 100644 payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/paygiftactivity/AdvancedSetting.java create mode 100644 payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/paygiftactivity/AvailablePeriods.java create mode 100644 payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/paygiftactivity/AwardItem.java create mode 100644 payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/paygiftactivity/AwardSendRule.java create mode 100644 payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/paygiftactivity/DeleteActivityMchRequest.java create mode 100644 payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/paygiftactivity/GiftActivityParams.java create mode 100644 payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/paygiftactivity/LocalTimePeriods.java create mode 100644 payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/paygiftactivity/NewActivityMchRequest.java create mode 100644 payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/paygiftactivity/OffsetDateTimePeriods.java diff --git a/docs/wechat_v3_api.md b/docs/wechat_v3_api.md index c8de1c8..0d66149 100644 --- a/docs/wechat_v3_api.md +++ b/docs/wechat_v3_api.md @@ -1,6 +1,7 @@ ## 入口类 -`WechatApiProvider`是本项目微信支付的入口类,已被注入**Spring IoC**,由它来初始化微信支付相关的**API**,具体分为**直连商户**和**服务商**两个体系。 +`WechatApiProvider`是本项目微信支付的入口类,已被注入**Spring IoC**,由它来初始化微信支付相关的**API**,具体分为**直连商户 +**和**服务商**两个体系。 > 以下清单请搭配微信支付文档使用。 @@ -152,7 +153,15 @@ ##### 支付有礼 -- [ ] 功能实现中…… +- [x] `WechatMarketingPayGiftActivityApi` 支付有礼,通过`WechatApiProvider#marketingPayGiftActivityApi`初始化 + - [x] `create` 创建全场满额送活动 + - [x] `details` 查询活动详情接口 + - [x] `merchants` 查询活动发券商户号 + - [x] `goods` 查询活动指定商品列表 + - [x] `terminate` 终止活动 + - [x] `addMches` 新增活动发券商户号 + - [x] `page` 获取支付有礼活动列表 + - [x] `deleteMch` 删除活动发券商户号 ##### 图片上传(营销专用) @@ -221,5 +230,7 @@ - [x] `marketingImageUpload` 营销图片上传 > 通过营销**图片上传API**上传图片后可获得图片url地址。图片url可在微信支付营销相关的API使用,包括商家券、代金券、支付有礼等。 + ### 服务商 + 施工中…… \ No newline at end of file diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/InMemoryWechatTenantService.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/InMemoryWechatTenantService.java index a43b186..f0de581 100644 --- a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/InMemoryWechatTenantService.java +++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/InMemoryWechatTenantService.java @@ -34,7 +34,7 @@ import java.util.stream.Collectors; /** * 从配置文件中加载租户信息,默认实现,可被覆盖 * - * @author xiafang + * @author dax * @since 2023/2/3 11:40 */ @AllArgsConstructor diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/enumeration/ActivityStatus.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/enumeration/ActivityStatus.java new file mode 100644 index 0000000..605a420 --- /dev/null +++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/enumeration/ActivityStatus.java @@ -0,0 +1,58 @@ +/* + * Copyright 2019-2022 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.enumeration; + +/** + * The enum Activity status. + * + * @author dax + * @since 1.0.19.RELEASE + */ +public enum ActivityStatus { + /** + * 状态未知 + */ + ACT_STATUS_UNKNOWN, + /** + * 已创建 + */ + CREATE_ACT_STATUS, + /** + * 运行中 + */ + ONGOING_ACT_STATUS, + /** + * 已终止 + */ + TERMINATE_ACT_STATUS, + + /** + * 已暂停 + */ + STOP_ACT_STATUS, + + /** + * 已过期 + */ + OVER_TIME_ACT_STATUS, + + /** + * 创建活动失败 + */ + CREATE_ACT_FAILED +} diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/enumeration/AwardType.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/enumeration/AwardType.java new file mode 100644 index 0000000..93dce2a --- /dev/null +++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/enumeration/AwardType.java @@ -0,0 +1,31 @@ +/* + * Copyright 2019-2022 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.enumeration; + +/** + * The enum Award type. + * + * @author dax + * @since 1.0.19.RELEASE + */ +public enum AwardType { + /** + * 商家券 + */ + BUSIFAVOR +} diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/enumeration/DeliveryPurpose.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/enumeration/DeliveryPurpose.java new file mode 100644 index 0000000..f5169d2 --- /dev/null +++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/enumeration/DeliveryPurpose.java @@ -0,0 +1,35 @@ +/* + * Copyright 2019-2022 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.enumeration; + +/** + * The enum Delivery purpose. + * + * @author felord.cn + * @since 1.0.19.RELEASE + */ +public enum DeliveryPurpose { + /** + * 拉用户回店消费 + */ + OFF_LINE_PAY, + /** + * 引导用户前往小程序消费 + */ + JUMP_MINI_APP +} diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/enumeration/DeliveryUserCategory.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/enumeration/DeliveryUserCategory.java new file mode 100644 index 0000000..2d0c00f --- /dev/null +++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/enumeration/DeliveryUserCategory.java @@ -0,0 +1,33 @@ +/* + * Copyright 2019-2022 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.enumeration; + +/** + * @author dax + * @since 1.0.19.RELEASE + */ +public enum DeliveryUserCategory { + /** + * 所有用户 + */ + DELIVERY_ALL_PERSON, + /** + * 会员用户 + */ + DELIVERY_MEMBER_PERSON +} diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/enumeration/SendContent.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/enumeration/SendContent.java new file mode 100644 index 0000000..3f66b42 --- /dev/null +++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/enumeration/SendContent.java @@ -0,0 +1,35 @@ +/* + * Copyright 2019-2022 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.enumeration; + +/** + * The enum Send content. + * + * @author dax + * @since 1.0.19.RELEASE + */ +public enum SendContent { + /** + * 单张券 + */ + SINGLE_COUPON, + /** + * 礼包 + */ + GIFT_PACKAGE +} diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/enumeration/WechatPayAlgorithms.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/enumeration/WechatPayAlgorithms.java index da1ec98..b8fc883 100644 --- a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/enumeration/WechatPayAlgorithms.java +++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/enumeration/WechatPayAlgorithms.java @@ -20,7 +20,7 @@ package cn.felord.payment.wechat.enumeration; import lombok.Getter; /** - * @author xiafang + * @author dax * @since 2023/2/1 8:59 */ @Getter diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/enumeration/WechatPayV3Type.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/enumeration/WechatPayV3Type.java index 2dd3496..b7824f4 100644 --- a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/enumeration/WechatPayV3Type.java +++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/enumeration/WechatPayV3Type.java @@ -507,6 +507,55 @@ public enum WechatPayV3Type { */ MARKETING_PARTNERSHIPS_GET(HttpMethod.GET, "%s/v3/marketing/partnerships"), + //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + /** + * 创建全场满额送活动API + * + * @since 1.0.19.RELEASES + */ + MARKETING_PAYGIFTACTIVITY(HttpMethod.POST, "%s/v3/marketing/paygiftactivity/unique-threshold-activity"), + /** + * 查询活动详情接口API + * + * @since 1.0.19.RELEASES + */ + MARKETING_PAYGIFTACTIVITY_DETAIL(HttpMethod.GET, "%s/v3/marketing/paygiftactivity/activities/{activity_id}"), + /** + * 查询活动发券商户号API + * + * @since 1.0.19.RELEASES + */ + MARKETING_PAYGIFTACTIVITY_MCH(HttpMethod.GET, "%s/v3/marketing/paygiftactivity/activities/{activity_id}/merchants"), + /** + * 查询活动指定商品列表API + * + * @since 1.0.19.RELEASES + */ + MARKETING_PAYGIFTACTIVITY_GOODS(HttpMethod.GET, "%s/v3/marketing/paygiftactivity/activities/{activity_id}/goods"), + /** + * 终止活动API + * + * @since 1.0.19.RELEASES + */ + MARKETING_PAYGIFTACTIVITY_TERMINATE(HttpMethod.POST, "%s/v3/marketing/paygiftactivity/activities/{activity_id}/terminate"), + /** + * 新增活动发券商户号API + * + * @since 1.0.19.RELEASES + */ + MARKETING_PAYGIFTACTIVITY_MCH_ADD(HttpMethod.POST, "%s/v3/marketing/paygiftactivity/activities/{activity_id}/merchants/add"), + /** + * 获取支付有礼活动列表API + * + * @since 1.0.19.RELEASES + */ + MARKETING_PAYGIFTACTIVITY_ACTIVITIES(HttpMethod.GET, "%s/v3/marketing/paygiftactivity/activities"), + /** + * 删除活动发券商户号API + * + * @since 1.0.19.RELEASES + */ + MARKETING_PAYGIFTACTIVITY_MCH_DEL(HttpMethod.POST, "%s/v3/marketing/paygiftactivity/activities/{activity_id}/merchants/delete"), //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /** * 发起批量转账API. 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 9989623..e6516a2 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 @@ -140,6 +140,17 @@ public class WechatApiProvider { return new WechatMarketingPartnershipApi(this.wechatPayClient, tenantId); } + /** + * 支付有礼-直连商户 + * + * @param tenantId the tenant id + * @return the wechat marketing pay gift activity api + * @since 1.0.19.RELEASE + */ + public WechatMarketingPayGiftActivityApi marketingPayGiftActivityApi(String tenantId) { + return new WechatMarketingPayGiftActivityApi(this.wechatPayClient, tenantId); + } + /** * 批量转账到零钱. *

diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/WechatMarketingPayGiftActivityApi.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/WechatMarketingPayGiftActivityApi.java new file mode 100644 index 0000000..d97a16b --- /dev/null +++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/WechatMarketingPayGiftActivityApi.java @@ -0,0 +1,232 @@ +/* + * Copyright 2019-2022 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.v3; + +import cn.felord.payment.wechat.enumeration.WeChatServer; +import cn.felord.payment.wechat.enumeration.WechatPayV3Type; +import cn.felord.payment.wechat.v3.model.paygiftactivity.ActivitiesListPageRequest; +import cn.felord.payment.wechat.v3.model.paygiftactivity.ActivitiesPageRequest; +import cn.felord.payment.wechat.v3.model.paygiftactivity.DeleteActivityMchRequest; +import cn.felord.payment.wechat.v3.model.paygiftactivity.GiftActivityParams; +import cn.felord.payment.wechat.v3.model.paygiftactivity.NewActivityMchRequest; +import com.fasterxml.jackson.databind.node.ObjectNode; +import org.springframework.web.util.UriComponentsBuilder; + +import java.net.URI; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; + +/** + * 支付有礼 + * + * @author dax + * @since 1.0.19.RELEASE + */ +public class WechatMarketingPayGiftActivityApi extends AbstractApi { + /** + * Instantiates a new Abstract api. + * + * @param wechatPayClient the wechat pay client + * @param tenantId the tenant id + */ + public WechatMarketingPayGiftActivityApi(WechatPayClient wechatPayClient, String tenantId) { + super(wechatPayClient, tenantId); + } + + /** + * 创建全场满额送活动API + * + * @param params the params + * @return the wechat response entity + */ + public WechatResponseEntity create(GiftActivityParams params) { + WechatResponseEntity wechatResponseEntity = new WechatResponseEntity<>(); + this.client().withType(WechatPayV3Type.MARKETING_PAYGIFTACTIVITY, params) + .function((type, activityParams) -> { + URI uri = UriComponentsBuilder.fromHttpUrl(type.uri(WeChatServer.CHINA)) + .build() + .toUri(); + return Post(uri, activityParams); + }) + .consumer(wechatResponseEntity::convert) + .request(); + return wechatResponseEntity; + } + + /** + * 查询活动详情接口API + * + * @param activityId the activity id + * @return the wechat response entity + */ + public WechatResponseEntity details(String activityId) { + WechatResponseEntity wechatResponseEntity = new WechatResponseEntity<>(); + this.client().withType(WechatPayV3Type.MARKETING_PAYGIFTACTIVITY_DETAIL, activityId) + .function((type, param) -> { + URI uri = UriComponentsBuilder.fromHttpUrl(type.uri(WeChatServer.CHINA)) + .build() + .expand(param) + .toUri(); + return Get(uri); + }) + .consumer(wechatResponseEntity::convert) + .request(); + return wechatResponseEntity; + } + + /** + * 查询活动发券商户号API + * + * @param request the request + * @return the wechat response entity + */ + public WechatResponseEntity merchants(ActivitiesPageRequest request) { + WechatResponseEntity wechatResponseEntity = new WechatResponseEntity<>(); + this.client().withType(WechatPayV3Type.MARKETING_PAYGIFTACTIVITY_MCH, request) + .function((type, params) -> { + URI uri = UriComponentsBuilder.fromHttpUrl(type.uri(WeChatServer.CHINA)) + .queryParam("offset", params.getOffset()) + .queryParam("limit", params.getLimit()) + .build() + .expand(params.getActivityId()) + .toUri(); + return Get(uri); + }) + .consumer(wechatResponseEntity::convert) + .request(); + return wechatResponseEntity; + } + + /** + * 查询活动指定商品列表API + * + * @param request the request + * @return the wechat response entity + */ + public WechatResponseEntity goods(ActivitiesPageRequest request) { + WechatResponseEntity wechatResponseEntity = new WechatResponseEntity<>(); + this.client().withType(WechatPayV3Type.MARKETING_PAYGIFTACTIVITY_GOODS, request) + .function((type, params) -> { + URI uri = UriComponentsBuilder.fromHttpUrl(type.uri(WeChatServer.CHINA)) + .queryParam("offset", params.getOffset()) + .queryParam("limit", params.getLimit()) + .build() + .expand(params.getActivityId()) + .toUri(); + return Get(uri); + }) + .consumer(wechatResponseEntity::convert) + .request(); + return wechatResponseEntity; + } + + /** + * 终止活动API + * + * @param activityId the activity id + * @return the wechat response entity + */ + public WechatResponseEntity terminate(String activityId) { + WechatResponseEntity wechatResponseEntity = new WechatResponseEntity<>(); + this.client().withType(WechatPayV3Type.MARKETING_PAYGIFTACTIVITY_TERMINATE, activityId) + .function((type, param) -> { + URI uri = UriComponentsBuilder.fromHttpUrl(type.uri(WeChatServer.CHINA)) + .build() + .expand(param) + .toUri(); + return Post(uri, Collections.emptyMap()); + }) + .consumer(wechatResponseEntity::convert) + .request(); + return wechatResponseEntity; + } + + /** + * 新增活动发券商户号API + * + * @param request the request + * @return the wechat response entity + */ + public WechatResponseEntity addMches(NewActivityMchRequest request) { + WechatResponseEntity wechatResponseEntity = new WechatResponseEntity<>(); + this.client().withType(WechatPayV3Type.MARKETING_PAYGIFTACTIVITY_MCH_ADD, request) + .function((type, params) -> { + URI uri = UriComponentsBuilder.fromHttpUrl(type.uri(WeChatServer.CHINA)) + .build() + .expand(params.getActivityId()) + .toUri(); + Map body = new HashMap<>(); + body.put("merchant_id_list", params.getMerchantIdList()); + body.put("add_request_no", params.getAddRequestNo()); + return Post(uri, body); + }) + .consumer(wechatResponseEntity::convert) + .request(); + return wechatResponseEntity; + } + + /** + * 获取支付有礼活动列表API + * + * @param request the request + * @return the wechat response entity + */ + public WechatResponseEntity page(ActivitiesListPageRequest request) { + WechatResponseEntity wechatResponseEntity = new WechatResponseEntity<>(); + this.client().withType(WechatPayV3Type.MARKETING_PAYGIFTACTIVITY_ACTIVITIES, request) + .function((type, params) -> { + URI uri = UriComponentsBuilder.fromHttpUrl(type.uri(WeChatServer.CHINA)) + .queryParam("offset", params.getOffset()) + .queryParam("limit", params.getLimit()) + .queryParam("activity_name", params.getActivityName()) + .queryParam("activity_status", params.getActivityStatus()) + .queryParam("award_type", params.getAwardType()) + .build() + .toUri(); + return Get(uri); + }) + .consumer(wechatResponseEntity::convert) + .request(); + return wechatResponseEntity; + } + + /** + * 删除活动发券商户号API + * + * @param request the request + * @return the wechat response entity + */ + public WechatResponseEntity deleteMch(DeleteActivityMchRequest request) { + WechatResponseEntity wechatResponseEntity = new WechatResponseEntity<>(); + this.client().withType(WechatPayV3Type.MARKETING_PAYGIFTACTIVITY_MCH_DEL, request) + .function((type, params) -> { + URI uri = UriComponentsBuilder.fromHttpUrl(type.uri(WeChatServer.CHINA)) + .build() + .expand(params.getActivityId()) + .toUri(); + Map body = new HashMap<>(); + body.put("merchant_id_list", params.getMerchantIdList()); + body.put("delete_request_no", params.getDeleteRequestNo()); + return Post(uri, body); + }) + .consumer(wechatResponseEntity::convert) + .request(); + return wechatResponseEntity; + } +} diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/paygiftactivity/ActivitiesListPageRequest.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/paygiftactivity/ActivitiesListPageRequest.java new file mode 100644 index 0000000..1cb9a2b --- /dev/null +++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/paygiftactivity/ActivitiesListPageRequest.java @@ -0,0 +1,35 @@ +/* + * Copyright 2019-2022 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.v3.model.paygiftactivity; + +import cn.felord.payment.wechat.enumeration.ActivityStatus; +import cn.felord.payment.wechat.enumeration.AwardType; +import lombok.Data; + +/** + * @author dax + * @since 1.0.19.RELEASE + */ +@Data +public class ActivitiesListPageRequest { + private final long offset; + private final long limit; + private String activityName; + private ActivityStatus activityStatus; + private AwardType awardType; +} diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/paygiftactivity/ActivitiesPageRequest.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/paygiftactivity/ActivitiesPageRequest.java new file mode 100644 index 0000000..21e86ed --- /dev/null +++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/paygiftactivity/ActivitiesPageRequest.java @@ -0,0 +1,31 @@ +/* + * Copyright 2019-2022 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.v3.model.paygiftactivity; + +import lombok.Data; + +/** + * @author dax + * @since 1.0.19.RELEASE + */ +@Data +public class ActivitiesPageRequest { + private final String activityId; + private Long offset; + private Long limit; +} diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/paygiftactivity/ActivityBaseInfo.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/paygiftactivity/ActivityBaseInfo.java new file mode 100644 index 0000000..0f442fb --- /dev/null +++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/paygiftactivity/ActivityBaseInfo.java @@ -0,0 +1,66 @@ +/* + * Copyright 2019-2022 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.v3.model.paygiftactivity; + +import cn.felord.payment.wechat.enumeration.CouponBgColor; +import cn.felord.payment.wechat.enumeration.DeliveryPurpose; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; + +import java.time.OffsetDateTime; + +/** + * The type Activity base info. + * + * @author dax + * @since 1.0.19.RELEASE + */ +@Data +public class ActivityBaseInfo { + private String activityName; + private String activitySecondTitle; + private String merchantLogoUrl; + private String backgroundColor; + @JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ssXXX") + private OffsetDateTime beginTime; + @JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ssXXX") + private OffsetDateTime endTime; + private AvailablePeriods availablePeriods; + private String outRequestNo; + private DeliveryPurpose deliveryPurpose; + private String miniProgramsPath; + + /** + * Sets background color. + * + * @param backgroundColor the background color + */ + void setBackgroundColor(String backgroundColor) { + this.backgroundColor = backgroundColor; + } + + /** + * Sets background color. + * + * @param backgroundColor the background color + */ + public void setBackgroundColor(CouponBgColor backgroundColor) { + this.backgroundColor = backgroundColor.getValue(); + } + +} diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/paygiftactivity/AdvancedSetting.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/paygiftactivity/AdvancedSetting.java new file mode 100644 index 0000000..755cbb1 --- /dev/null +++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/paygiftactivity/AdvancedSetting.java @@ -0,0 +1,34 @@ +/* + * Copyright 2019-2022 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.v3.model.paygiftactivity; + +import cn.felord.payment.wechat.enumeration.DeliveryUserCategory; +import lombok.Data; + +import java.util.Set; + +/** + * @author dax + * @since 1.0.19.RELEASE + */ +@Data +public class AdvancedSetting { + private DeliveryUserCategory deliveryUserCategory; + private String merchantMemberAppid; + private Set goodsTags; +} diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/paygiftactivity/AvailablePeriods.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/paygiftactivity/AvailablePeriods.java new file mode 100644 index 0000000..8f99606 --- /dev/null +++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/paygiftactivity/AvailablePeriods.java @@ -0,0 +1,34 @@ +/* + * Copyright 2019-2022 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.v3.model.paygiftactivity; + +import lombok.Data; + +import java.util.List; + +/** + * The type Available periods. + * + * @author dax + * @since 1.0.19.RELEASE + */ +@Data +public class AvailablePeriods { + private List availableTime; + private List availableDayTime; +} diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/paygiftactivity/AwardItem.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/paygiftactivity/AwardItem.java new file mode 100644 index 0000000..a6a63d1 --- /dev/null +++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/paygiftactivity/AwardItem.java @@ -0,0 +1,31 @@ +/* + * Copyright 2019-2022 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.v3.model.paygiftactivity; + +import lombok.Data; + +/** + * @author dax + * @since 1.0.19.RELEASE + */ +@Data +public class AwardItem { + private final String stock_id; + private final String original_image_url; + private String thumbnail_url; +} diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/paygiftactivity/AwardSendRule.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/paygiftactivity/AwardSendRule.java new file mode 100644 index 0000000..5917942 --- /dev/null +++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/paygiftactivity/AwardSendRule.java @@ -0,0 +1,40 @@ +/* + * Copyright 2019-2022 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.v3.model.paygiftactivity; + +import cn.felord.payment.wechat.enumeration.AwardType; +import cn.felord.payment.wechat.enumeration.SendContent; +import lombok.Data; + +import java.util.List; + +/** + * 满送活动规则 + * + * @author dax + * @since 1.0.19.RELEASE + */ +@Data +public class AwardSendRule { + private final int transactionAmountMinimum; + private final SendContent sendContent; + private final AwardType awardType; + private final List awardList; + private final String merchantOption; + private final List merchantIdList; +} diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/paygiftactivity/DeleteActivityMchRequest.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/paygiftactivity/DeleteActivityMchRequest.java new file mode 100644 index 0000000..0421519 --- /dev/null +++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/paygiftactivity/DeleteActivityMchRequest.java @@ -0,0 +1,33 @@ +/* + * Copyright 2019-2022 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.v3.model.paygiftactivity; + +import lombok.Data; + +import java.util.List; + +/** + * @author dax + * @since 1.0.19.RELEASE + */ +@Data +public class DeleteActivityMchRequest { + private final String activityId; + private String deleteRequestNo; + private List merchantIdList; +} diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/paygiftactivity/GiftActivityParams.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/paygiftactivity/GiftActivityParams.java new file mode 100644 index 0000000..b5c660b --- /dev/null +++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/paygiftactivity/GiftActivityParams.java @@ -0,0 +1,31 @@ +/* + * Copyright 2019-2022 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.v3.model.paygiftactivity; + +import lombok.Data; + +/** + * @author dax + * @since 1.0.19.RELEASE + */ +@Data +public class GiftActivityParams { + private final ActivityBaseInfo activityBaseInfo; + private final AwardSendRule awardSendRule; + private AdvancedSetting advancedSetting; +} diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/paygiftactivity/LocalTimePeriods.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/paygiftactivity/LocalTimePeriods.java new file mode 100644 index 0000000..f69e95a --- /dev/null +++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/paygiftactivity/LocalTimePeriods.java @@ -0,0 +1,35 @@ +/* + * Copyright 2019-2022 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.v3.model.paygiftactivity; + +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; + +import java.time.OffsetDateTime; + +/** + * @author dax + * @since 1.0.19.RELEASE + */ +@Data +public class LocalTimePeriods { + @JsonFormat(pattern = "HHmmss") + private final OffsetDateTime beginDayTime; + @JsonFormat(pattern = "HHmmss") + private final OffsetDateTime endDayTime; +} diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/paygiftactivity/NewActivityMchRequest.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/paygiftactivity/NewActivityMchRequest.java new file mode 100644 index 0000000..8dcc27d --- /dev/null +++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/paygiftactivity/NewActivityMchRequest.java @@ -0,0 +1,33 @@ +/* + * Copyright 2019-2022 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.v3.model.paygiftactivity; + +import lombok.Data; + +import java.util.List; + +/** + * @author dax + * @since 1.0.19.RELEASE + */ +@Data +public class NewActivityMchRequest { + private final String activityId; + private final String addRequestNo; + private List merchantIdList; +} diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/paygiftactivity/OffsetDateTimePeriods.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/paygiftactivity/OffsetDateTimePeriods.java new file mode 100644 index 0000000..08e818e --- /dev/null +++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/paygiftactivity/OffsetDateTimePeriods.java @@ -0,0 +1,37 @@ +/* + * Copyright 2019-2022 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.v3.model.paygiftactivity; + +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; + +import java.time.OffsetDateTime; + +/** + * The type Time periods. + * + * @author dax + * @since 1.0.19.RELEASE + */ +@Data +public class OffsetDateTimePeriods { + @JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ssXXX") + private final OffsetDateTime beginTime; + @JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ssXXX") + private final OffsetDateTime endTime; +} diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/profitsharing/BrandProfitsharingOrder.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/profitsharing/BrandProfitsharingOrder.java index 32c5886..30f2fd1 100644 --- a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/profitsharing/BrandProfitsharingOrder.java +++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/profitsharing/BrandProfitsharingOrder.java @@ -1,3 +1,20 @@ +/* + * Copyright 2019-2022 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.v3.model.profitsharing; import lombok.Data; @@ -5,7 +22,7 @@ import lombok.Data; import java.util.List; /** - * @author xiafang + * @author dax * @since 2023/1/3 10:27 */ @Data