fix: 茅台预约商品,修复刷新预约商品bug。

This commit is contained in:
tianyongbao
2024-12-13 19:27:43 +08:00
parent 25db2f530d
commit c4a45c72f8

View File

@@ -153,7 +153,7 @@ public class IShopServiceImpl implements IShopService {
}
@Override
public String getCurrentSessionId() {
String mtSessionId = Convert.toStr(redisCache.getCacheObject(IMTCacheConstants.MT_SESSION_ID));
@@ -170,7 +170,24 @@ public class IShopServiceImpl implements IShopService {
JSONObject data = jsonObject.getJSONObject("data");
mtSessionId = data.getString("sessionId");
redisCache.setCacheObject(IMTCacheConstants.MT_SESSION_ID, mtSessionId, 2, TimeUnit.HOURS);
}
return mtSessionId;
}
@Override
public void refreshItem() {
redisCache.deleteObject(IMTCacheConstants.MT_SESSION_ID);
long dayTime = LocalDate.now().atStartOfDay().toInstant(ZoneOffset.of("+8")).toEpochMilli();
String res = HttpUtil.get("https://static.moutai519.com.cn/mt-backend/xhr/front/mall/index/session/get/" + dayTime);
//替换 current_session_id 673 ['data']['sessionId']
JSONObject jsonObject = JSONObject.parseObject(res);
if (jsonObject.getString("code").equals("2000")) {
JSONObject data = jsonObject.getJSONObject("data");
redisCache.setCacheObject(IMTCacheConstants.MT_SESSION_ID, data.getString("sessionId"), 2, TimeUnit.HOURS);
iItemMapper.truncateItem();
//item插入数据库
JSONArray itemList = data.getJSONArray("itemList");
@@ -182,15 +199,6 @@ public class IShopServiceImpl implements IShopService {
}
}
return mtSessionId;
}
@Override
public void refreshItem() {
redisCache.deleteObject(IMTCacheConstants.MT_SESSION_ID);
getCurrentSessionId();
}
@Override