From 912f0e32818bd1b62e783b234e5371ebb89f3856 Mon Sep 17 00:00:00 2001 From: yuanye <418471657@qq.com> Date: Fri, 24 May 2024 17:21:05 +0800 Subject: [PATCH] Changes --- .../business/BsOrderGoodsController.java | 13 ++++++++- .../service/goods/BsOrderGoodsService.java | 10 +++---- .../goods/impl/BsOrderGoodsServiceImpl.java | 27 ++++++------------- 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/order/src/main/java/com/order/controller/business/BsOrderGoodsController.java b/order/src/main/java/com/order/controller/business/BsOrderGoodsController.java index b75bd16..4e7c56c 100644 --- a/order/src/main/java/com/order/controller/business/BsOrderGoodsController.java +++ b/order/src/main/java/com/order/controller/business/BsOrderGoodsController.java @@ -9,6 +9,7 @@ import com.hfkj.common.exception.ErrorHelp; import com.hfkj.common.exception.SysCode; import com.hfkj.common.security.SessionObject; import com.hfkj.common.security.UserCenter; +import com.hfkj.common.utils.OrderUtil; import com.hfkj.common.utils.ResponseMsgUtil; import com.hfkj.entity.BsOrderGoods; import com.hfkj.entity.GoodsLogistics; @@ -145,7 +146,17 @@ public class BsOrderGoodsController { public ResponseData getLogisticsMsg(@RequestParam(value = "id" , required = false) Long id) { try { Map map = new HashMap<>(); - GoodsLogistics logistics = (GoodsLogistics) bsOrderGoodsService.getLogisticsMsg(id); + + BsOrderGoods orderGoods = bsOrderGoodsService.queryDetail(id); + if (orderGoods == null || orderGoods.getLogisticsNo() == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "暂未发货!"); + } + + GoodsLogistics logistics = (GoodsLogistics) bsOrderGoodsService.getLogisticsMsg(orderGoods.getLogisticsNo()); + + orderGoods.setLogisticsStatus(logistics.getLogisticsStatus()); + orderGoods.setLogisticsStatusDesc(logistics.getLogisticsStatusDesc()); + bsOrderGoodsService.update(orderGoods); map.put("logistics", logistics); JSONArray object = JSONArray.parseArray(logistics.getLogisticsTraceDetails()); diff --git a/service/src/main/java/com/hfkj/service/goods/BsOrderGoodsService.java b/service/src/main/java/com/hfkj/service/goods/BsOrderGoodsService.java index 9c36f58..26c5cef 100644 --- a/service/src/main/java/com/hfkj/service/goods/BsOrderGoodsService.java +++ b/service/src/main/java/com/hfkj/service/goods/BsOrderGoodsService.java @@ -118,22 +118,22 @@ public interface BsOrderGoodsService { * @Param [num] * @Return com.alibaba.fastjson.JSONObject */ - Object getLogisticsMsg(Long orderGoodsId); + Object getLogisticsMsg(String logisticsNo); /** * 更新缓存 - * @param orderGoodsId + * @param logisticsNo * @param logistics * @return */ - GoodsLogistics cache(Long orderGoodsId , GoodsLogistics logistics); + GoodsLogistics cache(String logisticsNo , GoodsLogistics logistics); /** * 删除缓存 - * @param orderGoodsId + * @param logisticsNo * @return */ - void cacheDelete(Long orderGoodsId); + void cacheDelete(String logisticsNo); /** * @Author Sum1Dream diff --git a/service/src/main/java/com/hfkj/service/goods/impl/BsOrderGoodsServiceImpl.java b/service/src/main/java/com/hfkj/service/goods/impl/BsOrderGoodsServiceImpl.java index c1af2e4..a4a68b2 100644 --- a/service/src/main/java/com/hfkj/service/goods/impl/BsOrderGoodsServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/goods/impl/BsOrderGoodsServiceImpl.java @@ -213,27 +213,16 @@ public class BsOrderGoodsServiceImpl implements BsOrderGoodsService { } @Override - public Object getLogisticsMsg(Long orderGoodsId) { - Object data = redisUtil.get(CACHE_KEY + orderGoodsId); + public Object getLogisticsMsg(String logisticsNo) { + Object data = redisUtil.get(CACHE_KEY + logisticsNo); if (data == null) { - BsOrderGoods orderGoods = queryDetail(orderGoodsId); - if (orderGoods == null || orderGoods.getLogisticsNo() == null) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "暂未发货!"); - } - - JSONObject jsonObjects = OrderUtil.getLogisticsMsg(orderGoods.getLogisticsNo()); - + JSONObject jsonObjects = OrderUtil.getLogisticsMsg(logisticsNo); if (jsonObjects == null) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "暂未发货!"); } - redisUtil.set(CACHE_KEY + orderGoods.getLogisticsNo(), jsonObjects, CACHE_TIME); if (jsonObjects.getInteger("code") == 200 && jsonObjects.getBoolean("success")) { - jsonObjects.getJSONObject("data").put("orderId" , orderGoodsId); GoodsLogistics logistics = editLogistics((JSONObject) jsonObjects.get("data")); - orderGoods.setLogisticsStatus(logistics.getLogisticsStatus()); - orderGoods.setLogisticsStatusDesc(logistics.getLogisticsStatusDesc()); - update(orderGoods); - return cache(orderGoodsId , logistics); + return cache(logisticsNo , logistics); } return jsonObjects; } else { @@ -242,16 +231,16 @@ public class BsOrderGoodsServiceImpl implements BsOrderGoodsService { } @Override - public GoodsLogistics cache(Long orderGoodsId , GoodsLogistics logistics) { + public GoodsLogistics cache(String getLogisticsNo , GoodsLogistics logistics) { // 缓存 - redisUtil.set(CACHE_KEY + orderGoodsId, logistics, CACHE_TIME); + redisUtil.set(CACHE_KEY + getLogisticsNo, logistics, CACHE_TIME); return logistics; } @Override - public void cacheDelete(Long orderGoodsId) { + public void cacheDelete(String getLogisticsNo) { // 缓存 - redisUtil.del(CACHE_KEY + orderGoodsId); + redisUtil.del(CACHE_KEY + getLogisticsNo); } @Override