From bbe0a2fd03063316e50cf141986bda984599bbda Mon Sep 17 00:00:00 2001 From: 935090232@qq.com <ak473600000> Date: Tue, 22 Feb 2022 23:41:42 +0800 Subject: [PATCH] Merge branch 'developer' --- zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/impl/WxShopLogisticsQueryServiceImpl.java | 153 +++++++++++++++++++++++++-------------------------- 1 files changed, 75 insertions(+), 78 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 c5c1514..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 @@ -1,20 +1,18 @@ package com.matrix.system.shopXcx.api.service.impl; import com.alibaba.fastjson.JSON; -import com.matrix.core.constance.SystemErrorCode; +import com.matrix.component.tools.HttpCurlUtil; import com.matrix.core.exception.GlobleException; import com.matrix.core.pojo.AjaxResult; import com.matrix.core.tools.LogUtil; import com.matrix.core.tools.StringUtils; import com.matrix.system.common.constance.AppConstance; +import com.matrix.system.shopXcx.api.service.WxShopLogisticsQueryService; +import com.matrix.system.shopXcx.api.vo.LogisticsInfoVo; import com.matrix.system.shopXcx.bean.ShopDeliveryInfo; import com.matrix.system.shopXcx.bean.ShopLogisticsInfo; import com.matrix.system.shopXcx.dao.ShopDeliveryInfoDao; import com.matrix.system.shopXcx.dao.ShopLogisticsInfoDao; -import com.matrix.component.tools.HttpCurlUtil; -import com.matrix.system.shopXcx.api.service.WxShopLogisticsQueryService; -import com.matrix.system.shopXcx.api.vo.LogisticsInfoVo; -import com.matrix.system.shopXcx.api.vo.SfLogisticsInfoVo; import org.apache.commons.collections.CollectionUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; @@ -81,77 +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(SystemErrorCode.REQUEST_INVALID, logisticsInfoVo.getReason()); - } - - } catch (Exception e) { - LogUtil.error("物流信息查询失败", e); - throw new GlobleException(SystemErrorCode.REQUEST_INVALID); + 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); @@ -190,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