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