| | |
| | | using DTO; |
| | | using IServices; |
| | | using Microsoft.Extensions.Configuration; |
| | | using Microsoft.Extensions.DependencyInjection; |
| | | using Microsoft.Extensions.Hosting; |
| | | using Microsoft.Extensions.Logging; |
| | | using Newtonsoft.Json; |
| | | using Newtonsoft.Json.Linq; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.IO; |
| | | using System.Linq; |
| | | using System.Net.Http; |
| | | using System.Net.Http.Headers; |
| | | using System.Threading; |
| | | using System.Threading.Tasks; |
| | | using System.Transactions; |
| | |
| | | private readonly ICusFangwenjiluService _cusFangwenjiluService; |
| | | private readonly ILiaotianService _liaotianService; |
| | | private readonly IDtChannelArticleNewsService _dtChannelArticleNewsService; |
| | | private readonly IConfiguration _configuration; |
| | | private readonly IHttpClientFactory _clientFactory; |
| | | |
| | | private readonly decimal jiabangongzibiaozhun = new decimal(21.5); |
| | | public TimedBackgroundService(ILogger<TimedBackgroundService> logger, IServiceScopeFactory factory) |
| | |
| | | _cusFangwenjiluService = factory.CreateScope().ServiceProvider.GetRequiredService<ICusFangwenjiluService>(); |
| | | _liaotianService = factory.CreateScope().ServiceProvider.GetRequiredService<ILiaotianService>(); |
| | | _dtChannelArticleNewsService = factory.CreateScope().ServiceProvider.GetRequiredService<IDtChannelArticleNewsService>(); |
| | | _configuration = factory.CreateScope().ServiceProvider.GetRequiredService<IConfiguration>(); |
| | | _clientFactory = factory.CreateScope().ServiceProvider.GetRequiredService<IHttpClientFactory>(); |
| | | } |
| | | protected override async Task ExecuteAsync(CancellationToken stoppingToken) |
| | | { |
| | |
| | | //using (TransactionScope scope = new TransactionScope()) |
| | | //{ |
| | | this.jisuankaoqin(); |
| | | this.jisuangongzi(); |
| | | await this.jisuangongziAsync(); |
| | | //scope.Complete(); |
| | | //} |
| | | |
| | |
| | | |
| | | |
| | | //计算工资 |
| | | public void jisuangongzi() |
| | | public async Task jisuangongziAsync() |
| | | { |
| | | //查询所有的有效人员 |
| | | DateTime dateminkaoqin = new DateTime(DateTime.Now.Year, DateTime.Now.Month - 1, 1); |
| | |
| | | } |
| | | #endregion |
| | | |
| | | |
| | | #region 新增注册会员 |
| | | |
| | | //本月数量 |
| | | List<YaoQingYongHuDTO> zhucehuiyuansyue = new List<YaoQingYongHuDTO>(); |
| | | try |
| | | { |
| | | //var pltUserDTO = _userService.GetPltUserEntity(userList[i].Id); |
| | | string huiyuanurl = _configuration.GetSection("huiyuanurl").Value; |
| | | string GetYGYaoQingYonghu = _configuration.GetSection("GetYGYaoQingYonghu").Value; |
| | | Uri postUrl2 = new Uri(huiyuanurl + GetYGYaoQingYonghu); |
| | | |
| | | JObject questions2 = new JObject(); |
| | | questions2.Add("UserID", userList[i].Id); |
| | | questions2.Add("StartTime", dateminkaoqin.ToString("yyyy-MM-dd HH:mm:ss")); |
| | | questions2.Add("EndTime", datemaxkaoqin.ToString("yyyy-MM-dd HH:mm:ss")); |
| | | |
| | | string requestJson2 = questions2.ToString(); |
| | | string result2 = string.Empty; |
| | | |
| | | using (HttpContent httpContent = new StringContent(requestJson2)) |
| | | { |
| | | httpContent.Headers.ContentType = new MediaTypeHeaderValue("application/json"); |
| | | |
| | | var httpClient2 = _clientFactory.CreateClient(); |
| | | httpClient2.Timeout = new TimeSpan(0, 0, 10); |
| | | var Result2 = await httpClient2.PostAsync(postUrl2, httpContent); |
| | | result2 = Result2.Content.ReadAsStringAsync().Result; |
| | | } |
| | | |
| | | _logger.LogInformation("result2:" + result2); |
| | | JObject jobjectresult = (JObject)JsonConvert.DeserializeObject(result2); |
| | | |
| | | if (jobjectresult["code"] != null && jobjectresult["code"].ToString() == "1") |
| | | { |
| | | |
| | | zhucehuiyuansyue = JsonConvert.DeserializeObject<List<YaoQingYongHuDTO>>(jobjectresult["data"].ToString()); |
| | | |
| | | } |
| | | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | |
| | | } |
| | | |
| | | |
| | | //var qianyueDTOsyue = _cooperatecustomCustomerService.GetListsalary(userList[i].Id, dateminkaoqin, datemaxkaoqin); |
| | | if (zhucehuiyuansyue != null && zhucehuiyuansyue.Count > 0) |
| | | { |
| | | var jijianidddd = fiPiecerateDTOs.Where(x => x.Project == "新增注册会员").FirstOrDefault(); |
| | | if (jijianidddd != null) |
| | | { |
| | | var jixiaotichengfangan = hrJixiaotichengThis.Where(x => x.PiecerateId == jijianidddd.Id).OrderByDescending(x => x.Effecttime).FirstOrDefault(); |
| | | if (jixiaotichengfangan != null && jixiaotichengfangan.Ticheng.HasValue && jixiaotichengfangan.Renwu.HasValue) |
| | | { |
| | | if (jixiaotichengfangan.Renwustandard == "01") |
| | | { |
| | | decimal renwujishu = admAttendanceDTO.Yingchuqin * jixiaotichengfangan.Renwu.Value; |
| | | if (jixiaotichengfangan.Tichengstandard == "01") |
| | | { |
| | | decimal youxiaojijian = zhucehuiyuansyue.Count - renwujishu; |
| | | if (youxiaojijian > 0) |
| | | { |
| | | hrSalaryDTO.Jixiaoticheng += Math.Round(jixiaotichengfangan.Ticheng.Value * youxiaojijian, 2); |
| | | } |
| | | |
| | | } |
| | | |
| | | } |
| | | else if (jixiaotichengfangan.Renwustandard == "02") |
| | | { |
| | | decimal renwujishu = jixiaotichengfangan.Renwu.Value; |
| | | if (jixiaotichengfangan.Tichengstandard == "01") |
| | | { |
| | | decimal youxiaojijian = zhucehuiyuansyue.Count - renwujishu; |
| | | if (youxiaojijian > 0) |
| | | { |
| | | hrSalaryDTO.Jixiaoticheng += Math.Round(jixiaotichengfangan.Ticheng.Value * youxiaojijian, 2); |
| | | } |
| | | |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | |
| | | #region 新增签约客户 |
| | | |
| | | var qianyueDTOsyue = _cooperatecustomCustomerService.GetListsalary(userList[i].Id, dateminkaoqin, datemaxkaoqin); |