From 052926d5c5852ac561832c2408080de3959c1dc1 Mon Sep 17 00:00:00 2001 From: xxe Date: Mon, 12 Sep 2022 12:30:08 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=B7=E5=8D=A1=E7=AB=AF=E5=BA=97=E9=93=BA?= =?UTF-8?q?=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HKCardOUT/Bootstrapper.cs | 2 + HKCardOUT/Helper/DataBus.cs | 9 ++- .../Logic/RemoteModel/StoreInfoResponse.cs | 70 +++++++++++++++++++ HKCardOUT/Logic/RemoteService.cs | 16 ++--- HKCardOUT/ViewModels/RootViewModel.cs | 8 +++ HKCardOUT/options.json | 1 + 6 files changed, 90 insertions(+), 16 deletions(-) create mode 100644 HKCardOUT/Logic/RemoteModel/StoreInfoResponse.cs diff --git a/HKCardOUT/Bootstrapper.cs b/HKCardOUT/Bootstrapper.cs index 3b32dae..e00f096 100644 --- a/HKCardOUT/Bootstrapper.cs +++ b/HKCardOUT/Bootstrapper.cs @@ -38,7 +38,9 @@ namespace HKCardOUT DataBus.ConnectionString = configer.GetConnectionString("Sqlite"); DataBus.Cron = configer["Cron"]; DataBus.SaasRoute = configer["SaasRoute"]; + DataBus.StoreId = configer["StoreId"]; DbContext.InitTable(); + //RemoteService.PullShopInfo(); base.Configure(); } diff --git a/HKCardOUT/Helper/DataBus.cs b/HKCardOUT/Helper/DataBus.cs index 676513b..5b09e61 100644 --- a/HKCardOUT/Helper/DataBus.cs +++ b/HKCardOUT/Helper/DataBus.cs @@ -1,4 +1,5 @@ using HKCardOUT.Views; +using Logic.RemoteModel; using System; using System.Collections.Generic; using System.Globalization; @@ -25,7 +26,9 @@ namespace HKCardOUT.Helper } public static bool NetWordState { get; set; } = false; public static string Cron { get; set; } + public static string StoreId { get; set; } public static string SaasRoute { get; set; } + public static StoreInfoResponse StoreInfo { get; set; } public static Dictionary AdStatus { get; set; } = new Dictionary(); } public class ApiRoute @@ -39,13 +42,9 @@ namespace HKCardOUT.Helper /// public static string SyncSaleLog = DataBus.SaasRoute + ""; /// - /// 获取档口信息 - /// - public static string PullWindow = DataBus.SaasRoute + ""; - /// /// 获取店铺信息 /// - public static string PullShopInfo = DataBus.SaasRoute + ""; + public static string PullShopInfo = DataBus.SaasRoute + $"api/StoreHelper/GeBasisGateList?StoreId={DataBus.StoreId}"; } public class HKConverter : IValueConverter { diff --git a/HKCardOUT/Logic/RemoteModel/StoreInfoResponse.cs b/HKCardOUT/Logic/RemoteModel/StoreInfoResponse.cs new file mode 100644 index 0000000..9159ead --- /dev/null +++ b/HKCardOUT/Logic/RemoteModel/StoreInfoResponse.cs @@ -0,0 +1,70 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Text; + +namespace Logic.RemoteModel +{ + public class StoreInfoResponse + { + /// + /// 档口 + /// + [JsonProperty("gateList")] + public List Stalls { get; set; } + /// + /// 设备 + /// + [JsonProperty("payCardList")] + public List Devices { get; set; } + } + public class StallModelResponse + { + + public string Id { get; set; } + /// + /// 档口名称 + /// + public string Name { get; set; } + /// + /// 归属门店 + /// + public string StoreId { get; set; } + /// + /// 收费方式(1,固定金额2,自由设定) + /// + public int Mode { get; set; } + /// + /// 收款金额 + /// + public decimal Price { get; set; } + /// + /// 广告 + /// + public string Remaek { get; set; } + /// + ///状态0正常,1停用 + /// + public int Status { get; set; } + } + public class DeviceModelResponse + { + public string Id { get; set; } + /// + /// 刷卡设备名称 + /// + public string Name { get; set; } + /// + /// 档口id + /// + public string GateId { get; set; } + /// + /// 刷卡间隔时间 + /// + public int SleepTime { get; set; } + /// + /// 状态0正常,1停用 + /// + public int Status { get; set; } + } +} diff --git a/HKCardOUT/Logic/RemoteService.cs b/HKCardOUT/Logic/RemoteService.cs index ff3f1a4..be228f8 100644 --- a/HKCardOUT/Logic/RemoteService.cs +++ b/HKCardOUT/Logic/RemoteService.cs @@ -1,10 +1,13 @@ using HKCardOUT.Helper; +using Logic.RemoteModel; +using Newtonsoft.Json.Linq; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using XExten.Advance.HttpFramework.MultiFactory; +using XExten.Advance.LinqFramework; namespace HKCardOUT.Logic { @@ -33,16 +36,6 @@ namespace HKCardOUT.Logic }).Build().RunStringFirst(); } /// - /// 获取档口信息 - /// - public static void PullWindow() - { - IHttpMultiClient.HttpMulti.AddNode(t => - { - t.NodePath = ApiRoute.PullWindow; - }).Build().RunStringFirst(); - } - /// /// 获取店铺信息 /// public static void PullShopInfo() @@ -50,7 +43,8 @@ namespace HKCardOUT.Logic IHttpMultiClient.HttpMulti.AddNode(t => { t.NodePath = ApiRoute.PullShopInfo; - }).Build().RunStringFirst(); + }).Build().RunStringFirst() + .ToModel()["data"].ToJson().ToModel(); } } } diff --git a/HKCardOUT/ViewModels/RootViewModel.cs b/HKCardOUT/ViewModels/RootViewModel.cs index 19ccb9f..09e814c 100644 --- a/HKCardOUT/ViewModels/RootViewModel.cs +++ b/HKCardOUT/ViewModels/RootViewModel.cs @@ -29,6 +29,14 @@ namespace HKCardOUT.ViewModels Result = new ObservableCollection(this.Container.Get().PullDaySaleLog()); Thread.Sleep(3000); }, "消费记录查询"); + var Init = DataBus.StoreInfo?.Devices.Join(DataBus.StoreInfo?.Stalls, t => t.GateId, x => x.Id, (t, x) => new AdDTO + { + Ad = x.Remaek, + IsActive = false, + Device = $"{x.Name}({t.Name})" + }).ToList(); + if (Init != null) + Ad = new ObservableCollection(Init); } #region 属性 diff --git a/HKCardOUT/options.json b/HKCardOUT/options.json index 4b872b7..a161907 100644 --- a/HKCardOUT/options.json +++ b/HKCardOUT/options.json @@ -1,6 +1,7 @@ { "SaasRoute": "", "Cron": "0 0 11,15 * * ? ", + "StoreId": "", "ConnectionStrings": { "Sqlite": "HKSQL.db3" }