|
|
|
@ -2,31 +2,82 @@ package common.ecommerce.lingxing.dto; |
|
|
|
|
|
|
|
|
|
|
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; |
|
|
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; |
|
|
|
import com.fasterxml.jackson.annotation.JsonProperty; |
|
|
|
import com.fasterxml.jackson.annotation.JsonProperty; |
|
|
|
|
|
|
|
import com.fasterxml.jackson.core.JsonParser; |
|
|
|
|
|
|
|
import com.fasterxml.jackson.core.JsonToken; |
|
|
|
|
|
|
|
import com.fasterxml.jackson.databind.DeserializationContext; |
|
|
|
|
|
|
|
import com.fasterxml.jackson.databind.JsonDeserializer; |
|
|
|
|
|
|
|
import com.fasterxml.jackson.databind.JsonNode; |
|
|
|
import lombok.Getter; |
|
|
|
import lombok.Getter; |
|
|
|
import lombok.Setter; |
|
|
|
import lombok.Setter; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.io.IOException; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 领星订单标签({@code order_tag[]} / {@code exception_order_tag[]} / |
|
|
|
* 领星订单标签({@code order_tag[]} / {@code exception_order_tag[]} / |
|
|
|
* {@code pending_order_tag[]})。 |
|
|
|
* {@code pending_order_tag[]})。 |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* <p>同一类字段领星有两种返回形态:</p> |
|
|
|
|
|
|
|
* <ul> |
|
|
|
|
|
|
|
* <li>{@code order_tag[]} 是对象: |
|
|
|
|
|
|
|
* {@code {"tag_name":"商品未配对","tag_no":"3-8","tag_type":"系统处理类型"}}</li> |
|
|
|
|
|
|
|
* <li>{@code pending_order_tag[]} / {@code exception_order_tag[]} 可能是纯字符串: |
|
|
|
|
|
|
|
* {@code ["未分配物流"]}</li> |
|
|
|
|
|
|
|
* </ul> |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* <p>对应字段用 {@link Deserializer} 兼容两种形态,字符串只填 {@link #tagName}。</p> |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Getter |
|
|
|
@Getter |
|
|
|
@Setter |
|
|
|
@Setter |
|
|
|
@JsonIgnoreProperties(ignoreUnknown = true) |
|
|
|
@JsonIgnoreProperties(ignoreUnknown = true) |
|
|
|
public class LingxingOrderTagDto { |
|
|
|
public class LingxingOrderTagDto { |
|
|
|
|
|
|
|
|
|
|
|
/** 标签名称,如「商品未配对」。 */ |
|
|
|
/** 标签名称,如「商品未配对」「未分配物流」。 */ |
|
|
|
@JsonProperty("tag_name") |
|
|
|
@JsonProperty("tag_name") |
|
|
|
private String tagName; |
|
|
|
private String tagName; |
|
|
|
|
|
|
|
|
|
|
|
/** 标签编号,如 {@code 3-8}。 */ |
|
|
|
/** 标签编号,如 {@code 3-8};字符串形态没有这个字段。 */ |
|
|
|
@JsonProperty("tag_no") |
|
|
|
@JsonProperty("tag_no") |
|
|
|
private String tagNo; |
|
|
|
private String tagNo; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 标签类型:1 自定义处理类型、2 自定义订单标签、3 系统处理类型、4 系统订单标签。 |
|
|
|
* 标签类型:1 自定义处理类型、2 自定义订单标签、3 系统处理类型、4 系统订单标签。 |
|
|
|
* |
|
|
|
* |
|
|
|
* <p>文档类型是 string;示例响应里直接返回中文名(如「系统处理类型」)。</p> |
|
|
|
* <p>文档类型是 string;示例响应里直接返回中文名(如「系统处理类型」)。 |
|
|
|
|
|
|
|
* 字符串形态没有这个字段。</p> |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@JsonProperty("tag_type") |
|
|
|
@JsonProperty("tag_type") |
|
|
|
private String tagType; |
|
|
|
private String tagType; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 同时接受「对象」与「纯字符串」两种标签形态。 |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* <p>注册方式是在 {@link LingxingOrderDto} 的列表字段上用 |
|
|
|
|
|
|
|
* {@code @JsonDeserialize(contentUsing = LingxingOrderTagDto.Deserializer.class)}, |
|
|
|
|
|
|
|
* 不放在类上,避免 {@link #deserialize} 里回读对象时递归。</p> |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public static final class Deserializer extends JsonDeserializer<LingxingOrderTagDto> { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public LingxingOrderTagDto deserialize(JsonParser p, DeserializationContext ctxt) |
|
|
|
|
|
|
|
throws IOException { |
|
|
|
|
|
|
|
if (p.hasToken(JsonToken.VALUE_STRING)) { |
|
|
|
|
|
|
|
return fromName(p.getText()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
JsonNode node = p.readValueAsTree(); |
|
|
|
|
|
|
|
if (node == null || node.isNull()) { |
|
|
|
|
|
|
|
return null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (node.isTextual()) { |
|
|
|
|
|
|
|
return fromName(node.asText()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 对象形态交回标准绑定,tag_no / tag_type 照常映射
|
|
|
|
|
|
|
|
return p.getCodec().treeToValue(node, LingxingOrderTagDto.class); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static LingxingOrderTagDto fromName(String name) { |
|
|
|
|
|
|
|
LingxingOrderTagDto tag = new LingxingOrderTagDto(); |
|
|
|
|
|
|
|
tag.setTagName(name); |
|
|
|
|
|
|
|
return tag; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|