Browse Source

【深爱-物流-创建订单】

DINGYL 11 months ago
parent
commit
82b0ec023c

+ 0 - 17
src/main/java/com/uas/eis/controller/ERPController.java

@@ -20,23 +20,6 @@ public class ERPController {
     @Autowired
     private ERPService erpService;
 
-    /**
-     * 创建顺丰订单
-     */
-    @RequestMapping(value="/erp/creatSFOrder",method=RequestMethod.POST)
-    @ResponseBody
-    public Map<String, Object> creatSFOrder(String master, Integer id,String emCode){
-        return erpService.creatSFOrder(master,id,emCode);
-    }
-
-    /**
-     * 取消顺丰订单
-     */
-    @RequestMapping(value="/erp/cancelSFOrder",method=RequestMethod.POST)
-    @ResponseBody
-    public Map<String, Object> cancelSFOrder(String master, Integer id,String emCode){
-        return erpService.cancelSFOrder(master,id,emCode);
-    }
 
     @RequestMapping(value="/erp/getLogisticsPrice")
     @ResponseBody

+ 61 - 7
src/main/java/com/uas/eis/service/Impl/ERPServiceImpl.java

@@ -698,26 +698,26 @@ public class ERPServiceImpl implements ERPService {
                                     retMap.put("message","取消失败:["+sfOrderResp.getResStatus()+"]");
                                 }
                                 retMap.put("success",false);
-                                logger.info("creatSFOrder-F: id {} err {}",logisticsPrice.getLp_Id(),retMap.get("message"));
+                                logger.info("cancelSFOrder-F: id {} err {}",logisticsPrice.getLp_Id(),retMap.get("message"));
                                 return retMap;
                             }
                         }else {
                             retMap.put("success",false);
                             retMap.put("message","取消失败:["+sfApiRespData.getErrorCode()+"]"+sfApiRespData.getErrorMsg());
-                            logger.info("creatSFOrder-F: id {} err {}",logisticsPrice.getLp_Id(),retMap.get("message"));
+                            logger.info("cancelSFOrder-F: id {} err {}",logisticsPrice.getLp_Id(),retMap.get("message"));
                             return retMap;
                         }
                     }else {
                         retMap.put("message","取消失败:["+sfApiResp.getApiResultCode()+"]"+sfApiResp.getApiErrorMsg());
                         retMap.put("success",false);
-                        logger.info("creatSFOrder-F: id {} err {}",logisticsPrice.getLp_Id(),retMap.get("message"));
+                        logger.info("cancelSFOrder-F: id {} err {}",logisticsPrice.getLp_Id(),retMap.get("message"));
                         return retMap;
                     }
                 }
             }catch (Exception e){
                 e.printStackTrace();
                 retMap.put("message","取消失败"+(StringUtil.nvl(e.getMessage(),"")));   retMap.put("success",false);
-                logger.info("creatSFOrder-F: id {} err {}",logisticsPrice.getLp_Id(),retMap.get("message"));
+                logger.info("cancelSFOrder-F: id {} err {}",logisticsPrice.getLp_Id(),retMap.get("message"));
                 return retMap;
             }
         }else {
@@ -827,7 +827,6 @@ public class ERPServiceImpl implements ERPService {
         infoItems.add(orderInfoItem);
         orderInfo.setRepeatCheck("10");
         orderInfo.setOrderInfos(infoItems);
-        boolean suc = true;
         boolean isSandbox = true;
         String method="open.api.openCommon.batchOrder";
         String bizBody =JSONArray.toJSONString(orderInfo);
@@ -881,9 +880,60 @@ public class ERPServiceImpl implements ERPService {
         }
         return modelMap;
     }
-    private Map<String, Object> cancelOrder_KY(LogisticsPrice logisticsPrice){
+    private Map<String, Object> cancelOrder_KY(LogisticsPrice logisticsPrice) throws IOException{
         Map<String, Object> modelMap = new HashMap<String, Object>();
         logger.info("cancelKYOrder-Begin");
+        Object[] obs = baseDao.getFieldsDataByCondition("SZSI_P.DOCK_LOGISTICS_CONFIG A "
+                , new String[]{"CALL_URL","CLIENT_CODE","CHECK_WORD","ENABLE_"}, "LOGISTICS_='KYTEST' and type_='CREATEORDER' AND A.ENABLE_ = 1");
+        String appkey="83955";//obs[1].toString();
+        String appSecret = obs[2].toString();//"46129BED8B381806B1FE15562523E2E0";
+        boolean isSandbox = true;
+        String method="open.api.openCommon.batchCancelOrder";
+        String customerCode=obs[1].toString();
+        List<String> waybillNumbers=new ArrayList();
+        waybillNumbers.add(logisticsPrice.getLp_TrackingNumber());
+        Map<String,Object> msgDataMap = new HashMap<>();
+        msgDataMap.put("customerCode",customerCode);
+        msgDataMap.put("waybillNumbers",waybillNumbers);
+        String bizBody =JSONArray.toJSONString(msgDataMap);
+        String response = null;
+        System.out.println("appkey:"+appkey);
+        System.out.println("appSecret:"+appSecret);
+        try {
+            response = KyeDefaultOpenApi.builder
+                            (appkey, appSecret) //应用Key,密钥
+                    .env("prod") //对应环境,包含(uat:测试环境,prod:生产环境),获取对应环境的请求路径
+                    .api(method) //所调用Api Code
+                    .sandbox(isSandbox)//是否沙盒环境(env=prod且isSandbox=true时对应的就是跨越测试环境)
+                    .body(bizBody) //请求体参数,可接受字符串,List,Map三种类型的参数
+                    .connectTimeout(3000) //连接超时时间
+                    .readTimeout(15000) //读取超时时间
+                    .request()
+                    .response();
+        } catch (KyeOpenApiException e) {
+            throw new RuntimeException(e);
+        }
+        logger.info("cancelKYOrder:id {} res {}",logisticsPrice.getLp_Id(),response);
+        Map<Object, Object> res  = BaseUtil.parseFormStoreToMap(response);
+        if(Boolean.valueOf(res.get("success").toString())){
+            if("10000".equals(res.get("code"))){//10000:成功 非10000:失败失败
+                modelMap.put("success",true);
+                logger.info("cancelKYOrder-S:id {} ",logisticsPrice.getLp_Id(),logisticsPrice.getLp_TrackingNumber());
+                return modelMap;
+            }else{
+                modelMap.put("message","取消失败:"+res.get("code"));
+                modelMap.put("success",false);
+                logger.info("cancelKYOrder-F:id {} err {}",logisticsPrice.getLp_Id(),modelMap.get("message"));
+            }
+        }else{
+            modelMap.put("success",false);
+            if(StringUtil.hasText(res.get("msg"))) {
+                Object put = modelMap.put("message", "创建失败:" + res.get("msg").toString());
+            }
+            logger.info("cancelKYOrder-F:id {} err {}",logisticsPrice.getLp_Id(),modelMap.get("message"));
+            return modelMap;
+        }
+        modelMap.put("success",true);
         return modelMap;
     }
     @Override
@@ -922,7 +972,11 @@ public class ERPServiceImpl implements ERPService {
             }else if("德邦".equals(logisticsPrice.getLp_FinalCompany())){
                 modelMap=cancelOrder_DoP(logisticsPrice);
             }else if("跨越".equals(logisticsPrice.getLp_FinalCompany())){
-                modelMap=cancelOrder_KY(logisticsPrice);
+                try {
+                    modelMap=cancelOrder_KY(logisticsPrice);
+                } catch (IOException e) {
+                    throw new RuntimeException(e);
+                }
             }
             return modelMap;
         }else{

+ 17 - 1
src/test/java/com/uas/eis/UasEisApplicationTests.java

@@ -56,7 +56,7 @@ public class UasEisApplicationTests {
 
 	@Test
 	public void TestCancelOrder(){
-		erpService.cancelOrder("SZSI_P",3268);//3267
+		erpService.cancelOrder("SZSI_P",3283);//3267
 	}
 	@Test
 	public void Test() throws UnsupportedEncodingException {
@@ -143,4 +143,20 @@ public class UasEisApplicationTests {
 		}*/
 
 	}
+	@Test
+	public void Test1(){
+		String response="res {\"code\":10000,\"msg\":\"取消订单成功\",\"data\":1,\"traceId\":\"39f6713ae0e04b28007b4655122eb5e1\",\"success\":true}";
+		Map<Object, Object> res  = BaseUtil.parseFormStoreToMap(response);
+		if(Boolean.valueOf(res.get("success").toString())){
+			if("10000".equals(res.get("code"))){//10000:成功 非10000:失败失败
+				System.out.println("true");
+			}else{
+				System.out.println("false");
+				System.out.println(res.get("code"));
+			}
+		}else{
+			System.out.println("false");
+			System.out.println(res.get("code"));
+		}
+	}
 }