|
@@ -51,6 +51,9 @@ import org.springframework.stereotype.Component;
|
|
|
import javax.annotation.PostConstruct;
|
|
|
import java.util.*;
|
|
|
|
|
|
+import static com.iamberry.rst.controllers.mq.TaobaoConfig.DB_JD_PULL_ORDER_LIMIT_TIME;
|
|
|
+import static com.iamberry.rst.controllers.mq.TaobaoConfig.DB_JD_TOKEN_ID;
|
|
|
+
|
|
|
/**
|
|
|
* @author root
|
|
|
*/
|
|
@@ -97,7 +100,7 @@ public class JingdongTask {
|
|
|
}
|
|
|
logger.info("【京东订单】开始抓取数据......");
|
|
|
// 组装请求数据
|
|
|
- SysConfig sysConfigTime = sysConfigService.getSysConfigAll(28);
|
|
|
+ SysConfig sysConfigTime = sysConfigService.getSysConfigAll(DB_JD_PULL_ORDER_LIMIT_TIME);
|
|
|
String startTime = sysConfigTime.getConfigParameter();
|
|
|
if (StringUtils.isEmpty(startTime)) {
|
|
|
startTime = DateTimeUtil.format(DateTimeUtil.addDay(-20), "yyyy-MM-dd HH:mm:ss");
|
|
@@ -123,29 +126,19 @@ public class JingdongTask {
|
|
|
PopOrderEnSearchRequest orderSearchRequest = null;
|
|
|
PopOrderEnSearchResponse rsp = null;
|
|
|
try {
|
|
|
- SysConfig sysConfig = sysConfigService.getSysConfigAll(27);
|
|
|
- client = new DefaultJdClient(TaobaoConfig.JINGDONG_API_URL, (String) AdminJingdongAuthController.getToken(sysConfig).get("token"), TaobaoConfig.jd_appkey, TaobaoConfig.jd_secret);
|
|
|
+ SysConfig sysConfig = sysConfigService.getSysConfigAll(DB_JD_TOKEN_ID);
|
|
|
+ client = new DefaultJdClient(TaobaoConfig.JINGDONG_API_URL, sysConfig.getConfigParameter(), TaobaoConfig.jd_appkey, TaobaoConfig.jd_secret);
|
|
|
orderSearchRequest = new PopOrderEnSearchRequest();
|
|
|
orderSearchRequest.setStartDate(startTime);
|
|
|
orderSearchRequest.setEndDate(endTime);
|
|
|
orderSearchRequest.setOrderState("WAIT_SELLER_STOCK_OUT,WAIT_SELLER_DELIVERY");//待出库和境外待发货, 一般仅存在前者
|
|
|
- orderSearchRequest.setOptionalFields("orderId,venderId,orderType,payType,orderTotalPrice,orderSellerPrice,orderPayment,freightPrice,sellerDiscount,orderState,orderStateRemark,deliveryType," +
|
|
|
- "invoiceEasyInfo," +
|
|
|
- "invoiceCode,invoiceInfo,invoiceCode,orderRemark,orderStartTime,orderEndTime," +
|
|
|
- "consigneeInfo," +
|
|
|
- "itemInfoList," +
|
|
|
- "couponDetailList," +
|
|
|
- "venderRemark,balanceUsed,pin,returnOrder,paymentConfirmTime,waybill,logisticsId," +
|
|
|
- "vatInfo," +
|
|
|
- "modified,directParentOrderId,parentOrderId,customs,customsModel,orderSource,storeOrder,idSopShipmenttype,scDT,serviceFee," +
|
|
|
- "pauseBizInfo," +
|
|
|
- "taxFee,tuiHuoWuYou,orderSign,storeId,realPin,orderMarkDesc,open_id,xid,open_id_buyer,xid_buyer");
|
|
|
+ orderSearchRequest.setOptionalFields(initOrderOptionalFields());
|
|
|
orderSearchRequest.setPage("" + pageNo);
|
|
|
orderSearchRequest.setPageSize("" + 40L);
|
|
|
orderSearchRequest.setDateType(0);//按照最后修改时间查询
|
|
|
rsp = client.execute(orderSearchRequest);
|
|
|
} catch (Exception e) {
|
|
|
- logger.error("", e);
|
|
|
+ logger.error("请求京东服务器异常:{}", e);
|
|
|
}
|
|
|
if (rsp == null) {
|
|
|
logger.error("【京东订单】请求京东服务器失败!");
|
|
@@ -228,27 +221,12 @@ public class JingdongTask {
|
|
|
}
|
|
|
|
|
|
try {
|
|
|
- JdClient client = null;
|
|
|
- PopOrderEnGetRequest request = null;
|
|
|
- PopOrderEnGetResponse rsp = null;
|
|
|
-
|
|
|
-
|
|
|
- SysConfig sysConfig = sysConfigService.getSysConfigAll(27);
|
|
|
- client = new DefaultJdClient(TaobaoConfig.JINGDONG_API_URL, (String) AdminJingdongAuthController.getToken(sysConfig).get("token"), TaobaoConfig.jd_appkey, TaobaoConfig.jd_secret);
|
|
|
- request=new PopOrderEnGetRequest();
|
|
|
+ SysConfig sysConfig = sysConfigService.getSysConfigAll(DB_JD_TOKEN_ID);
|
|
|
+ JdClient client = new DefaultJdClient(TaobaoConfig.JINGDONG_API_URL, sysConfig.getConfigParameter(), TaobaoConfig.jd_appkey, TaobaoConfig.jd_secret);
|
|
|
+ PopOrderEnGetRequest request = new PopOrderEnGetRequest();
|
|
|
request.setOrderId(tid);
|
|
|
- request.setOptionalFields("orderId,venderId,orderType,payType,orderTotalPrice,orderSellerPrice,orderPayment,freightPrice,sellerDiscount,orderState,orderStateRemark,deliveryType," +
|
|
|
- "invoiceEasyInfo," +
|
|
|
- "invoiceCode,invoiceInfo,invoiceCode,orderRemark,orderStartTime,orderEndTime," +
|
|
|
- "consigneeInfo," +
|
|
|
- "itemInfoList," +
|
|
|
- "couponDetailList," +
|
|
|
- "venderRemark,balanceUsed,pin,returnOrder,paymentConfirmTime,waybill,logisticsId," +
|
|
|
- "vatInfo," +
|
|
|
- "modified,directParentOrderId,parentOrderId,customs,customsModel,orderSource,storeOrder,idSopShipmenttype,scDT,serviceFee," +
|
|
|
- "pauseBizInfo," +
|
|
|
- "taxFee,tuiHuoWuYou,orderSign,storeId,realPin,orderMarkDesc,open_id,xid,open_id_buyer,xid_buyer");
|
|
|
- rsp = client.execute(request);
|
|
|
+ request.setOptionalFields(initOrderOptionalFields());
|
|
|
+ PopOrderEnGetResponse rsp = client.execute(request);
|
|
|
String code = rsp.getCode();
|
|
|
logger.info("查询京东订单详情返回信息:code:{}, msg:{}", rsp.getCode(), rsp.getMsg());
|
|
|
if ("0".equals(code)) {
|
|
@@ -264,6 +242,21 @@ public class JingdongTask {
|
|
|
}
|
|
|
|
|
|
|
|
|
+ public String initOrderOptionalFields() {
|
|
|
+ return "orderId,venderId,orderType,payType,orderTotalPrice,orderSellerPrice,orderPayment,freightPrice,sellerDiscount,orderState,orderStateRemark,deliveryType," +
|
|
|
+ "invoiceEasyInfo," +
|
|
|
+ "invoiceCode,invoiceInfo,invoiceCode,orderRemark,orderStartTime,orderEndTime," +
|
|
|
+ "consigneeInfo," +
|
|
|
+ "itemInfoList," +
|
|
|
+ "couponDetailList," +
|
|
|
+ "venderRemark,balanceUsed,pin,returnOrder,paymentConfirmTime,waybill,logisticsId," +
|
|
|
+ "vatInfo," +
|
|
|
+ "modified,directParentOrderId,parentOrderId,customs,customsModel,orderSource,storeOrder,idSopShipmenttype,scDT,serviceFee," +
|
|
|
+ "pauseBizInfo," +
|
|
|
+ "taxFee,tuiHuoWuYou,orderSign,storeId,realPin,orderMarkDesc,open_id,xid,open_id_buyer,xid_buyer";
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 京东发货
|
|
|
* @param orderId
|
|
@@ -272,21 +265,14 @@ public class JingdongTask {
|
|
|
*/
|
|
|
public OperatorResult orderShipment(String orderId, String logiCoprId, String logiNo){
|
|
|
|
|
|
- SysConfig sysConfigAll = sysConfigService.getSysConfigAll(27);
|
|
|
- JdClient client = new DefaultJdClient(JingdongConfig.JINGDONG_API_URL, sysConfigAll.getConfigParameter(), JingdongConfig.jd_appkey, JingdongConfig.jd_secret);
|
|
|
+ SysConfig sysConfig = sysConfigService.getSysConfigAll(DB_JD_TOKEN_ID);
|
|
|
+ JdClient client = new DefaultJdClient(JingdongConfig.JINGDONG_API_URL, sysConfig.getConfigParameter(), JingdongConfig.jd_appkey, JingdongConfig.jd_secret);
|
|
|
PopOrderShipmentRequest req = new PopOrderShipmentRequest();
|
|
|
req.setOrderId(Long.parseLong(orderId));
|
|
|
req.setLogiCoprId(logiCoprId);
|
|
|
req.setLogiNo(logiNo);
|
|
|
try {
|
|
|
PopOrderShipmentResponse rsp = client.execute(req);
|
|
|
-// PopOrderShipmentResponse rsp = new PopOrderShipmentResponse();
|
|
|
-// rsp.setCode("0");
|
|
|
-// rsp.setMsg("伪造成功, 生产放开");
|
|
|
-// OperatorResult result = new OperatorResult();
|
|
|
-// result.setSuccess(true);
|
|
|
-// result.setChineseErrCode("伪造成功,生产放开");
|
|
|
-// rsp.setSopjosshipmentResult(result);
|
|
|
logger.info("京东订单发货回录:code:{}, msg:{}", rsp.getCode(), rsp.getMsg());
|
|
|
if ("0".equals(rsp.getCode())) {
|
|
|
OperatorResult sopjosshipmentResult = rsp.getSopjosshipmentResult();
|
|
@@ -309,14 +295,10 @@ public class JingdongTask {
|
|
|
}
|
|
|
|
|
|
try {
|
|
|
- JdClient client = null;
|
|
|
- PopOrderGetmobilelistRequest request = null;
|
|
|
+ SysConfig sysConfig = sysConfigService.getSysConfigAll(DB_JD_TOKEN_ID);
|
|
|
PopOrderGetmobilelistResponse rsp = null;
|
|
|
-
|
|
|
-
|
|
|
- SysConfig sysConfig = sysConfigService.getSysConfigAll(27);
|
|
|
- client = new DefaultJdClient(TaobaoConfig.JINGDONG_API_URL, (String) AdminJingdongAuthController.getToken(sysConfig).get("token"), TaobaoConfig.jd_appkey, TaobaoConfig.jd_secret);
|
|
|
- request = new PopOrderGetmobilelistRequest();
|
|
|
+ JdClient client = new DefaultJdClient(TaobaoConfig.JINGDONG_API_URL, sysConfig.getConfigParameter(), TaobaoConfig.jd_appkey, TaobaoConfig.jd_secret);
|
|
|
+ PopOrderGetmobilelistRequest request = new PopOrderGetmobilelistRequest();
|
|
|
request.setAppName("爱贝源官方旗航店");
|
|
|
// request.setRegion("https://jd.com");
|
|
|
request.setOrderId(orderId);
|
|
@@ -531,89 +513,4 @@ public class JingdongTask {
|
|
|
return (int)(p * 100);
|
|
|
}
|
|
|
|
|
|
- private String findZip(String receiverState, String receiverCity, String receiverDistrict, String address) {
|
|
|
- logger.info("地址数据:{}, {}, {}, {}", receiverState, receiverCity, receiverDistrict, address);
|
|
|
- //获取省份
|
|
|
- List<Province> provinceList = addressService.listProvince(new Province());
|
|
|
- // 没有邮编,从系统开始查找
|
|
|
- if(provinceList != null && provinceList.size() >0 ){
|
|
|
- int provinceIdNum = 0;
|
|
|
- int provinceId = 0;
|
|
|
- for (Province proiv : provinceList) {
|
|
|
- int proNum = 0;
|
|
|
- String newPro = proiv.getProvince().replaceAll("省|自治区|壮族自治区|特别行政区|维吾尔自治区","");
|
|
|
- if(newPro.contains(receiverState)){
|
|
|
- proNum++;
|
|
|
- }
|
|
|
- if(receiverState.contains(newPro)){
|
|
|
- proNum++;
|
|
|
- }
|
|
|
- if(proNum > provinceIdNum){
|
|
|
- provinceIdNum = proNum;
|
|
|
- provinceId = proiv.getProvinceId();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- receiverCity = receiverCity.replaceAll("市|州|地区|自治区|特别行政区","");
|
|
|
-
|
|
|
- int cityNum = 0;
|
|
|
- Integer cityId = null;
|
|
|
-
|
|
|
- City city = new City();
|
|
|
- city.setProvinceId(provinceId);
|
|
|
- List<City> cityList = addressService.listCity(city);
|
|
|
- for (City ci:cityList) {
|
|
|
- int ciNum = 0;
|
|
|
- String newCi = ci.getCity().replaceAll("市|州|地区|自治区|特别行政区","");
|
|
|
- if(receiverCity.contains(newCi)){
|
|
|
- ciNum ++;
|
|
|
- }
|
|
|
- if(newCi.contains(receiverCity)){
|
|
|
- ciNum ++;
|
|
|
- }
|
|
|
- if(cityNum < ciNum){
|
|
|
- cityNum = ciNum;
|
|
|
- cityId = ci.getCityId();
|
|
|
- }
|
|
|
- }
|
|
|
- if(cityId == null){
|
|
|
- throw new RuntimeException("未查询到该县区:"+address);
|
|
|
- }
|
|
|
-
|
|
|
- int districtNum = 0;
|
|
|
- String postcode = null;
|
|
|
-
|
|
|
- District district = new District();
|
|
|
- district.setCityId(cityId);
|
|
|
- List<District> districtList = addressService.listDistrict(district);
|
|
|
- for (District dis:districtList) {
|
|
|
- int disNum = 0;
|
|
|
-
|
|
|
- String newDIs = dis.getDistrict();
|
|
|
- String newLastNewArea = newDIs.substring(newDIs.length()-1,newDIs.length());
|
|
|
- newLastNewArea = newLastNewArea.replaceAll("县|区|镇|乡|市|州|洲","");
|
|
|
- newDIs = newDIs.substring(0,newDIs.length()-1);
|
|
|
- newDIs += newLastNewArea;
|
|
|
-
|
|
|
- if(newDIs.contains(receiverDistrict)){
|
|
|
- disNum++;
|
|
|
- }
|
|
|
- if(receiverDistrict.contains(newDIs)){
|
|
|
- disNum++;
|
|
|
- }
|
|
|
- if(districtNum < disNum){
|
|
|
- districtNum = disNum;
|
|
|
- postcode = dis.getPostcode();
|
|
|
- }
|
|
|
- }
|
|
|
- if(postcode != null){
|
|
|
- return postcode;
|
|
|
- }else{
|
|
|
- throw new RuntimeException("未查询到该县区,原地址:"+address);
|
|
|
- }
|
|
|
- }else{
|
|
|
- throw new RuntimeException("未查询到该省份,原地址:"+address);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
}
|