Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

101 rader
3.4 KiB

  1. using HKCardOUT.Helper;
  2. using HKCardOUT.Logic.Model;
  3. using HKCardOUT.Logic.Service;
  4. using Logic.RemoteModel;
  5. using Newtonsoft.Json.Linq;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.IO;
  9. using System.Linq;
  10. using System.Text;
  11. using System.Threading.Tasks;
  12. using System.Windows.Markup;
  13. using UHFHelper;
  14. using XExten.Advance.HttpFramework.MultiCommon;
  15. using XExten.Advance.HttpFramework.MultiFactory;
  16. using XExten.Advance.LinqFramework;
  17. using XExten.Advance.StaticFramework;
  18. namespace HKCardOUT.Logic
  19. {
  20. public class RemoteService
  21. {
  22. /// <summary>
  23. /// 获取所有卡状态和卡号
  24. /// </summary>
  25. /// <param name="input"></param>
  26. public static int GetCardStuatas()
  27. {
  28. var data = IHttpMultiClient.HttpMulti.AddNode(t =>
  29. {
  30. t.NodePath = ApiRoute.CheckCardStatus;
  31. t.ReqType = MultiType.GET;
  32. }).Build().RunStringFirst().ToModel<JObject>()["data"]["cardState"];
  33. HKCore.AddCard(new CardStutas
  34. {
  35. });
  36. return data != null ? data.ToString().AsInt() : 0;
  37. }
  38. /// <summary>
  39. /// 同步时间段
  40. /// </summary>
  41. public static void SyncTime()
  42. {
  43. var data = IHttpMultiClient.HttpMulti.AddNode(t =>
  44. {
  45. t.NodePath = ApiRoute.CheckCardStatus;
  46. t.ReqType = MultiType.GET;
  47. }).Build().RunStringFirst().ToModel<JObject>()["data"];
  48. }
  49. /// <summary>
  50. /// 同步消费记录
  51. /// </summary>
  52. /// <param name="CardNo"></param>
  53. /// <param name="Money"></param>
  54. public static bool SyncSaleLog(string CardNo, string StallId)
  55. {
  56. try
  57. {
  58. var GateId = DataBus.StoreInfo.Devices.FirstOrDefault(t => t.Address.AsInt() == StallId.AsInt())?.GateId;
  59. var data = IHttpMultiClient.HttpMulti.AddNode(t =>
  60. {
  61. t.ReqType = MultiType.POST;
  62. t.JsonParam = (new { GateId = GateId, Type = -1, CardNum = CardNo }).ToJson();
  63. t.NodePath = ApiRoute.SyncSaleLog;
  64. }).Build().RunStringFirst();
  65. HKLog.HKLogImport.WriteInfo($"同步消费时候调用:{data}");
  66. return bool.Parse(data.ToModel<JObject>()["data"].ToString());
  67. }
  68. catch (Exception ex)
  69. {
  70. HKLog.HKLogImport.WriteError(ex);
  71. return false;
  72. }
  73. }
  74. /// <summary>
  75. /// 获取店铺信息
  76. /// </summary>
  77. public static void PullShopInfo()
  78. {
  79. if (DataBus.NetWordState)
  80. {
  81. var data = IHttpMultiClient.HttpMulti.AddNode(t =>
  82. {
  83. t.NodePath = ApiRoute.PullShopInfo;
  84. }).Build().RunStringFirst()
  85. .ToModel<JObject>()["data"].ToJson().ToModel<StoreInfoResponse>();
  86. DataBus.StoreInfo = data;
  87. var storeinfo = SyncStatic.CreateFile(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "StoreInfo.json"));
  88. SyncStatic.WriteFile(Encoding.UTF8.GetBytes(data.ToJson()), storeinfo);
  89. }
  90. else
  91. {
  92. DataBus.StoreInfo = SyncStatic.ReadFile(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "StoreInfo.json")).ToModel<StoreInfoResponse>();
  93. }
  94. }
  95. }
  96. }