diff --git a/channel-sdk-core/src/main/java/common/ecommerce/channel/model/aftersale/RefundCommand.java b/channel-sdk-core/src/main/java/common/ecommerce/channel/model/aftersale/RefundCommand.java
index d4813e2..85039a3 100644
--- a/channel-sdk-core/src/main/java/common/ecommerce/channel/model/aftersale/RefundCommand.java
+++ b/channel-sdk-core/src/main/java/common/ecommerce/channel/model/aftersale/RefundCommand.java
@@ -9,9 +9,15 @@ import java.util.List;
/**
* 退款命令。
*
- *
按平台退货单发起退款。平台侧的退款通常细到退货行 × 费用项
- * (沃尔玛 {@code refundLines[].refundCharges[]}),所以这里不是「退多少钱」,
- * 而是逐行逐费用给金额。
+ * 按平台退货单发起退款。各平台表达「退多少」的方式不同:
+ *
+ * - 按数量(沃尔玛当前 API):给 {@code lineId} + {@code quantity},
+ * 金额由平台按单价算;{@code charges} 会被忽略。
+ * - 按费用项(部分平台/旧接口):给 {@code lineId} + {@code charges} 金额明细。
+ *
+ *
+ * 所以 {@code charges} 与 {@code quantity} 都是可选的,由适配器按平台要求取用;
+ * 两者都不给时,适配器按「整行全退」处理。
*
* 调用前应先查售后详情核对 {@code refundedQty} / {@code cancellableQty},
* 避免超退——各平台超额规则不同,适配器只做格式校验,不做余额校验。
@@ -21,6 +27,14 @@ public final class RefundCommand {
/** 平台退货单号;必填。 */
private final String afterSaleId;
+ /**
+ * 平台客户订单号;可选。
+ *
+ * 沃尔玛退款接口把它列为必填({@code customerOrderId}),
+ * 其他平台可以不用。为空时由适配器决定是报错还是从别处补。
+ */
+ private final String customerOrderId;
+
/** 退款行;不可变,至少一行。 */
private final List lines;
@@ -32,6 +46,7 @@ public final class RefundCommand {
throw new IllegalArgumentException("refund requires at least one line");
}
this.afterSaleId = b.afterSaleId.trim();
+ this.customerOrderId = b.customerOrderId == null ? null : b.customerOrderId.trim();
this.lines = Collections.unmodifiableList(new ArrayList(b.lines));
}
@@ -45,6 +60,11 @@ public final class RefundCommand {
return afterSaleId;
}
+ /** 平台客户订单号;可空。 */
+ public String customerOrderId() {
+ return customerOrderId;
+ }
+
/** 退款行;不可变,至少一行。 */
public List lines() {
return lines;
@@ -66,23 +86,27 @@ public final class RefundCommand {
*
* {@code lineId} 是平台退货行号(沃尔玛 {@code returnOrderLineNumber}),
* 不是统一模型的 {@code afterSaleId()};后者是「退货单号:行号」的拼接。
+ *
+ * {@code quantity} 为空表示「整行全退」;{@code charges} 为空表示
+ * 「金额由平台计算」——沃尔玛当前接口就是这种。
*/
public static final class Line {
/** 平台退货行号;必填。 */
private final String lineId;
- /** 费用明细;不可变,至少一条。 */
+ /** 退款数量;可空,空表示整行。 */
+ private final Integer quantity;
+
+ /** 费用明细;可空(按数量退款的平台不需要)。 */
private final List charges;
private Line(Builder b) {
if (isBlank(b.lineId)) {
throw new IllegalArgumentException("refund lineId must not be blank");
}
- if (b.charges.isEmpty()) {
- throw new IllegalArgumentException("refund line requires at least one charge");
- }
this.lineId = b.lineId.trim();
+ this.quantity = b.quantity;
this.charges = Collections.unmodifiableList(new ArrayList(b.charges));
}
@@ -96,7 +120,12 @@ public final class RefundCommand {
return lineId;
}
- /** 费用明细。 */
+ /** 退款数量;可空(空 = 整行)。 */
+ public Integer quantity() {
+ return quantity;
+ }
+
+ /** 费用明细;可能为空。 */
public List charges() {
return charges;
}
@@ -106,6 +135,8 @@ public final class RefundCommand {
/** 平台退货行号。 */
private String lineId;
+ /** 退款数量;空表示整行。 */
+ private Integer quantity;
/** 费用明细。 */
private final List charges = new ArrayList();
@@ -115,6 +146,12 @@ public final class RefundCommand {
return this;
}
+ /** 设置退款数量;不设表示整行全退。 */
+ public Builder quantity(Integer quantity) {
+ this.quantity = quantity;
+ return this;
+ }
+
/** 追加一条费用明细。 */
public Builder charge(Charge charge) {
if (charge != null) {
@@ -236,6 +273,8 @@ public final class RefundCommand {
/** 平台退货单号。 */
private String afterSaleId;
+ /** 平台客户订单号;沃尔玛必填。 */
+ private String customerOrderId;
/** 退款行。 */
private final List lines = new ArrayList();
@@ -245,6 +284,12 @@ public final class RefundCommand {
return this;
}
+ /** 设置平台客户订单号;沃尔玛退款必填,其他平台可不用。 */
+ public Builder customerOrderId(String customerOrderId) {
+ this.customerOrderId = customerOrderId;
+ return this;
+ }
+
/** 追加一条退款行。 */
public Builder line(Line line) {
if (line != null) {