Browse Source

一件测试

Lishi
xxe 2 years ago
parent
commit
db0655dfe7
4 changed files with 32 additions and 20 deletions
  1. +3
    -1
      HKCardOUT/Bootstrapper.cs
  2. +3
    -1
      HKCardOUT/Helper/DataBus.cs
  3. +15
    -14
      HKCardOUT/Logic/Service/HKCore.cs
  4. +11
    -4
      HKCardOUT/options.json

+ 3
- 1
HKCardOUT/Bootstrapper.cs View File

@@ -42,9 +42,11 @@ namespace HKCardOUT
DataBus.SaasRoute = configer["SaasRoute"]; DataBus.SaasRoute = configer["SaasRoute"];
DataBus.StoreId = configer["StoreId"]; DataBus.StoreId = configer["StoreId"];
DataBus.COM = configer["COM"]; DataBus.COM = configer["COM"];
DataBus.IsTest = configer["IsTest"].AsBool();
DataBus.StartDevice = configer["StartDevice"].AsBool();
DataBus.Cancel = configer["Cancel"].AsBool();
DataBus.AM = configer["AM"]; DataBus.AM = configer["AM"];
DataBus.PM = configer["PM"]; DataBus.PM = configer["PM"];
DataBus.Count = configer["Count"].AsInt();
DataBus.AT = configer["AT"]; DataBus.AT = configer["AT"];
DbContext.InitTable(); DbContext.InitTable();
RemoteService.PullShopInfo(); RemoteService.PullShopInfo();


+ 3
- 1
HKCardOUT/Helper/DataBus.cs View File

@@ -26,13 +26,15 @@ namespace HKCardOUT.Helper
} }
public static bool NetWordState { get; set; } = false; public static bool NetWordState { get; set; } = false;
public static string Cron { get; set; } 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 StoreId { get; set; }
public static string COM { get; set; } public static string COM { get; set; }
public static string SaasRoute { get; set; } public static string SaasRoute { get; set; }
public static string AM { get; set; } public static string AM { get; set; }
public static string PM { get; set; } public static string PM { get; set; }
public static string AT { get; set; } public static string AT { get; set; }
public static int Count { get; set; }
public static StoreInfoResponse StoreInfo { get; set; } public static StoreInfoResponse StoreInfo { get; set; }
public static Dictionary<string, AdWindow> AdStatus { get; set; } = new Dictionary<string, AdWindow>(); public static Dictionary<string, AdWindow> AdStatus { get; set; } = new Dictionary<string, AdWindow>();
} }


+ 15
- 14
HKCardOUT/Logic/Service/HKCore.cs View File

@@ -13,16 +13,17 @@ namespace HKCardOUT.Logic.Service
{ {
public class HKCore public class HKCore
{ {
List<SaleLog> Commom(SaleLog input)
List<SaleLog> Commom(SaleLog input)
{ {
if (!DataBus.IsTest)
if (DataBus.StartDevice)
if (!Main.GetInstance.GetIsSwipe(input.Location.AsInt())) return null; if (!Main.GetInstance.GetIsSwipe(input.Location.AsInt())) return null;
var Old = DbContext.Context.Queryable<SaleLog>() var Old = DbContext.Context.Queryable<SaleLog>()
.Where(t => t.CardNo == input.CardNo) .Where(t => t.CardNo == input.CardNo)
.Where(t => t.CreateTime.Year == DateTime.Now.Year) .Where(t => t.CreateTime.Year == DateTime.Now.Year)
.Where(t => t.CreateTime.Month == DateTime.Now.Month) .Where(t => t.CreateTime.Month == DateTime.Now.Month)
.Where(t => t.CreateTime.Day == DateTime.Now.Day).ToList(); .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; return Old;
} }
/// <summary> /// <summary>
@@ -45,7 +46,7 @@ namespace HKCardOUT.Logic.Service
.Count(); .Count();
HKLog.HKLogImport.WriteInfo($"卡号{input.CardNo}上午消费次数:{AMDay}"); HKLog.HKLogImport.WriteInfo($"卡号{input.CardNo}上午消费次数:{AMDay}");


if (AMDay < 1)
if (AMDay < DataBus.Count)
{ {
var entity = DbContext.Context.Insertable(input).CallEntityMethod(t => t.Create()).ExecuteReturnEntity(); var entity = DbContext.Context.Insertable(input).CallEntityMethod(t => t.Create()).ExecuteReturnEntity();
if (entity.Id != Guid.Empty) if (entity.Id != Guid.Empty)
@@ -54,16 +55,16 @@ namespace HKCardOUT.Logic.Service
if (DataBus.NetWordState) if (DataBus.NetWordState)
{ {
//先出餐后推数据 //先出餐后推数据
if (!DataBus.IsTest)
if (DataBus.StartDevice)
Main.GetInstance.Start(input.Location.AsInt()); Main.GetInstance.Start(input.Location.AsInt());
var res = RemoteService.SyncSaleLog(input.CardNo, input.Location); var res = RemoteService.SyncSaleLog(input.CardNo, input.Location);
if(res)
if (res)
DbContext.Context.Updateable<SaleLog>().SetColumns(t => t.IsSync == true).Where(t => t.Id == entity.Id).ExecuteCommand(); DbContext.Context.Updateable<SaleLog>().SetColumns(t => t.IsSync == true).Where(t => t.Id == entity.Id).ExecuteCommand();
return res; return res;
} }
else else
{ {
if (!DataBus.IsTest)
if (DataBus.StartDevice)
Main.GetInstance.Start(input.Location.AsInt()); Main.GetInstance.Start(input.Location.AsInt());
return true; return true;
} }
@@ -97,7 +98,7 @@ namespace HKCardOUT.Logic.Service
.Where(t => t.CreateTime.Day == DateTime.Now.Day) .Where(t => t.CreateTime.Day == DateTime.Now.Day)
.Count(); .Count();
HKLog.HKLogImport.WriteInfo($"卡号{input.CardNo}中午消费次数:{PMDay}"); HKLog.HKLogImport.WriteInfo($"卡号{input.CardNo}中午消费次数:{PMDay}");
if (PMDay < 1)
if (PMDay < DataBus.Count)
{ {
var entity = DbContext.Context.Insertable(input).CallEntityMethod(t => t.Create()).ExecuteReturnEntity(); var entity = DbContext.Context.Insertable(input).CallEntityMethod(t => t.Create()).ExecuteReturnEntity();
if (entity.Id != Guid.Empty) if (entity.Id != Guid.Empty)
@@ -106,7 +107,7 @@ namespace HKCardOUT.Logic.Service
if (DataBus.NetWordState) if (DataBus.NetWordState)
{ {
//先出餐后推数据 //先出餐后推数据
if (!DataBus.IsTest)
if (DataBus.StartDevice)
Main.GetInstance.Start(input.Location.AsInt()); Main.GetInstance.Start(input.Location.AsInt());
var res = RemoteService.SyncSaleLog(input.CardNo, input.Location); var res = RemoteService.SyncSaleLog(input.CardNo, input.Location);
if (res) if (res)
@@ -115,7 +116,7 @@ namespace HKCardOUT.Logic.Service
} }
else else
{ {
if (!DataBus.IsTest)
if (DataBus.StartDevice)
Main.GetInstance.Start(input.Location.AsInt()); Main.GetInstance.Start(input.Location.AsInt());
return true; return true;
} }
@@ -149,7 +150,7 @@ namespace HKCardOUT.Logic.Service
.Where(t => t.CreateTime.Day == DateTime.Now.Day) .Where(t => t.CreateTime.Day == DateTime.Now.Day)
.Count(); .Count();
HKLog.HKLogImport.WriteInfo($"卡号{input.CardNo}下午消费次数:{ATDay}"); HKLog.HKLogImport.WriteInfo($"卡号{input.CardNo}下午消费次数:{ATDay}");
if (ATDay < 1)
if (ATDay < DataBus.Count)
{ {
var entity = DbContext.Context.Insertable(input).CallEntityMethod(t => t.Create()).ExecuteReturnEntity(); var entity = DbContext.Context.Insertable(input).CallEntityMethod(t => t.Create()).ExecuteReturnEntity();
if (entity.Id != Guid.Empty) if (entity.Id != Guid.Empty)
@@ -158,16 +159,16 @@ namespace HKCardOUT.Logic.Service
if (DataBus.NetWordState) if (DataBus.NetWordState)
{ {
//先出餐后推数据 //先出餐后推数据
if (!DataBus.IsTest)
if (DataBus.StartDevice)
Main.GetInstance.Start(input.Location.AsInt()); Main.GetInstance.Start(input.Location.AsInt());
var res = RemoteService.SyncSaleLog(input.CardNo, input.Location); var res = RemoteService.SyncSaleLog(input.CardNo, input.Location);
if (res) if (res)
DbContext.Context.Updateable<SaleLog>().SetColumns(t => t.IsSync == true).Where(t => t.Id == entity.Id).ExecuteCommand(); DbContext.Context.Updateable<SaleLog>().SetColumns(t => t.IsSync == true).Where(t => t.Id == entity.Id).ExecuteCommand();
return res; return res;
} }
else
else
{ {
if (!DataBus.IsTest)
if (DataBus.StartDevice)
Main.GetInstance.Start(input.Location.AsInt()); Main.GetInstance.Start(input.Location.AsInt());
return true; return true;
} }


+ 11
- 4
HKCardOUT/options.json View File

@@ -1,12 +1,15 @@
{ {
//服务地址 //服务地址
"SaasRoute": "https://bpa.black-pa.com:21527/kitchen/", "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 //店铺ID
"StoreId": "a19535e8-119f-4b10-a011-6288fd3ddb37", "StoreId": "a19535e8-119f-4b10-a011-6288fd3ddb37",
//本地数据库
"ConnectionStrings": { "ConnectionStrings": {
"Sqlite": "HKSQL.db3" "Sqlite": "HKSQL.db3"
}, },
@@ -15,5 +18,9 @@
//中午 //中午
"PM": "11,14", "PM": "11,14",
//下午 //下午
"AT": "17,20"
"AT": "17,20",
//每个时间段的刷卡次数
"Count":1,
//取消单卡刷卡限制
"Cancel":true
} }

Loading…
Cancel
Save