feat 电子餐券
This commit is contained in:
@@ -0,0 +1,11 @@
|
|||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
namespace Dlhis.Canteen.EMealVoucher.Controllers;
|
||||||
|
|
||||||
|
[Authorize]
|
||||||
|
[Route("api/[controller]")]
|
||||||
|
[ApiController]
|
||||||
|
public class EMealVoucherController : ControllerBase
|
||||||
|
{
|
||||||
|
}
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
using Kurisu.AspNetCore.DataAccess.SqlSugar;
|
||||||
|
using SqlSugar;
|
||||||
|
|
||||||
|
namespace Dlhis.Entity.Canteen.Entities;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 电子餐券明细
|
||||||
|
/// </summary>
|
||||||
|
[SugarTable(TableName = "EMealVoucherDetail", TableDescription = "电子餐券明细")]
|
||||||
|
public class EMealVoucherDetailEntity : SugarBaseEntity
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 主表id
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(ColumnDescription = "主表id")]
|
||||||
|
public long VoucherId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 流水号
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(ColumnDescription = "流水号")]
|
||||||
|
public string No { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 人员类型
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(ColumnDescription = "人员类型(新员工/外来人员)")]
|
||||||
|
public string UserType { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 身份证
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(ColumnDescription = "序号")]
|
||||||
|
public string IdNo { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 用餐人
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(ColumnDescription = "用餐人")]
|
||||||
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 手机号
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(ColumnDescription = "手机号")]
|
||||||
|
public string Phone { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 就餐开始
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(ColumnDescription = "使用开始", ColumnDataType = "date")]
|
||||||
|
public DateTime Start { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 就餐结束
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(ColumnDescription = "使用结束", ColumnDataType = "date")]
|
||||||
|
public DateTime End { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 金额
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(ColumnDescription = "金额", ColumnDataType = "decimal(16,2)")]
|
||||||
|
public decimal Amount { get; set; }
|
||||||
|
}
|
||||||
78
Src/Dlhis.Entity/Canteen/Entities/EMealVoucherEntity.cs
Normal file
78
Src/Dlhis.Entity/Canteen/Entities/EMealVoucherEntity.cs
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
using Dlhis.Entity.Canteen.Enums;
|
||||||
|
using Kurisu.AspNetCore.DataAccess.SqlSugar;
|
||||||
|
using SqlSugar;
|
||||||
|
|
||||||
|
namespace Dlhis.Entity.Canteen.Entities;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 餐券
|
||||||
|
/// </summary>
|
||||||
|
[SugarTable(TableName = "EMealVoucher", TableDescription = "电子餐券")]
|
||||||
|
public class EMealVoucherEntity : SugarBaseEntity
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// oa流程id
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(ColumnDescription = "oa流程id", UniqueGroupNameList = new[] { "index_EMealVoucher_No" })]
|
||||||
|
public string No { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 标题
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(ColumnDescription = "标题")]
|
||||||
|
public string Title { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 申请人工号
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(ColumnDescription = "申请人工号", IndexGroupNameList = new[] { "index_EMealVoucher_Code" })]
|
||||||
|
public string Code { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 成本中心
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(ColumnDescription = "成本中心")]
|
||||||
|
public string CostId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 来宾公司
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(ColumnDescription = "来宾来源")]
|
||||||
|
public string Source { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 联系人
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(ColumnDescription = "手机号")]
|
||||||
|
public string Phone { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 来宾人数
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(ColumnDescription = "来宾人数")]
|
||||||
|
public int Number { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 就餐事由
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(ColumnDescription = "申请事由")]
|
||||||
|
public string Reason { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 就餐次
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(ColumnDescription = "就餐次", ColumnDataType = "varchar(500)", IsJson = true)]
|
||||||
|
public List<ShiftEnumType> Shifts { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 可消费厂区
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(ColumnDescription = "可消费厂区", ColumnDataType = "varchar(500)", IsJson = true)]
|
||||||
|
public List<string> Factories { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 申请日期
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(ColumnDescription = "申请日期")]
|
||||||
|
public DateTime Date { get; set; }
|
||||||
|
}
|
||||||
@@ -1,84 +0,0 @@
|
|||||||
using SqlSugar;
|
|
||||||
|
|
||||||
namespace Dlhis.Entity.Canteen.Entities;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// OA餐券明细
|
|
||||||
/// </summary>
|
|
||||||
[SugarTable(TableName = "OaEMealVoucherDetail", TableDescription = "OA餐券明细")]
|
|
||||||
public class OaEMealVoucherDetailEntity
|
|
||||||
{
|
|
||||||
public long Id { get; set; }
|
|
||||||
|
|
||||||
|
|
||||||
[SugarColumn(ColumnDescription = "餐券id")]
|
|
||||||
public long VoucherId { get; set; }
|
|
||||||
|
|
||||||
|
|
||||||
[SugarColumn(ColumnDescription = "序号")]
|
|
||||||
public int Sequence { get; set; }
|
|
||||||
|
|
||||||
|
|
||||||
[SugarColumn(ColumnDescription = "用餐人情况(新员工/外来人员)")]
|
|
||||||
public string DinnerType { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 身份证
|
|
||||||
/// </summary>
|
|
||||||
[SugarColumn(ColumnDescription = "序号")]
|
|
||||||
public string IdNo { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 用餐人
|
|
||||||
/// </summary>
|
|
||||||
[SugarColumn(ColumnDescription = "用餐人")]
|
|
||||||
public string Name { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 手机号
|
|
||||||
/// </summary>
|
|
||||||
[SugarColumn(ColumnDescription = "手机号")]
|
|
||||||
public string Phone { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 就餐开始
|
|
||||||
/// </summary>
|
|
||||||
[SugarColumn(ColumnDescription = "就餐开始")]
|
|
||||||
public DateTime Start { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 就餐结束
|
|
||||||
/// </summary>
|
|
||||||
[SugarColumn(ColumnDescription = "就餐结束")]
|
|
||||||
public DateTime End { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 就餐天数
|
|
||||||
/// </summary>
|
|
||||||
[SugarColumn(ColumnDescription = "就餐天数")]
|
|
||||||
public int Days { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 金额
|
|
||||||
/// </summary>
|
|
||||||
[SugarColumn(ColumnDescription = "金额")]
|
|
||||||
public decimal Amount { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 二维码
|
|
||||||
/// </summary>
|
|
||||||
[SugarColumn(ColumnDescription = "二维码")]
|
|
||||||
public string QrCode { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 状态
|
|
||||||
/// </summary>
|
|
||||||
[SugarColumn(ColumnDescription = "状态,默认为R")]
|
|
||||||
public string Status { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 信息
|
|
||||||
/// </summary>
|
|
||||||
[SugarColumn(ColumnDescription = "信息/错误信息")]
|
|
||||||
public string Message { get; set; }
|
|
||||||
}
|
|
||||||
@@ -1,122 +0,0 @@
|
|||||||
using SqlSugar;
|
|
||||||
|
|
||||||
namespace Dlhis.Entity.Canteen.Entities;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// OA餐券
|
|
||||||
/// </summary>
|
|
||||||
[SugarTable(TableName = "OaEMealVoucher", TableDescription = "OA餐券")]
|
|
||||||
public class OaEMealVoucherEntity
|
|
||||||
{
|
|
||||||
[SugarColumn(IsIdentity = true, IsPrimaryKey = true)]
|
|
||||||
public long Id { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 标题
|
|
||||||
/// </summary>
|
|
||||||
[SugarColumn(ColumnDescription = "标题")]
|
|
||||||
public string Title { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 申请人工号
|
|
||||||
/// </summary>
|
|
||||||
[SugarColumn(ColumnDescription = "申请人工号")]
|
|
||||||
public string UserCode { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 申请人名称
|
|
||||||
/// </summary>
|
|
||||||
[SugarColumn(ColumnDescription = "申请人名称")]
|
|
||||||
public string Name { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 基地代码
|
|
||||||
/// </summary>
|
|
||||||
[SugarColumn(ColumnDescription = "基地代码")]
|
|
||||||
public string TenantId { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 基地名称
|
|
||||||
/// </summary>
|
|
||||||
[SugarColumn(ColumnDescription = "基地名称")]
|
|
||||||
public string TenantName { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 成本中心
|
|
||||||
/// </summary>
|
|
||||||
[SugarColumn(ColumnDescription = "成本中心")]
|
|
||||||
public string CostId { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 成本中心名称
|
|
||||||
/// </summary>
|
|
||||||
[SugarColumn(ColumnDescription = "成本中心名称")]
|
|
||||||
public string CostName { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 来宾公司
|
|
||||||
/// </summary>
|
|
||||||
[SugarColumn(ColumnDescription = "来宾公司")]
|
|
||||||
public string Company { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 联系人
|
|
||||||
/// </summary>
|
|
||||||
[SugarColumn(ColumnDescription = "联系人")]
|
|
||||||
public string Phone { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 来宾人数
|
|
||||||
/// </summary>
|
|
||||||
[SugarColumn(ColumnDescription = "来宾人数")]
|
|
||||||
public int Num { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 就餐食堂
|
|
||||||
/// </summary>
|
|
||||||
[SugarColumn(ColumnDescription = "就餐食堂")]
|
|
||||||
public string Canteen { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 就餐事由
|
|
||||||
/// </summary>
|
|
||||||
[SugarColumn(ColumnDescription = "就餐事由")]
|
|
||||||
public string Reason { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 就餐次
|
|
||||||
/// </summary>
|
|
||||||
[SugarColumn(ColumnDescription = "就餐次")]
|
|
||||||
public string CanteenShift { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// oa流程id
|
|
||||||
/// </summary>
|
|
||||||
[SugarColumn(ColumnDescription = "oa流程id")]
|
|
||||||
public string OaId { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 部门号
|
|
||||||
/// </summary>
|
|
||||||
[SugarColumn(ColumnDescription = "部门号")]
|
|
||||||
public string DepartmentNo { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 部门名称
|
|
||||||
/// </summary>
|
|
||||||
[SugarColumn(ColumnDescription = "部门名称")]
|
|
||||||
public string DepartmentName { get; set; }
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 申请日期
|
|
||||||
/// </summary>
|
|
||||||
[SugarColumn(ColumnDescription = "申请日期")]
|
|
||||||
public DateTime LogDate { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 数据创建时间
|
|
||||||
/// </summary>
|
|
||||||
[SugarColumn(ColumnDescription = "数据创建时间")]
|
|
||||||
public DateTime CreateTime { get; set; }
|
|
||||||
}
|
|
||||||
@@ -13,6 +13,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Folder Include="EMealVoucher\Response\" />
|
||||||
<Folder Include="MealSupplement\Response\" />
|
<Folder Include="MealSupplement\Response\" />
|
||||||
<Folder Include="OpenApi\Request\" />
|
<Folder Include="OpenApi\Request\" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
using Dlhis.External.EMealVoucher.Request;
|
||||||
|
using Dlhis.External.EMealVoucher.Services;
|
||||||
|
using Kurisu.AspNetCore.DataAccess.SqlSugar.Aop;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
namespace Dlhis.External.EMealVoucher.Controllers;
|
||||||
|
|
||||||
|
[Route("api/[controller]")]
|
||||||
|
[ApiController]
|
||||||
|
public class EMealVoucherController : ControllerBase
|
||||||
|
{
|
||||||
|
private readonly IEMealVoucherService _eMealVoucherService;
|
||||||
|
|
||||||
|
public EMealVoucherController(IEMealVoucherService eMealVoucherService)
|
||||||
|
{
|
||||||
|
_eMealVoucherService = eMealVoucherService;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 接收
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="request"></param>
|
||||||
|
[HttpPost("receive")]
|
||||||
|
[Transactional]
|
||||||
|
public async Task Receive(EMealVoucherReceiveRequest request)
|
||||||
|
{
|
||||||
|
await _eMealVoucherService.ReceiveAsync(request);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,144 @@
|
|||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
|
namespace Dlhis.External.EMealVoucher.Request;
|
||||||
|
|
||||||
|
public class EMealVoucherReceiveRequest : IValidatableObject
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 流水号
|
||||||
|
/// </summary>
|
||||||
|
[Required(ErrorMessage = "流水号不能为空")]
|
||||||
|
public string No { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 标题
|
||||||
|
/// </summary>
|
||||||
|
[Required(ErrorMessage = "标题不能为空")]
|
||||||
|
public string Title { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 工号
|
||||||
|
/// </summary>
|
||||||
|
[Required(ErrorMessage = "工号不能为空")]
|
||||||
|
public string Code { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 手机号
|
||||||
|
/// </summary>
|
||||||
|
[Required(ErrorMessage = "成本中心不能为空")]
|
||||||
|
public string Phone { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 申请日期
|
||||||
|
/// </summary>
|
||||||
|
public DateTime Date { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 成本中心
|
||||||
|
/// </summary>
|
||||||
|
[Required(ErrorMessage = "成本中心不能为空")]
|
||||||
|
public string CostId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 来宾来源
|
||||||
|
/// </summary>
|
||||||
|
[Required(ErrorMessage = "来宾来源不能为空")]
|
||||||
|
public string Source { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 来宾数量
|
||||||
|
/// </summary>
|
||||||
|
[Range(1, int.MaxValue, ErrorMessage = "来宾数量有误")]
|
||||||
|
public int Number { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 申请事由
|
||||||
|
/// </summary>
|
||||||
|
[Required(ErrorMessage = "申请事由不能为空")]
|
||||||
|
public string Reason { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 餐别组合 早餐1;午餐2;晚餐3;夜宵4,凌晨餐5
|
||||||
|
/// </summary>
|
||||||
|
[MinLength(1, ErrorMessage = "消费厂区不能为空")]
|
||||||
|
[MaxLength(5, ErrorMessage = "消费厂区不能为空")]
|
||||||
|
public List<int> Shifts { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 餐券可消费厂区代码,逗号分隔
|
||||||
|
/// </summary>
|
||||||
|
[MinLength(1, ErrorMessage = "消费厂区不能为空")]
|
||||||
|
public List<string> Factories { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 明细
|
||||||
|
/// </summary>
|
||||||
|
[MinLength(1, ErrorMessage = "明细不能为空")]
|
||||||
|
public List<EMealVoucherReceiveDetailRequest> Details { get; set; }
|
||||||
|
|
||||||
|
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
|
||||||
|
{
|
||||||
|
if (Number != Details.Count)
|
||||||
|
{
|
||||||
|
yield return new ValidationResult("来宾数量不匹配", new[] { nameof(Number) });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class EMealVoucherReceiveDetailRequest : IValidatableObject
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 用户类型 新员工/外来人员
|
||||||
|
/// </summary>
|
||||||
|
[Required(ErrorMessage = "用户类型不可为空")]
|
||||||
|
public string UserType { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 身份证号
|
||||||
|
/// </summary>
|
||||||
|
[Required(ErrorMessage = "身份证号不可为空")]
|
||||||
|
public string IdNo { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 姓名
|
||||||
|
/// </summary>
|
||||||
|
[Required(ErrorMessage = "姓名不可为空")]
|
||||||
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 手机号
|
||||||
|
/// </summary>
|
||||||
|
[MinLength(11, ErrorMessage = "手机号不合法")]
|
||||||
|
[MaxLength(11, ErrorMessage = "手机号不合法")]
|
||||||
|
public string Phone { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 使用开始
|
||||||
|
/// </summary>
|
||||||
|
public DateTime Start { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 使用结束
|
||||||
|
/// </summary>
|
||||||
|
public DateTime End { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 金额
|
||||||
|
/// </summary>
|
||||||
|
[Range(0.01, double.MaxValue)]
|
||||||
|
public decimal Amount { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
|
||||||
|
{
|
||||||
|
if (End <= DateTime.Now)
|
||||||
|
{
|
||||||
|
yield return new ValidationResult("使用结束时间不可小于当前时间", new[] { nameof(End) });
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Start >= End)
|
||||||
|
{
|
||||||
|
yield return new ValidationResult("使用开始,使用结束时间有误", new[] { nameof(Start) });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
using Dlhis.External.EMealVoucher.Request;
|
||||||
|
|
||||||
|
namespace Dlhis.External.EMealVoucher.Services;
|
||||||
|
|
||||||
|
public interface IEMealVoucherService : IScopeDependency
|
||||||
|
{
|
||||||
|
Task ReceiveAsync(EMealVoucherReceiveRequest request);
|
||||||
|
}
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
using Dlhis.Entity.Canteen.Entities;
|
||||||
|
using Dlhis.Entity.Canteen.Enums;
|
||||||
|
using Dlhis.External.EMealVoucher.Request;
|
||||||
|
using Kurisu.AspNetCore.DataAccess.SqlSugar.Services;
|
||||||
|
using Kurisu.AspNetCore.Utils.Extensions;
|
||||||
|
|
||||||
|
namespace Dlhis.External.EMealVoucher.Services.Implements;
|
||||||
|
|
||||||
|
public class EMealVoucherService : IEMealVoucherService
|
||||||
|
{
|
||||||
|
private readonly IDbContext _dbContext;
|
||||||
|
|
||||||
|
public EMealVoucherService(IDbContext dbContext)
|
||||||
|
{
|
||||||
|
_dbContext = dbContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task ReceiveAsync(EMealVoucherReceiveRequest request)
|
||||||
|
{
|
||||||
|
(await _dbContext.Queryable<EMealVoucherEntity>().Where(x => x.No == request.No).AnyAsync()).ThrowIfTrue($"{request.No}已存在");
|
||||||
|
|
||||||
|
var voucher = new EMealVoucherEntity
|
||||||
|
{
|
||||||
|
No = request.No,
|
||||||
|
Title = request.Title,
|
||||||
|
Code = request.Code,
|
||||||
|
CostId = request.CostId,
|
||||||
|
Source = request.Source,
|
||||||
|
Phone = request.Phone,
|
||||||
|
Number = request.Number,
|
||||||
|
Reason = request.Reason,
|
||||||
|
Shifts = request.Shifts.Select(x => (ShiftEnumType)x).ToList(),
|
||||||
|
Date = request.Date,
|
||||||
|
Factories = request.Factories
|
||||||
|
};
|
||||||
|
|
||||||
|
var details = request.Details.Select(x => new EMealVoucherDetailEntity
|
||||||
|
{
|
||||||
|
No = request.No,
|
||||||
|
UserType = x.UserType,
|
||||||
|
IdNo = x.IdNo,
|
||||||
|
Name = x.Name,
|
||||||
|
Phone = x.Phone,
|
||||||
|
Start = x.Start,
|
||||||
|
End = x.End,
|
||||||
|
Amount = x.Amount
|
||||||
|
}).ToList();
|
||||||
|
|
||||||
|
var id = await _dbContext.InsertReturnIdentityAsync(voucher);
|
||||||
|
details.ForEach(x => x.VoucherId = id);
|
||||||
|
await _dbContext.InsertAsync(details);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user