You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

79 lines
2.7 KiB

  1. using HKCardOUT.Helper;
  2. using Logic.RemoteModel;
  3. using Newtonsoft.Json.Linq;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Markup;
  10. using UHFHelper;
  11. using XExten.Advance.HttpFramework.MultiCommon;
  12. using XExten.Advance.HttpFramework.MultiFactory;
  13. using XExten.Advance.LinqFramework;
  14. namespace HKCardOUT.Logic
  15. {
  16. public class RemoteService
  17. {
  18. /// <summary>
  19. /// 判断卡状态
  20. /// </summary>
  21. /// <param name="input"></param>
  22. public static int CheckCardStuatas(string CardNo)
  23. {
  24. var data = IHttpMultiClient.HttpMulti.AddNode(t =>
  25. {
  26. t.NodePath = ApiRoute.CheckCardStatus;
  27. t.ReqType = MultiType.POST;
  28. t.JsonParam = (new { cardNum = CardNo }).ToJson();
  29. }).Build().RunStringFirst().ToModel<JObject>()["data"]["cardState"];
  30. return data != null ? data.ToString().AsInt() : 0;
  31. }
  32. /// <summary>
  33. /// 同步消费记录
  34. /// </summary>
  35. /// <param name="CardNo"></param>
  36. /// <param name="Money"></param>
  37. public static bool SyncSaleLog(string CardNo, string StallId)
  38. {
  39. try
  40. {
  41. var GateId = DataBus.StoreInfo.Devices.FirstOrDefault(t => t.Address.AsInt() == StallId.AsInt())?.GateId;
  42. var data = IHttpMultiClient.HttpMulti.AddNode(t =>
  43. {
  44. t.ReqType = MultiType.POST;
  45. t.JsonParam = (new { GateId = GateId, Type = -1, CardNum = CardNo }).ToJson();
  46. t.NodePath = ApiRoute.SyncSaleLog;
  47. }).Build().RunStringFirst();
  48. HKLog.HKLogImport.WriteInfo($"同步消费时候调用:{data}");
  49. var m = bool.Parse(data.ToModel<JObject>()["data"].ToString());
  50. if (m)
  51. {
  52. UHF_RS485_Helper.GetInstance().OpenBeep(StallId.AsInt());
  53. return m;
  54. }
  55. else return false;
  56. }
  57. catch (Exception ex)
  58. {
  59. HKLog.HKLogImport.WriteError(ex);
  60. return false;
  61. }
  62. }
  63. /// <summary>
  64. /// 获取店铺信息
  65. /// </summary>
  66. public static void PullShopInfo()
  67. {
  68. var data = IHttpMultiClient.HttpMulti.AddNode(t =>
  69. {
  70. t.NodePath = ApiRoute.PullShopInfo;
  71. }).Build().RunStringFirst()
  72. .ToModel<JObject>()["data"].ToJson().ToModel<StoreInfoResponse>();
  73. DataBus.StoreInfo = data;
  74. }
  75. }
  76. }