UsersController.cs 87 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958
  1. /*
  2. * 创客
  3. */
  4. using System;
  5. using System.Web;
  6. using System.Collections.Generic;
  7. using System.Diagnostics;
  8. using System.Linq;
  9. using System.Data;
  10. using System.Threading.Tasks;
  11. using Microsoft.AspNetCore.Mvc;
  12. using Microsoft.AspNetCore.Http;
  13. using Microsoft.Extensions.Logging;
  14. using Microsoft.Extensions.Options;
  15. using MySystem.Models;
  16. using Library;
  17. using LitJson;
  18. using MySystemLib;
  19. namespace MySystem.Areas.Admin.Controllers
  20. {
  21. [Area("Admin")]
  22. [Route("Admin/[controller]/[action]")]
  23. public class UsersController : BaseController
  24. {
  25. public UsersController(IHttpContextAccessor accessor, ILogger<BaseController> logger, IOptions<Setting> setting) : base(accessor, logger, setting)
  26. {
  27. OtherMySqlConn.connstr = ConfigurationManager.AppSettings["SqlConnStr"].ToString();
  28. }
  29. #region 创客列表
  30. /// <summary>
  31. /// 根据条件查询创客列表
  32. /// </summary>
  33. /// <returns></returns>
  34. public IActionResult Index(Users data, string right, int SelfId = 0, int ParentId = 0, string MakerCode = "")
  35. {
  36. ViewBag.RightInfo = RightInfo;
  37. ViewBag.right = right;
  38. ViewBag.SelfId = SelfId.ToString();
  39. ViewBag.ParentId = ParentId.ToString();
  40. ViewBag.MakerCode = MakerCode;
  41. List<Users> TopUsers = db.Users.Where(m => m.ParentUserId == 0).ToList();
  42. ViewBag.TopUsers = TopUsers;
  43. List<UserLevelSet> Levels = db.UserLevelSet.OrderBy(m => m.Id).ToList();
  44. ViewBag.Levels = Levels;
  45. return View();
  46. }
  47. #endregion
  48. #region 根据条件查询创客列表
  49. /// <summary>
  50. /// 创客列表
  51. /// </summary>
  52. /// <returns></returns>
  53. public JsonResult IndexData(Users data, string ParentMakerCode, string ParentRealName, string AuthFlagSelect, string CreateDateData, int TopUserId, string RiskFlagSelect, string MerchantTypeSelect, int? sSettleAmount, int? eSettleAmount, int? sCashFreezeAmt, int? eCashFreezeAmt, int UserId, int SelfId = 0, int ParentId = 0, int ShowFlag = 0, int page = 1, int limit = 30)
  54. {
  55. Dictionary<string, string> Fields = new Dictionary<string, string>();
  56. Fields.Add("MakerCode", "1"); //创客编号
  57. Fields.Add("RealName", "1"); //创客名称
  58. Fields.Add("Mobile", "1"); //手机号
  59. Fields.Add("CertId", "1"); //身份证号码
  60. Fields.Add("SettleAmount", "3"); //结算金额
  61. Fields.Add("CashFreezeAmt", "3"); //冻结金额
  62. Fields.Add("UserLevel", "0"); //创客等级
  63. if (SelfId == 0 && ParentId == 0)
  64. {
  65. if (ShowFlag == 0)
  66. {
  67. Dictionary<string, object> objs = new Dictionary<string, object>();
  68. return Json(objs);
  69. }
  70. }
  71. string condition = " and Status>-1";
  72. string sort = "Id desc";
  73. //直属创客编号
  74. if (!string.IsNullOrEmpty(ParentMakerCode))
  75. {
  76. condition += " and ParentUserId in (select UserId from UserForMakerCode where MakerCode='" + ParentMakerCode + "')";
  77. }
  78. //直属创客名称
  79. if (!string.IsNullOrEmpty(ParentRealName))
  80. {
  81. condition += " and ParentUserId in (select UserId from UserForRealName where RealName='" + ParentRealName + "')";
  82. }
  83. //实名状态
  84. if (!string.IsNullOrEmpty(AuthFlagSelect))
  85. {
  86. condition += " and AuthFlag=" + AuthFlagSelect;
  87. }
  88. //顶级创客
  89. if (TopUserId > 0)
  90. {
  91. condition += " and ParentNav like '," + TopUserId + ",%'";
  92. }
  93. //风控标识
  94. if (!string.IsNullOrEmpty(RiskFlagSelect))
  95. {
  96. condition += " and RiskFlag=" + RiskFlagSelect;
  97. }
  98. //商户创客类型
  99. if (!string.IsNullOrEmpty(MerchantTypeSelect))
  100. {
  101. condition += " and MerchantType=" + MerchantTypeSelect;
  102. }
  103. if (sSettleAmount != null)
  104. {
  105. condition += " and SettleAmount>=" + sSettleAmount.Value;
  106. }
  107. if (eSettleAmount != null)
  108. {
  109. condition += " and SettleAmount<=" + eSettleAmount.Value;
  110. }
  111. if (sCashFreezeAmt != null)
  112. {
  113. condition += " and CashFreezeAmt>=" + sCashFreezeAmt.Value;
  114. }
  115. if (eCashFreezeAmt != null)
  116. {
  117. condition += " and CashFreezeAmt<=" + eCashFreezeAmt.Value;
  118. }
  119. if (SelfId > 0)
  120. {
  121. Users self = db.Users.FirstOrDefault(m => m.Id == SelfId);
  122. if (self != null)
  123. {
  124. string ParentNav = function.CheckNull(self.ParentNav);
  125. condition += " and Id in (" + ParentNav.Trim(',').Replace(",,", ",") + ")";
  126. sort = "ParentNav asc";
  127. }
  128. }
  129. if (ParentId > 0)
  130. {
  131. condition += " and ParentUserId=" + ParentId;
  132. }
  133. if (UserId > 0)
  134. {
  135. condition += " and Id=" + UserId;
  136. }
  137. if (!string.IsNullOrEmpty(CreateDateData))
  138. {
  139. string[] datelist = CreateDateData.Split(new string[] { " - " }, StringSplitOptions.None);
  140. string start = datelist[0];
  141. string end = datelist[1];
  142. condition += " and CreateDate>='" + start + " 00:00:00' and CreateDate<='" + end + " 23:59:59'";
  143. }
  144. Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("Users", Fields, sort, "True", page, limit, condition);
  145. List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
  146. foreach (Dictionary<string, object> dic in diclist)
  147. {
  148. dic["AuthFlagName"] = dic["AuthFlag"].ToString() == "1" ? "已实名" : "未实名";
  149. dic["RiskFlagName"] = dic["RiskFlag"].ToString() == "1" ? "已风控" : "未风控";
  150. dic["UserLevel"] = RelationClass.GetUserLevelSetInfo(int.Parse(dic["UserLevel"].ToString()));
  151. dic["MerchantType"] = RelationClassForConst.GetMerchantTypeInfo(int.Parse(dic["MerchantType"].ToString()));
  152. int ParentUserId = int.Parse(dic["ParentUserId"].ToString());
  153. Users puser = db.Users.FirstOrDefault(m => m.Id == ParentUserId) ?? new Users();
  154. dic["ParentMakerCode"] = puser.MakerCode;
  155. dic["ParentRealName"] = puser.RealName;
  156. string ParentNav = dic["ParentNav"].ToString();
  157. if (!string.IsNullOrEmpty(ParentNav))
  158. {
  159. string[] list = ParentNav.Trim(',').Replace(",,", ",").Split(',');
  160. if (list.Length > 1)
  161. {
  162. int TopId = int.Parse(function.CheckInt(list[1]));
  163. Users tuser = db.Users.FirstOrDefault(m => m.Id == TopId) ?? new Users();
  164. dic["TopMakerCode"] = tuser.MakerCode;
  165. dic["TopRealName"] = tuser.RealName;
  166. }
  167. }
  168. }
  169. return Json(obj);
  170. }
  171. #endregion
  172. #region 增加创客
  173. /// <summary>
  174. /// 增加或修改创客信息
  175. /// </summary>
  176. /// <returns></returns>
  177. public IActionResult Add(string right)
  178. {
  179. ViewBag.RightInfo = RightInfo;
  180. ViewBag.right = right;
  181. return View();
  182. }
  183. #endregion
  184. #region 增加创客
  185. /// <summary>
  186. /// 增加或修改创客信息
  187. /// </summary>
  188. /// <returns></returns>
  189. [HttpPost]
  190. public string Add(Users data, string ParentMakerCode)
  191. {
  192. bool check = db.UserForMobile.Any(m => m.Mobile == data.Mobile);
  193. if (check)
  194. {
  195. return "手机号已存在,请重新输入";
  196. }
  197. check = db.UserForRealName.Any(m => m.RealName == data.RealName);
  198. if (check)
  199. {
  200. return "姓名已存在,请重新输入";
  201. }
  202. if (!string.IsNullOrEmpty(data.MakerCode))
  203. {
  204. check = db.UserForMakerCode.Any(m => m.MakerCode == data.MakerCode);
  205. if (check)
  206. {
  207. return "创客编码已存在,请重新输入";
  208. }
  209. }
  210. Dictionary<string, object> Fields = new Dictionary<string, object>();
  211. Fields.Add("RealName", data.RealName); //真实姓名
  212. Fields.Add("CertId", data.CertId); //身份证号
  213. Fields.Add("Mobile", data.Mobile); //手机号
  214. Fields.Add("LoginPwd", function.MD532(data.LoginPwd)); //登录密码
  215. Fields.Add("SettleBankCardNo", data.SettleBankCardNo); //结算银行卡号
  216. if (!string.IsNullOrEmpty(ParentMakerCode))
  217. {
  218. UserForMakerCode userFor = db.UserForMakerCode.FirstOrDefault(m => m.MakerCode == ParentMakerCode) ?? new UserForMakerCode();
  219. Users puser = db.Users.FirstOrDefault(m => m.Id == userFor.UserId) ?? new Users();
  220. Fields.Add("ParentUserId", userFor.UserId);
  221. Fields.Add("ParentNav", puser.ParentNav + "," + userFor.UserId + ",");
  222. }
  223. int Id = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Add("Users", Fields, 0);
  224. if (string.IsNullOrEmpty(ParentMakerCode))
  225. {
  226. string MakerCode = Id.ToString();
  227. for (int i = 0; i < 7 - Id.ToString().Length; i++)
  228. {
  229. MakerCode = "0" + MakerCode;
  230. }
  231. MakerCode = "K" + MakerCode;
  232. Fields = new Dictionary<string, object>();
  233. Fields.Add("MakerCode", MakerCode); //编号
  234. new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("Users", Fields, Id);
  235. }
  236. db.UserDetail.Add(new UserDetail() { Id = Id });
  237. db.UserData.Add(new UserData() { UserId = Id });
  238. AddSysLog(data.Id.ToString(), "Users", "add");
  239. db.SaveChanges();
  240. return "success";
  241. }
  242. #endregion
  243. #region 修改创客
  244. /// <summary>
  245. /// 增加或修改创客信息
  246. /// </summary>
  247. /// <returns></returns>
  248. public IActionResult Edit(string right, int Id = 0)
  249. {
  250. ViewBag.RightInfo = RightInfo;
  251. ViewBag.right = right;
  252. Users editData = db.Users.FirstOrDefault(m => m.Id == Id) ?? new Users();
  253. ViewBag.data = editData;
  254. return View();
  255. }
  256. #endregion
  257. #region 修改创客
  258. /// <summary>
  259. /// 增加或修改创客信息
  260. /// </summary>
  261. /// <returns></returns>
  262. [HttpPost]
  263. public string Edit(Users data, UserDetail userdetail, UserData userdata)
  264. {
  265. Dictionary<string, object> Fields = new Dictionary<string, object>();
  266. Fields.Add("RealName", data.RealName); //真实姓名
  267. Fields.Add("CertId", data.CertId); //身份证号
  268. Fields.Add("Mobile", data.Mobile); //手机号
  269. Fields.Add("SettleBankName", data.SettleBankName); //结算银行名称
  270. Fields.Add("SettleBankCardNo", data.SettleBankCardNo); //结算银行卡号
  271. new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("Users", Fields, data.Id);
  272. AddSysLog(data.Id.ToString(), "Users", "update");
  273. db.SaveChanges();
  274. return "success";
  275. }
  276. #endregion
  277. #region 修改结算金额
  278. public IActionResult EditSettleAmount(string right, int Id = 0)
  279. {
  280. ViewBag.RightInfo = RightInfo;
  281. ViewBag.right = right;
  282. Users editData = db.Users.FirstOrDefault(m => m.Id == Id) ?? new Users();
  283. ViewBag.data = editData;
  284. return View();
  285. }
  286. #endregion
  287. #region 修改结算金额
  288. [HttpPost]
  289. public string EditSettleAmount(Users data)
  290. {
  291. Dictionary<string, object> Fields = new Dictionary<string, object>();
  292. Fields.Add("SettleAmount", data.SettleAmount);
  293. new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("Users", Fields, data.Id);
  294. AddSysLog(data.Id.ToString(), "Users", "EditSettleAmount");
  295. db.SaveChanges();
  296. return "success";
  297. }
  298. #endregion
  299. #region 修改账户金额
  300. public IActionResult EditCashFreezeAmt(string right, int Id = 0)
  301. {
  302. ViewBag.RightInfo = RightInfo;
  303. ViewBag.right = right;
  304. Users editData = db.Users.FirstOrDefault(m => m.Id == Id) ?? new Users();
  305. ViewBag.data = editData;
  306. return View();
  307. }
  308. #endregion
  309. #region 修改账户金额
  310. [HttpPost]
  311. public string EditCashFreezeAmt(Users data, string Note, int Kind)
  312. {
  313. int UserId = data.Id;
  314. UserAccount account = db.UserAccount.FirstOrDefault(m => m.Id == UserId);
  315. if (account == null)
  316. {
  317. account = db.UserAccount.Add(new UserAccount()
  318. {
  319. Id = UserId,
  320. UserId = UserId,
  321. }).Entity;
  322. db.SaveChanges();
  323. }
  324. if ((Kind == 1 || Kind == 3) && data.CashFreezeAmt > account.BalanceAmount)
  325. {
  326. return "账号余额不足";
  327. }
  328. decimal BeforeTotalAmount = account.TotalAmount; //变更前总金额
  329. decimal BeforeFreezeAmount = account.FreezeAmount; //变更前冻结金额
  330. decimal BeforeBalanceAmount = account.BalanceAmount; //变更前余额
  331. int ChangeType = 0;
  332. if (Kind == 1 && data.CashFreezeAmt <= account.BalanceAmount)
  333. {
  334. account.BalanceAmount -= data.CashFreezeAmt;
  335. account.FreezeAmount += data.CashFreezeAmt;
  336. ChangeType = 61;
  337. }
  338. else if (Kind == 1 && data.CashFreezeAmt > account.BalanceAmount)
  339. {
  340. return "冻结金额大于余额";
  341. }
  342. else if (Kind == 2 && data.CashFreezeAmt <= account.FreezeAmount)
  343. {
  344. account.BalanceAmount += data.CashFreezeAmt;
  345. account.FreezeAmount -= data.CashFreezeAmt;
  346. ChangeType = 62;
  347. }
  348. else if (Kind == 2 && data.CashFreezeAmt > account.FreezeAmount)
  349. {
  350. return "解冻金额大于冻结金额";
  351. }
  352. else if (Kind == 3 && data.CashFreezeAmt <= account.BalanceAmount)
  353. {
  354. account.TotalAmount -= data.CashFreezeAmt;
  355. account.BalanceAmount -= data.CashFreezeAmt;
  356. ChangeType = 63;
  357. }
  358. else if (Kind == 3 && data.CashFreezeAmt > account.BalanceAmount)
  359. {
  360. return "扣减金额大于余额";
  361. }
  362. else if (Kind == 4)
  363. {
  364. account.TotalAmount += data.CashFreezeAmt;
  365. account.BalanceAmount += data.CashFreezeAmt;
  366. ChangeType = 64;
  367. }
  368. decimal AfterTotalAmount = account.TotalAmount; //变更后总金额
  369. decimal AfterFreezeAmount = account.FreezeAmount; //变更后冻结金额
  370. decimal AfterBalanceAmount = account.BalanceAmount; //变更后余额
  371. UserAccountRecord userAccountRecord = db.UserAccountRecord.Add(new UserAccountRecord()
  372. {
  373. CreateDate = DateTime.Now,
  374. UpdateDate = DateTime.Now,
  375. UserId = UserId, //创客
  376. ChangeType = ChangeType, //变动类型
  377. ChangeAmount = data.CashFreezeAmt, //变更金额
  378. BeforeTotalAmount = BeforeTotalAmount, //变更前总金额
  379. AfterTotalAmount = AfterTotalAmount, //变更后总金额
  380. BeforeFreezeAmount = BeforeFreezeAmount, //变更前冻结金额
  381. AfterFreezeAmount = AfterFreezeAmount, //变更后冻结金额
  382. BeforeBalanceAmount = BeforeBalanceAmount, //变更前余额
  383. AfterBalanceAmount = AfterBalanceAmount, //变更后余额
  384. Remark = Note,
  385. }).Entity;
  386. db.SaveChanges();
  387. RedisDbconn.Instance.Set("UserAccount:" + UserId, account);
  388. AddSysLog(data.Id.ToString(), "Users", "EditCashFreezeAmt");
  389. db.SaveChanges();
  390. return "success";
  391. }
  392. #endregion
  393. #region 账户操作
  394. public IActionResult EditBalance(string right, int Id = 0)
  395. {
  396. ViewBag.RightInfo = RightInfo;
  397. ViewBag.right = right;
  398. Users editData = db.Users.FirstOrDefault(m => m.Id == Id) ?? new Users();
  399. ViewBag.data = editData;
  400. UserAccount account = db.UserAccount.FirstOrDefault(m => m.Id == Id) ?? new UserAccount();
  401. ViewBag.account = account;
  402. return View();
  403. }
  404. #endregion
  405. #region 账户操作
  406. [HttpPost]
  407. public string EditBalance(UserAccount data)
  408. {
  409. UserAccount account = db.UserAccount.FirstOrDefault(m => m.Id == data.Id);
  410. if (account != null)
  411. {
  412. decimal amount = data.BalanceAmount - account.BalanceAmount;
  413. if (amount != 0)
  414. {
  415. account.BalanceAmount += amount;
  416. account.TotalAmount += amount;
  417. AddSysLog(data.Id.ToString(), "UserAccount", "EditBalance");
  418. db.SaveChanges();
  419. }
  420. }
  421. return "success";
  422. }
  423. #endregion
  424. #region 详情
  425. public IActionResult Detail(string right, int Id = 0)
  426. {
  427. ViewBag.RightInfo = RightInfo;
  428. ViewBag.right = right;
  429. Users editData = db.Users.FirstOrDefault(m => m.Id == Id) ?? new Users();
  430. ViewBag.AuthDate = editData.AuthDate == null ? "" : editData.AuthDate.Value.ToString("yyyy-MM-dd HH:mm:ss");
  431. string Age = "";
  432. if (!string.IsNullOrEmpty(editData.CertId))
  433. {
  434. int year = DateTime.Now.Year - int.Parse(editData.CertId.Substring(6, 4));
  435. Age = year.ToString();
  436. }
  437. ViewBag.Age = Age;
  438. ViewBag.QrCode = string.IsNullOrEmpty(editData.ReferenceQrCode) ? defaultImage : SourceHost + editData.ReferenceQrCode;
  439. return View();
  440. }
  441. #endregion
  442. #region 三/四要素验证
  443. public IActionResult ThreeElement(string right)
  444. {
  445. ViewBag.RightInfo = RightInfo;
  446. ViewBag.right = right;
  447. return View();
  448. }
  449. #endregion
  450. #region 三/四要素验证
  451. [HttpPost]
  452. public string ThreeElement(string Name, string CertId, string CardNo, string Mobile)
  453. {
  454. return "success";
  455. }
  456. #endregion
  457. #region 删除创客信息
  458. /// <summary>
  459. /// 删除创客信息
  460. /// </summary>
  461. /// <returns></returns>
  462. public string Delete(string Id)
  463. {
  464. string[] idlist = Id.Split(new char[] { ',' });
  465. AddSysLog(Id, "Users", "del");
  466. foreach (string subid in idlist)
  467. {
  468. int id = int.Parse(subid);
  469. Dictionary<string, object> Fields = new Dictionary<string, object>();
  470. Fields.Add("Status", -1);
  471. new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("Users", Fields, id);
  472. }
  473. db.SaveChanges();
  474. return "success";
  475. }
  476. #endregion
  477. #region 注销
  478. // 1、未实名创客;
  479. // 2、已实名创客,无开通商户;
  480. // 3、近7天未在商城下单过商品;
  481. // 4、名下无未绑定机具、机具券,无未申请的循环机;
  482. public string Cancel(string UserId)
  483. {
  484. Users user = db.Users.FirstOrDefault(m => m.Id == Convert.ToInt32(UserId));
  485. if (user != null)
  486. {
  487. if (user.AuthFlag == 1)
  488. {
  489. bool check = db.PosMachinesTwo.Any(m => m.BuyUserId == user.Id && m.BindingState == 1);
  490. if (check)
  491. {
  492. // return Json(new AppResultJson() { Status = "-1", Info = "注销失败,未满足条件:已实名创客,无开通商户。如有疑问,请联系客服" });
  493. return "注销失败,未满足条件:已实名创客,无开通商户。如有疑问,请联系客服";
  494. }
  495. DateTime checkDate = DateTime.Now.AddDays(-7);
  496. check = db.Orders.Any(m => m.CreateDate >= checkDate && m.Status > 0 && m.UserId == user.Id);
  497. if (check)
  498. {
  499. // return Json(new AppResultJson() { Status = "-1", Info = "注销失败,未满足条件:近7天未在商城下单过商品。如有疑问,请联系客服" });
  500. return "注销失败,未满足条件:近7天未在商城下单过商品。如有疑问,请联系客服";
  501. }
  502. check = db.PosMachinesTwo.Any(m => m.BuyUserId == user.Id && m.IsPurchase == 0);
  503. if (check)
  504. {
  505. // return Json(new AppResultJson() { Status = "-1", Info = "注销失败,未满足条件:名下无未绑定机具、机具券,无未申请的循环机。如有疑问,请联系客服" });
  506. return "注销失败,未满足条件:名下无未绑定机具、机具券,无未申请的循环机。如有疑问,请联系客服";
  507. }
  508. check = db.PosCoupons.Any(m => m.UserId == user.Id && m.IsUse == 0);
  509. if (check)
  510. {
  511. // return Json(new AppResultJson() { Status = "-1", Info = "注销失败,未满足条件:名下无未绑定机具、机具券,无未申请的循环机。如有疑问,请联系客服" });
  512. return "注销失败,未满足条件:名下无未绑定机具、机具券,无未申请的循环机。如有疑问,请联系客服";
  513. }
  514. }
  515. UserForMobile forMobile = db.UserForMobile.FirstOrDefault(m => m.Mobile == user.Mobile);
  516. if (forMobile != null)
  517. {
  518. db.UserForMobile.Remove(forMobile);
  519. }
  520. UserForMakerCode forCode = db.UserForMakerCode.FirstOrDefault(m => m.MakerCode == user.MakerCode);
  521. if (forCode != null)
  522. {
  523. db.UserForMakerCode.Remove(forCode);
  524. }
  525. user.Status = -1;
  526. user.Mobile += "d";
  527. user.CertId += "d";
  528. function.WriteLog(user.Id + "于" + DateTime.Now.ToString() + "注销账号", "创客注销日志");
  529. // TODO: 每月扫描一次注销的创客,把注销创客伞下创客全部挂到注销创客的上级
  530. // TODO: 清除token,token登录返回
  531. db.SaveChanges();
  532. }
  533. return "success";
  534. }
  535. #endregion
  536. #region 开启
  537. /// <summary>
  538. /// 开启
  539. /// </summary>
  540. /// <returns></returns>
  541. public string Open(string Id)
  542. {
  543. string[] idlist = Id.Split(new char[] { ',' });
  544. AddSysLog(Id, "Users", "open");
  545. foreach (string subid in idlist)
  546. {
  547. int id = int.Parse(subid);
  548. Dictionary<string, object> Fields = new Dictionary<string, object>();
  549. Fields.Add("Status", 1);
  550. new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("Users", Fields, id);
  551. }
  552. db.SaveChanges();
  553. return "success";
  554. }
  555. #endregion
  556. #region 关闭
  557. /// <summary>
  558. /// 关闭
  559. /// </summary>
  560. /// <returns></returns>
  561. public string Close(string Id)
  562. {
  563. string[] idlist = Id.Split(new char[] { ',' });
  564. AddSysLog(Id, "Users", "close");
  565. foreach (string subid in idlist)
  566. {
  567. int id = int.Parse(subid);
  568. Dictionary<string, object> Fields = new Dictionary<string, object>();
  569. Fields.Add("Status", 0);
  570. new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("Users", Fields, id);
  571. }
  572. db.SaveChanges();
  573. return "success";
  574. }
  575. #endregion
  576. #region 一键企业创客
  577. /// <summary>
  578. /// 一键企业创客
  579. /// </summary>
  580. /// <returns></returns>
  581. public string OpenEnterpriseMaker(string Id)
  582. {
  583. string[] idlist = Id.Split(new char[] { ',' });
  584. AddSysLog(Id, "Users", "OpenEnterpriseMaker");
  585. foreach (string subid in idlist)
  586. {
  587. int id = int.Parse(subid);
  588. Dictionary<string, object> Fields = new Dictionary<string, object>();
  589. Fields.Add("BusinessFlag", 1);
  590. new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("Users", Fields, id);
  591. }
  592. db.SaveChanges();
  593. return "success";
  594. }
  595. #endregion
  596. #region 关闭企业创客
  597. /// <summary>
  598. /// 关闭企业创客
  599. /// </summary>
  600. /// <returns></returns>
  601. public string CloseEnterpriseMaker(string Id)
  602. {
  603. string[] idlist = Id.Split(new char[] { ',' });
  604. AddSysLog(Id, "Users", "CloseEnterpriseMaker");
  605. foreach (string subid in idlist)
  606. {
  607. int id = int.Parse(subid);
  608. Dictionary<string, object> Fields = new Dictionary<string, object>();
  609. Fields.Add("BusinessFlag", 0);
  610. new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("Users", Fields, id);
  611. }
  612. db.SaveChanges();
  613. return "success";
  614. }
  615. #endregion
  616. #region 一键大盟主
  617. /// <summary>
  618. /// 一键大盟主
  619. /// </summary>
  620. /// <returns></returns>
  621. public string SetBigLeader(string Id)
  622. {
  623. string[] idlist = Id.Split(new char[] { ',' });
  624. AddSysLog(Id, "Users", "SetBigLeader");
  625. foreach (string subid in idlist)
  626. {
  627. int id = int.Parse(subid);
  628. Dictionary<string, object> Fields = new Dictionary<string, object>();
  629. Fields.Add("LeaderLevel", 2);
  630. new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("Users", Fields, id);
  631. }
  632. db.SaveChanges();
  633. return "success";
  634. }
  635. #endregion
  636. #region 一键小盟主
  637. /// <summary>
  638. /// 一键小盟主
  639. /// </summary>
  640. /// <returns></returns>
  641. public string SetSmallLeader(string Id)
  642. {
  643. string[] idlist = Id.Split(new char[] { ',' });
  644. AddSysLog(Id, "Users", "SetSmallLeader");
  645. foreach (string subid in idlist)
  646. {
  647. int id = int.Parse(subid);
  648. Dictionary<string, object> Fields = new Dictionary<string, object>();
  649. Fields.Add("LeaderLevel", 1);
  650. new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("Users", Fields, id);
  651. }
  652. db.SaveChanges();
  653. return "success";
  654. }
  655. #endregion
  656. #region 风控
  657. public IActionResult Risk(string right, int Id = 0)
  658. {
  659. ViewBag.RightInfo = RightInfo;
  660. ViewBag.right = right;
  661. Users editData = db.Users.FirstOrDefault(m => m.Id == Id) ?? new Users();
  662. ViewBag.data = editData;
  663. return View();
  664. }
  665. #endregion
  666. #region 风控
  667. [HttpPost]
  668. public string Risk(Users data)
  669. {
  670. Users user = db.Users.FirstOrDefault(m => m.Id == data.Id);
  671. if (user != null)
  672. {
  673. user.RiskFlag = data.RiskFlag;
  674. user.RiskRemark = data.RiskRemark;
  675. db.SaveChanges();
  676. }
  677. return "success";
  678. }
  679. #endregion
  680. #region 解除风控
  681. public string UnRisk(string Id)
  682. {
  683. string[] idlist = Id.Split(new char[] { ',' });
  684. AddSysLog(Id, "Users", "UnRisk");
  685. foreach (string subid in idlist)
  686. {
  687. int id = int.Parse(subid);
  688. Dictionary<string, object> Fields = new Dictionary<string, object>();
  689. Fields.Add("RiskFlag", 0);
  690. new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("Users", Fields, id);
  691. }
  692. db.SaveChanges();
  693. return "success";
  694. }
  695. #endregion
  696. #region 重置密码
  697. public string ResetPwd(int Id)
  698. {
  699. string NewPwd = function.get_Random(6);
  700. Dictionary<string, object> Fields = new Dictionary<string, object>();
  701. Fields.Add("LoginPwd", function.MD532(NewPwd));
  702. new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("Users", Fields, Id);
  703. AddSysLog(Id, "Users", "ResetPwd");
  704. return "success|" + NewPwd;
  705. }
  706. #endregion
  707. #region 排序
  708. /// <summary>
  709. /// 排序
  710. /// </summary>
  711. /// <param name="Id"></param>
  712. public string Sort(int Id, int Sort)
  713. {
  714. new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Sort("Users", Sort, Id);
  715. AddSysLog(Id.ToString(), "Users", "sort");
  716. return "success";
  717. }
  718. #endregion
  719. #region 导入数据
  720. /// <summary>
  721. /// 导入数据
  722. /// </summary>
  723. /// <param name="ExcelData"></param>
  724. public string Import(string ExcelData, int Kind = 0)
  725. {
  726. ExcelData = HttpUtility.UrlDecode(ExcelData);
  727. JsonData list = JsonMapper.ToObject(ExcelData);
  728. if (Kind == 1)
  729. {
  730. for (int i = 1; i < list.Count; i++)
  731. {
  732. JsonData dr = list[i];
  733. string MakerCode = dr[0].ToString();
  734. string SettleAmount = dr[2].ToString();
  735. UserForMakerCode UserCode = db.UserForMakerCode.FirstOrDefault(m => m.MakerCode == MakerCode);
  736. if (UserCode != null)
  737. {
  738. Users User = db.Users.FirstOrDefault(m => m.Id == UserCode.UserId);
  739. if (User != null)
  740. {
  741. User.SettleAmount = decimal.Parse(function.CheckInt(SettleAmount));
  742. }
  743. }
  744. }
  745. db.SaveChanges();
  746. }
  747. else if (Kind == 2)
  748. {
  749. for (int i = 1; i < list.Count; i++)
  750. {
  751. JsonData dr = list[i];
  752. string MakerCode = dr[0].ToString();
  753. string CashFreezeAmt = dr[2].ToString();
  754. UserForMakerCode UserCode = db.UserForMakerCode.FirstOrDefault(m => m.MakerCode == MakerCode);
  755. if (UserCode != null)
  756. {
  757. Users User = db.Users.FirstOrDefault(m => m.Id == UserCode.UserId);
  758. if (User != null)
  759. {
  760. User.CashFreezeAmt = decimal.Parse(function.CheckInt(CashFreezeAmt));
  761. }
  762. }
  763. }
  764. db.SaveChanges();
  765. }
  766. else if (Kind == 3)
  767. {
  768. for (int i = 1; i < list.Count; i++)
  769. {
  770. JsonData dr = list[i];
  771. string MakerCode = dr[0].ToString();
  772. string RiskFlag = dr[2].ToString();
  773. string RiskNote = dr[3].ToString();
  774. UserForMakerCode UserCode = db.UserForMakerCode.FirstOrDefault(m => m.MakerCode == MakerCode);
  775. if (UserCode != null)
  776. {
  777. Users User = db.Users.FirstOrDefault(m => m.Id == UserCode.UserId);
  778. if (User != null)
  779. {
  780. User.RiskFlag = ulong.Parse(function.CheckInt(RiskFlag));
  781. User.RiskRemark = RiskNote;
  782. }
  783. }
  784. }
  785. db.SaveChanges();
  786. }
  787. else if (Kind == 4)
  788. {
  789. string error = "";
  790. for (int i = 1; i < list.Count; i++)
  791. {
  792. JsonData dr = list[i];
  793. string MakerCode = dr[0].ToString();
  794. string OperationAmt = dr[2].ToString();//操作金额
  795. string OperationType = dr[3].ToString();//操作类型
  796. UserForMakerCode UserCode = db.UserForMakerCode.FirstOrDefault(m => m.MakerCode == MakerCode);
  797. if (UserCode != null)
  798. {
  799. Users User = db.Users.FirstOrDefault(m => m.Id == UserCode.UserId);
  800. UserAccount account = db.UserAccount.FirstOrDefault(m => m.Id == User.Id);
  801. if (account == null)
  802. {
  803. account = db.UserAccount.Add(new UserAccount()
  804. {
  805. Id = User.Id,
  806. UserId = User.Id,
  807. }).Entity;
  808. db.SaveChanges();
  809. }
  810. if (User != null)
  811. {
  812. decimal BeforeTotalAmount = account.TotalAmount; //变更前总金额
  813. decimal BeforeFreezeAmount = account.FreezeAmount; //变更前冻结金额
  814. decimal BeforeBalanceAmount = account.BalanceAmount; //变更前余额
  815. int ChangeType = 0;
  816. if (OperationType == "1" && Convert.ToDecimal(OperationAmt) <= account.BalanceAmount)
  817. {
  818. account.BalanceAmount -= Convert.ToDecimal(OperationAmt);
  819. account.FreezeAmount += Convert.ToDecimal(OperationAmt);
  820. ChangeType = 61;
  821. }
  822. else if (OperationType == "1" && Convert.ToDecimal(OperationAmt) > account.BalanceAmount)
  823. {
  824. error += "以下操作失败" + User.MakerCode + ',' + User.RealName + "冻结金额大于余额" + '|' + '\n';
  825. }
  826. else if (OperationType == "2" && Convert.ToDecimal(OperationAmt) <= account.FreezeAmount)
  827. {
  828. account.BalanceAmount += Convert.ToDecimal(OperationAmt);
  829. account.FreezeAmount -= Convert.ToDecimal(OperationAmt);
  830. ChangeType = 62;
  831. }
  832. else if (OperationType == "2" && Convert.ToDecimal(OperationAmt) > account.FreezeAmount)
  833. {
  834. error += "以下操作失败" + User.MakerCode + ',' + User.RealName + "解冻金额大于冻结金额" + '|' + '\n';
  835. }
  836. else if (OperationType == "3" && Convert.ToDecimal(OperationAmt) <= account.BalanceAmount)
  837. {
  838. account.TotalAmount -= Convert.ToDecimal(OperationAmt);
  839. account.BalanceAmount -= Convert.ToDecimal(OperationAmt);
  840. ChangeType = 63;
  841. }
  842. else if (OperationType == "3" && Convert.ToDecimal(OperationAmt) > account.BalanceAmount)
  843. {
  844. error += "以下操作失败" + User.MakerCode + ',' + User.RealName + "扣减金额大于余额" + '|' + '\n';
  845. }
  846. else if (OperationType == "4")
  847. {
  848. account.TotalAmount += Convert.ToDecimal(OperationAmt);
  849. account.BalanceAmount += Convert.ToDecimal(OperationAmt);
  850. ChangeType = 64;
  851. }
  852. decimal AfterTotalAmount = account.TotalAmount; //变更后总金额
  853. decimal AfterFreezeAmount = account.FreezeAmount; //变更后冻结金额
  854. decimal AfterBalanceAmount = account.BalanceAmount; //变更后余额
  855. UserAccountRecord userAccountRecord = db.UserAccountRecord.Add(new UserAccountRecord()
  856. {
  857. CreateDate = DateTime.Now,
  858. UpdateDate = DateTime.Now,
  859. UserId = User.Id, //创客
  860. ChangeType = ChangeType, //变动类型
  861. ChangeAmount = Convert.ToDecimal(OperationAmt), //变更金额
  862. BeforeTotalAmount = BeforeTotalAmount, //变更前总金额
  863. AfterTotalAmount = AfterTotalAmount, //变更后总金额
  864. BeforeFreezeAmount = BeforeFreezeAmount, //变更前冻结金额
  865. AfterFreezeAmount = AfterFreezeAmount, //变更后冻结金额
  866. BeforeBalanceAmount = BeforeBalanceAmount, //变更前余额
  867. AfterBalanceAmount = AfterBalanceAmount, //变更后余额
  868. Remark = dr[4].ToString(),
  869. }).Entity;
  870. db.SaveChanges();
  871. AddSysLog(User.Id.ToString(), "Users", "ChangeCashFreezeAmts");
  872. db.SaveChanges();
  873. }
  874. }
  875. }
  876. db.SaveChanges();
  877. return "warning" + error;
  878. }
  879. AddSysLog("0", "Users", "Import");
  880. return "success";
  881. }
  882. #endregion
  883. #region 导出Excel
  884. /// <summary>
  885. /// 导出Excel
  886. /// </summary>
  887. /// <returns></returns>
  888. public JsonResult ExportExcel(Users data, string CreateDate, string ParentMakerCode, string ParentRealName, string AuthFlagSelect, int TopUserId, string RiskFlagSelect, string MerchantTypeSelect, int SelfId = 0, int ParentId = 0)
  889. {
  890. Dictionary<string, string> Fields = new Dictionary<string, string>();
  891. Fields.Add("MakerCode", "1"); //创客编号
  892. Fields.Add("RealName", "1"); //创客名称
  893. Fields.Add("Mobile", "1"); //手机号
  894. Fields.Add("CertId", "1"); //身份证号码
  895. Fields.Add("CreateDate", "3"); //注册时间
  896. Fields.Add("SettleAmount", "3"); //结算金额
  897. Fields.Add("CashFreezeAmt", "3"); //冻结金额
  898. Fields.Add("UserLevel", "0"); //创客等级
  899. string condition = " and Status>-1";
  900. //直属创客编号
  901. if (!string.IsNullOrEmpty(ParentMakerCode))
  902. {
  903. condition += " and Id in (select UserId from UserForMakerCode where MakerCode='" + ParentMakerCode + "')";
  904. }
  905. //直属创客名称
  906. if (!string.IsNullOrEmpty(ParentRealName))
  907. {
  908. condition += " and Id in (select UserId from UserForRealName where RealName='" + ParentRealName + "')";
  909. }
  910. //实名状态
  911. if (!string.IsNullOrEmpty(AuthFlagSelect))
  912. {
  913. condition += " and AuthFlag=" + AuthFlagSelect;
  914. }
  915. //顶级创客
  916. if (TopUserId > 0)
  917. {
  918. condition += " and ParentNav like '," + TopUserId + ",%'";
  919. }
  920. //风控标识
  921. if (!string.IsNullOrEmpty(RiskFlagSelect))
  922. {
  923. condition += " and RiskFlag=" + RiskFlagSelect;
  924. }
  925. //商户创客类型
  926. if (!string.IsNullOrEmpty(MerchantTypeSelect))
  927. {
  928. condition += " and MerchantType=" + MerchantTypeSelect;
  929. }
  930. if (SelfId > 0)
  931. {
  932. Users self = db.Users.FirstOrDefault(m => m.Id == SelfId);
  933. if (self != null)
  934. {
  935. string ParentNav = function.CheckNull(self.ParentNav);
  936. condition += " and Id in (" + ParentNav.Trim(',').Replace(",,", ",") + ")";
  937. }
  938. }
  939. if (ParentId > 0)
  940. {
  941. condition += " and ParentUserId=" + ParentId;
  942. }
  943. Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("Users", Fields, "Id desc", "True", 1, 20000, condition, "MakerCode,RealName,ParentUserId,ParentNav,UserLevel,SettleAmount,CashFreezeAmt,CertId,Mobile,MerchantType,MerchantDate,AuthFlag,RiskFlag,CreateDate", false);
  944. List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
  945. foreach (Dictionary<string, object> dic in diclist)
  946. {
  947. dic["AuthFlag"] = dic["AuthFlag"].ToString() == "1" ? "已实名" : "未实名";
  948. dic["RiskFlag"] = dic["RiskFlag"].ToString() == "1" ? "已风控" : "未风控";
  949. dic["UserLevel"] = RelationClass.GetUserLevelSetInfo(int.Parse(dic["UserLevel"].ToString()));
  950. dic["MerchantType"] = RelationClassForConst.GetMerchantTypeInfo(int.Parse(dic["MerchantType"].ToString()));
  951. int ParentUserId = int.Parse(dic["ParentUserId"].ToString());
  952. Users puser = db.Users.FirstOrDefault(m => m.Id == ParentUserId) ?? new Users();
  953. dic["ParentMakerCode"] = puser.MakerCode;
  954. dic["ParentRealName"] = puser.RealName;
  955. string ParentNav = dic["ParentNav"].ToString();
  956. if (!string.IsNullOrEmpty(ParentNav))
  957. {
  958. string[] list = ParentNav.Trim(',').Replace(",,", ",").Split(',');
  959. if (list.Length > 1)
  960. {
  961. int TopId = int.Parse(function.CheckInt(list[1]));
  962. Users tuser = db.Users.FirstOrDefault(m => m.Id == TopId) ?? new Users();
  963. dic["TopMakerCode"] = tuser.MakerCode;
  964. dic["TopRealName"] = tuser.RealName;
  965. }
  966. }
  967. dic.Remove("ParentUserId");
  968. dic.Remove("ParentNav");
  969. }
  970. Dictionary<string, object> result = new Dictionary<string, object>();
  971. result.Add("Status", "1");
  972. result.Add("Info", "Excel报表-" + DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss") + ".xlsx");
  973. result.Add("Obj", diclist);
  974. Dictionary<string, object> ReturnFields = new Dictionary<string, object>();
  975. ReturnFields.Add("MakerCode", "创客编号");
  976. ReturnFields.Add("RealName", "创客姓名");
  977. ReturnFields.Add("UserLevel", "创客等级");
  978. ReturnFields.Add("SettleAmount", "提现金额(元)");
  979. ReturnFields.Add("CashFreezeAmt", "冻结金额(元)");
  980. ReturnFields.Add("CertId", "身份证号");
  981. ReturnFields.Add("Mobile", "联系手机");
  982. ReturnFields.Add("MerchantType", "商户创客类型");
  983. ReturnFields.Add("MerchantDate", "成为商户创客时间");
  984. ReturnFields.Add("ParentMakerCode", "直属创客编号");
  985. ReturnFields.Add("ParentRealName", "直属创客名称");
  986. ReturnFields.Add("TopMakerCode", "顶级创客编号");
  987. ReturnFields.Add("TopRealName", "顶级创客名称");
  988. ReturnFields.Add("AuthFlag", "实名状态");
  989. ReturnFields.Add("RiskFlag", "风控状态");
  990. ReturnFields.Add("CreateDate", "注册时间");
  991. result.Add("Fields", ReturnFields);
  992. AddSysLog("0", "Users", "ExportExcel");
  993. return Json(result);
  994. }
  995. #endregion
  996. #region 直属创客导出Excel
  997. /// <summary>
  998. /// 直属创客导出Excel
  999. /// </summary>
  1000. /// <returns></returns>
  1001. public JsonResult ExportZSExcel(Users data, string MakerCode, string ParentMakerCode)
  1002. {
  1003. Dictionary<string, string> Fields = new Dictionary<string, string>();
  1004. string condition = " and Status>-1";
  1005. //创客编号
  1006. if (!string.IsNullOrEmpty(MakerCode))
  1007. {
  1008. condition += " and ParentUserId in (select UserId from UserForMakerCode where MakerCode='" + MakerCode + "')";
  1009. }
  1010. //直属创客编号
  1011. if (!string.IsNullOrEmpty(ParentMakerCode))
  1012. {
  1013. condition += " and ParentUserId in (select UserId from UserForMakerCode where MakerCode='" + ParentMakerCode + "')";
  1014. }
  1015. Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("Users", Fields, "Id desc", "True", 1, 20000, condition, "Id,MakerCode,RealName,UserLevel", false);
  1016. List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
  1017. foreach (Dictionary<string, object> dic in diclist)
  1018. {
  1019. int Id = int.Parse(dic["Id"].ToString());
  1020. Users userZS = db.Users.FirstOrDefault(m => m.Id == Id) ?? new Users();
  1021. dic["MakerCode"] = userZS.MakerCode;
  1022. dic["RealName"] = userZS.RealName;
  1023. dic["UserLevel"] = RelationClass.GetUserLevelSetInfo(int.Parse(dic["UserLevel"].ToString()));
  1024. }
  1025. Dictionary<string, object> result = new Dictionary<string, object>();
  1026. result.Add("Status", "1");
  1027. result.Add("Info", "Excel报表-" + DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss") + ".xlsx");
  1028. result.Add("Obj", diclist);
  1029. Dictionary<string, object> ReturnFields = new Dictionary<string, object>();
  1030. ReturnFields.Add("Id", "Id");
  1031. ReturnFields.Add("MakerCode", "创客编号");
  1032. ReturnFields.Add("RealName", "创客姓名");
  1033. ReturnFields.Add("UserLevel", "创客等级");
  1034. result.Add("Fields", ReturnFields);
  1035. AddSysLog("0", "Users", "ExportZSExcel");
  1036. return Json(result);
  1037. }
  1038. #endregion
  1039. #region 上级创客导出Excel
  1040. /// <summary>
  1041. /// 上级创客导出Excel
  1042. /// </summary>
  1043. /// <returns></returns>
  1044. public JsonResult ExportSJExcel(Users data, string MakerCode, string ParentMakerCode)
  1045. {
  1046. Dictionary<string, string> Fields = new Dictionary<string, string>();
  1047. string condition = " and Status>-1";
  1048. //创客编号
  1049. if (!string.IsNullOrEmpty(MakerCode))
  1050. {
  1051. var query = db.UserForMakerCode.FirstOrDefault(m => m.MakerCode == MakerCode);
  1052. Users self = db.Users.FirstOrDefault(m => m.Id == query.UserId);
  1053. if (self != null)
  1054. {
  1055. string ParentNav = function.CheckNull(self.ParentNav);
  1056. condition += " and Id in (" + ParentNav.Trim(',').Replace(",,", ",") + ")";
  1057. }
  1058. }
  1059. //直属创客编号
  1060. if (!string.IsNullOrEmpty(ParentMakerCode))
  1061. {
  1062. var query = db.UserForMakerCode.FirstOrDefault(m => m.MakerCode == ParentMakerCode);
  1063. Users self = db.Users.FirstOrDefault(m => m.Id == query.UserId);
  1064. if (self != null)
  1065. {
  1066. string ParentNav = function.CheckNull(self.ParentNav);
  1067. condition += " and Id in (" + ParentNav.Trim(',').Replace(",,", ",") + ")";
  1068. }
  1069. }
  1070. Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("Users", Fields, "Id desc", "True", 1, 20000, condition, "Id,MakerCode,RealName,UserLevel", false);
  1071. List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
  1072. foreach (Dictionary<string, object> dic in diclist)
  1073. {
  1074. int Id = int.Parse(dic["Id"].ToString());
  1075. Users userSJ = db.Users.FirstOrDefault(m => m.Id == Id) ?? new Users();
  1076. dic["MakerCode"] = userSJ.MakerCode;
  1077. dic["RealName"] = userSJ.RealName;
  1078. dic["UserLevel"] = RelationClass.GetUserLevelSetInfo(int.Parse(dic["UserLevel"].ToString()));
  1079. }
  1080. Dictionary<string, object> result = new Dictionary<string, object>();
  1081. result.Add("Status", "1");
  1082. result.Add("Info", "Excel报表-" + DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss") + ".xlsx");
  1083. result.Add("Obj", diclist);
  1084. Dictionary<string, object> ReturnFields = new Dictionary<string, object>();
  1085. ReturnFields.Add("Id", "Id");
  1086. ReturnFields.Add("MakerCode", "创客编号");
  1087. ReturnFields.Add("RealName", "创客姓名");
  1088. ReturnFields.Add("UserLevel", "创客等级");
  1089. result.Add("Fields", ReturnFields);
  1090. AddSysLog("0", "Users", "ExportExcel");
  1091. return Json(result);
  1092. }
  1093. #endregion
  1094. #region 同步数据
  1095. /// <summary>
  1096. /// 同步数据
  1097. /// </summary>
  1098. /// <returns></returns>
  1099. public string SycnData(int Id = 0)
  1100. {
  1101. var Brands = db.KqProducts.Where(m => m.Status == 1).ToList();
  1102. foreach (var Brand in Brands)
  1103. {
  1104. PublicFunction.SycnMachineCount(Id, Brand.Id);
  1105. }
  1106. AddSysLog(Id, "Users", "SycnData");
  1107. db.SaveChanges();
  1108. return "success";
  1109. }
  1110. #endregion
  1111. #region 同步交易额
  1112. public IActionResult SycnTradeAmount(string right, int Id = 0)
  1113. {
  1114. ViewBag.RightInfo = RightInfo;
  1115. ViewBag.right = right;
  1116. Users editData = db.Users.FirstOrDefault(m => m.Id == Id) ?? new Users();
  1117. ViewBag.data = editData;
  1118. return View();
  1119. }
  1120. #endregion
  1121. #region 同步交易额
  1122. [HttpPost]
  1123. public string SycnTradeAmountDo(DateTime sdate, DateTime edate, int UserId, int BrandId)
  1124. {
  1125. if (sdate.AddMonths(1) < edate)
  1126. {
  1127. return "时间间隔不能超过1个月";
  1128. }
  1129. if (edate >= DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd") + " 00:00:00"))
  1130. {
  1131. return "结束时间只能是今天之前";
  1132. }
  1133. string check = RedisDbconn.Instance.Get<string>("ResetUserTradeQueue:" + UserId + ":" + BrandId);
  1134. if (!string.IsNullOrEmpty(check))
  1135. {
  1136. return "请稍后再试";
  1137. }
  1138. try
  1139. {
  1140. RedisDbconn.Instance.AddList("ResetUserTradeQueue", UserId + "#cut#" + sdate.ToString("yyyy-MM-dd HH:mm:ss") + "#cut#" + edate.ToString("yyyy-MM-dd HH:mm:ss") + "#cut#" + BrandId);
  1141. RedisDbconn.Instance.Set("ResetUserTradeQueue:" + UserId + ":" + BrandId, "wait");
  1142. RedisDbconn.Instance.SetExpire("ResetUserTradeQueue:" + UserId + ":" + BrandId, 3600);
  1143. }
  1144. catch (Exception ex)
  1145. {
  1146. function.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString(), "统计创客的交易额异常");
  1147. return "同步异常";
  1148. }
  1149. return "success";
  1150. }
  1151. #endregion
  1152. #region 创客展业城市
  1153. public IActionResult City(Users data, string right)
  1154. {
  1155. ViewBag.RightInfo = RightInfo;
  1156. ViewBag.right = right;
  1157. List<Users> TopUsers = db.Users.Where(m => m.ParentUserId == 0).ToList();
  1158. ViewBag.TopUsers = TopUsers;
  1159. return View();
  1160. }
  1161. #endregion
  1162. #region 根据条件查询创客展业城市
  1163. public JsonResult CityData(Users data, string ParentMakerCode, string ParentRealName, int TopUserId, string Areas, int page = 1, int limit = 30)
  1164. {
  1165. Dictionary<string, string> Fields = new Dictionary<string, string>();
  1166. Fields.Add("MakerCode", "1"); //创客编号
  1167. Fields.Add("RealName", "1"); //创客名称
  1168. Fields.Add("CitySetDate", "3"); //创建时间
  1169. Fields.Add("Areas", "2"); //省市
  1170. string condition = " and Status>-1";
  1171. //直属创客编号
  1172. if (!string.IsNullOrEmpty(ParentMakerCode))
  1173. {
  1174. condition += " and Id in (select UserId from UserForMakerCode where MakerCode='" + ParentMakerCode + "')";
  1175. }
  1176. //直属创客名称
  1177. if (!string.IsNullOrEmpty(ParentRealName))
  1178. {
  1179. condition += " and Id in (select UserId from UserForRealName where RealName='" + ParentRealName + "')";
  1180. }
  1181. //顶级创客
  1182. if (TopUserId > 0)
  1183. {
  1184. condition += " and ParentNav like '," + TopUserId + ",%'";
  1185. }
  1186. Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("Users", Fields, "Id desc", "True", page, limit, condition);
  1187. List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
  1188. foreach (Dictionary<string, object> dic in diclist)
  1189. {
  1190. int ParentUserId = int.Parse(dic["ParentUserId"].ToString());
  1191. Users puser = db.Users.FirstOrDefault(m => m.Id == ParentUserId) ?? new Users();
  1192. dic["ParentMakerCode"] = puser.MakerCode;
  1193. dic["ParentRealName"] = puser.RealName;
  1194. string ParentNav = dic["ParentNav"].ToString();
  1195. if (!string.IsNullOrEmpty(ParentNav))
  1196. {
  1197. int TopId = int.Parse(ParentNav.Trim(',').Replace(",,", ",").Split(',')[0]);
  1198. Users tuser = db.Users.FirstOrDefault(m => m.Id == TopId) ?? new Users();
  1199. dic["TopMakerCode"] = tuser.MakerCode;
  1200. dic["TopRealName"] = tuser.RealName;
  1201. }
  1202. }
  1203. return Json(obj);
  1204. }
  1205. #endregion
  1206. #region 导出展业城市
  1207. public JsonResult ExportCity(Users data, string CreateDate, string ParentMakerCode, string ParentRealName, string AuthFlagSelect, int TopUserId, string RiskFlagSelect, string MerchantTypeSelect)
  1208. {
  1209. Dictionary<string, string> Fields = new Dictionary<string, string>();
  1210. Fields.Add("MakerCode", "1"); //创客编号
  1211. Fields.Add("RealName", "1"); //创客名称
  1212. Fields.Add("Mobile", "1"); //手机号
  1213. Fields.Add("CertId", "1"); //身份证号码
  1214. Fields.Add("CreateDate", "3"); //注册时间
  1215. Fields.Add("SettleAmount", "3"); //结算金额
  1216. Fields.Add("CashFreezeAmt", "3"); //冻结金额
  1217. Fields.Add("UserLevel", "0"); //创客等级
  1218. string condition = " and Status>-1";
  1219. //直属创客编号
  1220. if (!string.IsNullOrEmpty(ParentMakerCode))
  1221. {
  1222. condition += " and Id in (select UserId from UserForMakerCode where MakerCode='" + ParentMakerCode + "')";
  1223. }
  1224. //直属创客名称
  1225. if (!string.IsNullOrEmpty(ParentRealName))
  1226. {
  1227. condition += " and Id in (select UserId from UserForRealName where RealName='" + ParentRealName + "')";
  1228. }
  1229. //实名状态
  1230. if (!string.IsNullOrEmpty(AuthFlagSelect))
  1231. {
  1232. condition += " and AuthFlag=" + AuthFlagSelect;
  1233. }
  1234. //顶级创客
  1235. if (TopUserId > 0)
  1236. {
  1237. condition += " and ParentNav like '," + TopUserId + ",%'";
  1238. }
  1239. //风控标识
  1240. if (!string.IsNullOrEmpty(RiskFlagSelect))
  1241. {
  1242. condition += " and RiskFlag=" + RiskFlagSelect;
  1243. }
  1244. //商户创客类型
  1245. if (!string.IsNullOrEmpty(MerchantTypeSelect))
  1246. {
  1247. condition += " and MerchantType=" + MerchantTypeSelect;
  1248. }
  1249. Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("Users", Fields, "Id desc", "True", 1, 20000, condition, "ParentUserId,ParentNav,UserLevel,SettleAmount,CashFreezeAmt,CertId,Mobile,MerchantType,MerchantDate,AuthFlag,RiskFlag,CreateDate", false);
  1250. List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
  1251. foreach (Dictionary<string, object> dic in diclist)
  1252. {
  1253. dic["AuthFlag"] = dic["AuthFlag"].ToString() == "1" ? "已实名" : "未实名";
  1254. dic["RiskFlag"] = dic["RiskFlag"].ToString() == "1" ? "已风控" : "未风控";
  1255. dic["UserLevel"] = RelationClass.GetUserLevelSetInfo(int.Parse(dic["UserLevel"].ToString()));
  1256. dic["MerchantType"] = RelationClassForConst.GetMerchantTypeInfo(int.Parse(dic["MerchantType"].ToString()));
  1257. int ParentUserId = int.Parse(dic["ParentUserId"].ToString());
  1258. Users puser = db.Users.FirstOrDefault(m => m.Id == ParentUserId) ?? new Users();
  1259. dic["ParentMakerCode"] = puser.MakerCode;
  1260. dic["ParentRealName"] = puser.RealName;
  1261. string ParentNav = dic["ParentNav"].ToString();
  1262. if (!string.IsNullOrEmpty(ParentNav))
  1263. {
  1264. int TopId = int.Parse(ParentNav.Trim(',').Replace(",,", ",").Split(',')[0]);
  1265. Users tuser = db.Users.FirstOrDefault(m => m.Id == TopId) ?? new Users();
  1266. dic["TopMakerCode"] = tuser.MakerCode;
  1267. dic["TopRealName"] = tuser.RealName;
  1268. }
  1269. dic.Remove("ParentUserId");
  1270. dic.Remove("ParentNav");
  1271. }
  1272. Dictionary<string, object> result = new Dictionary<string, object>();
  1273. result.Add("Status", "1");
  1274. result.Add("Info", "Excel报表-" + DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss") + ".xlsx");
  1275. result.Add("Obj", diclist);
  1276. Dictionary<string, object> ReturnFields = new Dictionary<string, object>();
  1277. ReturnFields.Add("MakerCode", "创客编号");
  1278. ReturnFields.Add("RealName", "创客姓名");
  1279. ReturnFields.Add("UserLevel", "创客等级");
  1280. ReturnFields.Add("SettleAmount", "提现金额(元)");
  1281. ReturnFields.Add("CashFreezeAmt", "冻结金额(元)");
  1282. ReturnFields.Add("CertId", "身份证号");
  1283. ReturnFields.Add("Mobile", "联系手机");
  1284. ReturnFields.Add("MerchantType", "商户创客类型");
  1285. ReturnFields.Add("MerchantDate", "成为商户创客时间");
  1286. ReturnFields.Add("ParentMakerCode", "直属创客编号");
  1287. ReturnFields.Add("ParentRealName", "直属创客名称");
  1288. ReturnFields.Add("TopMakerCode", "顶级创客编号");
  1289. ReturnFields.Add("TopRealName", "顶级创客名称");
  1290. ReturnFields.Add("AuthFlag", "实名状态");
  1291. ReturnFields.Add("RiskFlag", "风控状态");
  1292. ReturnFields.Add("CreateDate", "注册时间");
  1293. result.Add("Fields", ReturnFields);
  1294. AddSysLog("0", "Users", "ExportExcel");
  1295. return Json(result);
  1296. }
  1297. #endregion
  1298. #region 根据条件查询直属创客交易额列表
  1299. /// <summary>
  1300. /// 直属创客交易额列表
  1301. /// </summary>
  1302. /// <returns></returns>
  1303. public IActionResult Children(Users data, string right, int ParentId = 0, string MakerCode = "")
  1304. {
  1305. ViewBag.RightInfo = RightInfo;
  1306. ViewBag.right = right;
  1307. ViewBag.ParentId = ParentId.ToString();
  1308. ViewBag.MakerCode = MakerCode;
  1309. List<Users> TopUsers = db.Users.Where(m => m.ParentUserId == 0).ToList();
  1310. ViewBag.TopUsers = TopUsers;
  1311. List<UserLevelSet> Levels = db.UserLevelSet.OrderBy(m => m.Id).ToList();
  1312. ViewBag.Levels = Levels;
  1313. List<KqProducts> Brands = db.KqProducts.OrderBy(m => m.Id).ToList();
  1314. ViewBag.Brands = Brands;
  1315. return View();
  1316. }
  1317. #endregion
  1318. #region 根据条件查询直属创客交易额列表
  1319. /// <summary>
  1320. /// 直属创客交易额列表
  1321. /// </summary>
  1322. /// <returns></returns>
  1323. public JsonResult ChildrenData(Users data, int BrandSelect, string MakerCode, string CreateDateData, int ParentId = 0, int page = 1, int limit = 30)
  1324. {
  1325. Dictionary<string, string> Fields = new Dictionary<string, string>();
  1326. WebCMSEntities db = new WebCMSEntities();
  1327. Fields.Add("MakerCode", "1"); //创客编号
  1328. int BrandId = BrandSelect;
  1329. string start = "";
  1330. string end = "";
  1331. string condition = " and Status>-1 and AuthFlag >0";
  1332. string con = " and Status>-1";
  1333. string cons = " and Status>=-1";
  1334. string sort = "Id desc";
  1335. //创客编号
  1336. if (!string.IsNullOrEmpty(MakerCode))
  1337. {
  1338. condition += " and Id in (select UserId from UserForMakerCode where MakerCode='" + MakerCode + "')";
  1339. }
  1340. if (ParentId > 0)
  1341. {
  1342. condition += " and ParentUserId=" + ParentId + " or Id=" + ParentId;
  1343. }
  1344. //时间不为空
  1345. if (!string.IsNullOrEmpty(CreateDateData))
  1346. {
  1347. string[] datelist = CreateDateData.Split(new string[] { " - " }, StringSplitOptions.None);
  1348. start = datelist[0].Replace("-", "");
  1349. end = datelist[1].Replace("-", "");
  1350. con += " and TradeDate>='" + start + "' and TradeDate<='" + end + "'";
  1351. cons += " and SeoKeyword >=" + start + " and SeoKeyword <=" + end;
  1352. }
  1353. //时间为空
  1354. else
  1355. {
  1356. start = DateTime.Now.ToString("yyyyMM") + "01";
  1357. end = DateTime.Now.AddMonths(1).ToString("yyyyMM") + "01";
  1358. con += " and TradeDate>='" + start + "' and TradeDate<'" + end + "'";
  1359. cons += " and SeoKeyword >=" + start + " and SeoKeyword <" + end;
  1360. }
  1361. if (!string.IsNullOrEmpty(BrandSelect.ToString()) && BrandId > 0)
  1362. {
  1363. con += " and BrandId='" + BrandId + "'";
  1364. cons += " and BrandId='" + BrandId + "'";
  1365. }
  1366. Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("Users", Fields, sort, "True", page, limit, condition);
  1367. List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
  1368. foreach (Dictionary<string, object> dic in diclist)
  1369. {
  1370. int UId = int.Parse(dic["Id"].ToString());
  1371. var Info = GetMonthTradeForBrand(UId, start, end, BrandId);
  1372. dic["TotalAmtfc"] = Convert.ToDecimal(Info["TotalAmtfc"].ToString()) + Convert.ToDecimal(Info["YAmtfc"].ToString());
  1373. dic["DAmtfc"] = Convert.ToDecimal(Info["DAmtfc"].ToString());
  1374. dic["JAmtfc"] = Convert.ToDecimal(Info["JAmtfc"].ToString());
  1375. dic["JfAmtfc"] = Convert.ToDecimal(Info["JfAmtfc"].ToString());
  1376. dic["JCountfc"] = Convert.ToInt32(Info["JCountfc"].ToString());
  1377. dic["YAmtfc"] = Convert.ToDecimal(Info["YAmtfc"].ToString());
  1378. dic["TotalAmtwd"] = Convert.ToDecimal(Info["TotalAmtwd"].ToString()) + Convert.ToDecimal(Info["YAmtwd"].ToString());
  1379. dic["DAmtwd"] = Convert.ToDecimal(Info["DAmtwd"].ToString());
  1380. dic["JAmtwd"] = Convert.ToDecimal(Info["JAmtwd"].ToString());
  1381. dic["JfAmtwd"] = Convert.ToDecimal(Info["JfAmtwd"].ToString());
  1382. dic["JCountwd"] = Convert.ToInt32(Info["JCountwd"].ToString());
  1383. dic["YAmtwd"] = Convert.ToDecimal(Info["YAmtwd"].ToString());
  1384. dic["TotalAmtyl"] = Convert.ToDecimal(Info["TotalAmtyl"].ToString()) + Convert.ToDecimal(Info["YAmtyl"].ToString());
  1385. dic["DAmtyl"] = Convert.ToDecimal(Info["DAmtyl"].ToString());
  1386. dic["JAmtyl"] = Convert.ToDecimal(Info["JAmtyl"].ToString());
  1387. dic["JfAmtyl"] = Convert.ToDecimal(Info["JfAmtyl"].ToString());
  1388. dic["JCountyl"] = Convert.ToInt32(Info["JCountyl"].ToString());
  1389. dic["YAmtyl"] = Convert.ToDecimal(Info["YAmtyl"].ToString());
  1390. dic["TBCount"] = Info["TBCount"].ToString();
  1391. dic["TACount"] = Info["TACount"].ToString();
  1392. // dic["BCount"] = Info["BCount"].ToString();
  1393. // dic["ACount"] = Info["ACount"].ToString();
  1394. }
  1395. //个人
  1396. //扶持期
  1397. decimal TotalAmtfc = 0;
  1398. decimal DAmtfc = 0;
  1399. decimal JAmtfc = 0;
  1400. decimal JfAmtfc = 0;
  1401. int JCountfc = 0;
  1402. decimal YAmtfc = 0;
  1403. //稳定期
  1404. decimal TotalAmtwd = 0;
  1405. decimal DAmtwd = 0;
  1406. decimal JAmtwd = 0;
  1407. decimal JfAmtwd = 0;
  1408. int JCountwd = 0;
  1409. decimal YAmtwd = 0;
  1410. //盈利期
  1411. decimal TotalAmtyl = 0;
  1412. decimal DAmtyl = 0;
  1413. decimal JAmtyl = 0;
  1414. decimal JfAmtyl = 0;
  1415. int JCountyl = 0;
  1416. decimal YAmtyl = 0;
  1417. //团队
  1418. //扶持期
  1419. decimal TotalAmtfc1 = 0;
  1420. decimal DAmtfc1 = 0;
  1421. decimal JAmtfc1 = 0;
  1422. decimal JfAmtfc1 = 0;
  1423. int JCountfc1 = 0;
  1424. decimal YAmtfc1 = 0;
  1425. //稳定期
  1426. decimal TotalAmtwd1 = 0;
  1427. decimal DAmtwd1 = 0;
  1428. decimal JAmtwd1 = 0;
  1429. decimal JfAmtwd1 = 0;
  1430. int JCountwd1 = 0;
  1431. decimal YAmtwd1 = 0;
  1432. //盈利期
  1433. decimal TotalAmtyl1 = 0;
  1434. decimal DAmtyl1 = 0;
  1435. decimal JAmtyl1 = 0;
  1436. decimal JfAmtyl1 = 0;
  1437. int JCountyl1 = 0;
  1438. decimal YAmtyl1 = 0;
  1439. int PBCount = 0;
  1440. int PACount = 0;
  1441. int TBCount = 0;
  1442. int TACount = 0;
  1443. Dictionary<string, object> other = new Dictionary<string, object>();
  1444. DataTable dt = OtherMySqlConn.dtable("SELECT Sum(HelpDirectTradeAmt + HelpDirectDebitTradeAmt),Sum(if (QueryCount = 0,HelpDirectTradeAmt,0)),Sum(if (QueryCount = 0,HelpDirectDebitTradeAmt - HelpDirectDebitCapTradeAmt,0)),Sum(if (QueryCount = 0,HelpDirectDebitCapTradeAmt,0)),Sum(if (QueryCount = 0,HelpDirectDebitCapNum,0)),Sum(if (QueryCount = 1,HelpDirectTradeAmt,0)),Sum(NotHelpDirectTradeAmt + NotHelpDirectDebitTradeAmt),Sum(if (QueryCount = 0,NotHelpDirectTradeAmt,0)),Sum(if (QueryCount = 0,NotHelpDirectDebitTradeAmt - NotHelpDirectDebitCapTradeAmt,0)),Sum(if (QueryCount = 0,NotHelpDirectDebitCapTradeAmt,0)),Sum(if (QueryCount = 0,NotHelpDirectDebitCapNum,0)),Sum(if (QueryCount = 1,NotHelpDirectTradeAmt,0)),Sum(ProfitDirectTradeAmt + ProfitDirectDebitTradeAmt),Sum(if (QueryCount = 0,ProfitDirectTradeAmt,0)),Sum(if (QueryCount = 0,ProfitDirectDebitTradeAmt - ProfitDirectDebitCapTradeAmt,0)),Sum(if (QueryCount = 0,ProfitDirectDebitCapTradeAmt,0)),Sum(if (QueryCount = 0,ProfitDirectDebitCapNum,0)),Sum(if (QueryCount = 1,ProfitDirectTradeAmt,0))from TradeDaySummary where SeoTitle = 'self' and UserId =" + ParentId + "" + con);
  1445. if (dt.Rows.Count > 0)
  1446. {
  1447. TotalAmtfc = Convert.ToDecimal(function.CheckNum(dt.Rows[0][0].ToString()));
  1448. DAmtfc = Convert.ToDecimal(function.CheckNum(dt.Rows[0][1].ToString()));
  1449. JAmtfc = Convert.ToDecimal(function.CheckNum(dt.Rows[0][2].ToString()));
  1450. JfAmtfc = Convert.ToDecimal(function.CheckNum(dt.Rows[0][3].ToString()));
  1451. JCountfc = Convert.ToInt32(function.CheckInt(dt.Rows[0][4].ToString()));
  1452. YAmtfc = Convert.ToDecimal(function.CheckNum(dt.Rows[0][5].ToString()));
  1453. TotalAmtwd = Convert.ToDecimal(function.CheckNum(dt.Rows[0][6].ToString()));
  1454. DAmtwd = Convert.ToDecimal(function.CheckNum(dt.Rows[0][7].ToString()));
  1455. JAmtwd = Convert.ToDecimal(function.CheckNum(dt.Rows[0][8].ToString()));
  1456. JfAmtwd = Convert.ToDecimal(function.CheckNum(dt.Rows[0][9].ToString()));
  1457. JCountwd = Convert.ToInt32(function.CheckInt(dt.Rows[0][10].ToString()));
  1458. YAmtwd = Convert.ToDecimal(function.CheckNum(dt.Rows[0][11].ToString()));
  1459. TotalAmtyl = Convert.ToDecimal(function.CheckNum(dt.Rows[0][12].ToString()));
  1460. DAmtyl = Convert.ToDecimal(function.CheckNum(dt.Rows[0][13].ToString()));
  1461. JAmtyl = Convert.ToDecimal(function.CheckNum(dt.Rows[0][14].ToString()));
  1462. JfAmtyl = Convert.ToDecimal(function.CheckNum(dt.Rows[0][15].ToString()));
  1463. JCountyl = Convert.ToInt32(function.CheckInt(dt.Rows[0][16].ToString()));
  1464. YAmtyl = Convert.ToDecimal(function.CheckNum(dt.Rows[0][17].ToString()));
  1465. }
  1466. //统计激活数(个人、团队)
  1467. dt = OtherMySqlConn.dtable("SELECT SUM(if(SeoTitle='self',ActiveBuddyMerStatus,0)),SUM(if(SeoTitle='team',ActiveBuddyMerStatus,0)) FROM UserTradeMonthSummary WHERE UserId= " + ParentId + "" + cons);
  1468. if (dt.Rows.Count > 0)
  1469. {
  1470. PACount = Convert.ToInt32(function.CheckNum(dt.Rows[0][0].ToString()));
  1471. TACount = Convert.ToInt32(function.CheckNum(dt.Rows[0][1].ToString()));
  1472. }
  1473. DataTable dts = OtherMySqlConn.dtable("SELECT Sum(HelpNonDirectTradeAmt + HelpNonDirectDebitTradeAmt),Sum(if (QueryCount = 0,HelpNonDirectTradeAmt,0)),Sum(if (QueryCount = 0,HelpNonDirectDebitTradeAmt - HelpNonDirectDebitCapTradeAmt,0)),Sum(if (QueryCount = 0,HelpNonDirectDebitCapTradeAmt,0)),Sum(if (QueryCount = 0,HelpNonDirectDebitCapNum,0)),Sum(if (QueryCount = 1,HelpNonDirectTradeAmt,0)),Sum(NotHelpNonDirectTradeAmt + NotHelpNonDirectDebitTradeAmt),Sum(if (QueryCount = 0,NotHelpNonDirectTradeAmt,0)),Sum(if (QueryCount = 0,NotHelpNonDirectDebitTradeAmt - NotHelpNonDirectDebitCapTradeAmt,0)),Sum(if (QueryCount = 0,NotHelpNonDirectDebitCapTradeAmt,0)),Sum(if (QueryCount = 0,NotHelpNonDirectDebitCapNum,0)),Sum(if (QueryCount = 1,NotHelpNonDirectTradeAmt,0)),Sum(ProfitNonDirectTradeAmt + ProfitNonDirectDebitTradeAmt),Sum(if (QueryCount = 0,ProfitNonDirectTradeAmt,0)),Sum(if (QueryCount = 0,ProfitNonDirectDebitTradeAmt - ProfitNonDirectDebitCapTradeAmt,0)),Sum(if (QueryCount = 0,ProfitNonDirectDebitCapTradeAmt,0)),Sum(if (QueryCount = 0,ProfitNonDirectDebitCapNum,0)),Sum(if (QueryCount = 1,ProfitNonDirectTradeAmt,0))from TradeDaySummary where SeoTitle = 'team' and UserId =" + ParentId + "" + con);
  1474. if (dts.Rows.Count > 0)
  1475. {
  1476. TotalAmtfc1 = Convert.ToDecimal(function.CheckNum(dts.Rows[0][0].ToString()));
  1477. DAmtfc1 = Convert.ToDecimal(function.CheckNum(dts.Rows[0][1].ToString()));
  1478. JAmtfc1 = Convert.ToDecimal(function.CheckNum(dts.Rows[0][2].ToString()));
  1479. JfAmtfc1 = Convert.ToDecimal(function.CheckNum(dts.Rows[0][3].ToString()));
  1480. JCountfc1 = Convert.ToInt32(function.CheckInt(dts.Rows[0][4].ToString()));
  1481. YAmtfc1 = Convert.ToDecimal(function.CheckNum(dts.Rows[0][5].ToString()));
  1482. TotalAmtwd1 = Convert.ToDecimal(function.CheckNum(dts.Rows[0][6].ToString()));
  1483. DAmtwd1 = Convert.ToDecimal(function.CheckNum(dts.Rows[0][7].ToString()));
  1484. JAmtwd1 = Convert.ToDecimal(function.CheckNum(dts.Rows[0][8].ToString()));
  1485. JfAmtwd1 = Convert.ToDecimal(function.CheckNum(dts.Rows[0][9].ToString()));
  1486. JCountwd1 = Convert.ToInt32(function.CheckInt(dts.Rows[0][10].ToString()));
  1487. YAmtwd1 = Convert.ToDecimal(function.CheckNum(dts.Rows[0][11].ToString()));
  1488. TotalAmtyl1 = Convert.ToDecimal(function.CheckNum(dts.Rows[0][12].ToString()));
  1489. DAmtyl1 = Convert.ToDecimal(function.CheckNum(dts.Rows[0][13].ToString()));
  1490. JAmtyl1 = Convert.ToDecimal(function.CheckNum(dts.Rows[0][14].ToString()));
  1491. JfAmtyl1 = Convert.ToDecimal(function.CheckNum(dts.Rows[0][15].ToString()));
  1492. JCountyl1 = Convert.ToInt32(function.CheckInt(dts.Rows[0][16].ToString()));
  1493. YAmtyl1 = Convert.ToDecimal(function.CheckNum(dts.Rows[0][17].ToString()));
  1494. }
  1495. other.Add("TotalAmtfc", TotalAmtfc);
  1496. other.Add("DAmtfc", DAmtfc);
  1497. other.Add("JAmtfc", JAmtfc);
  1498. other.Add("JfAmtfc", JfAmtfc);
  1499. other.Add("JCountfc", JCountfc);
  1500. other.Add("YAmtfc", YAmtfc);
  1501. other.Add("TotalAmtwd", TotalAmtwd);
  1502. other.Add("DAmtwd", DAmtwd);
  1503. other.Add("JAmtwd", JAmtwd);
  1504. other.Add("JfAmtwd", JfAmtwd);
  1505. other.Add("JCountwd", JCountwd);
  1506. other.Add("YAmtwd", YAmtwd);
  1507. other.Add("TotalAmtyl", TotalAmtyl);
  1508. other.Add("DAmtyl", DAmtyl);
  1509. other.Add("JAmtyl", JAmtyl);
  1510. other.Add("JfAmtyl", JfAmtyl);
  1511. other.Add("JCountyl", JCountyl);
  1512. other.Add("YAmtyl", YAmtyl);
  1513. other.Add("TotalAmtfc1", TotalAmtfc1);
  1514. other.Add("DAmtfc1", DAmtfc1);
  1515. other.Add("JAmtfc1", JAmtfc1);
  1516. other.Add("JfAmtfc1", JfAmtfc1);
  1517. other.Add("JCountfc1", JCountfc1);
  1518. other.Add("YAmtfc1", YAmtfc1);
  1519. other.Add("TotalAmtwd1", TotalAmtwd1);
  1520. other.Add("DAmtwd1", DAmtwd1);
  1521. other.Add("JAmtwd1", JAmtwd1);
  1522. other.Add("JfAmtwd1", JfAmtwd1);
  1523. other.Add("JCountwd1", JCountwd1);
  1524. other.Add("YAmtwd1", YAmtwd1);
  1525. other.Add("TotalAmtyl1", TotalAmtyl1);
  1526. other.Add("DAmtyl1", DAmtyl1);
  1527. other.Add("JAmtyl1", JAmtyl1);
  1528. other.Add("JfAmtyl1", JfAmtyl1);
  1529. other.Add("JCountyl1", JCountyl1);
  1530. other.Add("YAmtyl1", YAmtyl1);
  1531. other.Add("PBCount", PBCount);
  1532. other.Add("PACount", PACount);
  1533. other.Add("TBCount", TBCount);
  1534. other.Add("TACount", TACount);
  1535. db.Dispose();
  1536. obj.Add("other", other);
  1537. return Json(obj);
  1538. }
  1539. public Dictionary<string, object> GetMonthTradeForBrand(int UserId, string sTradeDate, string eTradeDate, int BrandId)
  1540. {
  1541. WebCMSEntities db = new WebCMSEntities();
  1542. string condition = " and Status>-1";
  1543. string cons = " and Status>=-1";
  1544. //产品类型
  1545. if (!string.IsNullOrEmpty(BrandId.ToString()) && BrandId > 0)
  1546. {
  1547. condition += " and BrandId =" + BrandId;
  1548. cons += " and BrandId =" + BrandId;
  1549. }
  1550. //创客Id
  1551. if (!string.IsNullOrEmpty(UserId.ToString()))
  1552. {
  1553. condition += " and UserId =" + UserId;
  1554. }
  1555. //开始时间
  1556. if (!string.IsNullOrEmpty(sTradeDate) && !string.IsNullOrEmpty(eTradeDate))
  1557. {
  1558. condition += " and TradeDate >=" + Convert.ToInt32(sTradeDate) + " and TradeDate <=" + Convert.ToInt32(eTradeDate);
  1559. cons += " and SeoKeyword >=" + Convert.ToInt32(sTradeDate) + " and SeoKeyword <=" + Convert.ToInt32(eTradeDate);
  1560. }
  1561. //结束时间
  1562. else
  1563. {
  1564. var start = DateTime.Now.ToString("yyyyMM") + "01";
  1565. condition += " and TradeDate >=" + Convert.ToInt32(start) + " and TradeDate <=" + Convert.ToInt32(eTradeDate);
  1566. cons += " and SeoKeyword >=" + Convert.ToInt32(start) + " and SeoKeyword <=" + Convert.ToInt32(eTradeDate);
  1567. }
  1568. //扶持期
  1569. decimal TotalAmtfc = 0;
  1570. decimal DAmtfc = 0;
  1571. decimal JAmtfc = 0;
  1572. decimal JfAmtfc = 0;
  1573. int JCountfc = 0;
  1574. decimal YAmtfc = 0;
  1575. //稳定期
  1576. decimal TotalAmtwd = 0;
  1577. decimal DAmtwd = 0;
  1578. decimal JAmtwd = 0;
  1579. decimal JfAmtwd = 0;
  1580. int JCountwd = 0;
  1581. decimal YAmtwd = 0;
  1582. //盈利期
  1583. decimal TotalAmtyl = 0;
  1584. decimal DAmtyl = 0;
  1585. decimal JAmtyl = 0;
  1586. decimal JfAmtyl = 0;
  1587. int JCountyl = 0;
  1588. decimal YAmtyl = 0;
  1589. int BCount = 0;
  1590. int ACount = 0;
  1591. int PBCount = 0;
  1592. int PACount = 0;
  1593. int TBCount = 0;
  1594. int TACount = 0;
  1595. Dictionary<string, object> obj = new Dictionary<string, object>();
  1596. DataTable dt = OtherMySqlConn.dtable("SELECT Sum(HelpNonDirectTradeAmt + HelpNonDirectDebitTradeAmt),Sum(if (QueryCount = 0,HelpNonDirectTradeAmt,0)),Sum(if (QueryCount = 0,HelpNonDirectDebitTradeAmt - HelpNonDirectDebitCapTradeAmt,0)),Sum(if (QueryCount = 0,HelpNonDirectDebitCapTradeAmt,0)),Sum(if (QueryCount = 0,HelpNonDirectDebitCapNum,0)),Sum(if (QueryCount = 1,HelpNonDirectTradeAmt,0)),Sum(NotHelpNonDirectTradeAmt + NotHelpNonDirectDebitTradeAmt),Sum(if (QueryCount = 0,NotHelpNonDirectTradeAmt,0)),Sum(if (QueryCount = 0,NotHelpNonDirectDebitTradeAmt - NotHelpNonDirectDebitCapTradeAmt,0)),Sum(if (QueryCount = 0,NotHelpNonDirectDebitCapTradeAmt,0)),Sum(if (QueryCount = 0,NotHelpNonDirectDebitCapNum,0)),Sum(if (QueryCount = 1,NotHelpNonDirectTradeAmt,0)),Sum(ProfitNonDirectTradeAmt + ProfitNonDirectDebitTradeAmt),Sum(if (QueryCount = 0,ProfitNonDirectTradeAmt,0)),Sum(if (QueryCount = 0,ProfitNonDirectDebitTradeAmt - ProfitNonDirectDebitCapTradeAmt,0)),Sum(if (QueryCount = 0,ProfitNonDirectDebitCapTradeAmt,0)),Sum(if (QueryCount = 0,ProfitNonDirectDebitCapNum,0)),Sum(if (QueryCount = 1,ProfitNonDirectTradeAmt,0))from TradeDaySummary where SeoTitle = 'team'" + condition);
  1597. if (dt.Rows.Count > 0)
  1598. {
  1599. TotalAmtfc = Convert.ToDecimal(function.CheckNum(dt.Rows[0][0].ToString()));
  1600. DAmtfc = Convert.ToDecimal(function.CheckNum(dt.Rows[0][1].ToString()));
  1601. JAmtfc = Convert.ToDecimal(function.CheckNum(dt.Rows[0][2].ToString()));
  1602. JfAmtfc = Convert.ToDecimal(function.CheckNum(dt.Rows[0][3].ToString()));
  1603. JCountfc = Convert.ToInt32(function.CheckInt(dt.Rows[0][4].ToString()));
  1604. YAmtfc = Convert.ToDecimal(function.CheckNum(dt.Rows[0][5].ToString()));
  1605. TotalAmtwd = Convert.ToDecimal(function.CheckNum(dt.Rows[0][6].ToString()));
  1606. DAmtwd = Convert.ToDecimal(function.CheckNum(dt.Rows[0][7].ToString()));
  1607. JAmtwd = Convert.ToDecimal(function.CheckNum(dt.Rows[0][8].ToString()));
  1608. JfAmtwd = Convert.ToDecimal(function.CheckNum(dt.Rows[0][9].ToString()));
  1609. JCountwd = Convert.ToInt32(function.CheckInt(dt.Rows[0][10].ToString()));
  1610. YAmtwd = Convert.ToDecimal(function.CheckNum(dt.Rows[0][11].ToString()));
  1611. TotalAmtyl = Convert.ToDecimal(function.CheckNum(dt.Rows[0][12].ToString()));
  1612. DAmtyl = Convert.ToDecimal(function.CheckNum(dt.Rows[0][13].ToString()));
  1613. JAmtyl = Convert.ToDecimal(function.CheckNum(dt.Rows[0][14].ToString()));
  1614. JfAmtyl = Convert.ToDecimal(function.CheckNum(dt.Rows[0][15].ToString()));
  1615. JCountyl = Convert.ToInt32(function.CheckInt(dt.Rows[0][16].ToString()));
  1616. YAmtyl = Convert.ToDecimal(function.CheckNum(dt.Rows[0][17].ToString()));
  1617. }
  1618. //统计激活数(个人、团队)
  1619. dt = OtherMySqlConn.dtable("SELECT SUM(if(SeoTitle='team',ActiveBuddyMerStatus,0)) FROM UserTradeMonthSummary WHERE UserId= " + UserId + "" + cons);
  1620. if (dt.Rows.Count > 0)
  1621. {
  1622. TACount = Convert.ToInt32(function.CheckNum(dt.Rows[0][0].ToString()));
  1623. }
  1624. obj.Add("TotalAmtfc", TotalAmtfc);
  1625. obj.Add("DAmtfc", DAmtfc);
  1626. obj.Add("JAmtfc", JAmtfc);
  1627. obj.Add("JfAmtfc", JfAmtfc);
  1628. obj.Add("JCountfc", JCountfc);
  1629. obj.Add("YAmtfc", YAmtfc);
  1630. obj.Add("TotalAmtwd", TotalAmtwd);
  1631. obj.Add("DAmtwd", DAmtwd);
  1632. obj.Add("JAmtwd", JAmtwd);
  1633. obj.Add("JfAmtwd", JfAmtwd);
  1634. obj.Add("JCountwd", JCountwd);
  1635. obj.Add("YAmtwd", YAmtwd);
  1636. obj.Add("TotalAmtyl", TotalAmtyl);
  1637. obj.Add("DAmtyl", DAmtyl);
  1638. obj.Add("JAmtyl", JAmtyl);
  1639. obj.Add("JfAmtyl", JfAmtyl);
  1640. obj.Add("JCountyl", JCountyl);
  1641. obj.Add("YAmtyl", YAmtyl);
  1642. obj.Add("BCount", BCount);
  1643. obj.Add("ACount", ACount);
  1644. obj.Add("PBCount", PBCount);
  1645. obj.Add("PACount", PACount);
  1646. obj.Add("TBCount", TBCount);
  1647. obj.Add("TACount", TACount);
  1648. db.Dispose();
  1649. return obj;
  1650. }
  1651. #endregion
  1652. #region 未实名创客列表
  1653. /// <summary>
  1654. /// 根据条件查询未实名创客列表
  1655. /// </summary>
  1656. /// <returns></returns>
  1657. public IActionResult AuthIndex(Users data, string right)
  1658. {
  1659. ViewBag.RightInfo = RightInfo;
  1660. ViewBag.right = right;
  1661. return View();
  1662. }
  1663. #endregion
  1664. #region 根据条件查询未实名创客列表
  1665. /// <summary>
  1666. /// 未实名创客列表
  1667. /// </summary>
  1668. /// <returns></returns>
  1669. public JsonResult AuthIndexData(Users data, int page = 1, int limit = 30)
  1670. {
  1671. Dictionary<string, string> Fields = new Dictionary<string, string>();
  1672. Fields.Add("MakerCode", "1"); //创客编号
  1673. string condition = " and Status>-1 and AuthFlag=0 and RealName is not null and CertId is not null and SettleBankCardNo is not null and SettleBankCardName is not null";
  1674. string sort = "Id desc";
  1675. Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("Users", Fields, sort, "True", page, limit, condition);
  1676. List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
  1677. foreach (Dictionary<string, object> dic in diclist)
  1678. {
  1679. dic["AuthFlagName"] = dic["AuthFlag"].ToString() == "1" ? "已实名" : "未实名";
  1680. dic["RiskFlagName"] = dic["RiskFlag"].ToString() == "1" ? "已风控" : "未风控";
  1681. dic["UserLevel"] = RelationClass.GetUserLevelSetInfo(int.Parse(dic["UserLevel"].ToString()));
  1682. dic["MerchantType"] = RelationClassForConst.GetMerchantTypeInfo(int.Parse(dic["MerchantType"].ToString()));
  1683. int ParentUserId = int.Parse(dic["ParentUserId"].ToString());
  1684. Users puser = db.Users.FirstOrDefault(m => m.Id == ParentUserId) ?? new Users();
  1685. dic["ParentMakerCode"] = puser.MakerCode;
  1686. dic["ParentRealName"] = puser.RealName;
  1687. string ParentNav = dic["ParentNav"].ToString();
  1688. if (!string.IsNullOrEmpty(ParentNav))
  1689. {
  1690. string[] list = ParentNav.Trim(',').Replace(",,", ",").Split(',');
  1691. if (list.Length > 1)
  1692. {
  1693. int TopId = int.Parse(function.CheckInt(list[1]));
  1694. Users tuser = db.Users.FirstOrDefault(m => m.Id == TopId) ?? new Users();
  1695. dic["TopMakerCode"] = tuser.MakerCode;
  1696. dic["TopRealName"] = tuser.RealName;
  1697. }
  1698. }
  1699. }
  1700. return Json(obj);
  1701. }
  1702. #endregion
  1703. #region 认证
  1704. /// <summary>
  1705. /// 认证
  1706. /// </summary>
  1707. /// <returns></returns>
  1708. public string Auth(string Id)
  1709. {
  1710. string[] idlist = Id.Split(new char[] { ',' });
  1711. AddSysLog(Id, "Users", "Auth");
  1712. foreach (string subid in idlist)
  1713. {
  1714. int id = int.Parse(subid);
  1715. Dictionary<string, object> Fields = new Dictionary<string, object>();
  1716. Fields.Add("AuthFlag", 1);
  1717. Fields.Add("AuthDate", DateTime.Now);
  1718. new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("Users", Fields, id);
  1719. }
  1720. db.SaveChanges();
  1721. return "success";
  1722. }
  1723. #endregion
  1724. }
  1725. }