master
袁野 6 months ago
parent 01e95ba5fb
commit 25e16aba27
  1. 13
      order/src/main/java/com/order/controller/business/BsOrderGoodsController.java
  2. 10
      service/src/main/java/com/hfkj/service/goods/BsOrderGoodsService.java
  3. 27
      service/src/main/java/com/hfkj/service/goods/impl/BsOrderGoodsServiceImpl.java

@ -9,6 +9,7 @@ import com.hfkj.common.exception.ErrorHelp;
import com.hfkj.common.exception.SysCode; import com.hfkj.common.exception.SysCode;
import com.hfkj.common.security.SessionObject; import com.hfkj.common.security.SessionObject;
import com.hfkj.common.security.UserCenter; import com.hfkj.common.security.UserCenter;
import com.hfkj.common.utils.OrderUtil;
import com.hfkj.common.utils.ResponseMsgUtil; import com.hfkj.common.utils.ResponseMsgUtil;
import com.hfkj.entity.BsOrderGoods; import com.hfkj.entity.BsOrderGoods;
import com.hfkj.entity.GoodsLogistics; import com.hfkj.entity.GoodsLogistics;
@ -145,7 +146,17 @@ public class BsOrderGoodsController {
public ResponseData getLogisticsMsg(@RequestParam(value = "id" , required = false) Long id) { public ResponseData getLogisticsMsg(@RequestParam(value = "id" , required = false) Long id) {
try { try {
Map<String , Object> map = new HashMap<>(); Map<String , Object> 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); map.put("logistics", logistics);
JSONArray object = JSONArray.parseArray(logistics.getLogisticsTraceDetails()); JSONArray object = JSONArray.parseArray(logistics.getLogisticsTraceDetails());

@ -118,22 +118,22 @@ public interface BsOrderGoodsService {
* @Param [num] * @Param [num]
* @Return com.alibaba.fastjson.JSONObject * @Return com.alibaba.fastjson.JSONObject
*/ */
Object getLogisticsMsg(Long orderGoodsId); Object getLogisticsMsg(String logisticsNo);
/** /**
* 更新缓存 * 更新缓存
* @param orderGoodsId * @param logisticsNo
* @param logistics * @param logistics
* @return * @return
*/ */
GoodsLogistics cache(Long orderGoodsId , GoodsLogistics logistics); GoodsLogistics cache(String logisticsNo , GoodsLogistics logistics);
/** /**
* 删除缓存 * 删除缓存
* @param orderGoodsId * @param logisticsNo
* @return * @return
*/ */
void cacheDelete(Long orderGoodsId); void cacheDelete(String logisticsNo);
/** /**
* @Author Sum1Dream * @Author Sum1Dream

@ -213,27 +213,16 @@ public class BsOrderGoodsServiceImpl implements BsOrderGoodsService {
} }
@Override @Override
public Object getLogisticsMsg(Long orderGoodsId) { public Object getLogisticsMsg(String logisticsNo) {
Object data = redisUtil.get(CACHE_KEY + orderGoodsId); Object data = redisUtil.get(CACHE_KEY + logisticsNo);
if (data == null) { if (data == null) {
BsOrderGoods orderGoods = queryDetail(orderGoodsId); JSONObject jsonObjects = OrderUtil.getLogisticsMsg(logisticsNo);
if (orderGoods == null || orderGoods.getLogisticsNo() == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "暂未发货!");
}
JSONObject jsonObjects = OrderUtil.getLogisticsMsg(orderGoods.getLogisticsNo());
if (jsonObjects == null) { if (jsonObjects == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "暂未发货!"); 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")) { if (jsonObjects.getInteger("code") == 200 && jsonObjects.getBoolean("success")) {
jsonObjects.getJSONObject("data").put("orderId" , orderGoodsId);
GoodsLogistics logistics = editLogistics((JSONObject) jsonObjects.get("data")); GoodsLogistics logistics = editLogistics((JSONObject) jsonObjects.get("data"));
orderGoods.setLogisticsStatus(logistics.getLogisticsStatus()); return cache(logisticsNo , logistics);
orderGoods.setLogisticsStatusDesc(logistics.getLogisticsStatusDesc());
update(orderGoods);
return cache(orderGoodsId , logistics);
} }
return jsonObjects; return jsonObjects;
} else { } else {
@ -242,16 +231,16 @@ public class BsOrderGoodsServiceImpl implements BsOrderGoodsService {
} }
@Override @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; return logistics;
} }
@Override @Override
public void cacheDelete(Long orderGoodsId) { public void cacheDelete(String getLogisticsNo) {
// 缓存 // 缓存
redisUtil.del(CACHE_KEY + orderGoodsId); redisUtil.del(CACHE_KEY + getLogisticsNo);
} }
@Override @Override

Loading…
Cancel
Save