现在京东物流开放平台下载 sdk
下载完 导入到项目中
下单校验为例 其他的都同理 传入参数即可
下单前置校验 (commonCheckPreCreateOrderV1)
/ecap/v1/orders/precheck
/**
* 京东下单校验
*
* @param atUserAddress
* @return
*/
public JSONObject cerateOrderCheck(AtUserAddress atUserAddress) {
DefaultDomainApiClient client = new DefaultDomainApiClient(url);
EcapV1OrdersPrecheckLopRequest ecapV1OrdersPrecheckLopRequest = new EcapV1OrdersPrecheckLopRequest();
CommonCreateOrderRequest commonCreateOrderRequest = new CommonCreateOrderRequest();
Contact senderContact = new Contact();
senderContact.setFullAddress(atUserAddress.getProvince() + atUserAddress.getCity() + atUserAddress.getCounty() +
atUserAddress.getDetail());
commonCreateOrderRequest.setSenderContact(senderContact);
Contact receiverContact = new Contact();
receiverContact.setFullAddress(recipient_address);
commonCreateOrderRequest.setReceiverContact(receiverContact);
//0-c2c;1-b2c;2-c2b
commonCreateOrderRequest.setOrderOrigin(2);
CommonGoodsInfo commonGoodsInfo = new CommonGoodsInfo();
commonGoodsInfo.setName(goodsName);
commonGoodsInfo.setQuantity(goodsQuantity);
List<CommonGoodsInfo> commonGoodsInfos = new ArrayList<>();
commonGoodsInfos.add(commonGoodsInfo);
commonCreateOrderRequest.setGoods(commonGoodsInfos);
commonCreateOrderRequest.setCustomerCode("");
ecapV1OrdersPrecheckLopRequest.setRequest(commonCreateOrderRequest);
//设置插件,必须的操作,不同类型的应用入参不同,请看入参注释
LopPlugin lopPlugin = OAuth2PluginFactory.produceLopPlugin(
appkey,
appSecret,
accessToken
);
ecapV1OrdersPrecheckLopRequest.addLopPlugin(lopPlugin);
EcapV1OrdersPrecheckLopResponse response = null;
JSONObject object = new JSONObject();
try {
response = client.execute(ecapV1OrdersPrecheckLopRequest);
object = JSON.parseObject(JSON.toJSONString(response));
return object;
} catch (LopException e) {
return null;
}
}
正文完