添加学生数据自动更新事件
parent
47c553b319
commit
7483262c3d
|
|
@ -20,13 +20,14 @@ namespace New_College.Api.Controllers.Back
|
||||||
private readonly IV_VipCardTypeServices iV_VipCardTypeServices;
|
private readonly IV_VipCardTypeServices iV_VipCardTypeServices;
|
||||||
private readonly IV_OrderInfoServices iV_OrderInfoServices;
|
private readonly IV_OrderInfoServices iV_OrderInfoServices;
|
||||||
private readonly IV_CustomerInfoServices _CustomerInfoServices;
|
private readonly IV_CustomerInfoServices _CustomerInfoServices;
|
||||||
|
private readonly ID_UserSettingBaseServices d_UserSettingBase;
|
||||||
public VipCardController(IV_VipCardInfoServices IV_VipCardInfoServices, IV_VipCardTypeServices IV_VipCardTypeServices, IV_OrderInfoServices IV_OrderInfoServices, IV_CustomerInfoServices customerInfoServices)
|
public VipCardController(IV_VipCardInfoServices IV_VipCardInfoServices, IV_VipCardTypeServices IV_VipCardTypeServices, IV_OrderInfoServices IV_OrderInfoServices, IV_CustomerInfoServices customerInfoServices, ID_UserSettingBaseServices userSettingBaseServices)
|
||||||
{
|
{
|
||||||
iV_VipCardInfoServices = IV_VipCardInfoServices;
|
iV_VipCardInfoServices = IV_VipCardInfoServices;
|
||||||
iV_VipCardTypeServices = IV_VipCardTypeServices;
|
iV_VipCardTypeServices = IV_VipCardTypeServices;
|
||||||
iV_OrderInfoServices = IV_OrderInfoServices;
|
iV_OrderInfoServices = IV_OrderInfoServices;
|
||||||
_CustomerInfoServices = customerInfoServices;
|
_CustomerInfoServices = customerInfoServices;
|
||||||
|
d_UserSettingBase = userSettingBaseServices;
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 生成卡信息
|
/// 生成卡信息
|
||||||
|
|
@ -116,17 +117,24 @@ namespace New_College.Api.Controllers.Back
|
||||||
var custom = await _CustomerInfoServices.Query(c => c.Id == query.CustomerId);
|
var custom = await _CustomerInfoServices.Query(c => c.Id == query.CustomerId);
|
||||||
if (custom.Any())
|
if (custom.Any())
|
||||||
{
|
{
|
||||||
|
var isverfiy = await d_UserSettingBase.Query(c => c.CustomerId == query.CustomerId);
|
||||||
|
if (!isverfiy.Any())
|
||||||
|
{
|
||||||
|
await d_UserSettingBase.SyncBaseInfo(new UserSettingBaseRequest() { CustomerId = query.CustomerId.Value });
|
||||||
|
}
|
||||||
response.IsVip = custom.FirstOrDefault().IsVIP;
|
response.IsVip = custom.FirstOrDefault().IsVIP;
|
||||||
response.pcRole = new PCRole()
|
|
||||||
|
var list = await d_UserSettingBase.GetUserBaseSettings(new UserSettingBaseRequest() { CustomerId = query.CustomerId.Value });
|
||||||
|
response.pcRole = list.Where(e => e.PType == 0).Select(c => new PCRole()
|
||||||
{
|
{
|
||||||
ScoreCount = 10,
|
ScoreCount = c.ScoreCount,
|
||||||
SearchCount = 99999
|
SearchCount = c.SearchCount,
|
||||||
};
|
}).FirstOrDefault();
|
||||||
response.minProRole = new MinProRole()
|
response.minProRole = list.Where(e => e.PType == 1).Select(c => new MinProRole()
|
||||||
{
|
{
|
||||||
ScoreCount = 10,
|
ScoreCount = c.ScoreCount,
|
||||||
SearchCount = 99999
|
SearchCount = c.SearchCount,
|
||||||
};
|
}).FirstOrDefault();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -24,9 +24,11 @@ namespace New_College.Api.Controllers.Front
|
||||||
public class CustomerController : ControllerBase
|
public class CustomerController : ControllerBase
|
||||||
{
|
{
|
||||||
private readonly IV_CustomerInfoServices _services;
|
private readonly IV_CustomerInfoServices _services;
|
||||||
public CustomerController(IV_CustomerInfoServices IV_CustomerInfoServices)
|
private readonly ID_UserSettingBaseServices _userSetting;
|
||||||
|
public CustomerController(IV_CustomerInfoServices IV_CustomerInfoServices, ID_UserSettingBaseServices userSetting)
|
||||||
{
|
{
|
||||||
_services = IV_CustomerInfoServices;
|
_services = IV_CustomerInfoServices;
|
||||||
|
_userSetting = userSetting;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -226,6 +228,7 @@ namespace New_College.Api.Controllers.Front
|
||||||
var result = await _services.UpdateScore(query);
|
var result = await _services.UpdateScore(query);
|
||||||
if (result.Id > 0)
|
if (result.Id > 0)
|
||||||
{
|
{
|
||||||
|
await _userSetting.UpdateSingleCustomerSetting(new UserBaseSettingUpdateDTO() { UType = 0, CustomerId = query.StudentId });//修改参数次数
|
||||||
var token = JwtHelper.IssueJwt(new TokenModelJwt() { Uid = result.Id, Role = "学生" });
|
var token = JwtHelper.IssueJwt(new TokenModelJwt() { Uid = result.Id, Role = "学生" });
|
||||||
result.Token = token;
|
result.Token = token;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1286,6 +1286,31 @@
|
||||||
分数(没有就是--)
|
分数(没有就是--)
|
||||||
</summary>
|
</summary>
|
||||||
</member>
|
</member>
|
||||||
|
<member name="T:New_College.Model.Models.D_UserSettingBase">
|
||||||
|
<summary>
|
||||||
|
用户配置表
|
||||||
|
</summary>
|
||||||
|
</member>
|
||||||
|
<member name="P:New_College.Model.Models.D_UserSettingBase.CustomerId">
|
||||||
|
<summary>
|
||||||
|
|
||||||
|
</summary>
|
||||||
|
</member>
|
||||||
|
<member name="P:New_College.Model.Models.D_UserSettingBase.PType">
|
||||||
|
<summary>
|
||||||
|
0-pc,1-minpro
|
||||||
|
</summary>
|
||||||
|
</member>
|
||||||
|
<member name="P:New_College.Model.Models.D_UserSettingBase.ScoreCount">
|
||||||
|
<summary>
|
||||||
|
分数修改次数
|
||||||
|
</summary>
|
||||||
|
</member>
|
||||||
|
<member name="P:New_College.Model.Models.D_UserSettingBase.SearchCount">
|
||||||
|
<summary>
|
||||||
|
功能查询次数
|
||||||
|
</summary>
|
||||||
|
</member>
|
||||||
<member name="T:New_College.Model.Models.FeedbackInfo">
|
<member name="T:New_College.Model.Models.FeedbackInfo">
|
||||||
<summary>
|
<summary>
|
||||||
|
|
||||||
|
|
@ -7495,6 +7520,26 @@
|
||||||
扩缩招生情况
|
扩缩招生情况
|
||||||
</summary>
|
</summary>
|
||||||
</member>
|
</member>
|
||||||
|
<member name="P:New_College.Model.ViewModels.UserBaseSettingUpdateDTO.UType">
|
||||||
|
<summary>
|
||||||
|
0分数修改次数|1查询次数
|
||||||
|
</summary>
|
||||||
|
</member>
|
||||||
|
<member name="P:New_College.Model.ViewModels.UserBaseSettingDto.PType">
|
||||||
|
<summary>
|
||||||
|
0-pc,1-minpro
|
||||||
|
</summary>
|
||||||
|
</member>
|
||||||
|
<member name="P:New_College.Model.ViewModels.UserBaseSettingDto.ScoreCount">
|
||||||
|
<summary>
|
||||||
|
分数修改次数
|
||||||
|
</summary>
|
||||||
|
</member>
|
||||||
|
<member name="P:New_College.Model.ViewModels.UserBaseSettingDto.SearchCount">
|
||||||
|
<summary>
|
||||||
|
功能查询次数
|
||||||
|
</summary>
|
||||||
|
</member>
|
||||||
<member name="P:New_College.Model.ViewModels.VolunteerTableDetailDtoView.CustomerId">
|
<member name="P:New_College.Model.ViewModels.VolunteerTableDetailDtoView.CustomerId">
|
||||||
<summary>
|
<summary>
|
||||||
用户ID
|
用户ID
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ namespace New_College.Extensions
|
||||||
|
|
||||||
//services.AddHostedService<Job1TimedService>();
|
//services.AddHostedService<Job1TimedService>();
|
||||||
//services.AddHostedService<Job2TimedService>();
|
//services.AddHostedService<Job2TimedService>();
|
||||||
|
services.AddHostedService<UserBaseSettingJobTimedService>();
|
||||||
services.AddSingleton<IJobFactory, JobFactory>();
|
services.AddSingleton<IJobFactory, JobFactory>();
|
||||||
services.AddTransient<Job_Blogs_Quartz>();//Job使用瞬时依赖注入
|
services.AddTransient<Job_Blogs_Quartz>();//Job使用瞬时依赖注入
|
||||||
services.AddSingleton<ISchedulerCenter, SchedulerCenterServer>();
|
services.AddSingleton<ISchedulerCenter, SchedulerCenterServer>();
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,39 @@
|
||||||
|
using New_College.IServices.BASE;
|
||||||
|
using New_College.Model.Models;
|
||||||
|
using New_College.Model.ViewModels;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace New_College.IServices
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// ID_UserSettingBaseServices
|
||||||
|
/// </summary>
|
||||||
|
public interface ID_UserSettingBaseServices :IBaseServices<D_UserSettingBase>
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 同步生成权益
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="request"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<bool> SyncBaseInfo(UserSettingBaseRequest request);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查询权益
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="request"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<List<UserBaseSettingDto>> GetUserBaseSettings(UserSettingBaseRequest request);
|
||||||
|
|
||||||
|
|
||||||
|
Task UpdateSingleCustomerSetting(UserBaseSettingUpdateDTO request);
|
||||||
|
/// <summary>
|
||||||
|
/// 初始化所有数据次数
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task UpdateBaseInit();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,34 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace New_College.Model.Models
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
///用户配置表
|
||||||
|
/// </summary>
|
||||||
|
public class D_UserSettingBase : EntityModel
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public int CustomerId { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 0-pc,1-minpro
|
||||||
|
/// </summary>
|
||||||
|
public int PType { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 分数修改次数
|
||||||
|
/// </summary>
|
||||||
|
public int ScoreCount { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 功能查询次数
|
||||||
|
/// </summary>
|
||||||
|
public int SearchCount { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,44 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace New_College.Model.ViewModels
|
||||||
|
{
|
||||||
|
public class UserSettingBaseRequest
|
||||||
|
{
|
||||||
|
public int CustomerId { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public class UserBaseSettingUpdateDTO
|
||||||
|
{
|
||||||
|
public int CustomerId { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 0分数修改次数|1查询次数
|
||||||
|
/// </summary>
|
||||||
|
public int UType { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public class UserBaseSettingDto
|
||||||
|
{
|
||||||
|
public int CustomerId { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 0-pc,1-minpro
|
||||||
|
/// </summary>
|
||||||
|
public int PType { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 分数修改次数
|
||||||
|
/// </summary>
|
||||||
|
public int ScoreCount { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 功能查询次数
|
||||||
|
/// </summary>
|
||||||
|
public int SearchCount { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,24 @@
|
||||||
|
using New_College.IRepository;
|
||||||
|
using New_College.IRepository.UnitOfWork;
|
||||||
|
using New_College.Model.Models;
|
||||||
|
using New_College.Repository.Base;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace New_College.Repository
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// D_UserSettingBaseRepository
|
||||||
|
/// </summary>
|
||||||
|
public class D_UserSettingBaseRepository : BaseRepository<D_UserSettingBase>, ID_UserSettingBaseRepository
|
||||||
|
{
|
||||||
|
public D_UserSettingBaseRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<bool> UpdateAllBaseInfo(List<D_UserSettingBase> userSettingBases)
|
||||||
|
{
|
||||||
|
return await this.Db.Updateable(userSettingBases).ExecuteCommandAsync()>0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
using New_College.IRepository.Base;
|
||||||
|
using New_College.Model.Models;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace New_College.IRepository
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// ID_UserSettingBaseRepository
|
||||||
|
/// </summary>
|
||||||
|
public interface ID_UserSettingBaseRepository : IBaseRepository<D_UserSettingBase>
|
||||||
|
{
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="userSettingBases"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<bool> UpdateAllBaseInfo(List<D_UserSettingBase> userSettingBases);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -14,6 +14,8 @@ using New_College.Common;
|
||||||
using New_College.IRepository;
|
using New_College.IRepository;
|
||||||
using LinqKit;
|
using LinqKit;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using New_College.Repository;
|
||||||
|
using System.Data.Entity.Infrastructure;
|
||||||
|
|
||||||
namespace New_College.Services
|
namespace New_College.Services
|
||||||
{
|
{
|
||||||
|
|
@ -26,12 +28,14 @@ namespace New_College.Services
|
||||||
private readonly IBaseRepository<D_PlanMajorDesc> _dal;
|
private readonly IBaseRepository<D_PlanMajorDesc> _dal;
|
||||||
private readonly ID_QualificationLineRepository _qualificationLineRepository;
|
private readonly ID_QualificationLineRepository _qualificationLineRepository;
|
||||||
private readonly ID_PlanMajorDescRepository _planMajorDescRepository;
|
private readonly ID_PlanMajorDescRepository _planMajorDescRepository;
|
||||||
public D_PlanMajorDescServices(IBaseRepository<D_PlanMajorDesc> dal, ID_QualificationLineRepository d_QualificationLineRepository, ID_PlanMajorDescRepository planMajorDescRepository)
|
private readonly IT_BatchlineRepository _batchlineRepository;
|
||||||
|
public D_PlanMajorDescServices(IBaseRepository<D_PlanMajorDesc> dal, ID_QualificationLineRepository d_QualificationLineRepository, ID_PlanMajorDescRepository planMajorDescRepository, IT_BatchlineRepository batchlineRepository)
|
||||||
{
|
{
|
||||||
this._dal = dal;
|
this._dal = dal;
|
||||||
base.BaseDal = dal;
|
base.BaseDal = dal;
|
||||||
_qualificationLineRepository = d_QualificationLineRepository;
|
_qualificationLineRepository = d_QualificationLineRepository;
|
||||||
_planMajorDescRepository = planMajorDescRepository;
|
_planMajorDescRepository = planMajorDescRepository;
|
||||||
|
_batchlineRepository = batchlineRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -55,11 +59,12 @@ namespace New_College.Services
|
||||||
{
|
{
|
||||||
request.PageSize = request.PageSize > 200 ? 200 : request.PageSize;
|
request.PageSize = request.PageSize > 200 ? 200 : request.PageSize;
|
||||||
var claim = request.SubjectClaim.Split(",", StringSplitOptions.RemoveEmptyEntries).ToList();
|
var claim = request.SubjectClaim.Split(",", StringSplitOptions.RemoveEmptyEntries).ToList();
|
||||||
|
|
||||||
var pagemodel = new AIGOPageModel<AIGOResponse>();
|
var pagemodel = new AIGOPageModel<AIGOResponse>();
|
||||||
int startscore = request.Score - 15;
|
int startscore = request.Score - 15;
|
||||||
int endscore = request.Score + 15;
|
int endscore = request.Score + 15;
|
||||||
int qyear = request.Year >= 2023 ? 2023 : request.Year;
|
int qyear = request.Year >= 2023 ? 2023 : request.Year;
|
||||||
|
var batlist = await _batchlineRepository.Query(c => c.Year == request.Year && c.Type_name == "综合");
|
||||||
|
request.BatchName = batlist.Where(c => c.Average >= request.Score).Any() ? batlist.Where(c => c.Average >= request.Score).FirstOrDefault().Batch_name : batlist.Where(c => c.Average < request.Score).FirstOrDefault().Batch_name;
|
||||||
Expression<Func<D_QualificationLine, bool>> expression = Expressionable.Create<D_QualificationLine>()
|
Expression<Func<D_QualificationLine, bool>> expression = Expressionable.Create<D_QualificationLine>()
|
||||||
.And(c => c.Years == qyear)
|
.And(c => c.Years == qyear)
|
||||||
.And(c => c.IsDelete == false)
|
.And(c => c.IsDelete == false)
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,117 @@
|
||||||
|
|
||||||
|
using New_College.IServices;
|
||||||
|
using New_College.Model.Models;
|
||||||
|
using New_College.Services.BASE;
|
||||||
|
using New_College.IRepository.Base;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using New_College.Model.ViewModels;
|
||||||
|
using New_College.IRepository;
|
||||||
|
using New_College.Common.WebApiClients.HttpApis;
|
||||||
|
using System;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using Senparc.NeuChar.Helpers;
|
||||||
|
|
||||||
|
namespace New_College.Services
|
||||||
|
{
|
||||||
|
public class D_UserSettingBaseServices : BaseServices<D_UserSettingBase>, ID_UserSettingBaseServices
|
||||||
|
{
|
||||||
|
private readonly IBaseRepository<D_UserSettingBase> _dal;
|
||||||
|
private readonly ID_UserSettingBaseRepository _userSettingBaseRepository;
|
||||||
|
private readonly IV_CustomerInfoRepository _CustomerInfoRepository;
|
||||||
|
public D_UserSettingBaseServices(IBaseRepository<D_UserSettingBase> dal, IV_CustomerInfoRepository v_CustomerInfoRepository, ID_UserSettingBaseRepository userSettingBaseRepository)
|
||||||
|
{
|
||||||
|
this._dal = dal;
|
||||||
|
base.BaseDal = dal;
|
||||||
|
_CustomerInfoRepository = v_CustomerInfoRepository;
|
||||||
|
_userSettingBaseRepository = userSettingBaseRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<List<UserBaseSettingDto>> GetUserBaseSettings(UserSettingBaseRequest request)
|
||||||
|
{
|
||||||
|
return (await _dal.Query(c => c.CustomerId == request.CustomerId)).Select(c => new UserBaseSettingDto()
|
||||||
|
{
|
||||||
|
CustomerId = request.CustomerId,
|
||||||
|
PType = c.PType,
|
||||||
|
ScoreCount = c.ScoreCount,
|
||||||
|
SearchCount = c.SearchCount,
|
||||||
|
}).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<bool> SyncBaseInfo(UserSettingBaseRequest request)
|
||||||
|
{
|
||||||
|
var customerinfo = await _CustomerInfoRepository.Query(c => c.Id == request.CustomerId);
|
||||||
|
if (customerinfo == null)
|
||||||
|
{
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
var basesettinginfo = new D_UserSettingBase()
|
||||||
|
{
|
||||||
|
CustomerId = request.CustomerId,
|
||||||
|
CreateTime = DateTime.Now,
|
||||||
|
IsDelete = false,
|
||||||
|
OrderSort = 0,
|
||||||
|
PType = 0,
|
||||||
|
ScoreCount = customerinfo.FirstOrDefault().IsVIP ? 10 : 3,
|
||||||
|
SearchCount = customerinfo.FirstOrDefault().IsVIP ? 9999 : 10,
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
var basesettingtypeinfo = new D_UserSettingBase()
|
||||||
|
{
|
||||||
|
CustomerId = request.CustomerId,
|
||||||
|
CreateTime = DateTime.Now,
|
||||||
|
IsDelete = false,
|
||||||
|
OrderSort = 0,
|
||||||
|
PType = 1,
|
||||||
|
ScoreCount = customerinfo.FirstOrDefault().IsVIP ? 10 : 3,
|
||||||
|
SearchCount = customerinfo.FirstOrDefault().IsVIP ? 9999 : 10,
|
||||||
|
};
|
||||||
|
await _dal.Add(basesettinginfo);
|
||||||
|
await _dal.Add(basesettingtypeinfo);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task UpdateBaseInit()
|
||||||
|
{
|
||||||
|
var modelslist = new List<D_UserSettingBase>();
|
||||||
|
var customerlist = await _CustomerInfoRepository.Query(c => c.IsDelete == false);
|
||||||
|
var userbaselist = await _userSettingBaseRepository.Query(c => c.IsDelete == false);
|
||||||
|
customerlist.ForEach(async c =>
|
||||||
|
{
|
||||||
|
var userbaseinfo = userbaselist.Where(e => e.CustomerId == c.Id);
|
||||||
|
if (userbaselist.Any())
|
||||||
|
{
|
||||||
|
var models = userbaselist.FirstOrDefault();
|
||||||
|
models.ScoreCount = c.IsVIP ? 10 : 3;
|
||||||
|
models.SearchCount = c.IsVIP ? 9999 : 10;
|
||||||
|
modelslist.Add(models);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
await _userSettingBaseRepository.UpdateAllBaseInfo(modelslist);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task UpdateSingleCustomerSetting(UserBaseSettingUpdateDTO request)
|
||||||
|
{
|
||||||
|
var basesettinglist = await _userSettingBaseRepository.Query(c => c.CustomerId == request.CustomerId);
|
||||||
|
basesettinglist.ForEach(async a =>
|
||||||
|
{
|
||||||
|
if (request.UType == 0)
|
||||||
|
{
|
||||||
|
a.ScoreCount = a.ScoreCount > 0 ? a.ScoreCount - 1 : 0;
|
||||||
|
}
|
||||||
|
if (request.UType == 1)
|
||||||
|
{
|
||||||
|
a.SearchCount = a.SearchCount > 0 ? a.SearchCount - 1 : 0;
|
||||||
|
}
|
||||||
|
await _userSettingBaseRepository.Update(a);
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -335,7 +335,7 @@ namespace New_College.Services
|
||||||
var cc = await _dal.Update(model);
|
var cc = await _dal.Update(model);
|
||||||
if (cc)
|
if (cc)
|
||||||
{
|
{
|
||||||
var oldorderlist = await _dal.Query(c => c.Id != model.Id && c.CustomerId == model.CustomerId);
|
var oldorderlist = await _dal.Query(c => c.Id != model.Id && c.CustomerId == model.CustomerId && c.Status == EnumOrderType.payment);
|
||||||
oldorderlist.ForEach(async c =>
|
oldorderlist.ForEach(async c =>
|
||||||
{
|
{
|
||||||
c.Status = EnumOrderType.Cancel;
|
c.Status = EnumOrderType.Cancel;
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,52 @@
|
||||||
|
using New_College.Common.Helper;
|
||||||
|
using Microsoft.Extensions.Hosting;
|
||||||
|
using System;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using New_College.IServices;
|
||||||
|
|
||||||
|
namespace New_College.Tasks
|
||||||
|
{
|
||||||
|
public class UserBaseSettingJobTimedService : IHostedService, IDisposable
|
||||||
|
{
|
||||||
|
private Timer _timer;
|
||||||
|
private ID_UserSettingBaseServices _UserSettingBaseServices;
|
||||||
|
// 这里可以注入
|
||||||
|
public UserBaseSettingJobTimedService(ID_UserSettingBaseServices d_UserSettingBaseServices)
|
||||||
|
{
|
||||||
|
_UserSettingBaseServices = d_UserSettingBaseServices;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task StartAsync(CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Job userbaseupdate is starting.");
|
||||||
|
// 获取当前时间
|
||||||
|
DateTime currentTime = DateTime.Now;
|
||||||
|
// 计算距离晚上12点的时间间隔
|
||||||
|
TimeSpan timeUntilMidnight = TimeSpan.FromDays(1) - currentTime.TimeOfDay;
|
||||||
|
_timer = new Timer(DoWork, null, timeUntilMidnight, TimeSpan.FromDays(1));//小时
|
||||||
|
return Task.CompletedTask;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DoWork(object state)
|
||||||
|
{
|
||||||
|
|
||||||
|
_UserSettingBaseServices.UpdateBaseInit();//晚上12点同步
|
||||||
|
ConsoleHelper.WriteWarningLine($"userbaseJobstart : {DateTime.Now}");
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task StopAsync(CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
Console.WriteLine("userbaseJob is stopping.");
|
||||||
|
|
||||||
|
_timer?.Change(Timeout.Infinite, 0);
|
||||||
|
|
||||||
|
return Task.CompletedTask;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
_timer?.Dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue