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.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<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);
JSONArray object = JSONArray.parseArray(logistics.getLogisticsTraceDetails());

@ -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

@ -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

Loading…
Cancel
Save