123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- // using MySystem.Models;
- namespace MySystem
- {
- public class PublicFunction
- {
- #region 生成创客Id
- public static int MakeUsersId()
- {
- string LockKey = "MakeUsersId";
- RedisDbconn.Instance.GetLock(LockKey);
- int UsersId = RedisDbconn.Instance.Get<int>("UsersId");
- if(UsersId == 0) UsersId = 1;
- RedisDbconn.Instance.AddInt("UsersId");
- RedisDbconn.Instance.ReleaseLock(LockKey);
- return UsersId;
- }
- #endregion
- #region 生成消费者Id
- public static int MakeConsumerId()
- {
- string LockKey = "MakeConsumerId";
- RedisDbconn.Instance.GetLock(LockKey);
- int ConsumerId = RedisDbconn.Instance.Get<int>("ConsumerId");
- if(ConsumerId == 0) ConsumerId = 1;
- RedisDbconn.Instance.AddInt("ConsumerId");
- RedisDbconn.Instance.ReleaseLock(LockKey);
- return ConsumerId;
- }
- #endregion
- #region 生成消费者支付订单Id
- public static int MakeConsumerOrderId()
- {
- string LockKey = "MakeConsumerOrderId";
- RedisDbconn.Instance.GetLock(LockKey);
- int ConsumerOrderId = RedisDbconn.Instance.Get<int>("ConsumerOrderId");
- if(ConsumerOrderId == 0) ConsumerOrderId = 1;
- RedisDbconn.Instance.AddInt("ConsumerOrderId");
- RedisDbconn.Instance.ReleaseLock(LockKey);
- return ConsumerOrderId;
- }
- #endregion
- #region 生成创客收货地址Id
- public static int MakeUserAddressId()
- {
- string LockKey = "MakeUserAddressId";
- RedisDbconn.Instance.GetLock(LockKey);
- int UserAddressId = RedisDbconn.Instance.Get<int>("UserAddressId");
- if(UserAddressId == 0) UserAddressId = 1;
- RedisDbconn.Instance.AddInt("UserAddressId");
- RedisDbconn.Instance.ReleaseLock(LockKey);
- return UserAddressId;
- }
- #endregion
- #region 生成订单Id
- public static int MakeOrdersId()
- {
- string LockKey = "MakeOrdersId";
- RedisDbconn.Instance.GetLock(LockKey);
- int OrdersId = RedisDbconn.Instance.Get<int>("OrdersId");
- if(OrdersId == 0) OrdersId = 1;
- RedisDbconn.Instance.AddInt("OrdersId");
- RedisDbconn.Instance.ReleaseLock(LockKey);
- return OrdersId;
- }
- #endregion
- #region 生成订单商品Id
- public static int MakeOrderProductId()
- {
- string LockKey = "MakeOrderProductId";
- RedisDbconn.Instance.GetLock(LockKey);
- int OrderProductId = RedisDbconn.Instance.Get<int>("OrderProductId");
- if(OrderProductId == 0) OrderProductId = 1;
- RedisDbconn.Instance.AddInt("OrderProductId");
- RedisDbconn.Instance.ReleaseLock(LockKey);
- return OrderProductId;
- }
- #endregion
- #region 生成提现申请记录Id
- public static int MakeUserCashRecordId()
- {
- string LockKey = "MakeUserCashRecordId";
- RedisDbconn.Instance.GetLock(LockKey);
- int UserCashRecordId = RedisDbconn.Instance.Get<int>("UserCashRecordId");
- if(UserCashRecordId == 0) UserCashRecordId = 1;
- RedisDbconn.Instance.AddInt("UserCashRecordId");
- RedisDbconn.Instance.ReleaseLock(LockKey);
- return UserCashRecordId;
- }
- #endregion
- #region 生成创客变动记录Id
- public static int MakeUserStoreChangeId()
- {
- string LockKey = "MakeUserStoreChangeId";
- RedisDbconn.Instance.GetLock(LockKey);
- int UserStoreChangeId = RedisDbconn.Instance.Get<int>("UserStoreChangeId");
- if(UserStoreChangeId == 0) UserStoreChangeId = 1;
- RedisDbconn.Instance.AddInt("UserStoreChangeId");
- RedisDbconn.Instance.ReleaseLock(LockKey);
- return UserStoreChangeId;
- }
- #endregion
- #region 生成仓库变动记录Id
- public static int MakeStoreStockChangeId()
- {
- string LockKey = "MakeStoreStockChangeId";
- RedisDbconn.Instance.GetLock(LockKey);
- int StoreStockChangeId = RedisDbconn.Instance.Get<int>("StoreStockChangeId");
- if(StoreStockChangeId == 0) StoreStockChangeId = 1;
- RedisDbconn.Instance.AddInt("StoreStockChangeId");
- RedisDbconn.Instance.ReleaseLock(LockKey);
- return StoreStockChangeId;
- }
- #endregion
- #region 生成机具申请订单Id
- public static int MakeMachineApplyId()
- {
- string LockKey = "MakeMachineApplyId";
- RedisDbconn.Instance.GetLock(LockKey);
- int MachineApplyId = RedisDbconn.Instance.Get<int>("MachineApplyId");
- if(MachineApplyId == 0) MachineApplyId = 1;
- RedisDbconn.Instance.AddInt("MachineApplyId");
- RedisDbconn.Instance.ReleaseLock(LockKey);
- return MachineApplyId;
- }
- #endregion
- #region 生成开团申请记录Id
- public static int MakeTeamApplyId()
- {
- string LockKey = "MakeTeamApplyId";
- RedisDbconn.Instance.GetLock(LockKey);
- int TeamApplyId = RedisDbconn.Instance.Get<int>("TeamApplyId");
- if(TeamApplyId == 0) TeamApplyId = 1;
- RedisDbconn.Instance.AddInt("TeamApplyId");
- RedisDbconn.Instance.ReleaseLock(LockKey);
- return TeamApplyId;
- }
- #endregion
- #region 生成参团申请记录Id
- public static int MakeTeamOfferApplyId()
- {
- string LockKey = "MakeTeamOfferApplyId";
- RedisDbconn.Instance.GetLock(LockKey);
- int TeamOfferApplyId = RedisDbconn.Instance.Get<int>("TeamOfferApplyId");
- if(TeamOfferApplyId == 0) TeamOfferApplyId = 1;
- RedisDbconn.Instance.AddInt("TeamOfferApplyId");
- RedisDbconn.Instance.ReleaseLock(LockKey);
- return TeamOfferApplyId;
- }
- #endregion
- #region 生成商家进件资料Id
- public static int MakeMerchantAddInfoId()
- {
- string LockKey = "MakeMerchantAddInfoId";
- RedisDbconn.Instance.GetLock(LockKey);
- int MerchantAddInfoId = RedisDbconn.Instance.Get<int>("MerchantAddInfoId");
- if(MerchantAddInfoId == 0) MerchantAddInfoId = 1;
- RedisDbconn.Instance.AddInt("MerchantAddInfoId");
- RedisDbconn.Instance.ReleaseLock(LockKey);
- return MerchantAddInfoId;
- }
- #endregion
- #region 生成收款二维码Id
- public static int MakeMerchantQrCodeId()
- {
- string LockKey = "MakeMerchantQrCodeId";
- RedisDbconn.Instance.GetLock(LockKey);
- int MerchantQrCodeId = RedisDbconn.Instance.Get<int>("MerchantQrCodeId");
- if(MerchantQrCodeId == 0) MerchantQrCodeId = 1;
- RedisDbconn.Instance.AddInt("MerchantQrCodeId");
- RedisDbconn.Instance.ReleaseLock(LockKey);
- return MerchantQrCodeId;
- }
- #endregion
- #region 生成音箱码Id
- public static int MakeMachineId()
- {
- string LockKey = "MakeMachineId";
- RedisDbconn.Instance.GetLock(LockKey);
- int MachineId = RedisDbconn.Instance.Get<int>("MachineId");
- if(MachineId == 0) MachineId = 1;
- RedisDbconn.Instance.AddInt("MachineId");
- RedisDbconn.Instance.ReleaseLock(LockKey);
- return MachineId;
- }
- #endregion
- #region 根据ParentNav获取顶级创客Id
- public static int GetTopUserId(string ParentNav)
- {
- int TopUserId = 0;
- if (!string.IsNullOrEmpty(ParentNav))
- {
- TopUserId = int.Parse(ParentNav.Trim(',').Replace(",,", ",").Split(',')[0]);
- }
- return TopUserId;
- }
- #endregion
- #region 隐藏身份证号
- public static string HideCertId(string str)
- {
- return str.Substring(0, 3) + "***********" + str.Substring(14);
- }
- #endregion
- #region 隐藏姓名
- public static string HideRealName(string str)
- {
- string result = "";
- for (int i = 0; i < str.Length; i++)
- {
- if (i == 0)
- {
- result += str.Substring(i, 1);
- }
- else
- {
- result += "*";
- }
- }
- return result;
- }
- #endregion
- #region 姓名脱敏
- /// <summary>
- /// 姓名敏感处理
- /// </summary>
- /// <param name="fullName">姓名</param>
- /// <returns>脱敏后的姓名</returns>
- public static string SetSensitiveName(string fullName)
- {
- if (string.IsNullOrEmpty(fullName)) return string.Empty;
- string familyName = fullName.Substring(0, 1);
- string end = fullName.Substring(fullName.Length - 1, 1);
- string name = string.Empty;
- //长度为2
- if (fullName.Length <= 2) name = familyName + "*";
- //长度⼤于2
- else if (fullName.Length >= 3)
- {
- name = familyName.PadRight(fullName.Length - 1, '*') + end;
- }
- return name;
- }
- #endregion
- public static Dictionary<string, Dictionary<string, string>> MainTables = new Dictionary<string, Dictionary<string, string>>();
- }
- }
|