change-name: Country => CountryCode
feat:优化订单类型名称缓存逻辑
This commit is contained in:
parent
ccc300bd56
commit
b39de2a613
@ -5,7 +5,7 @@ public class AreaCacheEntry
|
||||
/// <summary>
|
||||
/// 国家或地区
|
||||
/// </summary>
|
||||
public string Country { get; set; } = null!;
|
||||
public string CountryCode { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// 省份
|
||||
|
||||
@ -180,7 +180,7 @@ public class ForewarningCacheService : IForewarningCacheService, ISingletonDepen
|
||||
{
|
||||
return new AreaCacheEntry
|
||||
{
|
||||
Country = model.Country,
|
||||
CountryCode = model.CountryCode,
|
||||
Province = model.Province,
|
||||
City = model.City,
|
||||
LeftPostcode = model.LeftPostcode,
|
||||
|
||||
@ -322,7 +322,7 @@ public class ForewarningNotifyService : IForewarningNotifyService, ITransientDep
|
||||
if (!rule.Areas.IsNullOrEmpty())
|
||||
{
|
||||
var inArea = false;
|
||||
var areas = rule.Areas!.Where(area => order.ArrivalCountry == area.Country).ToList();
|
||||
var areas = rule.Areas!.Where(area => order.ArrivalCountry == area.CountryCode).ToList();
|
||||
foreach (var area in areas)
|
||||
{
|
||||
if (!area.LeftPostcode.IsNullOrEmpty() && !area.RightPostcode.IsNullOrEmpty())
|
||||
|
||||
@ -7,7 +7,7 @@ public class KpiAreaInfo
|
||||
/// <summary>
|
||||
/// 国家或地区
|
||||
/// </summary>
|
||||
public string Country { get; set; } = null!;
|
||||
public string CountryCode { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// 省份
|
||||
|
||||
@ -102,7 +102,7 @@ public class KpiAreaRepository : BasicRepository<RuleAreaEntity>, IKpiAreaReposi
|
||||
.Select((r, i) => new KpiAreaInfo
|
||||
{
|
||||
AreaId = r.AreaId,
|
||||
Country = r.CountryCode,
|
||||
CountryCode = r.CountryCode,
|
||||
LeftPostcode = r.LeftPostcode,
|
||||
City = r.City,
|
||||
Province = r.Province,
|
||||
|
||||
@ -65,8 +65,10 @@ public class OrderRepository : BasicRepository<OrderEntity>, IOrderRepository, I
|
||||
public async Task<Dictionary<string, string>> GetTrackOrderTypeDictAsync()
|
||||
{
|
||||
const string key = "TrackOrderType";
|
||||
var isRefresh = false;
|
||||
var orderTypes = await _memoryCache.GetOrCreateAsync(key, async (entry) =>
|
||||
{
|
||||
isRefresh = true;
|
||||
// 固定时间周期后强制更新
|
||||
entry.AbsoluteExpirationRelativeToNow = _orderTypeCacheTimeSpan;
|
||||
// 查询主数据
|
||||
@ -76,7 +78,8 @@ public class OrderRepository : BasicRepository<OrderEntity>, IOrderRepository, I
|
||||
});
|
||||
|
||||
// 更新redis缓存
|
||||
await RedisHelper.Client.HMSetAsync(GlobalConst.TrackOrderTypeKey, orderTypes);
|
||||
if (isRefresh)
|
||||
await RedisHelper.Client.HMSetAsync(GlobalConst.TrackOrderTypeKey, orderTypes);
|
||||
|
||||
// redis内数据只更新不清理
|
||||
var dict = RedisHelper.Client.HGetAll<string>(GlobalConst.TrackOrderTypeKey);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user