From c24bdddb16a3ee1bf2250b0af50ece1537a436e5 Mon Sep 17 00:00:00 2001 From: liguoyang Date: Wed, 7 Jan 2026 10:59:52 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E5=A2=9E=E5=8A=A0=E5=85=A5=E8=81=8C?= =?UTF-8?q?=E6=97=A5=E6=9C=9F=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Implements/BirthdayVoucherService.cs | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/Src/Dlhis.Canteen/Voucher/Services/Implements/BirthdayVoucherService.cs b/Src/Dlhis.Canteen/Voucher/Services/Implements/BirthdayVoucherService.cs index 799ef2cc..032fe680 100644 --- a/Src/Dlhis.Canteen/Voucher/Services/Implements/BirthdayVoucherService.cs +++ b/Src/Dlhis.Canteen/Voucher/Services/Implements/BirthdayVoucherService.cs @@ -59,6 +59,29 @@ public class BirthdayVoucherService : BaseVoucherService, IVoucherService try { var years = GetBirthdayYears(gainfo.Birthday.Value, p.begin, p.end); + if (gainfo.EntryDate.HasValue) + { + // 仅保留在候选发放年份中,入职日期严格早于该年生日的年份 + years = years.Where(y => + { + var r = gainfo.EntryDate.Value.Date < SafeDateForYear(y, gainfo.Birthday.Value); + + + if (!r) + { + events.Add(new UserBusinessEventEntity + { + UserCode = gainfo.Code, + EventType = "GenerateBirthdayVoucher", + Content = $"入职时间为{gainfo.EntryDate.Value.ToString("yyyy-MM-dd")},不发放日期{SafeDateForYear(y, gainfo.Birthday.Value).ToString("yyyy-MM-dd")}的生日券" + }); + } + + return r; + + }).ToList(); + } + foreach (var year in years) { await GenerateVoucherAsync(gainfo, departmentInfos, year, remark); @@ -98,7 +121,6 @@ public class BirthdayVoucherService : BaseVoucherService, IVoucherService // 使用安全日期来处理 2/29 情况:非闰年会退到当年该月最大天数(即 2/28) var claimDate = SafeDateForYear(year, gainfo.Birthday.Value); - await DbContext.InsertAsync(new VoucherEntity { No = no,