diff --git a/HKCardOUT/Helper/DataBus.cs b/HKCardOUT/Helper/DataBus.cs index 5b09e61..a9505f8 100644 --- a/HKCardOUT/Helper/DataBus.cs +++ b/HKCardOUT/Helper/DataBus.cs @@ -36,11 +36,11 @@ namespace HKCardOUT.Helper /// /// 检查卡的状态 /// - public static string CheckCardStatus = DataBus.SaasRoute + ""; + public static string CheckCardStatus = DataBus.SaasRoute + "api/member-helper/membercardinfo/"; /// /// 同步消费记录 /// - public static string SyncSaleLog = DataBus.SaasRoute + ""; + public static string SyncSaleLog = DataBus.SaasRoute + "api/member-helper/memberconsumptionorrecharge"; /// /// 获取店铺信息 /// diff --git a/HKCardOUT/Logic/RemoteService.cs b/HKCardOUT/Logic/RemoteService.cs index 9c23f1a..36da2c0 100644 --- a/HKCardOUT/Logic/RemoteService.cs +++ b/HKCardOUT/Logic/RemoteService.cs @@ -6,6 +6,8 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using System.Windows.Markup; +using XExten.Advance.HttpFramework.MultiCommon; using XExten.Advance.HttpFramework.MultiFactory; using XExten.Advance.LinqFramework; @@ -17,34 +19,38 @@ namespace HKCardOUT.Logic /// 判断卡状态 /// /// - public static void CheckCardStuatas(string input) + public static int CheckCardStuatas(string CardNo) { - IHttpMultiClient.HttpMulti.AddNode(t => - { - t.NodePath = ApiRoute.CheckCardStatus; - }).Build().RunStringFirst(); + return IHttpMultiClient.HttpMulti.AddNode(t => + { + t.NodePath = ApiRoute.CheckCardStatus + CardNo; + }).Build().RunStringFirst().ToModel()["data"]["cardState"].ToString().AsInt(); } /// /// 同步消费记录 /// - /// - public static void SyncSaleLog(dynamic input) + /// + /// + public static bool SyncSaleLog(string CardNo, decimal Money) { - IHttpMultiClient.HttpMulti.AddNode(t => - { - t.NodePath = ApiRoute.SyncSaleLog; - }).Build().RunStringFirst(); + var data = IHttpMultiClient.HttpMulti.AddNode(t => + { + t.ReqType = MultiType.POST; + t.JsonParam = (new { Money, Type = -1, CardNum = CardNo }).ToJson(); + t.NodePath = ApiRoute.SyncSaleLog; + }).Build().RunStringFirst(); + return bool.Parse(data.ToModel()["data"].ToString()); } /// /// 获取店铺信息 /// public static void PullShopInfo() { - var data = IHttpMultiClient.HttpMulti.AddNode(t => - { - t.NodePath = ApiRoute.PullShopInfo; - }).Build().RunStringFirst() - .ToModel()["data"].ToJson().ToModel(); + var data = IHttpMultiClient.HttpMulti.AddNode(t => + { + t.NodePath = ApiRoute.PullShopInfo; + }).Build().RunStringFirst() + .ToModel()["data"].ToJson().ToModel(); DataBus.StoreInfo = data; } } diff --git a/HKCardOUT/Logic/Service/HKCore.cs b/HKCardOUT/Logic/Service/HKCore.cs index 346712f..bf05ebd 100644 --- a/HKCardOUT/Logic/Service/HKCore.cs +++ b/HKCardOUT/Logic/Service/HKCore.cs @@ -1,4 +1,5 @@ -using HKCardOUT.Logic.Model; +using HandyControl.Controls; +using HKCardOUT.Logic.Model; using System; using System.Collections.Generic; using System.Linq; @@ -16,6 +17,7 @@ namespace HKCardOUT.Logic.Service /// public bool DeviceSale(SaleLog input) { + if (RemoteService.CheckCardStuatas(input.CardNo) != 1) return false; var Old = DbContext.Context.Queryable() .Where(t => t.CardNo == input.CardNo).OrderByDescending(t => t.CreateTime).First(); if (Old != null) @@ -23,7 +25,11 @@ namespace HKCardOUT.Logic.Service //10秒防止重复刷卡 if (Old.CreateTime.Subtract(DateTime.Now).TotalSeconds > 10d) { - return DbContext.Context.Insertable(input).CallEntityMethod(t => t.Create()).ExecuteCommand() > 0; + if (DbContext.Context.Insertable(input).CallEntityMethod(t => t.Create()).ExecuteCommand() > 0) + { + var res = RemoteService.SyncSaleLog(input.CardNo, input.Money); + + } } return false; }