From 2802f19190dd5233e7fd5c07994ea6ec6ee13768 Mon Sep 17 00:00:00 2001 From: liguoyang Date: Wed, 14 Aug 2024 15:07:08 +0800 Subject: [PATCH] =?UTF-8?q?feat=20=E7=94=B5=E5=AD=90=E9=A4=90=E5=88=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Order/Services/Implements/OrderService.cs | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/Src/Dlhis.Canteen/Order/Services/Implements/OrderService.cs b/Src/Dlhis.Canteen/Order/Services/Implements/OrderService.cs index d0c8b274..bea63211 100644 --- a/Src/Dlhis.Canteen/Order/Services/Implements/OrderService.cs +++ b/Src/Dlhis.Canteen/Order/Services/Implements/OrderService.cs @@ -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(), gainfo); + } + catch (Exception ex) + { + message = ex.Message; + } + } + else { if (request.IsOffline) { @@ -674,15 +690,16 @@ public class OrderService : BaseOrderService, IOrderService return await DbContext.Queryable().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() .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().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) {