bug fixed
parent
abb235df8a
commit
7beb557c68
|
|
@ -94,43 +94,56 @@ public class WeChatUserExService : IDynamicApiController, ITransient
|
|||
throw Oops.Oh("用户token无效");
|
||||
}
|
||||
var result = new WeChatUserExResponseDto();
|
||||
|
||||
|
||||
await PerfectInfo(new WeChatUserExRequestDto()
|
||||
{
|
||||
className = "test",
|
||||
provinceCode = "310000",
|
||||
provinceName = "上海",
|
||||
schoolName = "上海中学",
|
||||
score = 660,
|
||||
sp = 0,
|
||||
subjectGroup = "物,化,地",
|
||||
Year = 2021
|
||||
|
||||
});
|
||||
|
||||
var userext = await _rep.GetFirstAsync(u => u.WxId == _userManager.UserId);
|
||||
var wechatinfo = await _sysWechatUserRep.GetFirstAsync(u => u.Id == _userManager.UserId);
|
||||
result.nickName = MarkPhoneUtil.MaskPhoneNumber(wechatinfo.Mobile);
|
||||
// result.mobile = wechatinfo.Mobile;不给手机号
|
||||
// result.mobile = wechatinfo.Mobile;不给手机号
|
||||
result.avatar = wechatinfo.Avatar;
|
||||
result.customerType = wechatinfo.CustomerType;
|
||||
if (result.customerType == CustomerTypeEnum.Enterprise)
|
||||
//if (result.customerType == CustomerTypeEnum.Enterprise)
|
||||
//{
|
||||
// var spInfo = await _specialist.AsQueryable().FirstAsync(e => e.Phone == wechatinfo.Mobile && e.IsDelete == false);
|
||||
// if (spInfo != null)
|
||||
// {
|
||||
// result.cartId = spInfo?.MajorType.ToString();
|
||||
// result.nickName = spInfo?.Name;
|
||||
// }
|
||||
//}
|
||||
//if (userext != null && !string.IsNullOrWhiteSpace(userext.ProvinceCode))
|
||||
//{
|
||||
// try
|
||||
// {
|
||||
// var province = await _busProvince.AsQueryable().FirstAsync(u => u.Code == userext.ProvinceCode);
|
||||
// userext.ProvinceName = province?.Name;
|
||||
// result.BatchDataUrl = string.Format("https://api.static.ycymedu.com/api/v1/batch/s/{0}.json", userext.ProvinceCode);
|
||||
// //var response = await result.BatchDataUrl.SetJsonSerialization<NewtonsoftJsonSerializerProvider>().GetAsAsync<batchobject>();
|
||||
// var response = await result.BatchDataUrl.GetJsonAsync<batchobject>() ;
|
||||
// var batches = response.result.OrderByDescending(e => e.year).FirstOrDefault().batches;
|
||||
// result.batchName = batches.Where(e => userext.expectedScore >= e.score).Any() ? batches.Where(e => userext.expectedScore >= e.score).OrderByDescending(c => c.score).FirstOrDefault().batch : "";
|
||||
// result.batchScore = batches.Where(e => userext.expectedScore >= e.score).Any() ? batches.Where(e => userext.expectedScore >= e.score).OrderByDescending(c => c.score).FirstOrDefault().score : 0;
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// result.batchName = "";
|
||||
// }
|
||||
//}
|
||||
if (userext != null)
|
||||
{
|
||||
var spInfo = await _specialist.AsQueryable().FirstAsync(e => e.Phone == wechatinfo.Mobile && e.IsDelete == false);
|
||||
if (spInfo != null)
|
||||
{
|
||||
result.cartId = spInfo?.MajorType.ToString();
|
||||
result.nickName = spInfo?.Name;
|
||||
}
|
||||
}
|
||||
if (userext != null && !string.IsNullOrWhiteSpace(userext.ProvinceCode))
|
||||
{
|
||||
try
|
||||
{
|
||||
var province = await _busProvince.AsQueryable().FirstAsync(u => u.Code == userext.ProvinceCode);
|
||||
userext.ProvinceName = province?.Name;
|
||||
result.BatchDataUrl = string.Format("https://api.static.ycymedu.com/api/v1/batch/s/{0}.json", userext.ProvinceCode);
|
||||
//var response = await result.BatchDataUrl.SetJsonSerialization<NewtonsoftJsonSerializerProvider>().GetAsAsync<batchobject>();
|
||||
var response = await result.BatchDataUrl.GetJsonAsync<batchobject>() ;
|
||||
var batches = response.result.OrderByDescending(e => e.year).FirstOrDefault().batches;
|
||||
result.batchName = batches.Where(e => userext.expectedScore >= e.score).Any() ? batches.Where(e => userext.expectedScore >= e.score).OrderByDescending(c => c.score).FirstOrDefault().batch : "";
|
||||
result.batchScore = batches.Where(e => userext.expectedScore >= e.score).Any() ? batches.Where(e => userext.expectedScore >= e.score).OrderByDescending(c => c.score).FirstOrDefault().score : 0;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
result.batchName = "";
|
||||
}
|
||||
}
|
||||
if (userext != null && userext.sp.HasValue)
|
||||
{
|
||||
result.SelectRule = userext.sp.Value > 0 ? new List<string>() { "综合" } : new List<string>() { "文科", "理科" };
|
||||
|
||||
result.userExtend = userext;
|
||||
}
|
||||
var ylist = new List<YearRule>();
|
||||
|
|
@ -157,25 +170,25 @@ public class WeChatUserExService : IDynamicApiController, ITransient
|
|||
result.yearRules = ylist;
|
||||
if (userext != null)
|
||||
{
|
||||
var batchcache = await _distributed.GetAsync(CacheConst.KeyProvinceBatch + userext.ProvinceCode);
|
||||
if (batchcache == null)// 判断缓存是否存在,存在就直接返回,不存在就重新获取
|
||||
{
|
||||
var areaconfig = await _sysAreaConfig.AsQueryable().Where(e => e.IsDelete == false && e.LocationCode == userext.ProvinceCode)
|
||||
.Select(s => new ZyBatchRule()
|
||||
{
|
||||
batchName = s.BatchName,
|
||||
Count = s.Count,
|
||||
ItemCount = s.ItemCount,
|
||||
})
|
||||
.ToListAsync();
|
||||
_distributed.Set($"{CacheConst.KeyProvinceBatch}{userext.ProvinceCode}", Encoding.UTF8.GetBytes(areaconfig.ToJson()), new DistributedCacheEntryOptions()
|
||||
.SetSlidingExpiration(TimeSpan.FromHours(24)));
|
||||
result.zyBatches = areaconfig;
|
||||
}
|
||||
else
|
||||
{
|
||||
result.zyBatches = JsonConvert.DeserializeObject<List<ZyBatchRule>>(Encoding.UTF8.GetString(_distributed.Get($"{CacheConst.KeyProvinceBatch}{userext.ProvinceCode}")));
|
||||
}
|
||||
//var batchcache = await _distributed.GetAsync(CacheConst.KeyProvinceBatch + userext.ProvinceCode);
|
||||
//if (batchcache == null)// 判断缓存是否存在,存在就直接返回,不存在就重新获取
|
||||
//{
|
||||
// var areaconfig = await _sysAreaConfig.AsQueryable().Where(e => e.IsDelete == false && e.LocationCode == userext.ProvinceCode)
|
||||
// .Select(s => new ZyBatchRule()
|
||||
// {
|
||||
// batchName = s.BatchName,
|
||||
// Count = s.Count,
|
||||
// ItemCount = s.ItemCount,
|
||||
// })
|
||||
// .ToListAsync();
|
||||
// _distributed.Set($"{CacheConst.KeyProvinceBatch}{userext.ProvinceCode}", Encoding.UTF8.GetBytes(areaconfig.ToJson()), new DistributedCacheEntryOptions()
|
||||
// .SetSlidingExpiration(TimeSpan.FromHours(24)));
|
||||
// result.zyBatches = areaconfig;
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// result.zyBatches = JsonConvert.DeserializeObject<List<ZyBatchRule>>(Encoding.UTF8.GetString(_distributed.Get($"{CacheConst.KeyProvinceBatch}{userext.ProvinceCode}")));
|
||||
//}
|
||||
}
|
||||
|
||||
return result;
|
||||
|
|
@ -239,23 +252,24 @@ public class WeChatUserExService : IDynamicApiController, ITransient
|
|||
{
|
||||
throw Oops.Oh("不存在该用户");
|
||||
}
|
||||
var db_client = _mongoRepository.Context.GetDatabase("zhiyuan");
|
||||
|
||||
DateTime dt = DateTime.Now;
|
||||
DateTime fixedDate = new DateTime(dt.Year, 7, 20); // 创建当前年份的7月20日
|
||||
int year = dt > fixedDate ? dt.Year : dt.Year - 1; // 比较当前日期与固定日期
|
||||
var be_json = db_client.GetCollection<ZYOneScoreOneSection>(string.Format("scoresection_{0}_{1}", requestDto.provinceCode, year));
|
||||
// 动态条件列表
|
||||
var filterBuilders = new List<FilterDefinition<ZYOneScoreOneSection>>();
|
||||
if (requestDto.score.HasValue && requestDto.score > 0)
|
||||
{
|
||||
filterBuilders.Add(Builders<ZYOneScoreOneSection>.Filter.Lte(e => e.Score.Value, requestDto.score.Value));
|
||||
// var db_client = _mongoRepository.Context.GetDatabase("zhiyuan");
|
||||
// var be_json = db_client.GetCollection<ZYOneScoreOneSection>(string.Format("scoresection_{0}_{1}", requestDto.provinceCode, year));
|
||||
// 动态条件列表
|
||||
//var filterBuilders = new List<FilterDefinition<ZYOneScoreOneSection>>();
|
||||
//if (requestDto.score.HasValue && requestDto.score > 0)
|
||||
//{
|
||||
// filterBuilders.Add(Builders<ZYOneScoreOneSection>.Filter.Lte(e => e.Score.Value, requestDto.score.Value));
|
||||
|
||||
}
|
||||
FilterDefinition<ZYOneScoreOneSection> filter = filterBuilders.Count > 0
|
||||
? Builders<ZYOneScoreOneSection>.Filter.And(filterBuilders)
|
||||
: new BsonDocument(); // 如果没有条件,则使用空过滤器
|
||||
//}
|
||||
//FilterDefinition<ZYOneScoreOneSection> filter = filterBuilders.Count > 0
|
||||
// ? Builders<ZYOneScoreOneSection>.Filter.And(filterBuilders)
|
||||
// : new BsonDocument(); // 如果没有条件,则使用空过滤器
|
||||
|
||||
var limit = await be_json.Find(filter).Sort(Builders<ZYOneScoreOneSection>.Sort.Descending(s => s.Score)).Limit(1).FirstOrDefaultAsync();
|
||||
// var limit = await be_json.Find(filter).Sort(Builders<ZYOneScoreOneSection>.Sort.Descending(s => s.Score)).Limit(1).FirstOrDefaultAsync();
|
||||
|
||||
var model = await _rep.GetSingleAsync(e => e.WxId == _userManager.UserId);
|
||||
if (model == null)
|
||||
|
|
@ -285,11 +299,11 @@ public class WeChatUserExService : IDynamicApiController, ITransient
|
|||
{
|
||||
model.Year = requestDto.Year.Value;
|
||||
}
|
||||
if (requestDto.score.HasValue)
|
||||
{
|
||||
model.expectedScore = requestDto.score.Value;
|
||||
model.Rank = limit != null ? limit.CumulativeCount : 0;
|
||||
}
|
||||
//if (requestDto.score.HasValue)
|
||||
//{
|
||||
// model.expectedScore = requestDto.score.Value;
|
||||
// model.Rank = limit != null ? limit.CumulativeCount : 0;
|
||||
//}
|
||||
if (requestDto.sp.HasValue)
|
||||
{
|
||||
model.sp = requestDto.sp.Value;
|
||||
|
|
@ -323,11 +337,11 @@ public class WeChatUserExService : IDynamicApiController, ITransient
|
|||
{
|
||||
model.Year = requestDto.Year.Value;
|
||||
}
|
||||
if (requestDto.score.HasValue)
|
||||
{
|
||||
model.expectedScore = requestDto.score.Value;
|
||||
model.Rank = limit != null ? limit.CumulativeCount : 0;
|
||||
}
|
||||
//if (requestDto.score.HasValue)
|
||||
//{
|
||||
// model.expectedScore = requestDto.score.Value;
|
||||
// model.Rank = limit != null ? limit.CumulativeCount : 0;
|
||||
//}
|
||||
if (requestDto.sp.HasValue)
|
||||
{
|
||||
model.sp = requestDto.sp.Value;
|
||||
|
|
|
|||
Loading…
Reference in New Issue