fix 增加入职日期判断
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user