From 3f91c6109bcba82ca5e4fafc782ac63df906baa2 Mon Sep 17 00:00:00 2001 From: cheche <717840555@qq.com> Date: Thu, 11 Jan 2024 18:08:14 +0800 Subject: [PATCH] =?UTF-8?q?fix=20CanteenSettingItemEnumType=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Order/Services/Implements/OrderService.cs | 2 +- .../Implements/CanteenSettingService.cs | 47 +++++++++++++++++++ Src/Dlhis.ScheduledTask/Job/SyncPersonJob.cs | 3 +- 3 files changed, 49 insertions(+), 3 deletions(-) diff --git a/Src/Dlhis.Canteen/Order/Services/Implements/OrderService.cs b/Src/Dlhis.Canteen/Order/Services/Implements/OrderService.cs index c7a94a64..234abb59 100644 --- a/Src/Dlhis.Canteen/Order/Services/Implements/OrderService.cs +++ b/Src/Dlhis.Canteen/Order/Services/Implements/OrderService.cs @@ -298,7 +298,7 @@ public class OrderService : IOrderService var balanceRecords = await _dbContext.Queryable() .Where(x => x.UserNo == order.UserNo) - .Where(x => x.CreateTime <= beginOfDay && x.CreateTime <= endOfDay) //今天消费记录 + .Where(x => x.CreateTime >= beginOfDay && x.CreateTime <= endOfDay) //今天消费记录 .ToListAsync(); var dayMarketCostMax = GetSetting(settings, CanteenSettingItemEnumType.DayMarketCostMax); diff --git a/Src/Dlhis.Canteen/Setting/Services/Implements/CanteenSettingService.cs b/Src/Dlhis.Canteen/Setting/Services/Implements/CanteenSettingService.cs index af5cc8c2..3275e2b4 100644 --- a/Src/Dlhis.Canteen/Setting/Services/Implements/CanteenSettingService.cs +++ b/Src/Dlhis.Canteen/Setting/Services/Implements/CanteenSettingService.cs @@ -2,11 +2,15 @@ using Dlhis.Canteen.Setting.Response; using Dlhis.Entity.Basic.Entity; using Dlhis.Entity.Canteen.Enums; +using Kurisu.AspNetCore.UnifyResultAndValidation; using Kurisu.AspNetCore.Utils.Extensions; using Kurisu.Core.DataAccess.Dto; using Kurisu.SqlSugar.Extensions; using Kurisu.SqlSugar.Services; using Mapster; +using Newtonsoft.Json.Linq; +using System.ComponentModel.DataAnnotations; +using System.Globalization; namespace Dlhis.Canteen.Setting.Services.Implements; @@ -46,6 +50,7 @@ public class CanteenSettingService : ICanteenSettingService public async Task SaveSettingAsync(CanteenSettingSaveRequest request) { + Inspection(request);//校验参数 await CheckDuplicateSettingAsync(request); if (!request.Id.HasValue) @@ -62,6 +67,48 @@ public class CanteenSettingService : ICanteenSettingService } } + private void Inspection(CanteenSettingSaveRequest request) + { + switch (request.Item) + { + case CanteenSettingItemEnumType.BusinessSwitchTime: + ValidateBusinessSwitchTime(request); + break; + + case CanteenSettingItemEnumType.InitBalance: + case CanteenSettingItemEnumType.DayCostMax: + case CanteenSettingItemEnumType.DayMarketCostMax: + case CanteenSettingItemEnumType.OnceCostMax: + ValidateDecimal(request); + break; + } + } + + private void ValidateBusinessSwitchTime(CanteenSettingSaveRequest request) + { + // 对 BusinessSwitchTime 进行时间格式验证 + if (string.IsNullOrEmpty(request.Value) || !IsValidTimeFormat(request.Value)) + { + throw new UserFriendlyException("BusinessSwitchTime 参数无效。它应该是 HH:00:00 格式"); + } + } + // 用于验证时间格式 + private bool IsValidTimeFormat(string time) + { + return DateTime.TryParseExact(time, "HH:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.None, out _); + } + + private void ValidateDecimal(CanteenSettingSaveRequest request) + { + // 对 InitBalance 进行 decimal 转换验证 + if (!decimal.TryParse(request.Value, out _)) + { + throw new UserFriendlyException("InitBalance 参数无效。它应该是 decimal 类型"); + } + } + + + public async Task SetEnableAsync(CanteenSettingSetEnableRequest request) { var entity = await _context.Queryable().FirstAsync(x => x.Id == request.Id); diff --git a/Src/Dlhis.ScheduledTask/Job/SyncPersonJob.cs b/Src/Dlhis.ScheduledTask/Job/SyncPersonJob.cs index 4ee9a31a..7caca96a 100644 --- a/Src/Dlhis.ScheduledTask/Job/SyncPersonJob.cs +++ b/Src/Dlhis.ScheduledTask/Job/SyncPersonJob.cs @@ -152,7 +152,6 @@ namespace Dlhis.ScheduledTask.Job gainfo.Code = item.ename; gainfo.CountryNo = item.country; gainfo.IdClass = item.idcls; - gainfo.IdNo = item.idno; gainfo.Native = item.native; gainfo.Gender = item.sex == "F" ? GenderEnumType.Female : GenderEnumType.Male; gainfo.Birthday = (DateTime)item.birthday; @@ -164,7 +163,7 @@ namespace Dlhis.ScheduledTask.Job gainfo.Position = item.web; gainfo.Remark = item.remark; gainfo.Werks = item.WERKS; - gainfo.Employed = item.isowner; + gainfo.Employed = item.isowner; //int.Parse(person.ZSTATUS) < 4 ? "T" : "F", 是否离职 await _dbContext.UpdateAsync(gainfo); } else