feat 电子餐券

This commit is contained in:
2024-08-14 15:07:08 +08:00
parent f76052427d
commit 96b43876b8

View File

@@ -1,4 +1,4 @@
using Dlhis.Canteen.Order.Dto;
using Dlhis.Canteen.Order.Dto;
using Dlhis.Canteen.Setting.Services;
using Dlhis.Entity.Basic.Entity;
using Dlhis.Entity.Canteen.Entities;
@@ -575,6 +575,22 @@ public class OrderService : BaseOrderService, IOrderService
};
}
else
{
if (request.IsOffline)
{
if (request.ThirdNo.IsPresent())
{
try
{
await EMealVoucherConsumeAsync(request.Adapt<ConsumeRequest>(), gainfo);
}
catch (Exception ex)
{
message = ex.Message;
}
}
else
{
if (request.IsOffline)
{
@@ -674,15 +690,16 @@ public class OrderService : BaseOrderService, IOrderService
return await DbContext.Queryable<GainfoEntity>().Where(x => x.Code == gainfoQrCode.UserCode).SingleAsync();
}
private async Task EMealVoucherConsumeAsync(ConsumeRequest request, GainfoEntity gainfo, string originData, string no, string ts, string idNo)
{
var nowDate = DateTime.Now.Date;
var current = await DbContext.Queryable<EMealVoucherDetailEntity>()
.Where(x => x.No == no && x.IdNo == idNo).SingleAsync();
(nowDate >= current.Start && nowDate <= current.End).ThrowIfFalse("餐券已过期");
var time = DateTimeOffset.FromUnixTimeMilliseconds(Convert.ToInt64(ts.Reverse().Join(string.Empty))).ToLocalTime().DateTime;
(time.AddMinutes(60) >= DateTime.Now).ThrowIfFalse("二维码已过期");
var eMealVoucher = await DbContext.Queryable<EMealVoucherEntity>().Where(x => x.No == no).SingleAsync();
@@ -750,6 +767,7 @@ public class OrderService : BaseOrderService, IOrderService
.SetColumns(x => x.ModifiedTime == DateTime.Now)
.Where(x => x.Id == orderId)
.ExecuteCommandAsync();
}
catch (Exception ex)
{