Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

174 строки
6.7 KiB

  1. using HKLib.Dto;
  2. using HKLib.RabbitMQ.Config;
  3. using HKLib.RabbitMQ.Publisher;
  4. using Newtonsoft.Json.Linq;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using XExten.Advance.HttpFramework.MultiCommon;
  8. using XExten.Advance.HttpFramework.MultiFactory;
  9. using XExten.Advance.LinqFramework;
  10. namespace HKLib.Interfaces
  11. {
  12. public class HKLibHelper
  13. {
  14. static Dictionary<string, string> Header = new Dictionary<string, string> {
  15. {"TenantId",Configer.TenantId }
  16. };
  17. /// <summary>
  18. /// 设置刷卡时间端
  19. /// </summary>
  20. public static bool SetTime(TimeSpilte input)
  21. {
  22. return IHttpMultiClient.HttpMulti
  23. .AddHeader(t => t.Headers = Header)
  24. .AddNode(t =>
  25. {
  26. t.NodePath = $"{Configer.SaasRoute}";
  27. t.JsonParam = input.ToJson();
  28. t.ReqType = MultiType.POST;
  29. }).Build().RunStringFirst().ToModel<JObject>()["isSuccess"].ToString().AsBool();
  30. }
  31. /// <summary>
  32. /// 添加机构
  33. /// </summary>
  34. public static string SetOrg(string input)
  35. {
  36. return IHttpMultiClient.HttpMulti
  37. .AddHeader(t => t.Headers = Header)
  38. .AddNode(t =>
  39. {
  40. t.NodePath = $"{Configer.SaasRoute}api/one-card/member-tag";
  41. t.ReqType = MultiType.POST;
  42. t.JsonParam = (new { Name = input }).ToJson();
  43. }).Build().RunStringFirst().ToModel<JObject>()["data"]["data"]["id"].ToString();
  44. }
  45. /// <summary>
  46. /// 修改机构
  47. /// </summary>
  48. public static bool AlterOrg(string input, string Sid)
  49. {
  50. return IHttpMultiClient.HttpMulti.AddHeader(t => t.Headers = Header).AddNode(t =>
  51. {
  52. t.NodePath = $"{Configer.SaasRoute}api/one-card/member-tag";
  53. t.ReqType = MultiType.PUT;
  54. t.JsonParam = (new { Name = input, Id = Sid }).ToJson();
  55. }).Build().RunStringFirst().ToModel<JObject>()["data"]["isSuccess"].ToString().AsBool();
  56. }
  57. /// <summary>
  58. /// 根据用户命获取下拉用户列表
  59. /// </summary>
  60. /// <param name="keyword"></param>
  61. public static List<UserListDto> GetUserList(string keyword)
  62. {
  63. return IHttpMultiClient.HttpMulti.AddHeader(t => t.Headers = Header).AddNode(t =>
  64. {
  65. t.NodePath = $"{Configer.SaasRoute}api/one-card/staff-list";
  66. t.ReqType = MultiType.POST;
  67. t.JsonParam = (new { realName = keyword }).ToJson();
  68. }).Build().RunStringFirst().ToModel<JObject>()["data"]["data"].ToJson().ToModel<List<UserListDto>>();
  69. }
  70. /// <summary>
  71. /// 添加用户并绑卡
  72. /// </summary>
  73. /// <param name="input"></param>
  74. /// <returns></returns>
  75. public static bool AddUserAndBindCard(UserDto input)
  76. {
  77. return IHttpMultiClient.HttpMulti.AddHeader(t => t.Headers = Header).AddNode(t =>
  78. {
  79. t.NodePath = $"{Configer.SaasRoute}api/one-card/mmenber-card";
  80. t.ReqType = MultiType.POST;
  81. t.JsonParam = (new { tagId = input.OrgId, realName = input.Name, phone = input.Phone, cardNum = input.CardNo }).ToJson();
  82. }).Build().RunStringFirst().ToModel<JObject>()["data"]["isSuccess"].ToString().AsBool();
  83. }
  84. /// <summary>
  85. /// 添加用户
  86. /// </summary>
  87. /// <param name="input"></param>
  88. public static bool AddUser(UserDto input)
  89. {
  90. return IHttpMultiClient.HttpMulti.AddHeader(t => t.Headers = Header).AddNode(t =>
  91. {
  92. t.NodePath = $"{Configer.SaasRoute}api/one-card/staff";
  93. t.ReqType = MultiType.POST;
  94. t.JsonParam = (new { tagId = input.OrgId, realName = input.Name, phone = input.Phone }).ToJson();
  95. }).Build().RunStringFirst().ToModel<JObject>()["data"]["isSuccess"].ToString().AsBool();
  96. }
  97. /// <summary>
  98. /// 变更卡状态 销户
  99. /// </summary>
  100. /// <param name="input"></param>
  101. public static bool CardStutasChange(CardStutasDto input)
  102. {
  103. input.CardNo = GetUserList(input.keywrod).FirstOrDefault(t => t.Name.Equals(input.keywrod)).Cards.FirstOrDefault(t => t.State == 1).CardNum;
  104. var x = IHttpMultiClient.HttpMulti.AddHeader(t => t.Headers = Header).AddNode(t =>
  105. {
  106. t.NodePath = $"{Configer.SaasRoute}api/one-card/mmenber-card-state";
  107. t.ReqType = MultiType.PUT;
  108. t.JsonParam = (new { CardNum = input.CardNo, State = input.Stutas }).ToJson();
  109. }).Build().RunStringFirst().ToModel<JObject>()["data"]["isSuccess"].ToString().AsBool();
  110. if (x)
  111. {
  112. ServiceQueryPush.QueryPush.PushMQ(input, "CardStutasChanged", MQEnum.Top);
  113. return x;
  114. }
  115. return false;
  116. }
  117. /// <summary>
  118. /// 报表数据
  119. /// type=1 数据参考
  120. ///
  121. /// {
  122. ///"name": "张三",
  123. /// "phone": "18208263734",
  124. /// "date": "2022-09-24",
  125. /// "tag": null,
  126. /// "amCount": 3,
  127. /// "pmCount": 0,
  128. /// "atCount": 0,
  129. /// "totalCount": 3
  130. /// }
  131. ///
  132. /// type=2 数据参考
  133. ///
  134. /// {
  135. ///"name": null,
  136. ///"phone": null,
  137. ///"date": "2022-09-13",
  138. ///"tag": null,
  139. ///"amCount": 3,
  140. ///"pmCount": 1,
  141. ///"atCount": 0,
  142. ///"totalCount": 4
  143. ///}
  144. ///
  145. ///
  146. /// </summary>
  147. /// <param name="input"></param>
  148. /// <param name="type">1 计次就餐天消费表(每人),2每月餐段消费报表,3月餐段汇总表</param>
  149. public static List<ReportCountDto> Report(ReportDto input, int type = 1)
  150. {
  151. var Route = Configer.SaasRoute;
  152. if (type == 1)
  153. Route += "api/one-card/day-consume-info";
  154. if (type == 2)
  155. Route += "api/one-card/consume-info";
  156. if (type == 3)
  157. Route += "api/one-card/time-interval-consume-info";
  158. var data = IHttpMultiClient.HttpMulti.AddHeader(t => t.Headers = Header).AddNode(t =>
  159. {
  160. t.NodePath = Route;
  161. t.ReqType = MultiType.POST;
  162. t.JsonParam = (new { StartTime =input.StartTime.ToShortDateString(), EndTime=input.EndTime.ToShortDateString() }).ToJson();
  163. }).Build().RunStringFirst();
  164. return data.ToModel<JObject>()["data"]["data"].ToJson().ToModel<List<ReportCountDto>>();
  165. }
  166. }
  167. }