123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using MySystem.MainModels;
- using Library;
- namespace MySystem
- {
- public class PublicFunction
- {
- #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
- #region 统计机具绑定数据
- public static void StatUserMachineData(int UserId, int BrandId, int Count)
- {
- using (WebCMSEntities db = new WebCMSEntities())
- {
- string IdBrand = UserId + "_" + BrandId;
- UserMachineData MachineData = db.UserMachineData.FirstOrDefault(m => m.IdBrand == IdBrand);
- if (MachineData == null)
- {
- MachineData = db.UserMachineData.Add(new UserMachineData()
- {
- IdBrand = IdBrand,
- }).Entity;
- db.SaveChanges();
- }
- if(Count < 0)
- {
- MachineData.TotalMachineCount -= Math.Abs(Count);
- MachineData.UnBindCount -= Math.Abs(Count);
- }
- else
- {
- MachineData.TotalMachineCount += Count;
- MachineData.UnBindCount += Count;
- }
- db.SaveChanges();
- }
- }
- #endregion
- #region 设置押金添加记录公共方法
- public static void MerchantDepositSet(int BrandId, int UserId, int SnId, string SnNo, int BeforeDeposit, decimal DepositAmount, string ReturnNote)
- {
- try
- {
- WebCMSEntities maindb = new WebCMSEntities();
- MerchantDepositSet query = maindb.MerchantDepositSet.Add(new MerchantDepositSet()
- {
- CreateDate = DateTime.Now, //创建时间
- Sort = BrandId,//品牌
- SeoTitle = BeforeDeposit.ToString(),//变更前押金
- DepositAmount = DepositAmount,//押金
- ReturnNote = ReturnNote,//返回信息
- SnNo = SnNo,//机具Sn
- UserId = UserId,//创客Id
- }).Entity;
- maindb.SaveChanges();
- }
- catch (Exception ex)
- {
- function.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + ":" + ex.ToString(), "设置押金队列异常");
- }
- }
- #endregion
- //收支明细类别结合
- public static List<int> IncomeTypes()
- {
- List<int> list = new List<int>();
- list.Add(0);
- list.Add(1);
- list.Add(12);
- list.Add(31);
- list.Add(50);
- list.Add(60);
- list.Add(64);
- list.Add(66);
- list.Add(111);
- list.Add(112);
- list.Add(113);
- list.Add(114);
- list.Add(115);
- list.Add(116);
- list.Add(117);
- list.Add(118);
- list.Add(119);
- list.Add(120);
- list.Add(121);
- list.Add(122);
- list.Add(123);
- list.Add(126);
- return list;
- }
- public static List<int> ExpendTypes()
- {
- List<int> list = new List<int>();
- list.Add(3);
- list.Add(4);
- list.Add(5);
- list.Add(20);
- list.Add(63);
- list.Add(65);
- list.Add(124);
- list.Add(125);
- return list;
- }
- }
- }
|