From db0655dfe7a13cf8fd7215caeb4af2628222679e Mon Sep 17 00:00:00 2001 From: xxe Date: Thu, 6 Oct 2022 13:56:39 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=80=E4=BB=B6=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HKCardOUT/Bootstrapper.cs | 4 +++- HKCardOUT/Helper/DataBus.cs | 4 +++- HKCardOUT/Logic/Service/HKCore.cs | 29 +++++++++++++++-------------- HKCardOUT/options.json | 15 +++++++++++---- 4 files changed, 32 insertions(+), 20 deletions(-) diff --git a/HKCardOUT/Bootstrapper.cs b/HKCardOUT/Bootstrapper.cs index 4f88dd8..b25ffc0 100644 --- a/HKCardOUT/Bootstrapper.cs +++ b/HKCardOUT/Bootstrapper.cs @@ -42,9 +42,11 @@ namespace HKCardOUT DataBus.SaasRoute = configer["SaasRoute"]; DataBus.StoreId = configer["StoreId"]; DataBus.COM = configer["COM"]; - DataBus.IsTest = configer["IsTest"].AsBool(); + DataBus.StartDevice = configer["StartDevice"].AsBool(); + DataBus.Cancel = configer["Cancel"].AsBool(); DataBus.AM = configer["AM"]; DataBus.PM = configer["PM"]; + DataBus.Count = configer["Count"].AsInt(); DataBus.AT = configer["AT"]; DbContext.InitTable(); RemoteService.PullShopInfo(); diff --git a/HKCardOUT/Helper/DataBus.cs b/HKCardOUT/Helper/DataBus.cs index 71af5ca..d80d49d 100644 --- a/HKCardOUT/Helper/DataBus.cs +++ b/HKCardOUT/Helper/DataBus.cs @@ -26,13 +26,15 @@ namespace HKCardOUT.Helper } public static bool NetWordState { get; set; } = false; public static string Cron { get; set; } - public static bool IsTest { get; set; } + public static bool StartDevice { get; set; } + public static bool Cancel { get; set; } public static string StoreId { get; set; } public static string COM { get; set; } public static string SaasRoute { get; set; } public static string AM { get; set; } public static string PM { get; set; } public static string AT { get; set; } + public static int Count { get; set; } public static StoreInfoResponse StoreInfo { get; set; } public static Dictionary AdStatus { get; set; } = new Dictionary(); } diff --git a/HKCardOUT/Logic/Service/HKCore.cs b/HKCardOUT/Logic/Service/HKCore.cs index a0ccf68..1eeca0d 100644 --- a/HKCardOUT/Logic/Service/HKCore.cs +++ b/HKCardOUT/Logic/Service/HKCore.cs @@ -13,16 +13,17 @@ namespace HKCardOUT.Logic.Service { public class HKCore { - List Commom(SaleLog input) + List Commom(SaleLog input) { - if (!DataBus.IsTest) + if (DataBus.StartDevice) if (!Main.GetInstance.GetIsSwipe(input.Location.AsInt())) return null; var Old = DbContext.Context.Queryable() .Where(t => t.CardNo == input.CardNo) .Where(t => t.CreateTime.Year == DateTime.Now.Year) .Where(t => t.CreateTime.Month == DateTime.Now.Month) .Where(t => t.CreateTime.Day == DateTime.Now.Day).ToList(); - if (Old.Count > 3) return null; + if (DataBus.Cancel) + if (Old.Count > 3) return null; return Old; } /// @@ -45,7 +46,7 @@ namespace HKCardOUT.Logic.Service .Count(); HKLog.HKLogImport.WriteInfo($"卡号{input.CardNo}上午消费次数:{AMDay}"); - if (AMDay < 1) + if (AMDay < DataBus.Count) { var entity = DbContext.Context.Insertable(input).CallEntityMethod(t => t.Create()).ExecuteReturnEntity(); if (entity.Id != Guid.Empty) @@ -54,16 +55,16 @@ namespace HKCardOUT.Logic.Service if (DataBus.NetWordState) { //先出餐后推数据 - if (!DataBus.IsTest) + if (DataBus.StartDevice) Main.GetInstance.Start(input.Location.AsInt()); var res = RemoteService.SyncSaleLog(input.CardNo, input.Location); - if(res) + if (res) DbContext.Context.Updateable().SetColumns(t => t.IsSync == true).Where(t => t.Id == entity.Id).ExecuteCommand(); return res; } else { - if (!DataBus.IsTest) + if (DataBus.StartDevice) Main.GetInstance.Start(input.Location.AsInt()); return true; } @@ -97,7 +98,7 @@ namespace HKCardOUT.Logic.Service .Where(t => t.CreateTime.Day == DateTime.Now.Day) .Count(); HKLog.HKLogImport.WriteInfo($"卡号{input.CardNo}中午消费次数:{PMDay}"); - if (PMDay < 1) + if (PMDay < DataBus.Count) { var entity = DbContext.Context.Insertable(input).CallEntityMethod(t => t.Create()).ExecuteReturnEntity(); if (entity.Id != Guid.Empty) @@ -106,7 +107,7 @@ namespace HKCardOUT.Logic.Service if (DataBus.NetWordState) { //先出餐后推数据 - if (!DataBus.IsTest) + if (DataBus.StartDevice) Main.GetInstance.Start(input.Location.AsInt()); var res = RemoteService.SyncSaleLog(input.CardNo, input.Location); if (res) @@ -115,7 +116,7 @@ namespace HKCardOUT.Logic.Service } else { - if (!DataBus.IsTest) + if (DataBus.StartDevice) Main.GetInstance.Start(input.Location.AsInt()); return true; } @@ -149,7 +150,7 @@ namespace HKCardOUT.Logic.Service .Where(t => t.CreateTime.Day == DateTime.Now.Day) .Count(); HKLog.HKLogImport.WriteInfo($"卡号{input.CardNo}下午消费次数:{ATDay}"); - if (ATDay < 1) + if (ATDay < DataBus.Count) { var entity = DbContext.Context.Insertable(input).CallEntityMethod(t => t.Create()).ExecuteReturnEntity(); if (entity.Id != Guid.Empty) @@ -158,16 +159,16 @@ namespace HKCardOUT.Logic.Service if (DataBus.NetWordState) { //先出餐后推数据 - if (!DataBus.IsTest) + if (DataBus.StartDevice) Main.GetInstance.Start(input.Location.AsInt()); var res = RemoteService.SyncSaleLog(input.CardNo, input.Location); if (res) DbContext.Context.Updateable().SetColumns(t => t.IsSync == true).Where(t => t.Id == entity.Id).ExecuteCommand(); return res; } - else + else { - if (!DataBus.IsTest) + if (DataBus.StartDevice) Main.GetInstance.Start(input.Location.AsInt()); return true; } diff --git a/HKCardOUT/options.json b/HKCardOUT/options.json index d1989c7..238dae0 100644 --- a/HKCardOUT/options.json +++ b/HKCardOUT/options.json @@ -1,12 +1,15 @@ { //服务地址 "SaasRoute": "https://bpa.black-pa.com:21527/kitchen/", - "IsTest": true, - "COM": "COM4", +//启动设备调试 + "StartDevice": true, + //串口 + "COM": "COM3", //定时任务时间表达式 - "Cron": "0 0 0/1 * * ? ", + "Cron": "0/15 * * * * ? ", //店铺ID "StoreId": "a19535e8-119f-4b10-a011-6288fd3ddb37", + //本地数据库 "ConnectionStrings": { "Sqlite": "HKSQL.db3" }, @@ -15,5 +18,9 @@ //中午 "PM": "11,14", //下午 - "AT": "17,20" + "AT": "17,20", + //每个时间段的刷卡次数 + "Count":1, + //取消单卡刷卡限制 + "Cancel":true }