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

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

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