提交 e14d4eb7 authored 作者: 000516's avatar 000516

修改京东物流结果取值,当物流未生成状态时,返回空值

上级 fefb55d8
......@@ -12,8 +12,6 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Objects;
/**
* @author : liqiulin
......@@ -32,21 +30,19 @@ public class SentQueryController {
public Object query(String sentNo){
OrdersSentDto sent = orderSentQueryService.getSent(sentNo);
Object sentInfo = null;
if (sent.getTransport().equals("134")){
sent.setTransportName("京东TC");
sentInfo = jdTC(sent);
switch (sent.getTransport()) {
case "134":
sentInfo = jdTC134(sent);
break;
default:
throw new ServiceException(ECode.SENT_ISNULL_ERROR);
}
sent.setSentInfo(sentInfo);
return sent;
}
public Object jdTC(OrdersSentDto sent){
private Object jdTC134(OrdersSentDto sent){
JSONArray traces = jdtcUtil.getOrderTrace(sent.getBjSentNo() + "-" + sent.getBjSentVersion());
if (CollectionUtils.isEmpty(traces)){
throw new ServiceException(ECode.JINGDONG_TC_ORDER_TRACE_ERROR);
}
return traces.get(0);
return CollectionUtils.isEmpty(traces) ? null : traces.get(0);
}
}
......@@ -96,7 +96,8 @@ public class JdtcUtil {
log.error("请求京东TC物流轨迹接口返回异常:{}",reqJson);
throw new ServiceException(ECode.JINGDONG_TC_ORDER_TRACE_API_ERROR);
}
return reqJson.getJSONObject("data").getJSONArray("purchaseTraceList");
JSONObject data = reqJson.getJSONObject("data");
return data.containsKey("purchaseTraceList") ? data.getJSONArray("purchaseTraceList") : new JSONArray();
} catch (GeneralSecurityException | UnsupportedEncodingException e) {
throw new ServiceException(ECode.JINGDONG_TC_ORDER_TRACE_QUERY_ERROR);
}
......
......@@ -31,13 +31,13 @@
</sql>
<select id="findUnsyncQc" resultMap="BaseResultMap">
select send_id, ah_sent_no, bj_sent_no, transport, express_no
select send_id, ah_sent_no, bj_sent_no, transport,transport_name, express_no
from orders_sent
where push_qc = 1
</select>
<select id="selectBySentNo" resultMap="BaseResultMap">
select ah_sent_no,bj_sent_no,bj_sent_version,transport,express_no,dd_no
select ah_sent_no,bj_sent_no,bj_sent_version,transport,transport_name,express_no,dd_no
from orders_sent
<where>
<if test="sentNo.startsWith('BJHQ')">
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论