LargeDataScreenDbconn.cs 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484
  1. using System;
  2. using System.Collections.Generic;
  3. using Library;
  4. using System.Linq;
  5. using System.Data;
  6. using MySystem.MainModels;
  7. namespace MySystem
  8. {
  9. public class LargeDataScreenDbconn
  10. {
  11. public readonly static LargeDataScreenDbconn Instance = new LargeDataScreenDbconn();
  12. #region 本月新增创客数
  13. public int GetTeamMakerCountThisMonth(int UserId)
  14. {
  15. DateTime start = DateTime.Parse(DateTime.Now.ToString("yyyy-MM") + "-01 00:00:00");
  16. DateTime end = start.AddMonths(1);
  17. WebCMSEntities db = new WebCMSEntities();
  18. string IdString = "," + UserId + ",";
  19. int MakerCount = db.Users.Count(m => m.ParentNav.Contains(IdString) && m.AuthDate >= start && m.AuthDate < end);
  20. db.Dispose();
  21. return MakerCount;
  22. }
  23. #endregion
  24. #region 上月新增创客数
  25. public int GetTeamMakerCountLastMonth(int UserId)
  26. {
  27. DateTime end = DateTime.Parse(DateTime.Now.ToString("yyyy-MM") + "-01 00:00:00");
  28. DateTime start = end.AddMonths(-1);
  29. WebCMSEntities db = new WebCMSEntities();
  30. string IdString = "," + UserId + ",";
  31. int MakerCount = db.Users.Count(m => m.ParentNav.Contains(IdString) && m.AuthDate >= start && m.AuthDate < end);
  32. db.Dispose();
  33. return MakerCount;
  34. }
  35. #endregion
  36. #region 团队新增创客
  37. public int GetNewUserCount(int UserId, string Day = "")
  38. {
  39. string key = "AddUser:" + UserId;
  40. if (!string.IsNullOrEmpty(Day))
  41. {
  42. key += ":" + Day;
  43. }
  44. if (RedisDbconn.Instance.Exists(key))
  45. {
  46. int obj = RedisDbconn.Instance.Get<int>(key);
  47. if (obj > 0)
  48. {
  49. return obj;
  50. }
  51. }
  52. int ckcount = 0;
  53. string UserIdString = "," + UserId + ",";
  54. WebCMSEntities db = new WebCMSEntities();
  55. if (!string.IsNullOrEmpty(Day))
  56. {
  57. if (Day.Length == 8)
  58. {
  59. DateTime start = DateTime.Parse(Day.Substring(0, 4) + "-" + Day.Substring(4, 2) + "-" + Day.Substring(6, 2) + " 00:00:00");
  60. DateTime end = start.AddDays(1);
  61. ckcount = db.Users.Count(m => m.ParentNav.Contains(UserIdString) && m.CreateDate >= start && m.CreateDate < end);
  62. }
  63. else
  64. {
  65. DateTime start = DateTime.Parse(Day.Substring(0, 4) + "-" + Day.Substring(4, 2) + "-01 00:00:00");
  66. DateTime end = start.AddDays(1);
  67. ckcount = db.Users.Count(m => m.ParentNav.Contains(UserIdString) && m.CreateDate >= start && m.CreateDate < end);
  68. }
  69. }
  70. else
  71. {
  72. ckcount = db.Users.Count(m => m.ParentNav.Contains(UserIdString));
  73. }
  74. RedisDbconn.Instance.Set(key, ckcount);
  75. RedisDbconn.Instance.SetExpire(key, Library.function.get_Random(60, 180));
  76. db.Dispose();
  77. return ckcount;
  78. }
  79. #endregion
  80. #region 团队新增商户
  81. public int GetNewPosMerCount(int UserId, string Day = "")
  82. {
  83. string key = "AddPosMer:" + UserId;
  84. if (!string.IsNullOrEmpty(Day))
  85. {
  86. key += ":" + Day;
  87. }
  88. if (RedisDbconn.Instance.Exists(key))
  89. {
  90. int obj = RedisDbconn.Instance.Get<int>(key);
  91. if (obj > 0)
  92. {
  93. return obj;
  94. }
  95. }
  96. int shcount = 0;
  97. string UserIdString = "," + UserId + ",";
  98. WebCMSEntities db = new WebCMSEntities();
  99. if (!string.IsNullOrEmpty(Day))
  100. {
  101. if (Day.Length == 8)
  102. {
  103. DateTime start = DateTime.Parse(Day.Substring(0, 4) + "-" + Day.Substring(4, 2) + "-" + Day.Substring(6, 2) + " 00:00:00");
  104. DateTime end = start.AddDays(1);
  105. shcount = db.PosMerchantInfo.Count(m => m.CreateDate >= start && m.CreateDate < end);
  106. }
  107. else
  108. {
  109. DateTime start = DateTime.Parse(Day.Substring(0, 4) + "-" + Day.Substring(4, 2) + "-01 00:00:00");
  110. DateTime end = start.AddDays(1);
  111. shcount = db.PosMerchantInfo.Count(m => m.CreateDate >= start && m.CreateDate < end);
  112. }
  113. }
  114. else
  115. {
  116. shcount = db.PosMerchantInfo.Count();
  117. }
  118. RedisDbconn.Instance.Set(key, shcount);
  119. RedisDbconn.Instance.SetExpire(key, Library.function.get_Random(60, 180));
  120. db.Dispose();
  121. return shcount;
  122. }
  123. #endregion
  124. #region 全国今日新增创客和商户
  125. public List<MakerShopAdds> GetMakerShopAddsList()
  126. {
  127. List<MakerShopAdds> Obj = RedisDbconn.Instance.GetList<MakerShopAdds>("MakerShopAddsList");
  128. if (Obj.Count > 0)
  129. {
  130. return Obj;
  131. }
  132. OtherMySqlConn.connstr = Library.ConfigurationManager.AppSettings["SqlConnStr"].ToString();
  133. DataTable dt = OtherMySqlConn.dtable("select (select sum(RecUserAuthNum) from PullnewSummary where SeoTitle='team' and UserId=1) ckcount,(select count(0) count from PosMerchantInfo) shcount from PullnewSummary,PosMerchantInfo limit 1");
  134. foreach (DataRow item in dt.Rows)
  135. {
  136. Obj.Add(new MakerShopAdds()
  137. {
  138. shcount = Convert.ToInt32(item["shcount"]),
  139. ckcount = Convert.ToInt32(item["ckcount"])
  140. });
  141. }
  142. foreach (var sub in Obj)
  143. {
  144. RedisDbconn.Instance.AddRightList("MakerShopAddsList", sub);
  145. }
  146. RedisDbconn.Instance.SetExpire("MakerShopAddsList", Library.function.get_Random(60, 180));
  147. dt.Dispose();
  148. return Obj;
  149. }
  150. #endregion
  151. #region 全国创客开机列表
  152. public List<MakerOpenMachines> GetMakerOpenMachinesList(string key, int pageNum = 1, int pageSize = 30)
  153. {
  154. List<MakerOpenMachines> Obj = RedisDbconn.Instance.GetList<MakerOpenMachines>("MakerOpenMachinesList: "+pageNum, 1, pageSize);
  155. if (Obj.Count > 0)
  156. {
  157. return Obj;
  158. }
  159. List<MakerOpenMachines> list = new List<MakerOpenMachines>();
  160. int Skip = pageSize * (pageNum - 1);
  161. OtherMySqlConn.connstr = Library.ConfigurationManager.AppSettings["SqlConnStr"].ToString();
  162. DataTable dt = OtherMySqlConn.dtable("select b.ActivationTime ActivationTime,k.NAME productName,a.RealName realname,c.count count from Users a left join PosMachinesTwo b on a.Id=b.userId LEFT JOIN KqProducts k ON k.Id=b.BrandId left join (select a.Id,count(a.Id) as count from Users a left join PosMachinesTwo b on a.Id=b.UserId LEFT JOIN KqProducts k ON k.Id=b.BrandId where BindingState=1 group by a.Id)c on a.Id=c.Id where BindingState=1 AND MONTH(ActivationTime)=MONTH(now()) and YEAR(ActivationTime)=YEAR(now())order by b.ActivationTime desc limit " + Skip + "," + pageSize + "");
  163. foreach (DataRow item in dt.Rows)
  164. {
  165. list.Add(new MakerOpenMachines()
  166. {
  167. ActivationTime = Convert.ToDateTime(item["ActivationTime"]).ToString("yyyy-MM-dd HH:mm:ss"),
  168. productName = item["productName"].ToString(),
  169. realname = SetSensitiveName(item["RealName"].ToString()),
  170. count = Convert.ToInt32(item["count"])
  171. });
  172. }
  173. list = list.OrderByDescending(m => m.ActivationTime).ToList();
  174. foreach (var sub in list)
  175. {
  176. RedisDbconn.Instance.AddRightList("MakerOpenMachinesList: "+pageNum, sub);
  177. }
  178. RedisDbconn.Instance.SetExpire("MakerOpenMachinesList: "+pageNum, Library.function.get_Random(60, 180));
  179. dt.Dispose();
  180. return list;
  181. }
  182. #endregion
  183. #region 全国展业数据
  184. public List<Exhibitions> GetExhibitionList()
  185. {
  186. List<Exhibitions> Obj = RedisDbconn.Instance.GetList<Exhibitions>("ExhibitionList");
  187. if (Obj.Count > 0)
  188. {
  189. return Obj;
  190. }
  191. OtherMySqlConn.connstr = Library.ConfigurationManager.AppSettings["SqlConnStr"].ToString();
  192. DataTable dt = OtherMySqlConn.dtable("select(select count(0) count from StoreHouse where YEAR(CreateDate)=YEAR(now())) count,(select Sum(TotalAmount) WithdrawAmount from UserAccount) WithdrawAmount,(select sum(NonDirectTradeAmt) WithdrawAmount from UserTradeDaySummary where UserId=1 and SeoTitle='team' and left(TradeMonth,4) = YEAR(NOW())) yearsum,(select sum(NonDirectDebitCapNum) from UserTradeDaySummary where UserId=1 and SeoTitle='team' and left(TradeMonth,4) = YEAR(NOW())) yearcount,(select sum(NonDirectTradeAmt) from UserTradeDaySummary where UserId=1 and SeoTitle='team' and quarter(TradeDate)=quarter(now())) quartersum, (select sum(NonDirectDebitCapNum) from UserTradeDaySummary where UserId=1 and SeoTitle='team' and quarter(TradeDate)=quarter(now())) quartercount,(select sum(NonDirectTradeAmt) WithdrawAmount from UserTradeDaySummary where UserId=1 and SeoTitle='team' and RIGHT(TradeMonth,2) = MONTH(NOW())) monthsum,(select sum(NonDirectDebitCapNum) WithdrawAmount from UserTradeDaySummary where UserId=1 and SeoTitle='team' and RIGHT(TradeMonth,2) = MONTH(NOW())) monthcount,(select sum(NonDirectTradeAmt) from UserTradeDaySummary where UserId=1 and SeoTitle='team' and TO_DAYS(TradeDate)=TO_DAYS(NOW() - INTERVAL 1 DAY)) nowsum, (select sum(NonDirectDebitCapNum) from UserTradeDaySummary where UserId=1 and SeoTitle='team' and TO_DAYS(TradeDate)=TO_DAYS(NOW() - INTERVAL 1 DAY)) nowcount from UserTradeDaySummary limit 1");
  193. foreach (DataRow item in dt.Rows)
  194. {
  195. Obj.Add(new Exhibitions()
  196. {
  197. WithdrawAmount = decimal.Parse(function.CheckNum(item["WithdrawAmount"].ToString())),
  198. count = Convert.ToInt32(function.CheckNum(item["count"].ToString())),
  199. yearsum = decimal.Parse(function.CheckNum(item["yearsum"].ToString())),
  200. yearcount = Convert.ToInt32(function.CheckNum(item["yearcount"].ToString())),
  201. quartersum = decimal.Parse(function.CheckNum(item["quartersum"].ToString())),
  202. quartercount = Convert.ToInt32(function.CheckNum(item["quartercount"].ToString())),
  203. monthsum = decimal.Parse(function.CheckNum(item["monthsum"].ToString())),
  204. monthcount = Convert.ToInt32(function.CheckNum(item["monthcount"].ToString())),
  205. nowsum = decimal.Parse(function.CheckNum(item["nowsum"].ToString())),
  206. nowcount = Convert.ToInt32(function.CheckNum(item["nowcount"].ToString()))
  207. });
  208. }
  209. foreach (var sub in Obj)
  210. {
  211. RedisDbconn.Instance.AddRightList("ExhibitionList", sub);
  212. }
  213. RedisDbconn.Instance.SetExpire("ExhibitionList", Library.function.get_Random(60, 180));
  214. dt.Dispose();
  215. return Obj;
  216. }
  217. #endregion
  218. #region 团队累计开机榜排名前十
  219. public List<OpenMachines> GetOpenMachinesList(int UserId)
  220. {
  221. // string key = "OpenMachinesList:" + UserId;
  222. // List<int> list = new List<int>();
  223. // if (RedisDbconn.Instance.Exists(key))
  224. // {
  225. // list = RedisDbconn.Instance.GetList<int>(key, pageNum, pageSize);
  226. // if (list.Count > 0)
  227. // {
  228. // return list;
  229. // }
  230. // }
  231. // DateTime start = DateTime.Now.AddDays(1 - DateTime.Now.Day).Date;
  232. // DateTime end = DateTime.Now.AddDays(1 - DateTime.Now.Day).Date.AddMonths(1).AddSeconds(-1);
  233. // WebCMSEntities db = new WebCMSEntities();
  234. // List<int> newlist = new List<int>();
  235. // var mysqllist = db.PosMachinesTwo.Select(m => new { m.Id, m.UserId, m.BindingState, m.BindingTime, m.Status }).Where(m => m.Status > -1 && m.UserId == UserId && m.BindingState==1 && m.BindingTime >= start && m.BindingTime <= end).ToList();
  236. // if (mysqllist.Count > 0)
  237. // {
  238. // foreach (var sub in mysqllist)
  239. // {
  240. // newlist.Add(sub.Id);
  241. // }
  242. // RedisDbconn.Instance.Clear(key);
  243. // foreach (var sub in newlist)
  244. // {
  245. // RedisDbconn.Instance.AddRightList(key, sub);
  246. // }
  247. // RedisDbconn.Instance.SetExpire(key, Library.function.get_Random(60, 180));
  248. // }
  249. // db.Dispose();
  250. List<OpenMachines> Obj = RedisDbconn.Instance.GetList<OpenMachines>("OpenMachinesList:" + UserId);
  251. if (Obj.Count > 0)
  252. {
  253. return Obj;
  254. }
  255. OtherMySqlConn.connstr = Library.ConfigurationManager.AppSettings["SqlConnStr"].ToString();
  256. DataTable dt = OtherMySqlConn.dtable("select a.UserId UserId,b.RealName RealName,a.sum Sum from(select UserId, sum(NonDirectDebitCapNum) sum from UserTradeDaySummary where SeoTitle='team' and UserId in (select Id from Users where ParentNav like '%," + UserId + ",%')GROUP BY UserId ORDER BY sum desc limit 10)a left join Users b on a.UserId = b.Id");//累计数据统计
  257. foreach (DataRow item in dt.Rows)
  258. {
  259. Obj.Add(new OpenMachines()
  260. {
  261. userId = Convert.ToInt32(item["UserId"]),
  262. realName = SetSensitiveName(item["RealName"].ToString()),
  263. openCount = decimal.Parse(item["Sum"].ToString())
  264. });
  265. }
  266. Obj = Obj.OrderByDescending(m => m.openCount).ToList();
  267. foreach (var sub in Obj)
  268. {
  269. RedisDbconn.Instance.AddRightList("OpenMachinesList:" + UserId, sub);
  270. }
  271. RedisDbconn.Instance.SetExpire("OpenMachinesList:" + UserId, Library.function.get_Random(60, 180));
  272. dt.Dispose();
  273. return Obj;
  274. }
  275. #endregion
  276. #region 团队累计流水榜排名前十
  277. public List<FlowingWater> GetFlowingWaterList(int UserId)
  278. {
  279. List<FlowingWater> Obj = RedisDbconn.Instance.GetList<FlowingWater>("FlowingWaterList:" + UserId);
  280. if (Obj.Count > 0)
  281. {
  282. return Obj;
  283. }
  284. OtherMySqlConn.connstr = Library.ConfigurationManager.AppSettings["SqlConnStr"].ToString();
  285. DataTable dt = OtherMySqlConn.dtable("select a.UserId UserId,b.RealName RealName,a.sum Sum from(select UserId, sum(NonDirectDebitTradeAmt + NonDirectTradeAmt) sum from UserTradeDaySummary where SeoTitle='team' and UserId in (select Id from Users where ParentNav like '%," + UserId + ",%')GROUP BY UserId ORDER BY sum desc limit 10)a left join Users b on a.UserId = b.Id");//累计数据统计
  286. foreach (DataRow item in dt.Rows)
  287. {
  288. Obj.Add(new FlowingWater()
  289. {
  290. UserId = Convert.ToInt32(item["UserId"]),
  291. RealName = SetSensitiveName(item["RealName"].ToString()),
  292. Sum = decimal.Parse(item["Sum"].ToString())
  293. });
  294. }
  295. Obj = Obj.OrderByDescending(m => m.Sum).ToList();
  296. foreach (var sub in Obj)
  297. {
  298. RedisDbconn.Instance.AddRightList("FlowingWaterList:" + UserId, sub);
  299. }
  300. RedisDbconn.Instance.SetExpire("FlowingWaterList:" + UserId, Library.function.get_Random(60, 180));
  301. dt.Dispose();
  302. return Obj;
  303. }
  304. #endregion
  305. #region 累计收益榜排名前十
  306. public List<InCome> GetIncomeList()
  307. {
  308. List<InCome> Obj = RedisDbconn.Instance.GetList<InCome>("IncomeList");
  309. if (Obj.Count > 0)
  310. {
  311. return Obj;
  312. }
  313. OtherMySqlConn.connstr = Library.ConfigurationManager.AppSettings["SqlConnStr"].ToString();
  314. // DataTable dt = OtherMySqlConn.dtable("select c.RealName RealName,b.Sum Sum from(select a.UserId, sum(a.ChangeAmount) Sum from(select * from UserAccountRecord where ChangeType = 1 or ChangeType = 12 or ChangeType = 50 or ChangeType = 60 or ChangeType = 111 or ChangeType = 112)a where a.UserId != 0 GROUP BY a.UserId ORDER BY Sum desc limit 10)b left join Users c on b.UserId = c.Id");//累计数据统计
  315. DataTable dt = OtherMySqlConn.dtable("select b.RealName RealName,a.TotalAmount Sum from UserAccount a left join Users b on a.UserId=b.Id ORDER BY a.TotalAmount desc limit 10");
  316. foreach (DataRow item in dt.Rows)
  317. {
  318. Obj.Add(new InCome()
  319. {
  320. RealName = SetSensitiveName(item["RealName"].ToString()),
  321. Sum = decimal.Parse(item["Sum"].ToString())
  322. });
  323. }
  324. Obj = Obj.OrderByDescending(m => m.Sum).ToList();
  325. foreach (var sub in Obj)
  326. {
  327. RedisDbconn.Instance.AddRightList("IncomeList", sub);
  328. }
  329. RedisDbconn.Instance.SetExpire("IncomeList", Library.function.get_Random(60, 180));
  330. dt.Dispose();
  331. return Obj;
  332. }
  333. #endregion
  334. // #region 交易额统计-本年每月
  335. // public List<TradeYearMonth> GetTradeYearMonthList(int UserId)
  336. // {
  337. // List<TradeYearMonth> Obj = RedisDbconn.Instance.GetList<TradeYearMonth>("TradeYearMonthList:" + UserId);
  338. // if (Obj.Count > 0)
  339. // {
  340. // return Obj;
  341. // }
  342. // OtherMySqlConn.connstr = Library.ConfigurationManager.AppSettings["SqlConnStr"].ToString();
  343. // DataTable dt = OtherMySqlConn.dtable("select year(a.CreateDate) year,month(a.CreateDate) month,count(*) count,sum(a.TradeAmount) sumamount from TradeRecord a where YEAR(a.CreateDate) = YEAR(NOW())group by year(a.CreateDate), month(a.CreateDate)order by month(a.CreateDate)");
  344. // foreach (DataRow item in dt.Rows)
  345. // {
  346. // Obj.Add(new TradeYearMonth()
  347. // {
  348. // year = item["year"].ToString(),
  349. // month = item["month"].ToString(),
  350. // count = int.Parse(item["count"].ToString()),
  351. // sumamount = decimal.Parse(item["sumamount"].ToString())
  352. // });
  353. // }
  354. // foreach (var sub in Obj)
  355. // {
  356. // RedisDbconn.Instance.AddRightList("TradeYearMonthList:" + UserId, sub);
  357. // }
  358. // RedisDbconn.Instance.SetExpire("TradeYearMonthList:" + UserId, Library.function.get_Random(60, 180));
  359. // dt.Dispose();
  360. // return Obj;
  361. // }
  362. // #endregion
  363. #region 机型统计-机型占比统计
  364. public List<ModelType> GetModelTypeList(int UserId)
  365. {
  366. List<ModelType> Obj = RedisDbconn.Instance.GetList<ModelType>("ModelTypeList:" + UserId);
  367. if (Obj.Count > 0)
  368. {
  369. return Obj;
  370. }
  371. OtherMySqlConn.connstr = Library.ConfigurationManager.AppSettings["SqlConnStr"].ToString();
  372. DataTable dt = OtherMySqlConn.dtable("select b.Name name,a.count count from(select BrandId,count(0) count from PosMachinesTwo where UserId in(select Id from Users where ParentNav like '%," + UserId + ",%' or Id=" + UserId + ")GROUP BY BrandId)a left join KqProducts b on a.BrandId=b.Id");
  373. foreach (DataRow item in dt.Rows)
  374. {
  375. Obj.Add(new ModelType()
  376. {
  377. name = item["name"].ToString(),
  378. count = Convert.ToInt32(item["count"])
  379. });
  380. }
  381. foreach (var sub in Obj)
  382. {
  383. RedisDbconn.Instance.AddRightList("ModelTypeList:" + UserId, sub);
  384. }
  385. RedisDbconn.Instance.SetExpire("ModelTypeList:" + UserId, Library.function.get_Random(60, 180));
  386. dt.Dispose();
  387. return Obj;
  388. }
  389. #endregion
  390. #region 机型统计-交易额统计
  391. public List<ModelTypeTrade> GetModelTypeTradeList(int UserId)
  392. {
  393. List<ModelTypeTrade> Obj = RedisDbconn.Instance.GetList<ModelTypeTrade>("ModelTypeTradeList:" + UserId);
  394. if (Obj.Count > 0)
  395. {
  396. return Obj;
  397. }
  398. OtherMySqlConn.connstr = Library.ConfigurationManager.AppSettings["SqlConnStr"].ToString();
  399. DataTable dt = OtherMySqlConn.dtable("select b.Name name,a.sum sum from(select BrandId,sum(TradeAmount) sum from TradeRecord where UserId in (select Id from Users where ParentNav like '%," + UserId + ",%' or Id=" + UserId + ")GROUP BY BrandId)a left join KqProducts b on a.BrandId=b.Id");
  400. foreach (DataRow item in dt.Rows)
  401. {
  402. Obj.Add(new ModelTypeTrade()
  403. {
  404. name = item["name"].ToString(),
  405. sum = decimal.Parse(item["sum"].ToString())
  406. });
  407. }
  408. foreach (var sub in Obj)
  409. {
  410. RedisDbconn.Instance.AddRightList("ModelTypeTradeList:" + UserId, sub);
  411. }
  412. RedisDbconn.Instance.SetExpire("ModelTypeTradeList:" + UserId, Library.function.get_Random(60, 180));
  413. dt.Dispose();
  414. return Obj;
  415. }
  416. #endregion
  417. #region 交易额统计近一年
  418. public decimal GetMonthTrade(int UserId, string TradeMonth, string kind = "self")
  419. {
  420. decimal amt = 0;
  421. WebCMSEntities db = new WebCMSEntities();
  422. bool check = db.UserTradeDaySummary.Any(m => m.UserId == UserId && m.TradeMonth == TradeMonth && m.SeoTitle == kind);
  423. if (check)
  424. {
  425. if (kind == "self")
  426. {
  427. amt = db.UserTradeDaySummary.Where(m => m.UserId == UserId && m.TradeMonth == TradeMonth && m.SeoTitle == kind).Sum(m => m.DirectTradeAmt + m.DirectDebitTradeAmt);
  428. }
  429. else if (kind == "team")
  430. {
  431. amt = db.UserTradeDaySummary.Where(m => m.UserId == UserId && m.TradeMonth == TradeMonth && m.SeoTitle == kind).Sum(m => m.NonDirectTradeAmt + m.NonDirectDebitTradeAmt);
  432. }
  433. }
  434. db.Dispose();
  435. return amt;
  436. }
  437. #endregion
  438. #region 姓名脱敏
  439. /// <summary>
  440. /// 姓名敏感处理
  441. /// </summary>
  442. /// <param name="fullName">姓名</param>
  443. /// <returns>脱敏后的姓名</returns>
  444. public static string SetSensitiveName(string fullName)
  445. {
  446. if (string.IsNullOrEmpty(fullName)) return string.Empty;
  447. string familyName = fullName.Substring(0, 1);
  448. string end = fullName.Substring(fullName.Length - 1, 1);
  449. string name = string.Empty;
  450. //长度为2
  451. if (fullName.Length <= 2) name = familyName + "*";
  452. //长度⼤于2
  453. else if (fullName.Length >= 3)
  454. {
  455. name = familyName.PadRight(fullName.Length - 1, '*') + end;
  456. }
  457. return name;
  458. }
  459. #endregion
  460. }
  461. }