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 System.Windows.Markup;
using UHFHelper;
using XExten.Advance.HttpFramework.MultiCommon;
using XExten.Advance.HttpFramework.MultiFactory;
using XExten.Advance.LinqFramework;
namespace HKCardOUT.Logic
{
public class RemoteService
{
///
/// 判断卡状态
///
///
public static int CheckCardStuatas(string CardNo)
{
var data = IHttpMultiClient.HttpMulti.AddNode(t =>
{
t.NodePath = ApiRoute.CheckCardStatus;
t.ReqType = MultiType.POST;
t.JsonParam = (new { cardNum = CardNo }).ToJson();
}).Build().RunStringFirst().ToModel()["data"]["cardState"];
return data != null ? data.ToString().AsInt() : 0;
}
///
/// 同步消费记录
///
///
///
public static bool SyncSaleLog(string CardNo, string StallId)
{
try
{
var GateId = DataBus.StoreInfo.Devices.FirstOrDefault(t => t.Address.AsInt() == StallId.AsInt())?.GateId;
var data = IHttpMultiClient.HttpMulti.AddNode(t =>
{
t.ReqType = MultiType.POST;
t.JsonParam = (new { GateId = GateId, Type = -1, CardNum = CardNo }).ToJson();
t.NodePath = ApiRoute.SyncSaleLog;
}).Build().RunStringFirst();
HKLog.HKLogImport.WriteInfo($"同步消费时候调用:{data}");
var m = bool.Parse(data.ToModel()["data"].ToString());
if (m)
{
UHF_RS485_Helper.GetInstance().OpenBeep(StallId.AsInt());
return m;
}
else return false;
}
catch (Exception ex)
{
HKLog.HKLogImport.WriteError(ex);
return false;
}
}
///
/// 获取店铺信息
///
public static void PullShopInfo()
{
var data = IHttpMultiClient.HttpMulti.AddNode(t =>
{
t.NodePath = ApiRoute.PullShopInfo;
}).Build().RunStringFirst()
.ToModel()["data"].ToJson().ToModel();
DataBus.StoreInfo = data;
}
}
}