|
|
@@ -186,17 +186,18 @@ public class SaleOutServiceImpl implements SaleOutService {
|
|
|
Map<String, Object> order = orderRowList.getResultList().get(i);
|
|
|
String ordercode = order.get("pd_ordercode").toString();
|
|
|
String tbopenuid = order.get("sa_tbopenuid").toString();
|
|
|
- order.put("pi_logisticscode",piMsg.getGeneralString("pi_logisticscode"));
|
|
|
- order.put("cop_code",StringUtil.nvl(piMsg.getGeneralString("cop_code"),"OTHER"));
|
|
|
- order.put("pi_logisticscompany",piMsg.getGeneralString("pi_logisticscompany"));
|
|
|
order.put("piid",id);
|
|
|
order.put("piinoutno",piMsg.getGeneralString("pi_inoutno"));
|
|
|
order.put("sessionKey",sessionMap.get(tbopenuid));
|
|
|
order.put("oids",order.get("oids").toString());
|
|
|
order.put("emCode",emCode);
|
|
|
- Map<String, Object> sendRes = consign_resend(order);
|
|
|
- if(!(Boolean) sendRes.get("success")){
|
|
|
- errorMsg.append("订单号:").append(ordercode).append(",失败原因: ").append(sendRes.get("message"));
|
|
|
+ SqlRowList sendCodeList = baseDao.queryForRowSet("SELECT nvl(cop_code,'OTHER') cop_code,pi_logisticscompany,pi_logisticscode FROM PRODIODETAIL LEFT JOIN PRODINOUT ON PI_ID = PD_PIID LEFT JOIN tb_logistics ON COP_NAME = pi_logisticscompany " +
|
|
|
+ " WHERE PD_PICLASS='出货单' AND PD_ORDERCODE='"+ordercode+"' AND PD_STATUS = 99 GROUP BY cop_code,pi_logisticscompany,pi_logisticscode");
|
|
|
+ if(sendCodeList.hasNext()){
|
|
|
+ Map<String, Object> sendRes = consign_resend(order,sendCodeList.getResultList());
|
|
|
+ if(!(Boolean) sendRes.get("success")){
|
|
|
+ errorMsg.append("订单号:").append(ordercode).append(",失败原因: ").append(sendRes.get("message"));
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}else {
|
|
|
@@ -290,16 +291,13 @@ public class SaleOutServiceImpl implements SaleOutService {
|
|
|
* alibaba.ascp.logistics.consign.resend( 修改物流公司和运单号 )
|
|
|
* https://open.taobao.com/api.htm?docId=54935&docType=2&scopeId=23401
|
|
|
*/
|
|
|
- private Map<String,Object>consign_resend(Map<String, Object> order) {
|
|
|
+ private Map<String,Object>consign_resend(Map<String, Object> order,List<Map<String, Object>> sendList) {
|
|
|
Map<String, Object> resMap = new HashMap<>();
|
|
|
resMap.put("success", true);
|
|
|
String ordercode = order.get("pd_ordercode").toString();
|
|
|
Integer piid=Integer.valueOf(order.get("piid").toString());
|
|
|
String piinoutno = order.get("piinoutno").toString();
|
|
|
String sessionKey = order.get("sessionKey").toString();
|
|
|
- String cop_code = order.get("cop_code").toString();
|
|
|
- String pi_logisticscompany = order.get("pi_logisticscompany").toString();
|
|
|
- String outSid = order.get("pi_logisticscode").toString();
|
|
|
String emCode = order.get("emCode").toString();
|
|
|
|
|
|
TaobaoClient client = new DefaultTaobaoClient(taoBaoConfig.getServerUrl(), taoBaoConfig.getAppKey(), taoBaoConfig.getAppSecret());
|
|
|
@@ -307,10 +305,14 @@ public class SaleOutServiceImpl implements SaleOutService {
|
|
|
req.setTid(ordercode);
|
|
|
req.setSubTids(order.get("oids").toString());
|
|
|
List<AlibabaAscpLogisticsConsignResendRequest.TopConsignPkgRequest> consign_pkgs = new ArrayList<AlibabaAscpLogisticsConsignResendRequest.TopConsignPkgRequest>();
|
|
|
- AlibabaAscpLogisticsConsignResendRequest.TopConsignPkgRequest consign_pkg = new AlibabaAscpLogisticsConsignResendRequest.TopConsignPkgRequest();
|
|
|
- consign_pkg.setCompanyCode(cop_code);//物流公司代码.如"POST"代表中国邮政,"ZJS"代表宅急送。调用 taobao.logistics.companies.get 获取
|
|
|
- consign_pkg.setOutSid(outSid);//运单号.具体一个物流公司的真实运单号码。淘宝官方物流会校验,请谨慎传入
|
|
|
- consign_pkgs.add(consign_pkg);
|
|
|
+ StringBuffer sendMsg = new StringBuffer();
|
|
|
+ for (int i = 0; i < sendList.size(); i++) {
|
|
|
+ AlibabaAscpLogisticsConsignResendRequest.TopConsignPkgRequest consign_pkg = new AlibabaAscpLogisticsConsignResendRequest.TopConsignPkgRequest();
|
|
|
+ consign_pkg.setCompanyCode(sendList.get(i).get("cop_code").toString());//物流公司代码.如"POST"代表中国邮政,"ZJS"代表宅急送。调用 taobao.logistics.companies.get 获取
|
|
|
+ consign_pkg.setOutSid(sendList.get(i).get("pi_logisticscode").toString());//运单号.具体一个物流公司的真实运单号码。淘宝官方物流会校验,请谨慎传入
|
|
|
+ consign_pkgs.add(consign_pkg);
|
|
|
+ sendMsg.append("物流公司:").append( sendList.get(i).get("pi_logisticscompany").toString()).append("(").append(sendList.get(i).get("cop_code").toString()).append(")").append(",物流单号:").append(sendList.get(i).get("pi_logisticscode").toString()).append("</br>");
|
|
|
+ }
|
|
|
req.setConsignPkgs(consign_pkgs);
|
|
|
// req.setFeature("instantMobilePhoneNumber=12345678910");
|
|
|
try {
|
|
|
@@ -318,7 +320,7 @@ public class SaleOutServiceImpl implements SaleOutService {
|
|
|
System.out.println(rsp.getBody());
|
|
|
if(rsp.getResult()!=null&&rsp.getResult().getSuccess()){
|
|
|
baseDao.execute("Insert into MESSAGELOG (ML_ID,ML_DATE,ML_MAN,ML_CONTENT,ML_RESULT,ML_SEARCH,CODE) " +
|
|
|
- " SELECT MESSAGELOG_seq.nextval,sysdate,nVL(EM_NAME,'管理员')||'('||EMCODE||')','变更淘宝物流单号','变更成功,订单号:"+ordercode+",物流公司:"+pi_logisticscompany+",物流单号:"+outSid+"','ProdInOut!Sale|pi_id="+piid+"','"+piinoutno+"'" +
|
|
|
+ " SELECT MESSAGELOG_seq.nextval,sysdate,nVL(EM_NAME,'管理员')||'('||EMCODE||')','变更淘宝物流单号','变更成功,订单号:"+ordercode+","+sendMsg.toString()+"','ProdInOut!Sale|pi_id="+piid+"','"+piinoutno+"'" +
|
|
|
" from (SELECT '"+emCode+"' EMCODE FROM DUAL) LEFT JOIN EMPLOYEE ON EM_CODE = EMCODE ");
|
|
|
}else {
|
|
|
String errMsg = StringUtil.nvl(rsp.getSubCode(),rsp.getErrorCode())+":"+StringUtil.nvl(rsp.getSubMsg(),rsp.getMsg());
|