From 6360bea385553b45125d7fe99e03680f4c4731ed Mon Sep 17 00:00:00 2001
From: Binary Wang
Date: Sat, 22 Aug 2026 12:19:32 +0800
Subject: [PATCH 1/6] =?UTF-8?q?docs:=20=E8=A1=A5=E5=85=85=E4=BF=9D?=
=?UTF-8?q?=E9=9A=9C=E5=8D=95=E6=8E=A5=E5=8F=A3=E8=AE=BE=E8=AE=A1?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
...6-08-22-channel-guarantee-orders-design.md | 39 +++++++++++++++++++
1 file changed, 39 insertions(+)
create mode 100644 docs/superpowers/specs/2026-08-22-channel-guarantee-orders-design.md
diff --git a/docs/superpowers/specs/2026-08-22-channel-guarantee-orders-design.md b/docs/superpowers/specs/2026-08-22-channel-guarantee-orders-design.md
new file mode 100644
index 000000000..31bf84434
--- /dev/null
+++ b/docs/superpowers/specs/2026-08-22-channel-guarantee-orders-design.md
@@ -0,0 +1,39 @@
+# 微信小店保障单接口设计
+
+## 目标
+
+实现 Issue #3987 所列的微信小店售后保障单六个 API,并提供与现有 `weixin-java-channel` 售后模块一致、可离线验证的 Java SDK 接口。
+
+## 范围
+
+- 获取保障单列表。
+- 获取保障单详情。
+- 同意、协商、举证及拒绝保障单申请。
+- 保障单请求与响应模型、URL 常量和离线单元测试。
+
+不包含 Issue #4003 中其他售后端点,也不改变既有售后 API。
+
+## API 设计
+
+`WxChannelAfterSaleService` 新增六个方法。列表和详情返回专用响应对象;四个会产生状态变更的接口返回 `WxChannelBaseResponse`,以便调用方检查微信错误码和错误信息。
+
+保障单号在公开 API 中使用 `String`,保持与现有售后单接口的用法一致,即使微信示例中它以 JSON number 表示。每个请求模型通过 `@JsonProperty` 显式映射到官方字段名。
+
+列表参数覆盖官方的保障单号、订单号、申请时间、状态、偏移量与限制条数。详情和列表共用完整的保障单信息模型,包含基础字段、商品信息、支付信息、送礼信息以及两类保障申请的专用信息。模型对官方返回的未知字段保持前向兼容。
+
+协商请求按官方字段发送 `bad_level` 和 `merchant_remark`;举证请求发送 `content` 与 `pic_list`;拒绝请求发送 `reason` 与必填的 `pic_list`。这修正旧 PR 中不符合文档的 `amount`、`desc` 和缺失图片凭证的问题。
+
+## 实现结构
+
+- `WxChannelApiUrlConstants.AfterSale`:六个官方路径常量。
+- `WxChannelAfterSaleService`:六个带 Javadoc 文档链接的公开方法。
+- `WxChannelAfterSaleServiceImpl`:每个方法调用对应路径,并用 `ResponseUtils.decode` 解码所有微信响应。
+- `bean.after`:请求、响应和保障单嵌套信息模型;仅承担 JSON 映射,不含业务逻辑。
+
+## 测试策略
+
+测试不调用真实微信接口或依赖店铺凭据。使用 Mockito mock `BaseWxChannelServiceImpl`:验证每个方法使用正确 URL 和请求对象,并由固定 JSON 验证列表/详情响应的 Jackson 映射以及操作接口的基础响应解码。每个新增行为先以失败测试建立,再写最小实现使其通过。
+
+## 质量与交付
+
+构建至少执行 `mvn -pl weixin-java-channel -am test`,并执行目标模块的新增测试。提交信息使用中文。新 PR 目标分支为 `develop`,描述中包含 `Closes #3987`。新 PR 创建并验证后,关闭 #4035 并留下指向替代 PR 的说明。
From 35e3cffa59bcc8e92db229c8afc0896970400ba2 Mon Sep 17 00:00:00 2001
From: Binary Wang
Date: Sat, 22 Aug 2026 12:24:47 +0800
Subject: [PATCH 2/6] =?UTF-8?q?chore:=20=E5=BF=BD=E7=95=A5=E6=9C=AC?=
=?UTF-8?q?=E5=9C=B0=20superpowers=20=E6=96=87=E6=A1=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.gitignore | 3 ++
...6-08-22-channel-guarantee-orders-design.md | 39 -------------------
2 files changed, 3 insertions(+), 39 deletions(-)
delete mode 100644 docs/superpowers/specs/2026-08-22-channel-guarantee-orders-design.md
diff --git a/.gitignore b/.gitignore
index 6b8802547..34150b7b3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -55,3 +55,6 @@ sonar-project.properties
.factorypath
*.zip
.worktrees
+
+# Local Superpowers working documents; do not commit.
+/docs/superpowers/
diff --git a/docs/superpowers/specs/2026-08-22-channel-guarantee-orders-design.md b/docs/superpowers/specs/2026-08-22-channel-guarantee-orders-design.md
deleted file mode 100644
index 31bf84434..000000000
--- a/docs/superpowers/specs/2026-08-22-channel-guarantee-orders-design.md
+++ /dev/null
@@ -1,39 +0,0 @@
-# 微信小店保障单接口设计
-
-## 目标
-
-实现 Issue #3987 所列的微信小店售后保障单六个 API,并提供与现有 `weixin-java-channel` 售后模块一致、可离线验证的 Java SDK 接口。
-
-## 范围
-
-- 获取保障单列表。
-- 获取保障单详情。
-- 同意、协商、举证及拒绝保障单申请。
-- 保障单请求与响应模型、URL 常量和离线单元测试。
-
-不包含 Issue #4003 中其他售后端点,也不改变既有售后 API。
-
-## API 设计
-
-`WxChannelAfterSaleService` 新增六个方法。列表和详情返回专用响应对象;四个会产生状态变更的接口返回 `WxChannelBaseResponse`,以便调用方检查微信错误码和错误信息。
-
-保障单号在公开 API 中使用 `String`,保持与现有售后单接口的用法一致,即使微信示例中它以 JSON number 表示。每个请求模型通过 `@JsonProperty` 显式映射到官方字段名。
-
-列表参数覆盖官方的保障单号、订单号、申请时间、状态、偏移量与限制条数。详情和列表共用完整的保障单信息模型,包含基础字段、商品信息、支付信息、送礼信息以及两类保障申请的专用信息。模型对官方返回的未知字段保持前向兼容。
-
-协商请求按官方字段发送 `bad_level` 和 `merchant_remark`;举证请求发送 `content` 与 `pic_list`;拒绝请求发送 `reason` 与必填的 `pic_list`。这修正旧 PR 中不符合文档的 `amount`、`desc` 和缺失图片凭证的问题。
-
-## 实现结构
-
-- `WxChannelApiUrlConstants.AfterSale`:六个官方路径常量。
-- `WxChannelAfterSaleService`:六个带 Javadoc 文档链接的公开方法。
-- `WxChannelAfterSaleServiceImpl`:每个方法调用对应路径,并用 `ResponseUtils.decode` 解码所有微信响应。
-- `bean.after`:请求、响应和保障单嵌套信息模型;仅承担 JSON 映射,不含业务逻辑。
-
-## 测试策略
-
-测试不调用真实微信接口或依赖店铺凭据。使用 Mockito mock `BaseWxChannelServiceImpl`:验证每个方法使用正确 URL 和请求对象,并由固定 JSON 验证列表/详情响应的 Jackson 映射以及操作接口的基础响应解码。每个新增行为先以失败测试建立,再写最小实现使其通过。
-
-## 质量与交付
-
-构建至少执行 `mvn -pl weixin-java-channel -am test`,并执行目标模块的新增测试。提交信息使用中文。新 PR 目标分支为 `develop`,描述中包含 `Closes #3987`。新 PR 创建并验证后,关闭 #4035 并留下指向替代 PR 的说明。
From 34e7ea9eda233f4168d3cc5a6ad9a7bb802f93e7 Mon Sep 17 00:00:00 2001
From: Binary Wang
Date: Sat, 22 Aug 2026 12:34:31 +0800
Subject: [PATCH 3/6] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=A7=86=E9=A2=91?=
=?UTF-8?q?=E5=8F=B7=E4=BF=9D=E9=9A=9C=E5=8D=95=E4=BC=A0=E8=BE=93=E6=A8=A1?=
=?UTF-8?q?=E5=9E=8B?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../bean/after/GuaranteeModifyRequest.java | 34 ++++++++
.../bean/after/GuaranteeOrderIdParam.java | 25 ++++++
.../bean/after/GuaranteeOrderInfo.java | 81 +++++++++++++++++++
.../after/GuaranteeOrderInfoResponse.java | 22 +++++
.../bean/after/GuaranteeOrderListParam.java | 47 +++++++++++
.../after/GuaranteeOrderListResponse.java | 27 +++++++
.../bean/after/GuaranteeProofRequest.java | 35 ++++++++
.../bean/after/GuaranteeRefuseRequest.java | 35 ++++++++
.../constant/WxChannelApiUrlConstants.java | 12 +++
...nnelAfterSaleServiceImplGuaranteeTest.java | 65 +++++++++++++++
10 files changed, 383 insertions(+)
create mode 100644 weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/after/GuaranteeModifyRequest.java
create mode 100644 weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/after/GuaranteeOrderIdParam.java
create mode 100644 weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/after/GuaranteeOrderInfo.java
create mode 100644 weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/after/GuaranteeOrderInfoResponse.java
create mode 100644 weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/after/GuaranteeOrderListParam.java
create mode 100644 weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/after/GuaranteeOrderListResponse.java
create mode 100644 weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/after/GuaranteeProofRequest.java
create mode 100644 weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/after/GuaranteeRefuseRequest.java
create mode 100644 weixin-java-channel/src/test/java/me/chanjar/weixin/channel/api/impl/WxChannelAfterSaleServiceImplGuaranteeTest.java
diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/after/GuaranteeModifyRequest.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/after/GuaranteeModifyRequest.java
new file mode 100644
index 000000000..0141ac05d
--- /dev/null
+++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/after/GuaranteeModifyRequest.java
@@ -0,0 +1,34 @@
+package me.chanjar.weixin.channel.bean.after;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
+
+/**
+ * 商家协商保障单请求参数。
+ */
+@Data
+@NoArgsConstructor
+@EqualsAndHashCode(callSuper = true)
+@JsonInclude(Include.NON_NULL)
+public class GuaranteeModifyRequest extends GuaranteeOrderIdParam {
+
+ private static final long serialVersionUID = 4268864541609439068L;
+
+ /** 商品破损程度。 */
+ @JsonProperty("bad_level")
+ private Integer badLevel;
+
+ /** 商家协商备注。 */
+ @JsonProperty("merchant_remark")
+ private String merchantRemark;
+
+ public GuaranteeModifyRequest(String guaranteeOrderId, Integer badLevel, String merchantRemark) {
+ super(guaranteeOrderId);
+ this.badLevel = badLevel;
+ this.merchantRemark = merchantRemark;
+ }
+}
diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/after/GuaranteeOrderIdParam.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/after/GuaranteeOrderIdParam.java
new file mode 100644
index 000000000..930e82422
--- /dev/null
+++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/after/GuaranteeOrderIdParam.java
@@ -0,0 +1,25 @@
+package me.chanjar.weixin.channel.bean.after;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import java.io.Serializable;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+/**
+ * 保障单号参数。
+ */
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+@JsonInclude(Include.NON_NULL)
+public class GuaranteeOrderIdParam implements Serializable {
+
+ private static final long serialVersionUID = -6638498743123537413L;
+
+ /** 保障单号。 */
+ @JsonProperty("guarantee_order_id")
+ private String guaranteeOrderId;
+}
diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/after/GuaranteeOrderInfo.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/after/GuaranteeOrderInfo.java
new file mode 100644
index 000000000..a04f33a7c
--- /dev/null
+++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/after/GuaranteeOrderInfo.java
@@ -0,0 +1,81 @@
+package me.chanjar.weixin.channel.bean.after;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import java.io.Serializable;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+/**
+ * 保障单信息。
+ */
+@Data
+@NoArgsConstructor
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class GuaranteeOrderInfo implements Serializable {
+
+ private static final long serialVersionUID = -7360231942642541702L;
+
+ /** 保障单号。 */
+ @JsonProperty("guarantee_order_id")
+ private String guaranteeOrderId;
+
+ /** 订单号。 */
+ @JsonProperty("order_id")
+ private String orderId;
+
+ /** 保障单状态。 */
+ @JsonProperty("status")
+ private Integer status;
+
+ /** 申请原因。 */
+ @JsonProperty("apply_reason")
+ private String applyReason;
+
+ /** 申请时间,Unix 时间戳(秒)。 */
+ @JsonProperty("apply_time")
+ private Long applyTime;
+
+ /** 更新时间,Unix 时间戳(秒)。 */
+ @JsonProperty("update_time")
+ private Long updateTime;
+
+ /** 实付金额,单位:分。 */
+ @JsonProperty("pay_amount")
+ private Integer payAmount;
+
+ /** 商品信息。 */
+ @JsonProperty("product_info")
+ private ProductInfo productInfo;
+
+ /**
+ * 保障单商品信息。
+ */
+ @Data
+ @NoArgsConstructor
+ @JsonIgnoreProperties(ignoreUnknown = true)
+ public static class ProductInfo implements Serializable {
+
+ private static final long serialVersionUID = -4469201668900292237L;
+
+ /** 商品 SPU ID。 */
+ @JsonProperty("product_id")
+ private String productId;
+
+ /** 商品 SKU ID。 */
+ @JsonProperty("sku_id")
+ private String skuId;
+
+ /** SKU 名称。 */
+ @JsonProperty("sku_name")
+ private String skuName;
+
+ /** 商品标题。 */
+ @JsonProperty("product_title")
+ private String productTitle;
+
+ /** 商品数量。 */
+ @JsonProperty("count")
+ private Integer count;
+ }
+}
diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/after/GuaranteeOrderInfoResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/after/GuaranteeOrderInfoResponse.java
new file mode 100644
index 000000000..e5800bf19
--- /dev/null
+++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/after/GuaranteeOrderInfoResponse.java
@@ -0,0 +1,22 @@
+package me.chanjar.weixin.channel.bean.after;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
+import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse;
+
+/**
+ * 保障单详情响应。
+ */
+@Data
+@NoArgsConstructor
+@EqualsAndHashCode(callSuper = true)
+public class GuaranteeOrderInfoResponse extends WxChannelBaseResponse {
+
+ private static final long serialVersionUID = 7354122991247317485L;
+
+ /** 保障单详情。 */
+ @JsonProperty("guarantee_order")
+ private GuaranteeOrderInfo guaranteeOrder;
+}
diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/after/GuaranteeOrderListParam.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/after/GuaranteeOrderListParam.java
new file mode 100644
index 000000000..6ece369b1
--- /dev/null
+++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/after/GuaranteeOrderListParam.java
@@ -0,0 +1,47 @@
+package me.chanjar.weixin.channel.bean.after;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import java.io.Serializable;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+/**
+ * 保障单列表请求参数。
+ */
+@Data
+@NoArgsConstructor
+@JsonInclude(Include.NON_NULL)
+public class GuaranteeOrderListParam implements Serializable {
+
+ private static final long serialVersionUID = 1622570776364341988L;
+
+ /** 保障单号。 */
+ @JsonProperty("guarantee_order_id")
+ private String guaranteeOrderId;
+
+ /** 订单号。 */
+ @JsonProperty("order_id")
+ private String orderId;
+
+ /** 申请开始时间,Unix 时间戳(秒)。 */
+ @JsonProperty("begin_apply_time")
+ private Long beginApplyTime;
+
+ /** 申请结束时间,Unix 时间戳(秒)。 */
+ @JsonProperty("end_apply_time")
+ private Long endApplyTime;
+
+ /** 保障单状态。 */
+ @JsonProperty("status")
+ private Integer status;
+
+ /** 分页偏移量。 */
+ @JsonProperty("offset")
+ private Integer offset;
+
+ /** 返回条数。 */
+ @JsonProperty("limit")
+ private Integer limit;
+}
diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/after/GuaranteeOrderListResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/after/GuaranteeOrderListResponse.java
new file mode 100644
index 000000000..08588bdef
--- /dev/null
+++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/after/GuaranteeOrderListResponse.java
@@ -0,0 +1,27 @@
+package me.chanjar.weixin.channel.bean.after;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import java.util.List;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
+import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse;
+
+/**
+ * 保障单列表响应。
+ */
+@Data
+@NoArgsConstructor
+@EqualsAndHashCode(callSuper = true)
+public class GuaranteeOrderListResponse extends WxChannelBaseResponse {
+
+ private static final long serialVersionUID = 9105476087203713187L;
+
+ /** 保障单总数。 */
+ @JsonProperty("total_num")
+ private Integer totalNum;
+
+ /** 保障单列表。 */
+ @JsonProperty("guarantee_order_list")
+ private List guaranteeOrderList;
+}
diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/after/GuaranteeProofRequest.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/after/GuaranteeProofRequest.java
new file mode 100644
index 000000000..7bd1a95f3
--- /dev/null
+++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/after/GuaranteeProofRequest.java
@@ -0,0 +1,35 @@
+package me.chanjar.weixin.channel.bean.after;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import java.util.List;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
+
+/**
+ * 商家举证保障单请求参数。
+ */
+@Data
+@NoArgsConstructor
+@EqualsAndHashCode(callSuper = true)
+@JsonInclude(Include.NON_NULL)
+public class GuaranteeProofRequest extends GuaranteeOrderIdParam {
+
+ private static final long serialVersionUID = 6599721896742974275L;
+
+ /** 举证内容。 */
+ @JsonProperty("content")
+ private String content;
+
+ /** 举证图片 media_id 列表。 */
+ @JsonProperty("pic_list")
+ private List picList;
+
+ public GuaranteeProofRequest(String guaranteeOrderId, String content, List picList) {
+ super(guaranteeOrderId);
+ this.content = content;
+ this.picList = picList;
+ }
+}
diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/after/GuaranteeRefuseRequest.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/after/GuaranteeRefuseRequest.java
new file mode 100644
index 000000000..be967ebff
--- /dev/null
+++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/after/GuaranteeRefuseRequest.java
@@ -0,0 +1,35 @@
+package me.chanjar.weixin.channel.bean.after;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import java.util.List;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
+
+/**
+ * 商家拒绝保障单请求参数。
+ */
+@Data
+@NoArgsConstructor
+@EqualsAndHashCode(callSuper = true)
+@JsonInclude(Include.NON_NULL)
+public class GuaranteeRefuseRequest extends GuaranteeOrderIdParam {
+
+ private static final long serialVersionUID = -6905594717805091393L;
+
+ /** 拒绝原因。 */
+ @JsonProperty("reason")
+ private String reason;
+
+ /** 拒绝凭证图片 media_id 列表。 */
+ @JsonProperty("pic_list")
+ private List picList;
+
+ public GuaranteeRefuseRequest(String guaranteeOrderId, String reason, List picList) {
+ super(guaranteeOrderId);
+ this.reason = reason;
+ this.picList = picList;
+ }
+}
diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/constant/WxChannelApiUrlConstants.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/constant/WxChannelApiUrlConstants.java
index 0b62bf59d..8aa4fec11 100644
--- a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/constant/WxChannelApiUrlConstants.java
+++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/constant/WxChannelApiUrlConstants.java
@@ -302,6 +302,18 @@ public interface AfterSale {
String AFTER_SALE_REJECT_EXCHANGE_RESHIP_URL = "https://api.weixin.qq.com/channels/ec/aftersale/rejectexchangereship";
/** 商家协商*/
String AFTER_SALE_MERCHANT_UPDATE_URL = "https://api.weixin.qq.com/channels/ec/aftersale/merchantupdateaftersale";
+ /** 获取保障单列表 */
+ String GUARANTEE_ORDER_LIST_URL = "https://api.weixin.qq.com/channels/ec/aftersale/searchguaranteeorder";
+ /** 获取保障单详情 */
+ String GUARANTEE_ORDER_GET_URL = "https://api.weixin.qq.com/channels/ec/aftersale/getguaranteeorder";
+ /** 同意保障单申请 */
+ String GUARANTEE_ORDER_ACCEPT_URL = "https://api.weixin.qq.com/channels/ec/aftersale/merchantacceptguarantee";
+ /** 商家协商保障单 */
+ String GUARANTEE_ORDER_MODIFY_URL = "https://api.weixin.qq.com/channels/ec/aftersale/merchantmodifyguarantee";
+ /** 商家举证保障单 */
+ String GUARANTEE_ORDER_PROOF_URL = "https://api.weixin.qq.com/channels/ec/aftersale/merchantproofguarantee";
+ /** 拒绝保障单申请 */
+ String GUARANTEE_ORDER_REFUSE_URL = "https://api.weixin.qq.com/channels/ec/aftersale/merchantrefuseguarantee";
}
/** 纠纷相关接口 */
diff --git a/weixin-java-channel/src/test/java/me/chanjar/weixin/channel/api/impl/WxChannelAfterSaleServiceImplGuaranteeTest.java b/weixin-java-channel/src/test/java/me/chanjar/weixin/channel/api/impl/WxChannelAfterSaleServiceImplGuaranteeTest.java
new file mode 100644
index 000000000..69f5b8dfe
--- /dev/null
+++ b/weixin-java-channel/src/test/java/me/chanjar/weixin/channel/api/impl/WxChannelAfterSaleServiceImplGuaranteeTest.java
@@ -0,0 +1,65 @@
+package me.chanjar.weixin.channel.api.impl;
+
+import static org.testng.Assert.assertEquals;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import java.util.Arrays;
+import me.chanjar.weixin.channel.bean.after.GuaranteeModifyRequest;
+import me.chanjar.weixin.channel.bean.after.GuaranteeOrderInfoResponse;
+import me.chanjar.weixin.channel.bean.after.GuaranteeOrderListResponse;
+import me.chanjar.weixin.channel.bean.after.GuaranteeProofRequest;
+import me.chanjar.weixin.channel.bean.after.GuaranteeRefuseRequest;
+import org.testng.annotations.Test;
+
+/**
+ * 保障单模型 JSON 映射测试。
+ */
+public class WxChannelAfterSaleServiceImplGuaranteeTest {
+
+ private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
+
+ @Test
+ public void shouldSerializeGuaranteeOperationRequestsWithOfficialFieldNames() throws Exception {
+ JsonNode modify = OBJECT_MAPPER.readTree(OBJECT_MAPPER.writeValueAsString(
+ new GuaranteeModifyRequest("2000001077270153", 50, "协商说明")));
+ assertEquals(modify.get("guarantee_order_id").asText(), "2000001077270153");
+ assertEquals(modify.get("bad_level").asInt(), 50);
+ assertEquals(modify.get("merchant_remark").asText(), "协商说明");
+
+ JsonNode proof = OBJECT_MAPPER.readTree(OBJECT_MAPPER.writeValueAsString(
+ new GuaranteeProofRequest("2000001077270153", "举证说明", Arrays.asList("media-1"))));
+ assertEquals(proof.get("content").asText(), "举证说明");
+ assertEquals(proof.get("pic_list").get(0).asText(), "media-1");
+
+ JsonNode refuse = OBJECT_MAPPER.readTree(OBJECT_MAPPER.writeValueAsString(
+ new GuaranteeRefuseRequest("2000001077270153", "拒绝原因", Arrays.asList("media-2"))));
+ assertEquals(refuse.get("reason").asText(), "拒绝原因");
+ assertEquals(refuse.get("pic_list").get(0).asText(), "media-2");
+ }
+
+ @Test
+ public void shouldDeserializeGuaranteeOrderListAndDetail() throws Exception {
+ String listJson = "{\"errcode\":0,\"total_num\":1,\"guarantee_order_list\":[{"
+ + "\"guarantee_order_id\":\"2000001077270153\",\"apply_reason\":\"质量问题\","
+ + "\"pay_amount\":100,\"product_info\":{\"product_id\":\"123\","
+ + "\"sku_id\":\"456\",\"sku_name\":\"红色\"}}]}";
+ GuaranteeOrderListResponse listResponse = OBJECT_MAPPER.readValue(
+ listJson, GuaranteeOrderListResponse.class);
+ assertEquals(listResponse.getTotalNum(), Integer.valueOf(1));
+ assertEquals(listResponse.getGuaranteeOrderList().get(0).getGuaranteeOrderId(), "2000001077270153");
+ assertEquals(listResponse.getGuaranteeOrderList().get(0).getApplyReason(), "质量问题");
+ assertEquals(listResponse.getGuaranteeOrderList().get(0).getPayAmount(), Integer.valueOf(100));
+ assertEquals(listResponse.getGuaranteeOrderList().get(0).getProductInfo().getProductId(), "123");
+ assertEquals(listResponse.getGuaranteeOrderList().get(0).getProductInfo().getSkuName(), "红色");
+
+ String detailJson = "{\"errcode\":0,\"guarantee_order\":{"
+ + "\"guarantee_order_id\":\"2000001077270153\",\"apply_reason\":\"质量问题\","
+ + "\"pay_amount\":100,\"product_info\":{\"product_id\":\"123\","
+ + "\"sku_id\":\"456\",\"sku_name\":\"红色\"}}}";
+ GuaranteeOrderInfoResponse detailResponse = OBJECT_MAPPER.readValue(
+ detailJson, GuaranteeOrderInfoResponse.class);
+ assertEquals(detailResponse.getGuaranteeOrder().getGuaranteeOrderId(), "2000001077270153");
+ assertEquals(detailResponse.getGuaranteeOrder().getProductInfo().getSkuId(), "456");
+ }
+}
From 04e3104f119cdc44a149110f7de3c0360d367218 Mon Sep 17 00:00:00 2001
From: Binary Wang
Date: Sat, 22 Aug 2026 12:41:26 +0800
Subject: [PATCH 4/6] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=A7=86=E9=A2=91?=
=?UTF-8?q?=E5=8F=B7=E4=BF=9D=E9=9A=9C=E5=8D=95=E6=9C=8D=E5=8A=A1=E6=8E=A5?=
=?UTF-8?q?=E5=8F=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
weixin-java-channel/pom.xml | 5 ++
.../api/WxChannelAfterSaleService.java | 60 ++++++++++++++++++
.../impl/WxChannelAfterSaleServiceImpl.java | 38 ++++++++++++
...nnelAfterSaleServiceImplGuaranteeTest.java | 61 +++++++++++++++++++
4 files changed, 164 insertions(+)
diff --git a/weixin-java-channel/pom.xml b/weixin-java-channel/pom.xml
index 86d398b17..10417674f 100644
--- a/weixin-java-channel/pom.xml
+++ b/weixin-java-channel/pom.xml
@@ -84,6 +84,11 @@
testng
test
+
+ org.mockito
+ mockito-core
+ test
+
ch.qos.logback
logback-classic
diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/WxChannelAfterSaleService.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/WxChannelAfterSaleService.java
index b8d1156b6..d20d8ed4f 100644
--- a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/WxChannelAfterSaleService.java
+++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/WxChannelAfterSaleService.java
@@ -199,4 +199,64 @@ WxChannelBaseResponse addComplaintEvidence(String complaintId, String content, L
* @throws WxErrorException 异常
*/
WxChannelBaseResponse merchantUpdateAfterSale(AfterSaleMerchantUpdateParam param) throws WxErrorException;
+
+ /**
+ * 获取保障单列表。
+ * 文档地址:https://developers.weixin.qq.com/doc/channels/API/aftersale/searchguaranteeorder.html
+ *
+ * @param param 查询参数
+ * @return 保障单列表
+ * @throws WxErrorException 异常
+ */
+ GuaranteeOrderListResponse listGuaranteeOrder(GuaranteeOrderListParam param) throws WxErrorException;
+
+ /**
+ * 获取保障单详情。
+ * 文档地址:https://developers.weixin.qq.com/doc/channels/API/aftersale/getguaranteeorder.html
+ *
+ * @param guaranteeOrderId 保障单号
+ * @return 保障单详情
+ * @throws WxErrorException 异常
+ */
+ GuaranteeOrderInfoResponse getGuaranteeOrder(String guaranteeOrderId) throws WxErrorException;
+
+ /**
+ * 同意保障单申请。
+ * 文档地址:https://developers.weixin.qq.com/doc/channels/API/aftersale/merchantacceptguarantee.html
+ *
+ * @param guaranteeOrderId 保障单号
+ * @return 响应结果
+ * @throws WxErrorException 异常
+ */
+ WxChannelBaseResponse acceptGuarantee(String guaranteeOrderId) throws WxErrorException;
+
+ /**
+ * 商家协商保障单。
+ * 文档地址:https://developers.weixin.qq.com/doc/channels/API/aftersale/merchantmodifyguarantee.html
+ *
+ * @param request 协商参数
+ * @return 响应结果
+ * @throws WxErrorException 异常
+ */
+ WxChannelBaseResponse modifyGuarantee(GuaranteeModifyRequest request) throws WxErrorException;
+
+ /**
+ * 商家举证保障单。
+ * 文档地址:https://developers.weixin.qq.com/doc/channels/API/aftersale/merchantproofguarantee.html
+ *
+ * @param request 举证参数
+ * @return 响应结果
+ * @throws WxErrorException 异常
+ */
+ WxChannelBaseResponse proofGuarantee(GuaranteeProofRequest request) throws WxErrorException;
+
+ /**
+ * 拒绝保障单申请。
+ * 文档地址:https://developers.weixin.qq.com/doc/channels/API/aftersale/merchantrefuseguarantee.html
+ *
+ * @param request 拒绝参数
+ * @return 响应结果
+ * @throws WxErrorException 异常
+ */
+ WxChannelBaseResponse refuseGuarantee(GuaranteeRefuseRequest request) throws WxErrorException;
}
diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/WxChannelAfterSaleServiceImpl.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/WxChannelAfterSaleServiceImpl.java
index c7cdf9167..5f8c73874 100644
--- a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/WxChannelAfterSaleServiceImpl.java
+++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/WxChannelAfterSaleServiceImpl.java
@@ -136,4 +136,42 @@ public WxChannelBaseResponse merchantUpdateAfterSale(AfterSaleMerchantUpdatePara
return ResponseUtils.decode(resJson, WxChannelBaseResponse.class);
}
+ @Override
+ public GuaranteeOrderListResponse listGuaranteeOrder(GuaranteeOrderListParam param) throws WxErrorException {
+ String resJson = shopService.post(GUARANTEE_ORDER_LIST_URL, param);
+ return ResponseUtils.decode(resJson, GuaranteeOrderListResponse.class);
+ }
+
+ @Override
+ public GuaranteeOrderInfoResponse getGuaranteeOrder(String guaranteeOrderId) throws WxErrorException {
+ GuaranteeOrderIdParam param = new GuaranteeOrderIdParam(guaranteeOrderId);
+ String resJson = shopService.post(GUARANTEE_ORDER_GET_URL, param);
+ return ResponseUtils.decode(resJson, GuaranteeOrderInfoResponse.class);
+ }
+
+ @Override
+ public WxChannelBaseResponse acceptGuarantee(String guaranteeOrderId) throws WxErrorException {
+ GuaranteeOrderIdParam param = new GuaranteeOrderIdParam(guaranteeOrderId);
+ String resJson = shopService.post(GUARANTEE_ORDER_ACCEPT_URL, param);
+ return ResponseUtils.decode(resJson, WxChannelBaseResponse.class);
+ }
+
+ @Override
+ public WxChannelBaseResponse modifyGuarantee(GuaranteeModifyRequest request) throws WxErrorException {
+ String resJson = shopService.post(GUARANTEE_ORDER_MODIFY_URL, request);
+ return ResponseUtils.decode(resJson, WxChannelBaseResponse.class);
+ }
+
+ @Override
+ public WxChannelBaseResponse proofGuarantee(GuaranteeProofRequest request) throws WxErrorException {
+ String resJson = shopService.post(GUARANTEE_ORDER_PROOF_URL, request);
+ return ResponseUtils.decode(resJson, WxChannelBaseResponse.class);
+ }
+
+ @Override
+ public WxChannelBaseResponse refuseGuarantee(GuaranteeRefuseRequest request) throws WxErrorException {
+ String resJson = shopService.post(GUARANTEE_ORDER_REFUSE_URL, request);
+ return ResponseUtils.decode(resJson, WxChannelBaseResponse.class);
+ }
+
}
diff --git a/weixin-java-channel/src/test/java/me/chanjar/weixin/channel/api/impl/WxChannelAfterSaleServiceImplGuaranteeTest.java b/weixin-java-channel/src/test/java/me/chanjar/weixin/channel/api/impl/WxChannelAfterSaleServiceImplGuaranteeTest.java
index 69f5b8dfe..70e870fee 100644
--- a/weixin-java-channel/src/test/java/me/chanjar/weixin/channel/api/impl/WxChannelAfterSaleServiceImplGuaranteeTest.java
+++ b/weixin-java-channel/src/test/java/me/chanjar/weixin/channel/api/impl/WxChannelAfterSaleServiceImplGuaranteeTest.java
@@ -1,17 +1,32 @@
package me.chanjar.weixin.channel.api.impl;
import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.util.Arrays;
import me.chanjar.weixin.channel.bean.after.GuaranteeModifyRequest;
+import me.chanjar.weixin.channel.bean.after.GuaranteeOrderIdParam;
import me.chanjar.weixin.channel.bean.after.GuaranteeOrderInfoResponse;
+import me.chanjar.weixin.channel.bean.after.GuaranteeOrderListParam;
import me.chanjar.weixin.channel.bean.after.GuaranteeOrderListResponse;
import me.chanjar.weixin.channel.bean.after.GuaranteeProofRequest;
import me.chanjar.weixin.channel.bean.after.GuaranteeRefuseRequest;
+import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse;
import org.testng.annotations.Test;
+import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.AfterSale.GUARANTEE_ORDER_ACCEPT_URL;
+import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.AfterSale.GUARANTEE_ORDER_GET_URL;
+import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.AfterSale.GUARANTEE_ORDER_LIST_URL;
+import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.AfterSale.GUARANTEE_ORDER_MODIFY_URL;
+import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.AfterSale.GUARANTEE_ORDER_PROOF_URL;
+import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.AfterSale.GUARANTEE_ORDER_REFUSE_URL;
+
/**
* 保障单模型 JSON 映射测试。
*/
@@ -62,4 +77,50 @@ public void shouldDeserializeGuaranteeOrderListAndDetail() throws Exception {
assertEquals(detailResponse.getGuaranteeOrder().getGuaranteeOrderId(), "2000001077270153");
assertEquals(detailResponse.getGuaranteeOrder().getProductInfo().getSkuId(), "456");
}
+
+ @Test
+ public void shouldDelegateGuaranteeOrderEndpointsAndDecodeResponses() throws Exception {
+ BaseWxChannelServiceImpl shopService = mock(BaseWxChannelServiceImpl.class);
+ WxChannelAfterSaleServiceImpl service = new WxChannelAfterSaleServiceImpl(shopService);
+ GuaranteeOrderListParam listParam = new GuaranteeOrderListParam();
+ listParam.setOrderId("order-1");
+ GuaranteeModifyRequest modifyRequest = new GuaranteeModifyRequest("guarantee-1", 50, "协商说明");
+ GuaranteeProofRequest proofRequest = new GuaranteeProofRequest("guarantee-1", "举证说明",
+ Arrays.asList("media-1"));
+ GuaranteeRefuseRequest refuseRequest = new GuaranteeRefuseRequest("guarantee-1", "拒绝原因",
+ Arrays.asList("media-2"));
+
+ when(shopService.post(eq(GUARANTEE_ORDER_LIST_URL), eq(listParam))).thenReturn(
+ "{\"errcode\":0,\"total_num\":1,\"guarantee_order_list\":[{\"guarantee_order_id\":\"guarantee-1\"}]}" );
+ when(shopService.post(eq(GUARANTEE_ORDER_GET_URL), eq(new GuaranteeOrderIdParam("guarantee-1")))).thenReturn(
+ "{\"errcode\":0,\"guarantee_order\":{\"guarantee_order_id\":\"guarantee-1\"}}" );
+ when(shopService.post(eq(GUARANTEE_ORDER_ACCEPT_URL), eq(new GuaranteeOrderIdParam("guarantee-1"))))
+ .thenReturn("{\"errcode\":0,\"errmsg\":\"ok\"}");
+ when(shopService.post(eq(GUARANTEE_ORDER_MODIFY_URL), eq(modifyRequest)))
+ .thenReturn("{\"errcode\":0,\"errmsg\":\"ok\"}");
+ when(shopService.post(eq(GUARANTEE_ORDER_PROOF_URL), eq(proofRequest)))
+ .thenReturn("{\"errcode\":0,\"errmsg\":\"ok\"}");
+ when(shopService.post(eq(GUARANTEE_ORDER_REFUSE_URL), eq(refuseRequest)))
+ .thenReturn("{\"errcode\":0,\"errmsg\":\"ok\"}");
+
+ GuaranteeOrderListResponse listResponse = service.listGuaranteeOrder(listParam);
+ GuaranteeOrderInfoResponse detailResponse = service.getGuaranteeOrder("guarantee-1");
+ WxChannelBaseResponse acceptResponse = service.acceptGuarantee("guarantee-1");
+ WxChannelBaseResponse modifyResponse = service.modifyGuarantee(modifyRequest);
+ WxChannelBaseResponse proofResponse = service.proofGuarantee(proofRequest);
+ WxChannelBaseResponse refuseResponse = service.refuseGuarantee(refuseRequest);
+
+ assertEquals(listResponse.getGuaranteeOrderList().get(0).getGuaranteeOrderId(), "guarantee-1");
+ assertEquals(detailResponse.getGuaranteeOrder().getGuaranteeOrderId(), "guarantee-1");
+ assertTrue(acceptResponse.isSuccess());
+ assertTrue(modifyResponse.isSuccess());
+ assertTrue(proofResponse.isSuccess());
+ assertTrue(refuseResponse.isSuccess());
+ verify(shopService).post(GUARANTEE_ORDER_LIST_URL, listParam);
+ verify(shopService).post(GUARANTEE_ORDER_GET_URL, new GuaranteeOrderIdParam("guarantee-1"));
+ verify(shopService).post(GUARANTEE_ORDER_ACCEPT_URL, new GuaranteeOrderIdParam("guarantee-1"));
+ verify(shopService).post(GUARANTEE_ORDER_MODIFY_URL, modifyRequest);
+ verify(shopService).post(GUARANTEE_ORDER_PROOF_URL, proofRequest);
+ verify(shopService).post(GUARANTEE_ORDER_REFUSE_URL, refuseRequest);
+ }
}
From 327063990b70636caac1e257ac8480046d9d5b8f Mon Sep 17 00:00:00 2001
From: Binary Wang
Date: Sat, 22 Aug 2026 13:10:59 +0800
Subject: [PATCH 5/6] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E4=BF=9D=E9=9A=9C?=
=?UTF-8?q?=E5=8D=95=E6=8E=A5=E5=8F=A3=E5=A5=91=E7=BA=A6?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../api/WxChannelAfterSaleService.java | 36 ++++++---
.../bean/after/GuaranteeOrderInfo.java | 81 -------------------
.../after/GuaranteeOrderInfoResponse.java | 39 ++++++++-
.../bean/after/GuaranteeOrderListParam.java | 38 ++++-----
.../after/GuaranteeOrderListResponse.java | 39 ++++++++-
...nnelAfterSaleServiceImplGuaranteeTest.java | 62 ++++++++++----
6 files changed, 163 insertions(+), 132 deletions(-)
delete mode 100644 weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/after/GuaranteeOrderInfo.java
diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/WxChannelAfterSaleService.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/WxChannelAfterSaleService.java
index d20d8ed4f..89d3c169b 100644
--- a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/WxChannelAfterSaleService.java
+++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/WxChannelAfterSaleService.java
@@ -202,61 +202,73 @@ WxChannelBaseResponse addComplaintEvidence(String complaintId, String content, L
/**
* 获取保障单列表。
- * 文档地址:https://developers.weixin.qq.com/doc/channels/API/aftersale/searchguaranteeorder.html
+ * 文档地址:https://developers.weixin.qq.com/doc/channels/API/channels-shop-aftersale/guarantee/api_searchguaranteeorder
*
* @param param 查询参数
* @return 保障单列表
* @throws WxErrorException 异常
*/
- GuaranteeOrderListResponse listGuaranteeOrder(GuaranteeOrderListParam param) throws WxErrorException;
+ default GuaranteeOrderListResponse listGuaranteeOrder(GuaranteeOrderListParam param) throws WxErrorException {
+ throw new UnsupportedOperationException();
+ }
/**
* 获取保障单详情。
- * 文档地址:https://developers.weixin.qq.com/doc/channels/API/aftersale/getguaranteeorder.html
+ * 文档地址:https://developers.weixin.qq.com/doc/channels/API/channels-shop-aftersale/guarantee/api_getguaranteeorder
*
* @param guaranteeOrderId 保障单号
* @return 保障单详情
* @throws WxErrorException 异常
*/
- GuaranteeOrderInfoResponse getGuaranteeOrder(String guaranteeOrderId) throws WxErrorException;
+ default GuaranteeOrderInfoResponse getGuaranteeOrder(String guaranteeOrderId) throws WxErrorException {
+ throw new UnsupportedOperationException();
+ }
/**
* 同意保障单申请。
- * 文档地址:https://developers.weixin.qq.com/doc/channels/API/aftersale/merchantacceptguarantee.html
+ * 文档地址:https://developers.weixin.qq.com/doc/channels/API/channels-shop-aftersale/guarantee/api_merchantacceptguarantee
*
* @param guaranteeOrderId 保障单号
* @return 响应结果
* @throws WxErrorException 异常
*/
- WxChannelBaseResponse acceptGuarantee(String guaranteeOrderId) throws WxErrorException;
+ default WxChannelBaseResponse acceptGuarantee(String guaranteeOrderId) throws WxErrorException {
+ throw new UnsupportedOperationException();
+ }
/**
* 商家协商保障单。
- * 文档地址:https://developers.weixin.qq.com/doc/channels/API/aftersale/merchantmodifyguarantee.html
+ * 文档地址:https://developers.weixin.qq.com/doc/channels/API/channels-shop-aftersale/guarantee/api_merchantmodifyguarantee
*
* @param request 协商参数
* @return 响应结果
* @throws WxErrorException 异常
*/
- WxChannelBaseResponse modifyGuarantee(GuaranteeModifyRequest request) throws WxErrorException;
+ default WxChannelBaseResponse modifyGuarantee(GuaranteeModifyRequest request) throws WxErrorException {
+ throw new UnsupportedOperationException();
+ }
/**
* 商家举证保障单。
- * 文档地址:https://developers.weixin.qq.com/doc/channels/API/aftersale/merchantproofguarantee.html
+ * 文档地址:https://developers.weixin.qq.com/doc/channels/API/channels-shop-aftersale/guarantee/api_merchantproofguarantee
*
* @param request 举证参数
* @return 响应结果
* @throws WxErrorException 异常
*/
- WxChannelBaseResponse proofGuarantee(GuaranteeProofRequest request) throws WxErrorException;
+ default WxChannelBaseResponse proofGuarantee(GuaranteeProofRequest request) throws WxErrorException {
+ throw new UnsupportedOperationException();
+ }
/**
* 拒绝保障单申请。
- * 文档地址:https://developers.weixin.qq.com/doc/channels/API/aftersale/merchantrefuseguarantee.html
+ * 文档地址:https://developers.weixin.qq.com/doc/channels/API/channels-shop-aftersale/guarantee/api_merchantrefuseguarantee
*
* @param request 拒绝参数
* @return 响应结果
* @throws WxErrorException 异常
*/
- WxChannelBaseResponse refuseGuarantee(GuaranteeRefuseRequest request) throws WxErrorException;
+ default WxChannelBaseResponse refuseGuarantee(GuaranteeRefuseRequest request) throws WxErrorException {
+ throw new UnsupportedOperationException();
+ }
}
diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/after/GuaranteeOrderInfo.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/after/GuaranteeOrderInfo.java
deleted file mode 100644
index a04f33a7c..000000000
--- a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/after/GuaranteeOrderInfo.java
+++ /dev/null
@@ -1,81 +0,0 @@
-package me.chanjar.weixin.channel.bean.after;
-
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import java.io.Serializable;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-
-/**
- * 保障单信息。
- */
-@Data
-@NoArgsConstructor
-@JsonIgnoreProperties(ignoreUnknown = true)
-public class GuaranteeOrderInfo implements Serializable {
-
- private static final long serialVersionUID = -7360231942642541702L;
-
- /** 保障单号。 */
- @JsonProperty("guarantee_order_id")
- private String guaranteeOrderId;
-
- /** 订单号。 */
- @JsonProperty("order_id")
- private String orderId;
-
- /** 保障单状态。 */
- @JsonProperty("status")
- private Integer status;
-
- /** 申请原因。 */
- @JsonProperty("apply_reason")
- private String applyReason;
-
- /** 申请时间,Unix 时间戳(秒)。 */
- @JsonProperty("apply_time")
- private Long applyTime;
-
- /** 更新时间,Unix 时间戳(秒)。 */
- @JsonProperty("update_time")
- private Long updateTime;
-
- /** 实付金额,单位:分。 */
- @JsonProperty("pay_amount")
- private Integer payAmount;
-
- /** 商品信息。 */
- @JsonProperty("product_info")
- private ProductInfo productInfo;
-
- /**
- * 保障单商品信息。
- */
- @Data
- @NoArgsConstructor
- @JsonIgnoreProperties(ignoreUnknown = true)
- public static class ProductInfo implements Serializable {
-
- private static final long serialVersionUID = -4469201668900292237L;
-
- /** 商品 SPU ID。 */
- @JsonProperty("product_id")
- private String productId;
-
- /** 商品 SKU ID。 */
- @JsonProperty("sku_id")
- private String skuId;
-
- /** SKU 名称。 */
- @JsonProperty("sku_name")
- private String skuName;
-
- /** 商品标题。 */
- @JsonProperty("product_title")
- private String productTitle;
-
- /** 商品数量。 */
- @JsonProperty("count")
- private Integer count;
- }
-}
diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/after/GuaranteeOrderInfoResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/after/GuaranteeOrderInfoResponse.java
index e5800bf19..7b286807a 100644
--- a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/after/GuaranteeOrderInfoResponse.java
+++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/after/GuaranteeOrderInfoResponse.java
@@ -1,6 +1,7 @@
package me.chanjar.weixin.channel.bean.after;
import com.fasterxml.jackson.annotation.JsonProperty;
+import java.io.Serializable;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
@@ -18,5 +19,41 @@ public class GuaranteeOrderInfoResponse extends WxChannelBaseResponse {
/** 保障单详情。 */
@JsonProperty("guarantee_order")
- private GuaranteeOrderInfo guaranteeOrder;
+ private GuaranteeOrder guaranteeOrder;
+
+ /**
+ * 保障单详情。
+ */
+ @Data
+ @NoArgsConstructor
+ public static class GuaranteeOrder implements Serializable {
+
+ private static final long serialVersionUID = -2398976447575813507L;
+
+ /** 保障单号。 */
+ @JsonProperty("guarantee_order_id")
+ private String guaranteeOrderId;
+
+ /** 保障单状态。 */
+ @JsonProperty("status")
+ private String status;
+
+ /** 商品信息。 */
+ @JsonProperty("product_info")
+ private ProductInfo productInfo;
+ }
+
+ /**
+ * 详情商品信息。
+ */
+ @Data
+ @NoArgsConstructor
+ public static class ProductInfo implements Serializable {
+
+ private static final long serialVersionUID = -2455740986246085934L;
+
+ /** 商品 SPU ID。 */
+ @JsonProperty("product_id")
+ private String productId;
+ }
}
diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/after/GuaranteeOrderListParam.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/after/GuaranteeOrderListParam.java
index 6ece369b1..f95ccc091 100644
--- a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/after/GuaranteeOrderListParam.java
+++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/after/GuaranteeOrderListParam.java
@@ -17,31 +17,23 @@ public class GuaranteeOrderListParam implements Serializable {
private static final long serialVersionUID = 1622570776364341988L;
- /** 保障单号。 */
- @JsonProperty("guarantee_order_id")
- private String guaranteeOrderId;
+ /** 订单创建启始时间,Unix 时间戳(秒)。 */
+ @JsonProperty("begin_create_time")
+ private Long beginCreateTime;
- /** 订单号。 */
- @JsonProperty("order_id")
- private String orderId;
+ /** 订单创建结束时间,Unix 时间戳(秒)。 */
+ @JsonProperty("end_create_time")
+ private Long endCreateTime;
- /** 申请开始时间,Unix 时间戳(秒)。 */
- @JsonProperty("begin_apply_time")
- private Long beginApplyTime;
+ /** 保障单更新启始时间,Unix 时间戳(秒)。 */
+ @JsonProperty("begin_update_time")
+ private Long beginUpdateTime;
- /** 申请结束时间,Unix 时间戳(秒)。 */
- @JsonProperty("end_apply_time")
- private Long endApplyTime;
+ /** 保障单更新结束时间,Unix 时间戳(秒)。 */
+ @JsonProperty("end_update_time")
+ private Long endUpdateTime;
- /** 保障单状态。 */
- @JsonProperty("status")
- private Integer status;
-
- /** 分页偏移量。 */
- @JsonProperty("offset")
- private Integer offset;
-
- /** 返回条数。 */
- @JsonProperty("limit")
- private Integer limit;
+ /** 翻页参数。 */
+ @JsonProperty("next_key")
+ private String nextKey;
}
diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/after/GuaranteeOrderListResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/after/GuaranteeOrderListResponse.java
index 08588bdef..90daa0cc1 100644
--- a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/after/GuaranteeOrderListResponse.java
+++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/after/GuaranteeOrderListResponse.java
@@ -1,6 +1,7 @@
package me.chanjar.weixin.channel.bean.after;
import com.fasterxml.jackson.annotation.JsonProperty;
+import java.io.Serializable;
import java.util.List;
import lombok.Data;
import lombok.EqualsAndHashCode;
@@ -23,5 +24,41 @@ public class GuaranteeOrderListResponse extends WxChannelBaseResponse {
/** 保障单列表。 */
@JsonProperty("guarantee_order_list")
- private List guaranteeOrderList;
+ private List guaranteeOrderList;
+
+ /**
+ * 保障单列表项。
+ */
+ @Data
+ @NoArgsConstructor
+ public static class GuaranteeOrder implements Serializable {
+
+ private static final long serialVersionUID = 7151952524213202281L;
+
+ /** 保障单号。 */
+ @JsonProperty("guarantee_order_id")
+ private String guaranteeOrderId;
+
+ /** 保障单状态。 */
+ @JsonProperty("status")
+ private String status;
+
+ /** 商品信息列表。 */
+ @JsonProperty("product_info")
+ private List productInfo;
+ }
+
+ /**
+ * 列表商品信息。
+ */
+ @Data
+ @NoArgsConstructor
+ public static class ProductInfo implements Serializable {
+
+ private static final long serialVersionUID = -2565763879505631638L;
+
+ /** 商品 SPU ID。 */
+ @JsonProperty("product_id")
+ private String productId;
+ }
}
diff --git a/weixin-java-channel/src/test/java/me/chanjar/weixin/channel/api/impl/WxChannelAfterSaleServiceImplGuaranteeTest.java b/weixin-java-channel/src/test/java/me/chanjar/weixin/channel/api/impl/WxChannelAfterSaleServiceImplGuaranteeTest.java
index 70e870fee..1692c883f 100644
--- a/weixin-java-channel/src/test/java/me/chanjar/weixin/channel/api/impl/WxChannelAfterSaleServiceImplGuaranteeTest.java
+++ b/weixin-java-channel/src/test/java/me/chanjar/weixin/channel/api/impl/WxChannelAfterSaleServiceImplGuaranteeTest.java
@@ -1,15 +1,19 @@
package me.chanjar.weixin.channel.api.impl;
import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.fail;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+import static org.mockito.Answers.CALLS_REAL_METHODS;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.util.Arrays;
+import me.chanjar.weixin.channel.api.WxChannelAfterSaleService;
import me.chanjar.weixin.channel.bean.after.GuaranteeModifyRequest;
import me.chanjar.weixin.channel.bean.after.GuaranteeOrderIdParam;
import me.chanjar.weixin.channel.bean.after.GuaranteeOrderInfoResponse;
@@ -56,26 +60,56 @@ public void shouldSerializeGuaranteeOperationRequestsWithOfficialFieldNames() th
@Test
public void shouldDeserializeGuaranteeOrderListAndDetail() throws Exception {
String listJson = "{\"errcode\":0,\"total_num\":1,\"guarantee_order_list\":[{"
- + "\"guarantee_order_id\":\"2000001077270153\",\"apply_reason\":\"质量问题\","
- + "\"pay_amount\":100,\"product_info\":{\"product_id\":\"123\","
- + "\"sku_id\":\"456\",\"sku_name\":\"红色\"}}]}";
+ + "\"guarantee_order_id\":\"2000001077270153\",\"status\":\"PENDING\","
+ + "\"product_info\":[{\"product_id\":\"123\"}]}]}";
GuaranteeOrderListResponse listResponse = OBJECT_MAPPER.readValue(
listJson, GuaranteeOrderListResponse.class);
assertEquals(listResponse.getTotalNum(), Integer.valueOf(1));
assertEquals(listResponse.getGuaranteeOrderList().get(0).getGuaranteeOrderId(), "2000001077270153");
- assertEquals(listResponse.getGuaranteeOrderList().get(0).getApplyReason(), "质量问题");
- assertEquals(listResponse.getGuaranteeOrderList().get(0).getPayAmount(), Integer.valueOf(100));
- assertEquals(listResponse.getGuaranteeOrderList().get(0).getProductInfo().getProductId(), "123");
- assertEquals(listResponse.getGuaranteeOrderList().get(0).getProductInfo().getSkuName(), "红色");
+ assertEquals(listResponse.getGuaranteeOrderList().get(0).getStatus(), "PENDING");
+ assertEquals(listResponse.getGuaranteeOrderList().get(0).getProductInfo().get(0).getProductId(), "123");
String detailJson = "{\"errcode\":0,\"guarantee_order\":{"
- + "\"guarantee_order_id\":\"2000001077270153\",\"apply_reason\":\"质量问题\","
- + "\"pay_amount\":100,\"product_info\":{\"product_id\":\"123\","
- + "\"sku_id\":\"456\",\"sku_name\":\"红色\"}}}";
+ + "\"guarantee_order_id\":\"2000001077270153\",\"status\":\"PENDING\","
+ + "\"product_info\":{\"product_id\":\"123\"}}}";
GuaranteeOrderInfoResponse detailResponse = OBJECT_MAPPER.readValue(
detailJson, GuaranteeOrderInfoResponse.class);
assertEquals(detailResponse.getGuaranteeOrder().getGuaranteeOrderId(), "2000001077270153");
- assertEquals(detailResponse.getGuaranteeOrder().getProductInfo().getSkuId(), "456");
+ assertEquals(detailResponse.getGuaranteeOrder().getStatus(), "PENDING");
+ assertEquals(detailResponse.getGuaranteeOrder().getProductInfo().getProductId(), "123");
+ }
+
+ @Test
+ public void shouldSerializeGuaranteeOrderListParamWithOfficialFieldNames() throws Exception {
+ GuaranteeOrderListParam param = OBJECT_MAPPER.readValue(
+ "{\"begin_create_time\":1,\"end_create_time\":2,\"begin_update_time\":3,"
+ + "\"end_update_time\":4,\"next_key\":\"next\"}", GuaranteeOrderListParam.class);
+
+ JsonNode json = OBJECT_MAPPER.readTree(OBJECT_MAPPER.writeValueAsString(param));
+ assertEquals(json.get("begin_create_time").asLong(), 1L);
+ assertEquals(json.get("end_create_time").asLong(), 2L);
+ assertEquals(json.get("begin_update_time").asLong(), 3L);
+ assertEquals(json.get("end_update_time").asLong(), 4L);
+ assertEquals(json.get("next_key").asText(), "next");
+ }
+
+ @Test
+ public void shouldExposeGuaranteeMethodsAsDefaultMethods() throws Exception {
+ assertTrue(WxChannelAfterSaleService.class.getMethod("listGuaranteeOrder", GuaranteeOrderListParam.class)
+ .isDefault());
+ assertTrue(WxChannelAfterSaleService.class.getMethod("getGuaranteeOrder", String.class).isDefault());
+ assertTrue(WxChannelAfterSaleService.class.getMethod("acceptGuarantee", String.class).isDefault());
+ assertTrue(WxChannelAfterSaleService.class.getMethod("modifyGuarantee", GuaranteeModifyRequest.class).isDefault());
+ assertTrue(WxChannelAfterSaleService.class.getMethod("proofGuarantee", GuaranteeProofRequest.class).isDefault());
+ assertTrue(WxChannelAfterSaleService.class.getMethod("refuseGuarantee", GuaranteeRefuseRequest.class).isDefault());
+
+ WxChannelAfterSaleService service = mock(WxChannelAfterSaleService.class, CALLS_REAL_METHODS);
+ try {
+ service.acceptGuarantee("guarantee-1");
+ fail("Expected UnsupportedOperationException");
+ } catch (UnsupportedOperationException ignored) {
+ // Expected from the compatibility default method.
+ }
}
@Test
@@ -83,7 +117,7 @@ public void shouldDelegateGuaranteeOrderEndpointsAndDecodeResponses() throws Exc
BaseWxChannelServiceImpl shopService = mock(BaseWxChannelServiceImpl.class);
WxChannelAfterSaleServiceImpl service = new WxChannelAfterSaleServiceImpl(shopService);
GuaranteeOrderListParam listParam = new GuaranteeOrderListParam();
- listParam.setOrderId("order-1");
+ listParam.setBeginCreateTime(1L);
GuaranteeModifyRequest modifyRequest = new GuaranteeModifyRequest("guarantee-1", 50, "协商说明");
GuaranteeProofRequest proofRequest = new GuaranteeProofRequest("guarantee-1", "举证说明",
Arrays.asList("media-1"));
@@ -101,7 +135,7 @@ public void shouldDelegateGuaranteeOrderEndpointsAndDecodeResponses() throws Exc
when(shopService.post(eq(GUARANTEE_ORDER_PROOF_URL), eq(proofRequest)))
.thenReturn("{\"errcode\":0,\"errmsg\":\"ok\"}");
when(shopService.post(eq(GUARANTEE_ORDER_REFUSE_URL), eq(refuseRequest)))
- .thenReturn("{\"errcode\":0,\"errmsg\":\"ok\"}");
+ .thenReturn("{\"errcode\":40001,\"errmsg\":\"invalid credential\"}");
GuaranteeOrderListResponse listResponse = service.listGuaranteeOrder(listParam);
GuaranteeOrderInfoResponse detailResponse = service.getGuaranteeOrder("guarantee-1");
@@ -115,7 +149,7 @@ public void shouldDelegateGuaranteeOrderEndpointsAndDecodeResponses() throws Exc
assertTrue(acceptResponse.isSuccess());
assertTrue(modifyResponse.isSuccess());
assertTrue(proofResponse.isSuccess());
- assertTrue(refuseResponse.isSuccess());
+ assertFalse(refuseResponse.isSuccess());
verify(shopService).post(GUARANTEE_ORDER_LIST_URL, listParam);
verify(shopService).post(GUARANTEE_ORDER_GET_URL, new GuaranteeOrderIdParam("guarantee-1"));
verify(shopService).post(GUARANTEE_ORDER_ACCEPT_URL, new GuaranteeOrderIdParam("guarantee-1"));
From 8603cc5485b0d46f0a4a074db57d8c3256d59528 Mon Sep 17 00:00:00 2001
From: Binary Wang
Date: Sat, 22 Aug 2026 13:40:24 +0800
Subject: [PATCH 6/6] =?UTF-8?q?fix(channel):=20=E4=BF=AE=E6=AD=A3=E4=BF=9D?=
=?UTF-8?q?=E9=9A=9C=E5=8D=95=E5=88=97=E8=A1=A8=E6=9F=A5=E8=AF=A2=E5=8F=82?=
=?UTF-8?q?=E6=95=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../bean/after/GuaranteeOrderListParam.java | 35 +++++++++++--------
...nnelAfterSaleServiceImplGuaranteeTest.java | 33 +++++++++--------
2 files changed, 38 insertions(+), 30 deletions(-)
diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/after/GuaranteeOrderListParam.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/after/GuaranteeOrderListParam.java
index f95ccc091..fbe11f91e 100644
--- a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/after/GuaranteeOrderListParam.java
+++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/after/GuaranteeOrderListParam.java
@@ -4,6 +4,7 @@
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.io.Serializable;
+import java.util.List;
import lombok.Data;
import lombok.NoArgsConstructor;
@@ -17,23 +18,27 @@ public class GuaranteeOrderListParam implements Serializable {
private static final long serialVersionUID = 1622570776364341988L;
- /** 订单创建启始时间,Unix 时间戳(秒)。 */
- @JsonProperty("begin_create_time")
- private Long beginCreateTime;
+ @JsonProperty("guarantee_order_id_list")
+ private List guaranteeOrderIdList;
- /** 订单创建结束时间,Unix 时间戳(秒)。 */
- @JsonProperty("end_create_time")
- private Long endCreateTime;
+ @JsonProperty("order_id_list")
+ private List orderIdList;
- /** 保障单更新启始时间,Unix 时间戳(秒)。 */
- @JsonProperty("begin_update_time")
- private Long beginUpdateTime;
+ @JsonProperty("type")
+ private Integer type;
- /** 保障单更新结束时间,Unix 时间戳(秒)。 */
- @JsonProperty("end_update_time")
- private Long endUpdateTime;
+ @JsonProperty("begin_time")
+ private Long beginTime;
- /** 翻页参数。 */
- @JsonProperty("next_key")
- private String nextKey;
+ @JsonProperty("end_time")
+ private Long endTime;
+
+ @JsonProperty("status_list")
+ private String statusList;
+
+ @JsonProperty("offset")
+ private Integer offset;
+
+ @JsonProperty("limit")
+ private Integer limit;
}
diff --git a/weixin-java-channel/src/test/java/me/chanjar/weixin/channel/api/impl/WxChannelAfterSaleServiceImplGuaranteeTest.java b/weixin-java-channel/src/test/java/me/chanjar/weixin/channel/api/impl/WxChannelAfterSaleServiceImplGuaranteeTest.java
index 1692c883f..e8eaee0fc 100644
--- a/weixin-java-channel/src/test/java/me/chanjar/weixin/channel/api/impl/WxChannelAfterSaleServiceImplGuaranteeTest.java
+++ b/weixin-java-channel/src/test/java/me/chanjar/weixin/channel/api/impl/WxChannelAfterSaleServiceImplGuaranteeTest.java
@@ -9,6 +9,12 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.mockito.Answers.CALLS_REAL_METHODS;
+import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.AfterSale.GUARANTEE_ORDER_ACCEPT_URL;
+import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.AfterSale.GUARANTEE_ORDER_GET_URL;
+import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.AfterSale.GUARANTEE_ORDER_LIST_URL;
+import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.AfterSale.GUARANTEE_ORDER_MODIFY_URL;
+import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.AfterSale.GUARANTEE_ORDER_PROOF_URL;
+import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.AfterSale.GUARANTEE_ORDER_REFUSE_URL;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
@@ -24,12 +30,6 @@
import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse;
import org.testng.annotations.Test;
-import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.AfterSale.GUARANTEE_ORDER_ACCEPT_URL;
-import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.AfterSale.GUARANTEE_ORDER_GET_URL;
-import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.AfterSale.GUARANTEE_ORDER_LIST_URL;
-import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.AfterSale.GUARANTEE_ORDER_MODIFY_URL;
-import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.AfterSale.GUARANTEE_ORDER_PROOF_URL;
-import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.AfterSale.GUARANTEE_ORDER_REFUSE_URL;
/**
* 保障单模型 JSON 映射测试。
@@ -82,15 +82,18 @@ public void shouldDeserializeGuaranteeOrderListAndDetail() throws Exception {
@Test
public void shouldSerializeGuaranteeOrderListParamWithOfficialFieldNames() throws Exception {
GuaranteeOrderListParam param = OBJECT_MAPPER.readValue(
- "{\"begin_create_time\":1,\"end_create_time\":2,\"begin_update_time\":3,"
- + "\"end_update_time\":4,\"next_key\":\"next\"}", GuaranteeOrderListParam.class);
+ "{\"guarantee_order_id_list\":[\"g-1\"],\"order_id_list\":[\"o-1\"],\"type\":2,"
+ + "\"begin_time\":1,\"end_time\":2,\"status_list\":\"PENDING\",\"offset\":3,\"limit\":10}", GuaranteeOrderListParam.class);
JsonNode json = OBJECT_MAPPER.readTree(OBJECT_MAPPER.writeValueAsString(param));
- assertEquals(json.get("begin_create_time").asLong(), 1L);
- assertEquals(json.get("end_create_time").asLong(), 2L);
- assertEquals(json.get("begin_update_time").asLong(), 3L);
- assertEquals(json.get("end_update_time").asLong(), 4L);
- assertEquals(json.get("next_key").asText(), "next");
+ assertEquals(json.get("guarantee_order_id_list").get(0).asText(), "g-1");
+ assertEquals(json.get("order_id_list").get(0).asText(), "o-1");
+ assertEquals(json.get("type").asInt(), 2);
+ assertEquals(json.get("begin_time").asLong(), 1L);
+ assertEquals(json.get("end_time").asLong(), 2L);
+ assertEquals(json.get("status_list").asText(), "PENDING");
+ assertEquals(json.get("offset").asInt(), 3);
+ assertEquals(json.get("limit").asInt(), 10);
}
@Test
@@ -114,10 +117,10 @@ public void shouldExposeGuaranteeMethodsAsDefaultMethods() throws Exception {
@Test
public void shouldDelegateGuaranteeOrderEndpointsAndDecodeResponses() throws Exception {
- BaseWxChannelServiceImpl shopService = mock(BaseWxChannelServiceImpl.class);
+ BaseWxChannelServiceImpl, ?> shopService = mock(BaseWxChannelServiceImpl.class);
WxChannelAfterSaleServiceImpl service = new WxChannelAfterSaleServiceImpl(shopService);
GuaranteeOrderListParam listParam = new GuaranteeOrderListParam();
- listParam.setBeginCreateTime(1L);
+ listParam.setLimit(10);
GuaranteeModifyRequest modifyRequest = new GuaranteeModifyRequest("guarantee-1", 50, "协商说明");
GuaranteeProofRequest proofRequest = new GuaranteeProofRequest("guarantee-1", "举证说明",
Arrays.asList("media-1"));