|
@@ -1,6 +1,5 @@
|
|
package com.emato.ccnet.wx.biz.req.waybill.oms;
|
|
package com.emato.ccnet.wx.biz.req.waybill.oms;
|
|
|
|
|
|
-import com.alibaba.fastjson.JSONObject;
|
|
|
|
import com.emato.ccnet.wx.biz.CebReqSendDate;
|
|
import com.emato.ccnet.wx.biz.CebReqSendDate;
|
|
import com.emato.ccnet.wx.config.Cus;
|
|
import com.emato.ccnet.wx.config.Cus;
|
|
import com.emato.ccnet.wx.contants.CcnetContants;
|
|
import com.emato.ccnet.wx.contants.CcnetContants;
|
|
@@ -26,13 +25,13 @@ import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
import java.beans.BeanInfo;
|
|
import java.beans.BeanInfo;
|
|
import java.beans.Introspector;
|
|
import java.beans.Introspector;
|
|
import java.beans.PropertyDescriptor;
|
|
import java.beans.PropertyDescriptor;
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
import java.lang.reflect.Method;
|
|
import java.lang.reflect.Method;
|
|
-import java.math.BigDecimal;
|
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
|
|
@Component
|
|
@Component
|
|
@@ -67,8 +66,8 @@ public class Ceb511SendDateRequest implements CebReqSendDate{
|
|
public ResponseMessage sendDate() {
|
|
public ResponseMessage sendDate() {
|
|
//查找当前ccnet中的所有电子订单
|
|
//查找当前ccnet中的所有电子订单
|
|
List<CusWaybill> cusWaybills = cusWaybillService.findAllCusWaybill();
|
|
List<CusWaybill> cusWaybills = cusWaybillService.findAllCusWaybill();
|
|
- if(cusWaybills == null){
|
|
|
|
- String info = "查找当前ccnet中的所有运单失败";
|
|
|
|
|
|
+ if(cusWaybills.isEmpty()){
|
|
|
|
+ String info = "未查询到发送 OMS 的订单数据";
|
|
LOGGER.error("--- {}", info);
|
|
LOGGER.error("--- {}", info);
|
|
return ResponseMessage.failed(info);
|
|
return ResponseMessage.failed(info);
|
|
}
|
|
}
|
|
@@ -76,7 +75,7 @@ public class Ceb511SendDateRequest implements CebReqSendDate{
|
|
//发送给第三方的请求回调
|
|
//发送给第三方的请求回调
|
|
int orderSumbit = buildRequest(cusWaybills);
|
|
int orderSumbit = buildRequest(cusWaybills);
|
|
if(orderSumbit != 1){
|
|
if(orderSumbit != 1){
|
|
- String info = "发送请求响应失败";
|
|
|
|
|
|
+ String info = "发送 OMS 请求响应失败";
|
|
LOGGER.error("--- {}", info);
|
|
LOGGER.error("--- {}", info);
|
|
return ResponseMessage.failed(info);
|
|
return ResponseMessage.failed(info);
|
|
}
|
|
}
|
|
@@ -105,18 +104,17 @@ public class Ceb511SendDateRequest implements CebReqSendDate{
|
|
|
|
|
|
//构造请求oms的参数数值
|
|
//构造请求oms的参数数值
|
|
Map<String, String> sPara = buildCusWaybillMap(cusWaybill);
|
|
Map<String, String> sPara = buildCusWaybillMap(cusWaybill);
|
|
- if(sPara == null){
|
|
|
|
|
|
+ if(CollectionUtils.isEmpty(sPara)){
|
|
failedList.add(cusWaybill.getMerchOrderId());
|
|
failedList.add(cusWaybill.getMerchOrderId());
|
|
- String info = "构造请求oms的参数数值失败";
|
|
|
|
|
|
+ String info = "构造请求 oms 的参数数值失败";
|
|
LOGGER.error("--- {}", info);
|
|
LOGGER.error("--- {}", info);
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
|
|
|
|
//发送请求并获取响应信息
|
|
//发送请求并获取响应信息
|
|
String response = requestSubmit(sPara, cusWaybill.getWsFlag());
|
|
String response = requestSubmit(sPara, cusWaybill.getWsFlag());
|
|
- LOGGER.info("oms的响应报文:" + response);
|
|
|
|
|
|
+ LOGGER.info("OMS 的响应报文:{}", response);
|
|
|
|
|
|
- LOGGER.info("response date:"+response);
|
|
|
|
//解析响应信息并处理
|
|
//解析响应信息并处理
|
|
ResponseMessage addRespone = ceb511SendDateResponse.addResponse(response,cusWaybill.getCusWaybillSn());
|
|
ResponseMessage addRespone = ceb511SendDateResponse.addResponse(response,cusWaybill.getCusWaybillSn());
|
|
if(!ResponseMessage.isSuccess(addRespone)){
|
|
if(!ResponseMessage.isSuccess(addRespone)){
|
|
@@ -153,14 +151,16 @@ public class Ceb511SendDateRequest implements CebReqSendDate{
|
|
} else if (CcnetContants.wsFlag.item_10.getItem().equals(wsFlag)) {
|
|
} else if (CcnetContants.wsFlag.item_10.getItem().equals(wsFlag)) {
|
|
url = cus.getWaybill().get("shop-url");
|
|
url = cus.getWaybill().get("shop-url");
|
|
}
|
|
}
|
|
|
|
+
|
|
Request request = OkHttpUtils.buildRequest(url, JacksonUtil.toJson(sPara));
|
|
Request request = OkHttpUtils.buildRequest(url, JacksonUtil.toJson(sPara));
|
|
- LOGGER.info("oms的请求报文:" + request);
|
|
|
|
|
|
+ LOGGER.info("请求 OMS 下单地址 => 【{}】, 请求报文 => {}", url, JacksonUtil.toJson(sPara));
|
|
|
|
+
|
|
// 同步访问,返回结果字符串
|
|
// 同步访问,返回结果字符串
|
|
String response = null;
|
|
String response = null;
|
|
try {
|
|
try {
|
|
response = OkHttpUtils.post(request);
|
|
response = OkHttpUtils.post(request);
|
|
} catch (IOException e) {
|
|
} catch (IOException e) {
|
|
- e.printStackTrace();
|
|
|
|
|
|
+ LOGGER.error("--- 请求 OMS 发生异常: ", e);
|
|
}
|
|
}
|
|
|
|
|
|
return response;
|
|
return response;
|
|
@@ -197,13 +197,10 @@ public class Ceb511SendDateRequest implements CebReqSendDate{
|
|
sParaTemp.put("data",bondedStockMerchantOrderJson);
|
|
sParaTemp.put("data",bondedStockMerchantOrderJson);
|
|
sParaTemp.put("timestamp", timestamp);
|
|
sParaTemp.put("timestamp", timestamp);
|
|
//生成要请求给oms秘钥
|
|
//生成要请求给oms秘钥
|
|
-// String sign = OmsSign.sign(sParaTemp,cus.getWaybill().get("secret-key"));
|
|
|
|
LOGGER.info("md5混淆码参数:" + merchantSecret.getMd5Salt());
|
|
LOGGER.info("md5混淆码参数:" + merchantSecret.getMd5Salt());
|
|
String sign = OmsSign.sign(sParaTemp,merchantSecret.getMd5Salt());
|
|
String sign = OmsSign.sign(sParaTemp,merchantSecret.getMd5Salt());
|
|
sParaTemp.put("sign", sign);
|
|
sParaTemp.put("sign", sign);
|
|
|
|
|
|
-
|
|
|
|
- LOGGER.info("oms的请求报文:merchId参数:" + cusWaybill.getMerchSn()+"sign参数:"+sign+"data参数:"+bondedStockMerchantOrderJson+"timestamp参数:"+timestamp);
|
|
|
|
return sParaTemp;
|
|
return sParaTemp;
|
|
}
|
|
}
|
|
|
|
|