From ba3c255cbfc3fd6ff0708dca96c9e256c690e370 Mon Sep 17 00:00:00 2001 From: jyy <935090232@qq.com> Date: Tue, 13 Apr 2021 13:28:36 +0800 Subject: [PATCH] 修改订单物流查询信息 --- zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/impl/WxShopLogisticsQueryServiceImpl.java | 144 ++++++++++++++++++++++++------------------------ 1 files changed, 72 insertions(+), 72 deletions(-) diff --git a/zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/impl/WxShopLogisticsQueryServiceImpl.java b/zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/impl/WxShopLogisticsQueryServiceImpl.java index 92cf088..d5fc4b5 100644 --- a/zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/impl/WxShopLogisticsQueryServiceImpl.java +++ b/zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/impl/WxShopLogisticsQueryServiceImpl.java @@ -79,76 +79,72 @@ List<ShopLogisticsInfo> shopLogisticsList = new ArrayList<ShopLogisticsInfo>(); AjaxResult result = new AjaxResult(); Map<String, String> logisticsInfo = new HashMap<String, String>(); - try { - if (shopDeliveryInfo == null) { - return new AjaxResult(AjaxResult.STATUS_FAIL, "找不到发货信息"); - } - if (!StringUtils.isNotBlank(shopDeliveryInfo.getWaybillNo()) || !StringUtils.isNotBlank(shopDeliveryInfo.getLogisticsCompanyCode())) { - return new AjaxResult(AjaxResult.STATUS_FAIL, "物流公司信息为空"); - } - logisticsInfo.put("logisticsCompany", shopDeliveryInfo.getLogisticsCompany()); - logisticsInfo.put("waybillNo", shopDeliveryInfo.getWaybillNo()); - //如果已经签收直接查数据库 - if (AppConstance.LOGISTICS_STATUS_OF_SIGN_FOR.equals(shopDeliveryInfo.getLogisticsStatus())) { - - List<ShopLogisticsInfo> shopLogisticsInfos = shopLogisticsInfoDao.selectByDelieryId(shopDeliveryInfo.getId()); - logisticsInfo.put("logisticsStatus", String.valueOf(AppConstance.LOGISTICS_STATUS_OF_SIGN_FOR)); - result.setStatus(AjaxResult.STATUS_SUCCESS); - result.setRows(shopLogisticsInfos); - result.putInMap("logisticsInfo", logisticsInfo); - return result; - } - Map<String, String> param = new HashMap<String, String>(); - param.put("ShipperCode", shopDeliveryInfo.getLogisticsCompanyCode()); - param.put("LogisticCode", shopDeliveryInfo.getWaybillNo()); - Map<String, String> paramsUrl = getparams(param); - LogUtil.info("物流查询参数" + paramsUrl); - String logisticsResult = HttpCurlUtil.sendPost(logisticsUrl, paramsUrl); - LogUtil.info("查询物流返回信息" + logisticsResult); - LogisticsInfoVo logisticsInfoVo = JSON.parseObject(logisticsResult, LogisticsInfoVo.class); - if (logisticsInfoVo.isSuccess()) { - ShopDeliveryInfo shopDelivery = new ShopDeliveryInfo(); - shopDelivery.setLogisticsStatus(Integer.valueOf(logisticsInfoVo.getState())); - shopDelivery.setId(shopDeliveryInfo.getId()); - logisticsInfo.put("logisticsStatus", logisticsInfoVo.getState()); - //更新物流状态 - shopDeliveryInfoDao.updateByModel(shopDelivery); - if (CollectionUtils.isNotEmpty(logisticsInfoVo.getTraces())) { - List<Map<String, String>> mapTraces = logisticsInfoVo.getTraces(); - for (int i = 0; i < mapTraces.size(); i++) { - ShopLogisticsInfo shopLogisticsInfo = new ShopLogisticsInfo(); - shopLogisticsInfo.setCreateBy(AppConstance.SYSTEM_USER); - shopLogisticsInfo.setUpdateBy(AppConstance.SYSTEM_USER); - shopLogisticsInfo.setLogisticsTime(mapTraces.get(i).get("AcceptTime")); - String acceptStation = mapTraces.get(i).get("AcceptStation"); - shopLogisticsInfo.setDescribe(acceptStation); - shopLogisticsInfo.setDelieryId(shopDeliveryInfo.getId()); - if (acceptStation.indexOf(AppConstance.KDN_IS_SIGN) != -1) { - shopLogisticsInfo.setState(AppConstance.LOGISTICS_STATUS_OF_SIGN_FOR); - } else if (acceptStation.indexOf(AppConstance.KDN_IS_RECEIVE) != -1) { - shopLogisticsInfo.setState(AppConstance.LOGISTICS_STATUS_OF_RECEIVE); - } else if (acceptStation.indexOf(AppConstance.KDN_IS_ON_WAY) != -1) { - shopLogisticsInfo.setState(AppConstance.LOGISTICS_STATUS_OF_ON_WAY); - } else if (acceptStation.indexOf(AppConstance.KDN_IS_MISTAKE) != -1) { - shopLogisticsInfo.setState(AppConstance.LOGISTICS_STATUS_OF_MISTAKE); - } else { - shopLogisticsInfo.setState(AppConstance.LOGISTICS_STATUS_OF_NONE); - } - shopLogisticsList.add(shopLogisticsInfo); - } - shopLogisticsInfoDao.deleteByDelieryId(shopDeliveryInfo.getId()); - if (CollectionUtils.isNotEmpty(shopLogisticsList)) { - shopLogisticsInfoDao.batchInsert(shopLogisticsList); - } - } - } else { - throw new GlobleException(logisticsInfoVo.getReason()); - } - - } catch (Exception e) { - throw new GlobleException("物流信息查询失败"); + if (shopDeliveryInfo == null) { + return new AjaxResult(AjaxResult.STATUS_FAIL, "找不到发货信息"); } + if (!StringUtils.isNotBlank(shopDeliveryInfo.getWaybillNo()) || !StringUtils.isNotBlank(shopDeliveryInfo.getLogisticsCompanyCode())) { + return new AjaxResult(AjaxResult.STATUS_FAIL, "物流公司信息为空"); + } + logisticsInfo.put("logisticsCompany", shopDeliveryInfo.getLogisticsCompany()); + logisticsInfo.put("waybillNo", shopDeliveryInfo.getWaybillNo()); + + //如果已经签收直接查数据库 + if (AppConstance.LOGISTICS_STATUS_OF_SIGN_FOR.equals(shopDeliveryInfo.getLogisticsStatus())) { + + List<ShopLogisticsInfo> shopLogisticsInfos = shopLogisticsInfoDao.selectByDelieryId(shopDeliveryInfo.getId()); + logisticsInfo.put("logisticsStatus", String.valueOf(AppConstance.LOGISTICS_STATUS_OF_SIGN_FOR)); + result.setStatus(AjaxResult.STATUS_SUCCESS); + result.setRows(shopLogisticsInfos); + result.putInMap("logisticsInfo", logisticsInfo); + return result; + } + Map<String, String> param = new HashMap<String, String>(); + param.put("ShipperCode", shopDeliveryInfo.getLogisticsCompanyCode()); + param.put("LogisticCode", shopDeliveryInfo.getWaybillNo()); + Map<String, String> paramsUrl = getparams(param); + LogUtil.info("物流查询参数" + paramsUrl); + String logisticsResult = HttpCurlUtil.sendPost(logisticsUrl, paramsUrl); + LogUtil.info("查询物流返回信息" + logisticsResult); + LogisticsInfoVo logisticsInfoVo = JSON.parseObject(logisticsResult, LogisticsInfoVo.class); + if (logisticsInfoVo.isSuccess()) { + ShopDeliveryInfo shopDelivery = new ShopDeliveryInfo(); + shopDelivery.setLogisticsStatus(Integer.valueOf(logisticsInfoVo.getState())); + shopDelivery.setId(shopDeliveryInfo.getId()); + logisticsInfo.put("logisticsStatus", logisticsInfoVo.getState()); + //更新物流状态 + shopDeliveryInfoDao.updateByModel(shopDelivery); + if (CollectionUtils.isNotEmpty(logisticsInfoVo.getTraces())) { + List<Map<String, String>> mapTraces = logisticsInfoVo.getTraces(); + for (int i = 0; i < mapTraces.size(); i++) { + ShopLogisticsInfo shopLogisticsInfo = new ShopLogisticsInfo(); + shopLogisticsInfo.setCreateBy(AppConstance.SYSTEM_USER); + shopLogisticsInfo.setUpdateBy(AppConstance.SYSTEM_USER); + shopLogisticsInfo.setLogisticsTime(mapTraces.get(i).get("AcceptTime")); + String acceptStation = mapTraces.get(i).get("AcceptStation"); + shopLogisticsInfo.setDescribe(acceptStation); + shopLogisticsInfo.setDelieryId(shopDeliveryInfo.getId()); + if (acceptStation.indexOf(AppConstance.KDN_IS_SIGN) != -1) { + shopLogisticsInfo.setState(AppConstance.LOGISTICS_STATUS_OF_SIGN_FOR); + } else if (acceptStation.indexOf(AppConstance.KDN_IS_RECEIVE) != -1) { + shopLogisticsInfo.setState(AppConstance.LOGISTICS_STATUS_OF_RECEIVE); + } else if (acceptStation.indexOf(AppConstance.KDN_IS_ON_WAY) != -1) { + shopLogisticsInfo.setState(AppConstance.LOGISTICS_STATUS_OF_ON_WAY); + } else if (acceptStation.indexOf(AppConstance.KDN_IS_MISTAKE) != -1) { + shopLogisticsInfo.setState(AppConstance.LOGISTICS_STATUS_OF_MISTAKE); + } else { + shopLogisticsInfo.setState(AppConstance.LOGISTICS_STATUS_OF_NONE); + } + shopLogisticsList.add(shopLogisticsInfo); + } + shopLogisticsInfoDao.deleteByDelieryId(shopDeliveryInfo.getId()); + if (CollectionUtils.isNotEmpty(shopLogisticsList)) { + shopLogisticsInfoDao.batchInsert(shopLogisticsList); + } + } + } + + List<ShopLogisticsInfo> shopLogisticsInfos = shopLogisticsInfoDao.selectByDelieryId(shopDeliveryInfo.getId()); result.setStatus(AjaxResult.STATUS_SUCCESS); result.setRows(shopLogisticsInfos); @@ -187,14 +183,18 @@ * @param map * @return */ - private Map<String, String> getparams(Map<String, String> map) throws Exception { + private Map<String, String> getparams(Map<String, String> map) { String params = JSON.toJSONString(map); Map<String, String> paramsUrl = new HashMap<String, String>(); - paramsUrl.put("RequestData", URLEncoder.encode(params, "UTF-8")); + try { + paramsUrl.put("RequestData", URLEncoder.encode(params, "UTF-8")); + String dataSign = encrypt(params, appKey, "UTF-8"); + paramsUrl.put("DataSign", URLEncoder.encode(dataSign, "UTF-8")); + } catch (Exception e) { + throw new GlobleException(e.getMessage()); + } paramsUrl.put("EBusinessID", eBusinessID); paramsUrl.put("RequestType", requestType); - String dataSign = encrypt(params, appKey, "UTF-8"); - paramsUrl.put("DataSign", URLEncoder.encode(dataSign, "UTF-8")); paramsUrl.put("DataType", AppConstance.DATATYPE); return paramsUrl; } -- Gitblit v1.9.1