PublicFunction.cs 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. // using MySystem.Models;
  5. namespace MySystem
  6. {
  7. public class PublicFunction
  8. {
  9. #region 生成创客Id
  10. public static int MakeUsersId()
  11. {
  12. string LockKey = "MakeUsersId";
  13. RedisDbconn.Instance.GetLock(LockKey);
  14. int UsersId = RedisDbconn.Instance.Get<int>("UsersId");
  15. if(UsersId == 0) UsersId = 1;
  16. RedisDbconn.Instance.AddInt("UsersId");
  17. RedisDbconn.Instance.ReleaseLock(LockKey);
  18. return UsersId;
  19. }
  20. #endregion
  21. #region 生成消费者Id
  22. public static int MakeConsumerId()
  23. {
  24. string LockKey = "MakeConsumerId";
  25. RedisDbconn.Instance.GetLock(LockKey);
  26. int ConsumerId = RedisDbconn.Instance.Get<int>("ConsumerId");
  27. if(ConsumerId == 0) ConsumerId = 1;
  28. RedisDbconn.Instance.AddInt("ConsumerId");
  29. RedisDbconn.Instance.ReleaseLock(LockKey);
  30. return ConsumerId;
  31. }
  32. #endregion
  33. #region 生成消费者支付订单Id
  34. public static int MakeConsumerOrderId()
  35. {
  36. string LockKey = "MakeConsumerOrderId";
  37. RedisDbconn.Instance.GetLock(LockKey);
  38. int ConsumerOrderId = RedisDbconn.Instance.Get<int>("ConsumerOrderId");
  39. if(ConsumerOrderId == 0) ConsumerOrderId = 1;
  40. RedisDbconn.Instance.AddInt("ConsumerOrderId");
  41. RedisDbconn.Instance.ReleaseLock(LockKey);
  42. return ConsumerOrderId;
  43. }
  44. #endregion
  45. #region 生成创客收货地址Id
  46. public static int MakeUserAddressId()
  47. {
  48. string LockKey = "MakeUserAddressId";
  49. RedisDbconn.Instance.GetLock(LockKey);
  50. int UserAddressId = RedisDbconn.Instance.Get<int>("UserAddressId");
  51. if(UserAddressId == 0) UserAddressId = 1;
  52. RedisDbconn.Instance.AddInt("UserAddressId");
  53. RedisDbconn.Instance.ReleaseLock(LockKey);
  54. return UserAddressId;
  55. }
  56. #endregion
  57. #region 生成订单Id
  58. public static int MakeOrdersId()
  59. {
  60. string LockKey = "MakeOrdersId";
  61. RedisDbconn.Instance.GetLock(LockKey);
  62. int OrdersId = RedisDbconn.Instance.Get<int>("OrdersId");
  63. if(OrdersId == 0) OrdersId = 1;
  64. RedisDbconn.Instance.AddInt("OrdersId");
  65. RedisDbconn.Instance.ReleaseLock(LockKey);
  66. return OrdersId;
  67. }
  68. #endregion
  69. #region 生成订单商品Id
  70. public static int MakeOrderProductId()
  71. {
  72. string LockKey = "MakeOrderProductId";
  73. RedisDbconn.Instance.GetLock(LockKey);
  74. int OrderProductId = RedisDbconn.Instance.Get<int>("OrderProductId");
  75. if(OrderProductId == 0) OrderProductId = 1;
  76. RedisDbconn.Instance.AddInt("OrderProductId");
  77. RedisDbconn.Instance.ReleaseLock(LockKey);
  78. return OrderProductId;
  79. }
  80. #endregion
  81. #region 生成提现申请记录Id
  82. public static int MakeUserCashRecordId()
  83. {
  84. string LockKey = "MakeUserCashRecordId";
  85. RedisDbconn.Instance.GetLock(LockKey);
  86. int UserCashRecordId = RedisDbconn.Instance.Get<int>("UserCashRecordId");
  87. if(UserCashRecordId == 0) UserCashRecordId = 1;
  88. RedisDbconn.Instance.AddInt("UserCashRecordId");
  89. RedisDbconn.Instance.ReleaseLock(LockKey);
  90. return UserCashRecordId;
  91. }
  92. #endregion
  93. #region 生成创客变动记录Id
  94. public static int MakeUserStoreChangeId()
  95. {
  96. string LockKey = "MakeUserStoreChangeId";
  97. RedisDbconn.Instance.GetLock(LockKey);
  98. int UserStoreChangeId = RedisDbconn.Instance.Get<int>("UserStoreChangeId");
  99. if(UserStoreChangeId == 0) UserStoreChangeId = 1;
  100. RedisDbconn.Instance.AddInt("UserStoreChangeId");
  101. RedisDbconn.Instance.ReleaseLock(LockKey);
  102. return UserStoreChangeId;
  103. }
  104. #endregion
  105. #region 生成仓库变动记录Id
  106. public static int MakeStoreStockChangeId()
  107. {
  108. string LockKey = "MakeStoreStockChangeId";
  109. RedisDbconn.Instance.GetLock(LockKey);
  110. int StoreStockChangeId = RedisDbconn.Instance.Get<int>("StoreStockChangeId");
  111. if(StoreStockChangeId == 0) StoreStockChangeId = 1;
  112. RedisDbconn.Instance.AddInt("StoreStockChangeId");
  113. RedisDbconn.Instance.ReleaseLock(LockKey);
  114. return StoreStockChangeId;
  115. }
  116. #endregion
  117. #region 生成机具申请订单Id
  118. public static int MakeMachineApplyId()
  119. {
  120. string LockKey = "MakeMachineApplyId";
  121. RedisDbconn.Instance.GetLock(LockKey);
  122. int MachineApplyId = RedisDbconn.Instance.Get<int>("MachineApplyId");
  123. if(MachineApplyId == 0) MachineApplyId = 1;
  124. RedisDbconn.Instance.AddInt("MachineApplyId");
  125. RedisDbconn.Instance.ReleaseLock(LockKey);
  126. return MachineApplyId;
  127. }
  128. #endregion
  129. #region 生成开团申请记录Id
  130. public static int MakeTeamApplyId()
  131. {
  132. string LockKey = "MakeTeamApplyId";
  133. RedisDbconn.Instance.GetLock(LockKey);
  134. int TeamApplyId = RedisDbconn.Instance.Get<int>("TeamApplyId");
  135. if(TeamApplyId == 0) TeamApplyId = 1;
  136. RedisDbconn.Instance.AddInt("TeamApplyId");
  137. RedisDbconn.Instance.ReleaseLock(LockKey);
  138. return TeamApplyId;
  139. }
  140. #endregion
  141. #region 生成参团申请记录Id
  142. public static int MakeTeamOfferApplyId()
  143. {
  144. string LockKey = "MakeTeamOfferApplyId";
  145. RedisDbconn.Instance.GetLock(LockKey);
  146. int TeamOfferApplyId = RedisDbconn.Instance.Get<int>("TeamOfferApplyId");
  147. if(TeamOfferApplyId == 0) TeamOfferApplyId = 1;
  148. RedisDbconn.Instance.AddInt("TeamOfferApplyId");
  149. RedisDbconn.Instance.ReleaseLock(LockKey);
  150. return TeamOfferApplyId;
  151. }
  152. #endregion
  153. #region 生成商家进件资料Id
  154. public static int MakeMerchantAddInfoId()
  155. {
  156. string LockKey = "MakeMerchantAddInfoId";
  157. RedisDbconn.Instance.GetLock(LockKey);
  158. int MerchantAddInfoId = RedisDbconn.Instance.Get<int>("MerchantAddInfoId");
  159. if(MerchantAddInfoId == 0) MerchantAddInfoId = 1;
  160. RedisDbconn.Instance.AddInt("MerchantAddInfoId");
  161. RedisDbconn.Instance.ReleaseLock(LockKey);
  162. return MerchantAddInfoId;
  163. }
  164. #endregion
  165. #region 生成收款二维码Id
  166. public static int MakeMerchantQrCodeId()
  167. {
  168. string LockKey = "MakeMerchantQrCodeId";
  169. RedisDbconn.Instance.GetLock(LockKey);
  170. int MerchantQrCodeId = RedisDbconn.Instance.Get<int>("MerchantQrCodeId");
  171. if(MerchantQrCodeId == 0) MerchantQrCodeId = 1;
  172. RedisDbconn.Instance.AddInt("MerchantQrCodeId");
  173. RedisDbconn.Instance.ReleaseLock(LockKey);
  174. return MerchantQrCodeId;
  175. }
  176. #endregion
  177. #region 生成音箱码Id
  178. public static int MakeMachineId()
  179. {
  180. string LockKey = "MakeMachineId";
  181. RedisDbconn.Instance.GetLock(LockKey);
  182. int MachineId = RedisDbconn.Instance.Get<int>("MachineId");
  183. if(MachineId == 0) MachineId = 1;
  184. RedisDbconn.Instance.AddInt("MachineId");
  185. RedisDbconn.Instance.ReleaseLock(LockKey);
  186. return MachineId;
  187. }
  188. #endregion
  189. #region 根据ParentNav获取顶级创客Id
  190. public static int GetTopUserId(string ParentNav)
  191. {
  192. int TopUserId = 0;
  193. if (!string.IsNullOrEmpty(ParentNav))
  194. {
  195. TopUserId = int.Parse(ParentNav.Trim(',').Replace(",,", ",").Split(',')[0]);
  196. }
  197. return TopUserId;
  198. }
  199. #endregion
  200. #region 隐藏身份证号
  201. public static string HideCertId(string str)
  202. {
  203. return str.Substring(0, 3) + "***********" + str.Substring(14);
  204. }
  205. #endregion
  206. #region 隐藏姓名
  207. public static string HideRealName(string str)
  208. {
  209. string result = "";
  210. for (int i = 0; i < str.Length; i++)
  211. {
  212. if (i == 0)
  213. {
  214. result += str.Substring(i, 1);
  215. }
  216. else
  217. {
  218. result += "*";
  219. }
  220. }
  221. return result;
  222. }
  223. #endregion
  224. #region 姓名脱敏
  225. /// <summary>
  226. /// 姓名敏感处理
  227. /// </summary>
  228. /// <param name="fullName">姓名</param>
  229. /// <returns>脱敏后的姓名</returns>
  230. public static string SetSensitiveName(string fullName)
  231. {
  232. if (string.IsNullOrEmpty(fullName)) return string.Empty;
  233. string familyName = fullName.Substring(0, 1);
  234. string end = fullName.Substring(fullName.Length - 1, 1);
  235. string name = string.Empty;
  236. //长度为2
  237. if (fullName.Length <= 2) name = familyName + "*";
  238. //长度⼤于2
  239. else if (fullName.Length >= 3)
  240. {
  241. name = familyName.PadRight(fullName.Length - 1, '*') + end;
  242. }
  243. return name;
  244. }
  245. #endregion
  246. public static Dictionary<string, Dictionary<string, string>> MainTables = new Dictionary<string, Dictionary<string, string>>();
  247. }
  248. }