Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

191 linhas
7.5 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. TimeSpilteDto dto = new TimeSpilteDto
  23. {
  24. AMEndTime = input.AMEndTime.ToShortTimeString(),
  25. AMStartTime = input.AMStartTime.ToShortTimeString(),
  26. PMEndTime = input.PMEndTime.ToShortTimeString(),
  27. PMStartTime = input.PMStartTime.ToShortTimeString(),
  28. ATEndTime = input.ATEndTime.ToShortTimeString(),
  29. ATStartTime = input.ATStartTime.ToShortTimeString(),
  30. };
  31. var data = IHttpMultiClient.HttpMulti
  32. .AddHeader(t => t.Headers = Header)
  33. .AddNode(t =>
  34. {
  35. t.NodePath = $"{Configer.SaasRoute}api/one-card/eat-time-interval";
  36. t.JsonParam = dto.ToJson();
  37. t.ReqType = MultiType.PUT;
  38. }).Build().RunStringFirst();
  39. var res = data.ToModel<JObject>()["data"]["isSuccess"].ToString().AsBool();
  40. if (res)
  41. {
  42. ServiceQueryPush.QueryPush.PushMQ(input, "TimeChanged", MQEnum.Push);
  43. return res;
  44. }
  45. return false;
  46. }
  47. /// <summary>
  48. /// 添加机构
  49. /// </summary>
  50. public static string SetOrg(string input)
  51. {
  52. return IHttpMultiClient.HttpMulti
  53. .AddHeader(t => t.Headers = Header)
  54. .AddNode(t =>
  55. {
  56. t.NodePath = $"{Configer.SaasRoute}api/one-card/member-tag";
  57. t.ReqType = MultiType.POST;
  58. t.JsonParam = (new { Name = input }).ToJson();
  59. }).Build().RunStringFirst().ToModel<JObject>()["data"]["data"]["id"].ToString();
  60. }
  61. /// <summary>
  62. /// 修改机构
  63. /// </summary>
  64. public static bool AlterOrg(string input, string Sid)
  65. {
  66. return IHttpMultiClient.HttpMulti.AddHeader(t => t.Headers = Header).AddNode(t =>
  67. {
  68. t.NodePath = $"{Configer.SaasRoute}api/one-card/member-tag";
  69. t.ReqType = MultiType.PUT;
  70. t.JsonParam = (new { Name = input, Id = Sid }).ToJson();
  71. }).Build().RunStringFirst().ToModel<JObject>()["data"]["isSuccess"].ToString().AsBool();
  72. }
  73. /// <summary>
  74. /// 根据用户命获取下拉用户列表
  75. /// </summary>
  76. /// <param name="keyword"></param>
  77. public static List<UserListDto> GetUserList(string keyword)
  78. {
  79. return IHttpMultiClient.HttpMulti.AddHeader(t => t.Headers = Header).AddNode(t =>
  80. {
  81. t.NodePath = $"{Configer.SaasRoute}api/one-card/staff-list";
  82. t.ReqType = MultiType.POST;
  83. t.JsonParam = (new { realName = keyword }).ToJson();
  84. }).Build().RunStringFirst().ToModel<JObject>()["data"]["data"].ToJson().ToModel<List<UserListDto>>();
  85. }
  86. /// <summary>
  87. /// 添加用户并绑卡
  88. /// </summary>
  89. /// <param name="input"></param>
  90. /// <returns></returns>
  91. public static bool AddUserAndBindCard(UserDto input)
  92. {
  93. return IHttpMultiClient.HttpMulti.AddHeader(t => t.Headers = Header).AddNode(t =>
  94. {
  95. t.NodePath = $"{Configer.SaasRoute}api/one-card/mmenber-card";
  96. t.ReqType = MultiType.POST;
  97. t.JsonParam = (new { tagId = input.OrgId, realName = input.Name, phone = input.Phone, cardNum = input.CardNo }).ToJson();
  98. }).Build().RunStringFirst().ToModel<JObject>()["data"]["isSuccess"].ToString().AsBool();
  99. }
  100. /// <summary>
  101. /// 添加用户
  102. /// </summary>
  103. /// <param name="input"></param>
  104. public static bool AddUser(UserDto input)
  105. {
  106. return IHttpMultiClient.HttpMulti.AddHeader(t => t.Headers = Header).AddNode(t =>
  107. {
  108. t.NodePath = $"{Configer.SaasRoute}api/one-card/staff";
  109. t.ReqType = MultiType.POST;
  110. t.JsonParam = (new { tagId = input.OrgId, realName = input.Name, phone = input.Phone }).ToJson();
  111. }).Build().RunStringFirst().ToModel<JObject>()["data"]["isSuccess"].ToString().AsBool();
  112. }
  113. /// <summary>
  114. /// 变更卡状态 销户
  115. /// </summary>
  116. /// <param name="input"></param>
  117. public static bool CardStutasChange(CardStutasDto input)
  118. {
  119. input.CardNo = GetUserList(input.keywrod).FirstOrDefault(t => t.Name.Equals(input.keywrod)).Cards.FirstOrDefault(t => t.State == 1).CardNum;
  120. var x = IHttpMultiClient.HttpMulti.AddHeader(t => t.Headers = Header).AddNode(t =>
  121. {
  122. t.NodePath = $"{Configer.SaasRoute}api/one-card/mmenber-card-state";
  123. t.ReqType = MultiType.PUT;
  124. t.JsonParam = (new { CardNum = input.CardNo, State = input.Stutas }).ToJson();
  125. }).Build().RunStringFirst().ToModel<JObject>()["data"]["isSuccess"].ToString().AsBool();
  126. if (x)
  127. {
  128. ServiceQueryPush.QueryPush.PushMQ(input, "CardStutasChanged", MQEnum.Top);
  129. return x;
  130. }
  131. return false;
  132. }
  133. /// <summary>
  134. /// 报表数据
  135. /// type=1 数据参考
  136. ///
  137. /// {
  138. ///"name": "张三",
  139. /// "phone": "18208263734",
  140. /// "date": "2022-09-24",
  141. /// "tag": null,
  142. /// "amCount": 3,
  143. /// "pmCount": 0,
  144. /// "atCount": 0,
  145. /// "totalCount": 3
  146. /// }
  147. ///
  148. /// type=2 数据参考
  149. ///
  150. /// {
  151. ///"name": null,
  152. ///"phone": null,
  153. ///"date": "2022-09-13",
  154. ///"tag": null,
  155. ///"amCount": 3,
  156. ///"pmCount": 1,
  157. ///"atCount": 0,
  158. ///"totalCount": 4
  159. ///}
  160. ///
  161. ///
  162. /// </summary>
  163. /// <param name="input"></param>
  164. /// <param name="type">1 计次就餐天消费表(每人),2每月餐段消费报表,3月餐段汇总表</param>
  165. public static List<ReportCountDto> Report(ReportDto input, int type = 1)
  166. {
  167. var Route = Configer.SaasRoute;
  168. if (type == 1)
  169. Route += "api/one-card/day-consume-info";
  170. if (type == 2)
  171. Route += "api/one-card/consume-info";
  172. if (type == 3)
  173. Route += "api/one-card/time-interval-consume-info";
  174. var data = IHttpMultiClient.HttpMulti.AddHeader(t => t.Headers = Header).AddNode(t =>
  175. {
  176. t.NodePath = Route;
  177. t.ReqType = MultiType.POST;
  178. t.JsonParam = (new { StartTime =input.StartTime.ToShortDateString(), EndTime=input.EndTime.ToShortDateString() }).ToJson();
  179. }).Build().RunStringFirst();
  180. return data.ToModel<JObject>()["data"]["data"].ToJson().ToModel<List<ReportCountDto>>();
  181. }
  182. }
  183. }