fix 外包人员,餐补导入,人员列表
This commit is contained in:
@@ -1,15 +1,32 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Kurisu.AspNetCore.Utils.Extensions;
|
||||
|
||||
namespace Dlhis.Canteen.MealSupplementRecord.Request;
|
||||
|
||||
public class MealSupplementInitImportRequest
|
||||
public class MealSupplementInitImportRequest : IValidatableObject
|
||||
{
|
||||
[Required(ErrorMessage = "工号不能为空")]
|
||||
public string Code { get; set; }
|
||||
|
||||
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 余额
|
||||
/// </summary>
|
||||
[Range(1, int.MaxValue, ErrorMessage = "余额有误")]
|
||||
public decimal Balance { get; set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
|
||||
{
|
||||
if (Name.IsEmpty())
|
||||
{
|
||||
yield return new ValidationResult($"工号{Code}姓名不能为空", new[] { nameof(Name) });
|
||||
}
|
||||
|
||||
if (Balance <= 0)
|
||||
{
|
||||
yield return new ValidationResult($"工号{Code}余额有误", new[] { nameof(Balance) });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -117,10 +117,10 @@ public class MealSupplementRecordService : IMealSupplementRecordService
|
||||
foreach (var request in requests)
|
||||
{
|
||||
var gainfo = await _dbContext.Queryable<GainfoEntity>().Where(x => x.Code == request.Code).FirstAsync();
|
||||
if (gainfo == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
gainfo.ThrowIfNull($"工号{request.Code}不存在");
|
||||
|
||||
(_currentUser.GetStringTenantId() != gainfo.Factory).ThrowIfTrue($"工号{request.Code}属于{gainfo.Factory}人员,无法导入");
|
||||
(gainfo.Name != request.Name).ThrowIfTrue($"工号{request.Code}姓名不一致");
|
||||
|
||||
await CommonHelper.RetryAsync(async () =>
|
||||
{
|
||||
@@ -150,6 +150,9 @@ public class MealSupplementRecordService : IMealSupplementRecordService
|
||||
.ExecuteCommandThrowVersionAsync();
|
||||
}, 5);
|
||||
|
||||
(await _dbContext.Queryable<BalanceRecordEntity>().Where(x => x.UserCode == request.Code).Where(x => x.Remark == "期初导入").AnyAsync()).ThrowIfTrue($"工号{request.Code}已导入期初余额");
|
||||
|
||||
|
||||
await _dbContext.InsertAsync(new BalanceRecordEntity
|
||||
{
|
||||
Amount = request.Balance,
|
||||
|
||||
Reference in New Issue
Block a user