UsersController.cs 133 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784
  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 CancleUsers(Users data, string right, int SelfId = 0, int ParentId = 0, string MakerCode = "")
  178. {
  179. ViewBag.RightInfo = RightInfo;
  180. ViewBag.right = right;
  181. ViewBag.SelfId = SelfId.ToString();
  182. ViewBag.ParentId = ParentId.ToString();
  183. ViewBag.MakerCode = MakerCode;
  184. List<Users> TopUsers = db.Users.Where(m => m.ParentUserId == 0).ToList();
  185. ViewBag.TopUsers = TopUsers;
  186. List<UserLevelSet> Levels = db.UserLevelSet.OrderBy(m => m.Id).ToList();
  187. ViewBag.Levels = Levels;
  188. return View();
  189. }
  190. #endregion
  191. #region 根据条件查询创客列表
  192. /// <summary>
  193. /// 创客列表
  194. /// </summary>
  195. /// <returns></returns>
  196. public JsonResult CancleUsersData(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)
  197. {
  198. Dictionary<string, string> Fields = new Dictionary<string, string>();
  199. Fields.Add("MakerCode", "1"); //创客编号
  200. Fields.Add("RealName", "1"); //创客名称
  201. Fields.Add("Mobile", "1"); //手机号
  202. Fields.Add("CertId", "1"); //身份证号码
  203. Fields.Add("SettleAmount", "3"); //结算金额
  204. Fields.Add("CashFreezeAmt", "3"); //冻结金额
  205. Fields.Add("UserLevel", "0"); //创客等级
  206. string condition = " and Status=-1";
  207. string sort = "Id desc";
  208. //直属创客编号
  209. if (!string.IsNullOrEmpty(ParentMakerCode))
  210. {
  211. condition += " and ParentUserId in (select UserId from UserForMakerCode where MakerCode='" + ParentMakerCode + "')";
  212. }
  213. //直属创客名称
  214. if (!string.IsNullOrEmpty(ParentRealName))
  215. {
  216. condition += " and ParentUserId in (select UserId from UserForRealName where RealName='" + ParentRealName + "')";
  217. }
  218. //实名状态
  219. if (!string.IsNullOrEmpty(AuthFlagSelect))
  220. {
  221. condition += " and AuthFlag=" + AuthFlagSelect;
  222. }
  223. //顶级创客
  224. if (TopUserId > 0)
  225. {
  226. condition += " and ParentNav like '," + TopUserId + ",%'";
  227. }
  228. //风控标识
  229. if (!string.IsNullOrEmpty(RiskFlagSelect))
  230. {
  231. condition += " and RiskFlag=" + RiskFlagSelect;
  232. }
  233. //商户创客类型
  234. if (!string.IsNullOrEmpty(MerchantTypeSelect))
  235. {
  236. condition += " and MerchantType=" + MerchantTypeSelect;
  237. }
  238. if (sSettleAmount != null)
  239. {
  240. condition += " and SettleAmount>=" + sSettleAmount.Value;
  241. }
  242. if (eSettleAmount != null)
  243. {
  244. condition += " and SettleAmount<=" + eSettleAmount.Value;
  245. }
  246. if (sCashFreezeAmt != null)
  247. {
  248. condition += " and CashFreezeAmt>=" + sCashFreezeAmt.Value;
  249. }
  250. if (eCashFreezeAmt != null)
  251. {
  252. condition += " and CashFreezeAmt<=" + eCashFreezeAmt.Value;
  253. }
  254. if (SelfId > 0)
  255. {
  256. Users self = db.Users.FirstOrDefault(m => m.Id == SelfId);
  257. if (self != null)
  258. {
  259. string ParentNav = function.CheckNull(self.ParentNav);
  260. condition += " and Id in (" + ParentNav.Trim(',').Replace(",,", ",") + ")";
  261. sort = "ParentNav asc";
  262. }
  263. }
  264. if (ParentId > 0)
  265. {
  266. condition += " and ParentUserId=" + ParentId;
  267. }
  268. if (UserId > 0)
  269. {
  270. condition += " and Id=" + UserId;
  271. }
  272. if (!string.IsNullOrEmpty(CreateDateData))
  273. {
  274. string[] datelist = CreateDateData.Split(new string[] { " - " }, StringSplitOptions.None);
  275. string start = datelist[0];
  276. string end = datelist[1];
  277. condition += " and CreateDate>='" + start + " 00:00:00' and CreateDate<='" + end + " 23:59:59'";
  278. }
  279. Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("Users", Fields, sort, "True", page, limit, condition);
  280. List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
  281. foreach (Dictionary<string, object> dic in diclist)
  282. {
  283. dic["AuthFlagName"] = dic["AuthFlag"].ToString() == "1" ? "已实名" : "未实名";
  284. dic["RiskFlagName"] = dic["RiskFlag"].ToString() == "1" ? "已风控" : "未风控";
  285. dic["UserLevel"] = RelationClass.GetUserLevelSetInfo(int.Parse(dic["UserLevel"].ToString()));
  286. dic["MerchantType"] = RelationClassForConst.GetMerchantTypeInfo(int.Parse(dic["MerchantType"].ToString()));
  287. int ParentUserId = int.Parse(dic["ParentUserId"].ToString());
  288. Users puser = db.Users.FirstOrDefault(m => m.Id == ParentUserId) ?? new Users();
  289. dic["ParentMakerCode"] = puser.MakerCode;
  290. dic["ParentRealName"] = puser.RealName;
  291. string ParentNav = dic["ParentNav"].ToString();
  292. if (!string.IsNullOrEmpty(ParentNav))
  293. {
  294. string[] list = ParentNav.Trim(',').Replace(",,", ",").Split(',');
  295. if (list.Length > 1)
  296. {
  297. int TopId = int.Parse(function.CheckInt(list[1]));
  298. Users tuser = db.Users.FirstOrDefault(m => m.Id == TopId) ?? new Users();
  299. dic["TopMakerCode"] = tuser.MakerCode;
  300. dic["TopRealName"] = tuser.RealName;
  301. }
  302. }
  303. }
  304. return Json(obj);
  305. }
  306. #endregion
  307. #region 增加创客
  308. /// <summary>
  309. /// 增加或修改创客信息
  310. /// </summary>
  311. /// <returns></returns>
  312. public IActionResult Add(string right)
  313. {
  314. ViewBag.RightInfo = RightInfo;
  315. ViewBag.right = right;
  316. return View();
  317. }
  318. #endregion
  319. #region 增加创客
  320. /// <summary>
  321. /// 增加或修改创客信息
  322. /// </summary>
  323. /// <returns></returns>
  324. [HttpPost]
  325. public string Add(Users data, string ParentMakerCode)
  326. {
  327. bool check = db.UserForMobile.Any(m => m.Mobile == data.Mobile);
  328. if (check)
  329. {
  330. return "手机号已存在,请重新输入";
  331. }
  332. check = db.UserForRealName.Any(m => m.RealName == data.RealName);
  333. if (check)
  334. {
  335. return "姓名已存在,请重新输入";
  336. }
  337. if (!string.IsNullOrEmpty(data.MakerCode))
  338. {
  339. check = db.UserForMakerCode.Any(m => m.MakerCode == data.MakerCode);
  340. if (check)
  341. {
  342. return "创客编码已存在,请重新输入";
  343. }
  344. }
  345. Dictionary<string, object> Fields = new Dictionary<string, object>();
  346. Fields.Add("RealName", data.RealName); //真实姓名
  347. Fields.Add("CertId", data.CertId); //身份证号
  348. Fields.Add("Mobile", data.Mobile); //手机号
  349. Fields.Add("LoginPwd", function.MD532(data.LoginPwd)); //登录密码
  350. Fields.Add("SettleBankCardNo", data.SettleBankCardNo); //结算银行卡号
  351. if (!string.IsNullOrEmpty(ParentMakerCode))
  352. {
  353. UserForMakerCode userFor = db.UserForMakerCode.FirstOrDefault(m => m.MakerCode == ParentMakerCode) ?? new UserForMakerCode();
  354. Users puser = db.Users.FirstOrDefault(m => m.Id == userFor.UserId) ?? new Users();
  355. Fields.Add("ParentUserId", userFor.UserId);
  356. Fields.Add("ParentNav", puser.ParentNav + "," + userFor.UserId + ",");
  357. }
  358. int Id = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Add("Users", Fields, 0);
  359. if (string.IsNullOrEmpty(ParentMakerCode))
  360. {
  361. string MakerCode = Id.ToString();
  362. for (int i = 0; i < 7 - Id.ToString().Length; i++)
  363. {
  364. MakerCode = "0" + MakerCode;
  365. }
  366. MakerCode = "K" + MakerCode;
  367. Fields = new Dictionary<string, object>();
  368. Fields.Add("MakerCode", MakerCode); //编号
  369. new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("Users", Fields, Id);
  370. }
  371. db.UserDetail.Add(new UserDetail() { Id = Id });
  372. db.UserData.Add(new UserData() { UserId = Id });
  373. AddSysLog(data.Id.ToString(), "Users", "add");
  374. db.SaveChanges();
  375. return "success";
  376. }
  377. #endregion
  378. #region 修改创客
  379. /// <summary>
  380. /// 增加或修改创客信息
  381. /// </summary>
  382. /// <returns></returns>
  383. public IActionResult Edit(string right, int Id = 0)
  384. {
  385. ViewBag.RightInfo = RightInfo;
  386. ViewBag.right = right;
  387. Users editData = db.Users.FirstOrDefault(m => m.Id == Id) ?? new Users();
  388. ViewBag.data = editData;
  389. return View();
  390. }
  391. #endregion
  392. #region 修改创客
  393. /// <summary>
  394. /// 增加或修改创客信息
  395. /// </summary>
  396. /// <returns></returns>
  397. [HttpPost]
  398. public string Edit(Users data, UserDetail userdetail, UserData userdata)
  399. {
  400. Dictionary<string, object> Fields = new Dictionary<string, object>();
  401. Fields.Add("RealName", data.RealName); //真实姓名
  402. Fields.Add("CertId", data.CertId); //身份证号
  403. Fields.Add("Mobile", data.Mobile); //手机号
  404. Fields.Add("SettleBankName", data.SettleBankName); //结算银行名称
  405. Fields.Add("SettleBankCardNo", data.SettleBankCardNo); //结算银行卡号
  406. new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("Users", Fields, data.Id);
  407. AddSysLog(data.Id.ToString(), "Users", "update");
  408. db.SaveChanges();
  409. return "success";
  410. }
  411. #endregion
  412. #region 重置小分仓机具数
  413. public string ResetSmallPosCount(string Id)
  414. {
  415. DataTable dt = OtherMySqlConn.dtable("update SmallStoreHouse s set TotalNum=(select count(Id) from PreSendStockDetail where ToUserId=s.UserId and ApplyFlag=0 and Status>-1 and Status<2),LaveNum=10-(select count(Id) from PreSendStockDetail where ToUserId=s.UserId and ApplyFlag=0 and Status>-1 and Status<2) where UserId=" + Id);
  416. string text = string.Format("重置小分仓机具数,UserId: '" + Id + "',操作人: '" + SysUserName + "_" + SysRealName + "',Time'" + DateTime.Now + "'");
  417. function.WriteLog(text, "重置小分仓机具数");
  418. return "success";
  419. }
  420. #endregion
  421. #region 修改结算金额
  422. public IActionResult EditSettleAmount(string right, int Id = 0)
  423. {
  424. ViewBag.RightInfo = RightInfo;
  425. ViewBag.right = right;
  426. Users editData = db.Users.FirstOrDefault(m => m.Id == Id) ?? new Users();
  427. ViewBag.data = editData;
  428. return View();
  429. }
  430. #endregion
  431. #region 修改结算金额
  432. [HttpPost]
  433. public string EditSettleAmount(Users data)
  434. {
  435. Dictionary<string, object> Fields = new Dictionary<string, object>();
  436. Fields.Add("SettleAmount", data.SettleAmount);
  437. new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("Users", Fields, data.Id);
  438. AddSysLog(data.Id.ToString(), "Users", "EditSettleAmount");
  439. db.SaveChanges();
  440. return "success";
  441. }
  442. #endregion
  443. #region 修改账户金额
  444. public IActionResult EditCashFreezeAmt(string right, int Id = 0)
  445. {
  446. ViewBag.RightInfo = RightInfo;
  447. ViewBag.right = right;
  448. Users editData = db.Users.FirstOrDefault(m => m.Id == Id) ?? new Users();
  449. ViewBag.data = editData;
  450. return View();
  451. }
  452. #endregion
  453. #region 修改账户金额
  454. [HttpPost]
  455. public string EditCashFreezeAmt(Users data, string Note, int Kind)
  456. {
  457. int UserId = data.Id;
  458. UserAccount account = db.UserAccount.FirstOrDefault(m => m.Id == UserId);
  459. if (account == null)
  460. {
  461. account = db.UserAccount.Add(new UserAccount()
  462. {
  463. Id = UserId,
  464. UserId = UserId,
  465. }).Entity;
  466. db.SaveChanges();
  467. }
  468. if ((Kind == 1 || Kind == 3) && data.CashFreezeAmt > account.BalanceAmount)
  469. {
  470. return "账号余额不足";
  471. }
  472. decimal BeforeTotalAmount = account.TotalAmount; //变更前总金额
  473. decimal BeforeFreezeAmount = account.FreezeAmount; //变更前冻结金额
  474. decimal BeforeBalanceAmount = account.BalanceAmount; //变更前余额
  475. int ChangeType = 0;
  476. if (Kind == 1 && data.CashFreezeAmt <= account.BalanceAmount)
  477. {
  478. account.BalanceAmount -= data.CashFreezeAmt;
  479. account.FreezeAmount += data.CashFreezeAmt;
  480. ChangeType = 61;
  481. }
  482. else if (Kind == 1 && data.CashFreezeAmt > account.BalanceAmount)
  483. {
  484. return "冻结金额大于余额";
  485. }
  486. else if (Kind == 2 && data.CashFreezeAmt <= account.FreezeAmount)
  487. {
  488. account.BalanceAmount += data.CashFreezeAmt;
  489. account.FreezeAmount -= data.CashFreezeAmt;
  490. ChangeType = 62;
  491. }
  492. else if (Kind == 2 && data.CashFreezeAmt > account.FreezeAmount)
  493. {
  494. return "解冻金额大于冻结金额";
  495. }
  496. else if (Kind == 3 && data.CashFreezeAmt <= account.BalanceAmount)
  497. {
  498. account.TotalAmount -= data.CashFreezeAmt;
  499. account.BalanceAmount -= data.CashFreezeAmt;
  500. ChangeType = 63;
  501. }
  502. else if (Kind == 3 && data.CashFreezeAmt > account.BalanceAmount)
  503. {
  504. return "扣减金额大于余额";
  505. }
  506. else if (Kind == 4)
  507. {
  508. account.TotalAmount += data.CashFreezeAmt;
  509. account.BalanceAmount += data.CashFreezeAmt;
  510. ChangeType = 64;
  511. }
  512. decimal AfterTotalAmount = account.TotalAmount; //变更后总金额
  513. decimal AfterFreezeAmount = account.FreezeAmount; //变更后冻结金额
  514. decimal AfterBalanceAmount = account.BalanceAmount; //变更后余额
  515. UserAccountRecord userAccountRecord = db.UserAccountRecord.Add(new UserAccountRecord()
  516. {
  517. CreateDate = DateTime.Now,
  518. UpdateDate = DateTime.Now,
  519. UserId = UserId, //创客
  520. ChangeType = ChangeType, //变动类型
  521. ChangeAmount = data.CashFreezeAmt, //变更金额
  522. BeforeTotalAmount = BeforeTotalAmount, //变更前总金额
  523. AfterTotalAmount = AfterTotalAmount, //变更后总金额
  524. BeforeFreezeAmount = BeforeFreezeAmount, //变更前冻结金额
  525. AfterFreezeAmount = AfterFreezeAmount, //变更后冻结金额
  526. BeforeBalanceAmount = BeforeBalanceAmount, //变更前余额
  527. AfterBalanceAmount = AfterBalanceAmount, //变更后余额
  528. Remark = Note,
  529. }).Entity;
  530. db.SaveChanges();
  531. RedisDbconn.Instance.Set("UserAccount:" + UserId, account);
  532. AddSysLog(data.Id.ToString(), "Users", "EditCashFreezeAmt");
  533. db.SaveChanges();
  534. return "success";
  535. }
  536. #endregion
  537. #region 账户操作
  538. public IActionResult EditBalance(string right, int Id = 0)
  539. {
  540. ViewBag.RightInfo = RightInfo;
  541. ViewBag.right = right;
  542. Users editData = db.Users.FirstOrDefault(m => m.Id == Id) ?? new Users();
  543. ViewBag.data = editData;
  544. UserAccount account = db.UserAccount.FirstOrDefault(m => m.Id == Id) ?? new UserAccount();
  545. ViewBag.account = account;
  546. return View();
  547. }
  548. #endregion
  549. #region 账户操作
  550. [HttpPost]
  551. public string EditBalance(UserAccount data)
  552. {
  553. UserAccount account = db.UserAccount.FirstOrDefault(m => m.Id == data.Id);
  554. if (account != null)
  555. {
  556. decimal amount = data.BalanceAmount - account.BalanceAmount;
  557. if (amount != 0)
  558. {
  559. account.BalanceAmount += amount;
  560. account.TotalAmount += amount;
  561. AddSysLog(data.Id.ToString(), "UserAccount", "EditBalance");
  562. db.SaveChanges();
  563. }
  564. }
  565. return "success";
  566. }
  567. #endregion
  568. #region 详情
  569. public IActionResult Detail(string right, int Id = 0)
  570. {
  571. ViewBag.RightInfo = RightInfo;
  572. ViewBag.right = right;
  573. Users editData = db.Users.FirstOrDefault(m => m.Id == Id) ?? new Users();
  574. ViewBag.AuthDate = editData.AuthDate == null ? "" : editData.AuthDate.Value.ToString("yyyy-MM-dd HH:mm:ss");
  575. string Age = "";
  576. if (!string.IsNullOrEmpty(editData.CertId))
  577. {
  578. int year = DateTime.Now.Year - int.Parse(editData.CertId.Substring(6, 4));
  579. Age = year.ToString();
  580. }
  581. ViewBag.Age = Age;
  582. ViewBag.QrCode = string.IsNullOrEmpty(editData.ReferenceQrCode) ? defaultImage : SourceHost + editData.ReferenceQrCode;
  583. return View();
  584. }
  585. #endregion
  586. #region 三/四要素验证
  587. public IActionResult ThreeElement(string right)
  588. {
  589. ViewBag.RightInfo = RightInfo;
  590. ViewBag.right = right;
  591. return View();
  592. }
  593. #endregion
  594. #region 三/四要素验证
  595. [HttpPost]
  596. public string ThreeElement(string Name, string CertId, string CardNo, string Mobile)
  597. {
  598. return "success";
  599. }
  600. #endregion
  601. #region 删除创客信息
  602. /// <summary>
  603. /// 删除创客信息
  604. /// </summary>
  605. /// <returns></returns>
  606. public string Delete(string Id)
  607. {
  608. string[] idlist = Id.Split(new char[] { ',' });
  609. AddSysLog(Id, "Users", "del");
  610. foreach (string subid in idlist)
  611. {
  612. int id = int.Parse(subid);
  613. Dictionary<string, object> Fields = new Dictionary<string, object>();
  614. Fields.Add("Status", -1);
  615. new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("Users", Fields, id);
  616. }
  617. db.SaveChanges();
  618. return "success";
  619. }
  620. #endregion
  621. #region 注销
  622. // 1.创客名下无未绑定机具且没有申请中的机具循环及兑换订单
  623. // 2.创客名下无预发机
  624. // 3.创客名下无分仓及运营中心
  625. // 满足以上全部条件的用户可申请注销,申请后用户二次填写确认填写信息(姓名、手机号、身份证号)即可完成注销
  626. public string Cancel(string UserId)
  627. {
  628. Users user = db.Users.FirstOrDefault(m => m.Id == Convert.ToInt32(UserId));
  629. if (user != null)
  630. {
  631. if (user.AuthFlag == 1)
  632. {
  633. // bool check = db.PosMachinesTwo.Any(m => m.BuyUserId == user.Id && m.BindingState == 1);
  634. // if (check)
  635. // {
  636. // return "注销失败,未满足条件:已实名创客,无开通商户。如有疑问,请联系客服";
  637. // }
  638. // DateTime checkDate = DateTime.Now.AddDays(-7);
  639. // check = db.Orders.Any(m => m.CreateDate >= checkDate && m.Status > 0 && m.UserId == user.Id);
  640. // if (check)
  641. // {
  642. // return "注销失败,未满足条件:近7天未在商城下单过商品。如有疑问,请联系客服";
  643. // }
  644. // check = db.PosMachinesTwo.Any(m => m.BuyUserId == user.Id && m.IsPurchase == 0);
  645. // if (check)
  646. // {
  647. // return "注销失败,未满足条件:名下无未绑定机具、机具券,无未申请的循环机。如有疑问,请联系客服";
  648. // }
  649. // check = db.PosCoupons.Any(m => m.UserId == user.Id && m.IsUse == 0);
  650. // if (check)
  651. // {
  652. // return "注销失败,未满足条件:名下无未绑定机具、机具券,无未申请的循环机。如有疑问,请联系客服";
  653. // }
  654. bool check = db.PosMachinesTwo.Any(m => m.BuyUserId == user.Id && m.BindingState == 0);
  655. if (check)
  656. {
  657. return "注销失败,未满足条件:名下存在未绑定机具。如有疑问,请联系客服";
  658. }
  659. check = db.MachineApply.Any(m => m.Status == 0 && m.UserId == user.Id);
  660. if (check)
  661. {
  662. return "注销失败,未满足条件:名下存在未完成的机具循环兑换订单。如有疑问,请联系客服";
  663. }
  664. check = db.PreSendStockDetail.Any(m => m.Status == 1 && m.AuthFlag == 0 && m.ToUserId == user.Id);
  665. if (check)
  666. {
  667. return "注销失败,未满足条件:名下存在预发机。如有疑问,请联系客服";
  668. }
  669. if (user.UserType == 1)
  670. {
  671. return "注销失败,未满足条件:名下存在运营中心。如有疑问,请联系客服";
  672. }
  673. check = db.StoreHouse.Any(m => m.Status == 1 && m.UserId == user.Id);
  674. if (check)
  675. {
  676. return "注销失败,未满足条件:名下存在分仓。如有疑问,请联系客服";
  677. }
  678. UserForMobile forMobile = db.UserForMobile.FirstOrDefault(m => m.Mobile == user.Mobile);
  679. if (forMobile != null)
  680. {
  681. db.Remove(forMobile);
  682. }
  683. UserForMakerCode forCode = db.UserForMakerCode.FirstOrDefault(m => m.MakerCode == user.MakerCode);
  684. if (forCode != null)
  685. {
  686. db.UserForMakerCode.Remove(forCode);
  687. }
  688. user.Status = -1;
  689. user.Mobile += "d";
  690. user.CertId += "d";
  691. user.LogOutDate = DateTime.Now;
  692. }
  693. else
  694. {
  695. UserForMobile forMobile = db.UserForMobile.FirstOrDefault(m => m.Mobile == user.Mobile);
  696. if (forMobile != null)
  697. {
  698. db.UserForMobile.Remove(forMobile);
  699. }
  700. UserForMakerCode forCode = db.UserForMakerCode.FirstOrDefault(m => m.MakerCode == user.MakerCode);
  701. if (forCode != null)
  702. {
  703. db.UserForMakerCode.Remove(forCode);
  704. }
  705. user.Status = -1;
  706. user.Mobile += "d";
  707. user.CertId += "d";
  708. user.LogOutDate = DateTime.Now;
  709. }
  710. function.WriteLog(user.Id + "于" + DateTime.Now.ToString() + "注销账号", "创客注销日志");
  711. // TODO: 每月扫描一次注销的创客,把注销创客伞下创客全部挂到注销创客的上级
  712. // TODO: 清除token,token登录返回
  713. db.SaveChanges();
  714. }
  715. return "success";
  716. }
  717. #endregion
  718. #region 开启
  719. /// <summary>
  720. /// 开启
  721. /// </summary>
  722. /// <returns></returns>
  723. public string Open(string Id)
  724. {
  725. string[] idlist = Id.Split(new char[] { ',' });
  726. AddSysLog(Id, "Users", "open");
  727. foreach (string subid in idlist)
  728. {
  729. int id = int.Parse(subid);
  730. Dictionary<string, object> Fields = new Dictionary<string, object>();
  731. Fields.Add("Status", 1);
  732. new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("Users", Fields, id);
  733. }
  734. db.SaveChanges();
  735. return "success";
  736. }
  737. #endregion
  738. #region 关闭
  739. /// <summary>
  740. /// 关闭
  741. /// </summary>
  742. /// <returns></returns>
  743. public string Close(string Id)
  744. {
  745. string[] idlist = Id.Split(new char[] { ',' });
  746. AddSysLog(Id, "Users", "close");
  747. foreach (string subid in idlist)
  748. {
  749. int id = int.Parse(subid);
  750. Dictionary<string, object> Fields = new Dictionary<string, object>();
  751. Fields.Add("Status", 0);
  752. new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("Users", Fields, id);
  753. }
  754. db.SaveChanges();
  755. return "success";
  756. }
  757. #endregion
  758. #region 一键企业创客
  759. /// <summary>
  760. /// 一键企业创客
  761. /// </summary>
  762. /// <returns></returns>
  763. public string OpenEnterpriseMaker(string Id)
  764. {
  765. string[] idlist = Id.Split(new char[] { ',' });
  766. AddSysLog(Id, "Users", "OpenEnterpriseMaker");
  767. foreach (string subid in idlist)
  768. {
  769. int id = int.Parse(subid);
  770. Dictionary<string, object> Fields = new Dictionary<string, object>();
  771. Fields.Add("BusinessFlag", 1);
  772. new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("Users", Fields, id);
  773. }
  774. db.SaveChanges();
  775. return "success";
  776. }
  777. #endregion
  778. #region 关闭企业创客
  779. /// <summary>
  780. /// 关闭企业创客
  781. /// </summary>
  782. /// <returns></returns>
  783. public string CloseEnterpriseMaker(string Id)
  784. {
  785. string[] idlist = Id.Split(new char[] { ',' });
  786. AddSysLog(Id, "Users", "CloseEnterpriseMaker");
  787. foreach (string subid in idlist)
  788. {
  789. int id = int.Parse(subid);
  790. Dictionary<string, object> Fields = new Dictionary<string, object>();
  791. Fields.Add("BusinessFlag", 0);
  792. new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("Users", Fields, id);
  793. }
  794. db.SaveChanges();
  795. return "success";
  796. }
  797. #endregion
  798. #region 一键大盟主
  799. /// <summary>
  800. /// 一键大盟主
  801. /// </summary>
  802. /// <returns></returns>
  803. public string SetBigLeader(string Id)
  804. {
  805. string[] idlist = Id.Split(new char[] { ',' });
  806. AddSysLog(Id, "Users", "SetBigLeader");
  807. foreach (string subid in idlist)
  808. {
  809. int id = int.Parse(subid);
  810. Dictionary<string, object> Fields = new Dictionary<string, object>();
  811. Fields.Add("LeaderLevel", 2);
  812. new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("Users", Fields, id);
  813. }
  814. db.SaveChanges();
  815. return "success";
  816. }
  817. #endregion
  818. #region 一键小盟主
  819. /// <summary>
  820. /// 一键小盟主
  821. /// </summary>
  822. /// <returns></returns>
  823. public string SetSmallLeader(string Id)
  824. {
  825. string[] idlist = Id.Split(new char[] { ',' });
  826. AddSysLog(Id, "Users", "SetSmallLeader");
  827. foreach (string subid in idlist)
  828. {
  829. int id = int.Parse(subid);
  830. Dictionary<string, object> Fields = new Dictionary<string, object>();
  831. Fields.Add("LeaderLevel", 1);
  832. new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("Users", Fields, id);
  833. }
  834. db.SaveChanges();
  835. return "success";
  836. }
  837. #endregion
  838. #region 风控
  839. public IActionResult Risk(string right, int Id = 0)
  840. {
  841. ViewBag.RightInfo = RightInfo;
  842. ViewBag.right = right;
  843. Users editData = db.Users.FirstOrDefault(m => m.Id == Id) ?? new Users();
  844. ViewBag.data = editData;
  845. return View();
  846. }
  847. #endregion
  848. #region 风控
  849. [HttpPost]
  850. public string Risk(Users data)
  851. {
  852. Users user = db.Users.FirstOrDefault(m => m.Id == data.Id);
  853. if (user != null)
  854. {
  855. user.RiskFlag = data.RiskFlag;
  856. user.RiskRemark = data.RiskRemark;
  857. db.SaveChanges();
  858. }
  859. return "success";
  860. }
  861. #endregion
  862. #region 解除风控
  863. public string UnRisk(string Id)
  864. {
  865. string[] idlist = Id.Split(new char[] { ',' });
  866. AddSysLog(Id, "Users", "UnRisk");
  867. foreach (string subid in idlist)
  868. {
  869. int id = int.Parse(subid);
  870. Dictionary<string, object> Fields = new Dictionary<string, object>();
  871. Fields.Add("RiskFlag", 0);
  872. new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("Users", Fields, id);
  873. }
  874. db.SaveChanges();
  875. return "success";
  876. }
  877. #endregion
  878. #region 重置密码
  879. public string ResetPwd(int Id)
  880. {
  881. string NewPwd = function.get_Random(6);
  882. Dictionary<string, object> Fields = new Dictionary<string, object>();
  883. Fields.Add("LoginPwd", function.MD532(NewPwd));
  884. new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("Users", Fields, Id);
  885. AddSysLog(Id, "Users", "ResetPwd");
  886. return "success|" + NewPwd;
  887. }
  888. #endregion
  889. #region 排序
  890. /// <summary>
  891. /// 排序
  892. /// </summary>
  893. /// <param name="Id"></param>
  894. public string Sort(int Id, int Sort)
  895. {
  896. new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Sort("Users", Sort, Id);
  897. AddSysLog(Id.ToString(), "Users", "sort");
  898. return "success";
  899. }
  900. #endregion
  901. #region 导入数据
  902. /// <summary>
  903. /// 导入数据
  904. /// </summary>
  905. /// <param name="ExcelData"></param>
  906. public string Import(string ExcelData, int Kind = 0)
  907. {
  908. ExcelData = HttpUtility.UrlDecode(ExcelData);
  909. JsonData list = JsonMapper.ToObject(ExcelData);
  910. if (Kind == 1)
  911. {
  912. for (int i = 1; i < list.Count; i++)
  913. {
  914. JsonData dr = list[i];
  915. string MakerCode = dr[0].ToString();
  916. string SettleAmount = dr[2].ToString();
  917. UserForMakerCode UserCode = db.UserForMakerCode.FirstOrDefault(m => m.MakerCode == MakerCode);
  918. if (UserCode != null)
  919. {
  920. Users User = db.Users.FirstOrDefault(m => m.Id == UserCode.UserId);
  921. if (User != null)
  922. {
  923. User.SettleAmount = decimal.Parse(function.CheckInt(SettleAmount));
  924. }
  925. }
  926. }
  927. db.SaveChanges();
  928. }
  929. else if (Kind == 2)
  930. {
  931. for (int i = 1; i < list.Count; i++)
  932. {
  933. JsonData dr = list[i];
  934. string MakerCode = dr[0].ToString();
  935. string CashFreezeAmt = dr[2].ToString();
  936. UserForMakerCode UserCode = db.UserForMakerCode.FirstOrDefault(m => m.MakerCode == MakerCode);
  937. if (UserCode != null)
  938. {
  939. Users User = db.Users.FirstOrDefault(m => m.Id == UserCode.UserId);
  940. if (User != null)
  941. {
  942. User.CashFreezeAmt = decimal.Parse(function.CheckInt(CashFreezeAmt));
  943. }
  944. }
  945. }
  946. db.SaveChanges();
  947. }
  948. else if (Kind == 3)
  949. {
  950. for (int i = 1; i < list.Count; i++)
  951. {
  952. JsonData dr = list[i];
  953. string MakerCode = dr[0].ToString();
  954. string RiskFlag = dr[2].ToString();
  955. string RiskNote = dr[3].ToString();
  956. UserForMakerCode UserCode = db.UserForMakerCode.FirstOrDefault(m => m.MakerCode == MakerCode);
  957. if (UserCode != null)
  958. {
  959. Users User = db.Users.FirstOrDefault(m => m.Id == UserCode.UserId);
  960. if (User != null)
  961. {
  962. User.RiskFlag = ulong.Parse(function.CheckInt(RiskFlag));
  963. User.RiskRemark = RiskNote;
  964. }
  965. }
  966. }
  967. db.SaveChanges();
  968. }
  969. else if (Kind == 4)
  970. {
  971. string error = "";
  972. for (int i = 1; i < list.Count; i++)
  973. {
  974. JsonData dr = list[i];
  975. string MakerCode = dr[0].ToString();
  976. string OperationAmt = dr[2].ToString();//操作金额
  977. string OperationType = dr[3].ToString();//操作类型
  978. UserForMakerCode UserCode = db.UserForMakerCode.FirstOrDefault(m => m.MakerCode == MakerCode);
  979. if (UserCode != null)
  980. {
  981. Users User = db.Users.FirstOrDefault(m => m.Id == UserCode.UserId);
  982. UserAccount account = db.UserAccount.FirstOrDefault(m => m.Id == User.Id);
  983. if (account == null)
  984. {
  985. account = db.UserAccount.Add(new UserAccount()
  986. {
  987. Id = User.Id,
  988. UserId = User.Id,
  989. }).Entity;
  990. db.SaveChanges();
  991. }
  992. if (User != null)
  993. {
  994. decimal BeforeTotalAmount = account.TotalAmount; //变更前总金额
  995. decimal BeforeFreezeAmount = account.FreezeAmount; //变更前冻结金额
  996. decimal BeforeBalanceAmount = account.BalanceAmount; //变更前余额
  997. int ChangeType = 0;
  998. if (OperationType == "1" && Convert.ToDecimal(OperationAmt) <= account.BalanceAmount)
  999. {
  1000. account.BalanceAmount -= Convert.ToDecimal(OperationAmt);
  1001. account.FreezeAmount += Convert.ToDecimal(OperationAmt);
  1002. ChangeType = 61;
  1003. }
  1004. else if (OperationType == "1" && Convert.ToDecimal(OperationAmt) > account.BalanceAmount)
  1005. {
  1006. error += "以下操作失败" + User.MakerCode + ',' + User.RealName + "冻结金额大于余额" + '|' + '\n';
  1007. }
  1008. else if (OperationType == "2" && Convert.ToDecimal(OperationAmt) <= account.FreezeAmount)
  1009. {
  1010. account.BalanceAmount += Convert.ToDecimal(OperationAmt);
  1011. account.FreezeAmount -= Convert.ToDecimal(OperationAmt);
  1012. ChangeType = 62;
  1013. }
  1014. else if (OperationType == "2" && Convert.ToDecimal(OperationAmt) > account.FreezeAmount)
  1015. {
  1016. error += "以下操作失败" + User.MakerCode + ',' + User.RealName + "解冻金额大于冻结金额" + '|' + '\n';
  1017. }
  1018. else if (OperationType == "3" && Convert.ToDecimal(OperationAmt) <= account.BalanceAmount)
  1019. {
  1020. account.TotalAmount -= Convert.ToDecimal(OperationAmt);
  1021. account.BalanceAmount -= Convert.ToDecimal(OperationAmt);
  1022. ChangeType = 63;
  1023. }
  1024. else if (OperationType == "3" && Convert.ToDecimal(OperationAmt) > account.BalanceAmount)
  1025. {
  1026. error += "以下操作失败" + User.MakerCode + ',' + User.RealName + "扣减金额大于余额" + '|' + '\n';
  1027. }
  1028. else if (OperationType == "4")
  1029. {
  1030. account.TotalAmount += Convert.ToDecimal(OperationAmt);
  1031. account.BalanceAmount += Convert.ToDecimal(OperationAmt);
  1032. ChangeType = 64;
  1033. }
  1034. decimal AfterTotalAmount = account.TotalAmount; //变更后总金额
  1035. decimal AfterFreezeAmount = account.FreezeAmount; //变更后冻结金额
  1036. decimal AfterBalanceAmount = account.BalanceAmount; //变更后余额
  1037. UserAccountRecord userAccountRecord = db.UserAccountRecord.Add(new UserAccountRecord()
  1038. {
  1039. CreateDate = DateTime.Now,
  1040. UpdateDate = DateTime.Now,
  1041. UserId = User.Id, //创客
  1042. ChangeType = ChangeType, //变动类型
  1043. ChangeAmount = Convert.ToDecimal(OperationAmt), //变更金额
  1044. BeforeTotalAmount = BeforeTotalAmount, //变更前总金额
  1045. AfterTotalAmount = AfterTotalAmount, //变更后总金额
  1046. BeforeFreezeAmount = BeforeFreezeAmount, //变更前冻结金额
  1047. AfterFreezeAmount = AfterFreezeAmount, //变更后冻结金额
  1048. BeforeBalanceAmount = BeforeBalanceAmount, //变更前余额
  1049. AfterBalanceAmount = AfterBalanceAmount, //变更后余额
  1050. Remark = dr[4].ToString(),
  1051. }).Entity;
  1052. db.SaveChanges();
  1053. AddSysLog(User.Id.ToString(), "Users", "ChangeCashFreezeAmts");
  1054. db.SaveChanges();
  1055. }
  1056. }
  1057. }
  1058. db.SaveChanges();
  1059. return "warning" + error;
  1060. }
  1061. AddSysLog("0", "Users", "Import");
  1062. return "success";
  1063. }
  1064. #endregion
  1065. #region 导出Excel
  1066. /// <summary>
  1067. /// 导出Excel
  1068. /// </summary>
  1069. /// <returns></returns>
  1070. 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)
  1071. {
  1072. Dictionary<string, string> Fields = new Dictionary<string, string>();
  1073. Fields.Add("MakerCode", "1"); //创客编号
  1074. Fields.Add("RealName", "1"); //创客名称
  1075. Fields.Add("Mobile", "1"); //手机号
  1076. Fields.Add("CertId", "1"); //身份证号码
  1077. Fields.Add("CreateDate", "3"); //注册时间
  1078. Fields.Add("SettleAmount", "3"); //结算金额
  1079. Fields.Add("CashFreezeAmt", "3"); //冻结金额
  1080. Fields.Add("UserLevel", "0"); //创客等级
  1081. string condition = " and Status>-1";
  1082. //直属创客编号
  1083. if (!string.IsNullOrEmpty(ParentMakerCode))
  1084. {
  1085. condition += " and Id in (select UserId from UserForMakerCode where MakerCode='" + ParentMakerCode + "')";
  1086. }
  1087. //直属创客名称
  1088. if (!string.IsNullOrEmpty(ParentRealName))
  1089. {
  1090. condition += " and Id in (select UserId from UserForRealName where RealName='" + ParentRealName + "')";
  1091. }
  1092. //实名状态
  1093. if (!string.IsNullOrEmpty(AuthFlagSelect))
  1094. {
  1095. condition += " and AuthFlag=" + AuthFlagSelect;
  1096. }
  1097. //顶级创客
  1098. if (TopUserId > 0)
  1099. {
  1100. condition += " and ParentNav like '," + TopUserId + ",%'";
  1101. }
  1102. //风控标识
  1103. if (!string.IsNullOrEmpty(RiskFlagSelect))
  1104. {
  1105. condition += " and RiskFlag=" + RiskFlagSelect;
  1106. }
  1107. //商户创客类型
  1108. if (!string.IsNullOrEmpty(MerchantTypeSelect))
  1109. {
  1110. condition += " and MerchantType=" + MerchantTypeSelect;
  1111. }
  1112. if (SelfId > 0)
  1113. {
  1114. Users self = db.Users.FirstOrDefault(m => m.Id == SelfId);
  1115. if (self != null)
  1116. {
  1117. string ParentNav = function.CheckNull(self.ParentNav);
  1118. condition += " and Id in (" + ParentNav.Trim(',').Replace(",,", ",") + ")";
  1119. }
  1120. }
  1121. if (ParentId > 0)
  1122. {
  1123. condition += " and ParentUserId=" + ParentId;
  1124. }
  1125. 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);
  1126. List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
  1127. foreach (Dictionary<string, object> dic in diclist)
  1128. {
  1129. dic["AuthFlag"] = dic["AuthFlag"].ToString() == "1" ? "已实名" : "未实名";
  1130. dic["RiskFlag"] = dic["RiskFlag"].ToString() == "1" ? "已风控" : "未风控";
  1131. dic["UserLevel"] = RelationClass.GetUserLevelSetInfo(int.Parse(dic["UserLevel"].ToString()));
  1132. dic["MerchantType"] = RelationClassForConst.GetMerchantTypeInfo(int.Parse(dic["MerchantType"].ToString()));
  1133. int ParentUserId = int.Parse(dic["ParentUserId"].ToString());
  1134. Users puser = db.Users.FirstOrDefault(m => m.Id == ParentUserId) ?? new Users();
  1135. dic["ParentMakerCode"] = puser.MakerCode;
  1136. dic["ParentRealName"] = puser.RealName;
  1137. string ParentNav = dic["ParentNav"].ToString();
  1138. if (!string.IsNullOrEmpty(ParentNav))
  1139. {
  1140. string[] list = ParentNav.Trim(',').Replace(",,", ",").Split(',');
  1141. if (list.Length > 1)
  1142. {
  1143. int TopId = int.Parse(function.CheckInt(list[1]));
  1144. Users tuser = db.Users.FirstOrDefault(m => m.Id == TopId) ?? new Users();
  1145. dic["TopMakerCode"] = tuser.MakerCode;
  1146. dic["TopRealName"] = tuser.RealName;
  1147. }
  1148. }
  1149. dic.Remove("ParentUserId");
  1150. dic.Remove("ParentNav");
  1151. }
  1152. Dictionary<string, object> result = new Dictionary<string, object>();
  1153. result.Add("Status", "1");
  1154. result.Add("Info", "Excel报表-" + DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss") + ".xlsx");
  1155. result.Add("Obj", diclist);
  1156. Dictionary<string, object> ReturnFields = new Dictionary<string, object>();
  1157. ReturnFields.Add("MakerCode", "创客编号");
  1158. ReturnFields.Add("RealName", "创客姓名");
  1159. ReturnFields.Add("UserLevel", "创客等级");
  1160. ReturnFields.Add("SettleAmount", "提现金额(元)");
  1161. ReturnFields.Add("CashFreezeAmt", "冻结金额(元)");
  1162. ReturnFields.Add("CertId", "身份证号");
  1163. ReturnFields.Add("Mobile", "联系手机");
  1164. ReturnFields.Add("MerchantType", "商户创客类型");
  1165. ReturnFields.Add("MerchantDate", "成为商户创客时间");
  1166. ReturnFields.Add("ParentMakerCode", "直属创客编号");
  1167. ReturnFields.Add("ParentRealName", "直属创客名称");
  1168. ReturnFields.Add("TopMakerCode", "顶级创客编号");
  1169. ReturnFields.Add("TopRealName", "顶级创客名称");
  1170. ReturnFields.Add("AuthFlag", "实名状态");
  1171. ReturnFields.Add("RiskFlag", "风控状态");
  1172. ReturnFields.Add("CreateDate", "注册时间");
  1173. result.Add("Fields", ReturnFields);
  1174. AddSysLog("0", "Users", "ExportExcel");
  1175. return Json(result);
  1176. }
  1177. #endregion
  1178. #region 直属创客导出Excel
  1179. /// <summary>
  1180. /// 直属创客导出Excel
  1181. /// </summary>
  1182. /// <returns></returns>
  1183. public JsonResult ExportZSExcel(Users data, string MakerCode, string ParentMakerCode)
  1184. {
  1185. Dictionary<string, string> Fields = new Dictionary<string, string>();
  1186. string condition = " and Status>-1";
  1187. //创客编号
  1188. if (!string.IsNullOrEmpty(MakerCode))
  1189. {
  1190. condition += " and ParentUserId in (select UserId from UserForMakerCode where MakerCode='" + MakerCode + "')";
  1191. }
  1192. //直属创客编号
  1193. if (!string.IsNullOrEmpty(ParentMakerCode))
  1194. {
  1195. condition += " and ParentUserId in (select UserId from UserForMakerCode where MakerCode='" + ParentMakerCode + "')";
  1196. }
  1197. Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("Users", Fields, "Id desc", "True", 1, 20000, condition, "Id,MakerCode,RealName,UserLevel", false);
  1198. List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
  1199. foreach (Dictionary<string, object> dic in diclist)
  1200. {
  1201. int Id = int.Parse(dic["Id"].ToString());
  1202. Users userZS = db.Users.FirstOrDefault(m => m.Id == Id) ?? new Users();
  1203. dic["MakerCode"] = userZS.MakerCode;
  1204. dic["RealName"] = userZS.RealName;
  1205. dic["UserLevel"] = RelationClass.GetUserLevelSetInfo(int.Parse(dic["UserLevel"].ToString()));
  1206. }
  1207. Dictionary<string, object> result = new Dictionary<string, object>();
  1208. result.Add("Status", "1");
  1209. result.Add("Info", "Excel报表-" + DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss") + ".xlsx");
  1210. result.Add("Obj", diclist);
  1211. Dictionary<string, object> ReturnFields = new Dictionary<string, object>();
  1212. ReturnFields.Add("Id", "Id");
  1213. ReturnFields.Add("MakerCode", "创客编号");
  1214. ReturnFields.Add("RealName", "创客姓名");
  1215. ReturnFields.Add("UserLevel", "创客等级");
  1216. result.Add("Fields", ReturnFields);
  1217. AddSysLog("0", "Users", "ExportZSExcel");
  1218. return Json(result);
  1219. }
  1220. #endregion
  1221. #region 上级创客导出Excel
  1222. /// <summary>
  1223. /// 上级创客导出Excel
  1224. /// </summary>
  1225. /// <returns></returns>
  1226. public JsonResult ExportSJExcel(Users data, string MakerCode, string ParentMakerCode)
  1227. {
  1228. Dictionary<string, string> Fields = new Dictionary<string, string>();
  1229. string condition = " and Status>-1";
  1230. //创客编号
  1231. if (!string.IsNullOrEmpty(MakerCode))
  1232. {
  1233. var query = db.UserForMakerCode.FirstOrDefault(m => m.MakerCode == MakerCode);
  1234. Users self = db.Users.FirstOrDefault(m => m.Id == query.UserId);
  1235. if (self != null)
  1236. {
  1237. string ParentNav = function.CheckNull(self.ParentNav);
  1238. condition += " and Id in (" + ParentNav.Trim(',').Replace(",,", ",") + ")";
  1239. }
  1240. }
  1241. //直属创客编号
  1242. if (!string.IsNullOrEmpty(ParentMakerCode))
  1243. {
  1244. var query = db.UserForMakerCode.FirstOrDefault(m => m.MakerCode == ParentMakerCode);
  1245. Users self = db.Users.FirstOrDefault(m => m.Id == query.UserId);
  1246. if (self != null)
  1247. {
  1248. string ParentNav = function.CheckNull(self.ParentNav);
  1249. condition += " and Id in (" + ParentNav.Trim(',').Replace(",,", ",") + ")";
  1250. }
  1251. }
  1252. Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("Users", Fields, "Id desc", "True", 1, 20000, condition, "Id,MakerCode,RealName,UserLevel", false);
  1253. List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
  1254. foreach (Dictionary<string, object> dic in diclist)
  1255. {
  1256. int Id = int.Parse(dic["Id"].ToString());
  1257. Users userSJ = db.Users.FirstOrDefault(m => m.Id == Id) ?? new Users();
  1258. dic["MakerCode"] = userSJ.MakerCode;
  1259. dic["RealName"] = userSJ.RealName;
  1260. dic["UserLevel"] = RelationClass.GetUserLevelSetInfo(int.Parse(dic["UserLevel"].ToString()));
  1261. }
  1262. Dictionary<string, object> result = new Dictionary<string, object>();
  1263. result.Add("Status", "1");
  1264. result.Add("Info", "Excel报表-" + DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss") + ".xlsx");
  1265. result.Add("Obj", diclist);
  1266. Dictionary<string, object> ReturnFields = new Dictionary<string, object>();
  1267. ReturnFields.Add("Id", "Id");
  1268. ReturnFields.Add("MakerCode", "创客编号");
  1269. ReturnFields.Add("RealName", "创客姓名");
  1270. ReturnFields.Add("UserLevel", "创客等级");
  1271. result.Add("Fields", ReturnFields);
  1272. AddSysLog("0", "Users", "ExportExcel");
  1273. return Json(result);
  1274. }
  1275. #endregion
  1276. #region 同步数据
  1277. /// <summary>
  1278. /// 同步数据
  1279. /// </summary>
  1280. /// <returns></returns>
  1281. public string SycnData(int Id = 0)
  1282. {
  1283. var Brands = db.KqProducts.Where(m => m.Status == 1).ToList();
  1284. foreach (var Brand in Brands)
  1285. {
  1286. PublicFunction.SycnMachineCount(Id, Brand.Id);
  1287. }
  1288. AddSysLog(Id, "Users", "SycnData");
  1289. db.SaveChanges();
  1290. return "success";
  1291. }
  1292. #endregion
  1293. #region 同步交易额
  1294. public IActionResult SycnTradeAmount(string right, int Id = 0)
  1295. {
  1296. ViewBag.RightInfo = RightInfo;
  1297. ViewBag.right = right;
  1298. Users editData = db.Users.FirstOrDefault(m => m.Id == Id) ?? new Users();
  1299. ViewBag.data = editData;
  1300. return View();
  1301. }
  1302. #endregion
  1303. #region 同步交易额
  1304. [HttpPost]
  1305. public string SycnTradeAmountDo(DateTime sdate, DateTime edate, int UserId, int BrandId)
  1306. {
  1307. if (sdate.AddMonths(1) < edate)
  1308. {
  1309. return "时间间隔不能超过1个月";
  1310. }
  1311. if (edate >= DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd") + " 00:00:00"))
  1312. {
  1313. return "结束时间只能是今天之前";
  1314. }
  1315. string check = RedisDbconn.Instance.Get<string>("ResetUserTradeQueue:" + UserId + ":" + BrandId);
  1316. if (!string.IsNullOrEmpty(check))
  1317. {
  1318. return "请稍后再试";
  1319. }
  1320. try
  1321. {
  1322. 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);
  1323. RedisDbconn.Instance.Set("ResetUserTradeQueue:" + UserId + ":" + BrandId, "wait");
  1324. RedisDbconn.Instance.SetExpire("ResetUserTradeQueue:" + UserId + ":" + BrandId, 3600);
  1325. }
  1326. catch (Exception ex)
  1327. {
  1328. function.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString(), "统计创客的交易额异常");
  1329. return "同步异常";
  1330. }
  1331. return "success";
  1332. }
  1333. #endregion
  1334. #region 创客展业城市
  1335. public IActionResult City(Users data, string right)
  1336. {
  1337. ViewBag.RightInfo = RightInfo;
  1338. ViewBag.right = right;
  1339. List<Users> TopUsers = db.Users.Where(m => m.ParentUserId == 0).ToList();
  1340. ViewBag.TopUsers = TopUsers;
  1341. return View();
  1342. }
  1343. #endregion
  1344. #region 根据条件查询创客展业城市
  1345. public JsonResult CityData(Users data, string ParentMakerCode, string ParentRealName, int TopUserId, string Areas, int page = 1, int limit = 30)
  1346. {
  1347. Dictionary<string, string> Fields = new Dictionary<string, string>();
  1348. Fields.Add("MakerCode", "1"); //创客编号
  1349. Fields.Add("RealName", "1"); //创客名称
  1350. Fields.Add("CitySetDate", "3"); //创建时间
  1351. Fields.Add("Areas", "2"); //省市
  1352. string condition = " and Status>-1";
  1353. //直属创客编号
  1354. if (!string.IsNullOrEmpty(ParentMakerCode))
  1355. {
  1356. condition += " and Id in (select UserId from UserForMakerCode where MakerCode='" + ParentMakerCode + "')";
  1357. }
  1358. //直属创客名称
  1359. if (!string.IsNullOrEmpty(ParentRealName))
  1360. {
  1361. condition += " and Id in (select UserId from UserForRealName where RealName='" + ParentRealName + "')";
  1362. }
  1363. //顶级创客
  1364. if (TopUserId > 0)
  1365. {
  1366. condition += " and ParentNav like '," + TopUserId + ",%'";
  1367. }
  1368. Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("Users", Fields, "Id desc", "True", page, limit, condition);
  1369. List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
  1370. foreach (Dictionary<string, object> dic in diclist)
  1371. {
  1372. int ParentUserId = int.Parse(dic["ParentUserId"].ToString());
  1373. Users puser = db.Users.FirstOrDefault(m => m.Id == ParentUserId) ?? new Users();
  1374. dic["ParentMakerCode"] = puser.MakerCode;
  1375. dic["ParentRealName"] = puser.RealName;
  1376. string ParentNav = dic["ParentNav"].ToString();
  1377. if (!string.IsNullOrEmpty(ParentNav))
  1378. {
  1379. int TopId = int.Parse(ParentNav.Trim(',').Replace(",,", ",").Split(',')[0]);
  1380. Users tuser = db.Users.FirstOrDefault(m => m.Id == TopId) ?? new Users();
  1381. dic["TopMakerCode"] = tuser.MakerCode;
  1382. dic["TopRealName"] = tuser.RealName;
  1383. }
  1384. }
  1385. return Json(obj);
  1386. }
  1387. #endregion
  1388. #region 导出展业城市
  1389. public JsonResult ExportCity(Users data, string CreateDate, string ParentMakerCode, string ParentRealName, string AuthFlagSelect, int TopUserId, string RiskFlagSelect, string MerchantTypeSelect)
  1390. {
  1391. Dictionary<string, string> Fields = new Dictionary<string, string>();
  1392. Fields.Add("MakerCode", "1"); //创客编号
  1393. Fields.Add("RealName", "1"); //创客名称
  1394. Fields.Add("Mobile", "1"); //手机号
  1395. Fields.Add("CertId", "1"); //身份证号码
  1396. Fields.Add("CreateDate", "3"); //注册时间
  1397. Fields.Add("SettleAmount", "3"); //结算金额
  1398. Fields.Add("CashFreezeAmt", "3"); //冻结金额
  1399. Fields.Add("UserLevel", "0"); //创客等级
  1400. string condition = " and Status>-1";
  1401. //直属创客编号
  1402. if (!string.IsNullOrEmpty(ParentMakerCode))
  1403. {
  1404. condition += " and Id in (select UserId from UserForMakerCode where MakerCode='" + ParentMakerCode + "')";
  1405. }
  1406. //直属创客名称
  1407. if (!string.IsNullOrEmpty(ParentRealName))
  1408. {
  1409. condition += " and Id in (select UserId from UserForRealName where RealName='" + ParentRealName + "')";
  1410. }
  1411. //实名状态
  1412. if (!string.IsNullOrEmpty(AuthFlagSelect))
  1413. {
  1414. condition += " and AuthFlag=" + AuthFlagSelect;
  1415. }
  1416. //顶级创客
  1417. if (TopUserId > 0)
  1418. {
  1419. condition += " and ParentNav like '," + TopUserId + ",%'";
  1420. }
  1421. //风控标识
  1422. if (!string.IsNullOrEmpty(RiskFlagSelect))
  1423. {
  1424. condition += " and RiskFlag=" + RiskFlagSelect;
  1425. }
  1426. //商户创客类型
  1427. if (!string.IsNullOrEmpty(MerchantTypeSelect))
  1428. {
  1429. condition += " and MerchantType=" + MerchantTypeSelect;
  1430. }
  1431. 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);
  1432. List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
  1433. foreach (Dictionary<string, object> dic in diclist)
  1434. {
  1435. dic["AuthFlag"] = dic["AuthFlag"].ToString() == "1" ? "已实名" : "未实名";
  1436. dic["RiskFlag"] = dic["RiskFlag"].ToString() == "1" ? "已风控" : "未风控";
  1437. dic["UserLevel"] = RelationClass.GetUserLevelSetInfo(int.Parse(dic["UserLevel"].ToString()));
  1438. dic["MerchantType"] = RelationClassForConst.GetMerchantTypeInfo(int.Parse(dic["MerchantType"].ToString()));
  1439. int ParentUserId = int.Parse(dic["ParentUserId"].ToString());
  1440. Users puser = db.Users.FirstOrDefault(m => m.Id == ParentUserId) ?? new Users();
  1441. dic["ParentMakerCode"] = puser.MakerCode;
  1442. dic["ParentRealName"] = puser.RealName;
  1443. string ParentNav = dic["ParentNav"].ToString();
  1444. if (!string.IsNullOrEmpty(ParentNav))
  1445. {
  1446. int TopId = int.Parse(ParentNav.Trim(',').Replace(",,", ",").Split(',')[0]);
  1447. Users tuser = db.Users.FirstOrDefault(m => m.Id == TopId) ?? new Users();
  1448. dic["TopMakerCode"] = tuser.MakerCode;
  1449. dic["TopRealName"] = tuser.RealName;
  1450. }
  1451. dic.Remove("ParentUserId");
  1452. dic.Remove("ParentNav");
  1453. }
  1454. Dictionary<string, object> result = new Dictionary<string, object>();
  1455. result.Add("Status", "1");
  1456. result.Add("Info", "Excel报表-" + DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss") + ".xlsx");
  1457. result.Add("Obj", diclist);
  1458. Dictionary<string, object> ReturnFields = new Dictionary<string, object>();
  1459. ReturnFields.Add("MakerCode", "创客编号");
  1460. ReturnFields.Add("RealName", "创客姓名");
  1461. ReturnFields.Add("UserLevel", "创客等级");
  1462. ReturnFields.Add("SettleAmount", "提现金额(元)");
  1463. ReturnFields.Add("CashFreezeAmt", "冻结金额(元)");
  1464. ReturnFields.Add("CertId", "身份证号");
  1465. ReturnFields.Add("Mobile", "联系手机");
  1466. ReturnFields.Add("MerchantType", "商户创客类型");
  1467. ReturnFields.Add("MerchantDate", "成为商户创客时间");
  1468. ReturnFields.Add("ParentMakerCode", "直属创客编号");
  1469. ReturnFields.Add("ParentRealName", "直属创客名称");
  1470. ReturnFields.Add("TopMakerCode", "顶级创客编号");
  1471. ReturnFields.Add("TopRealName", "顶级创客名称");
  1472. ReturnFields.Add("AuthFlag", "实名状态");
  1473. ReturnFields.Add("RiskFlag", "风控状态");
  1474. ReturnFields.Add("CreateDate", "注册时间");
  1475. result.Add("Fields", ReturnFields);
  1476. AddSysLog("0", "Users", "ExportExcel");
  1477. return Json(result);
  1478. }
  1479. #endregion
  1480. #region 根据条件查询直属创客交易额列表
  1481. /// <summary>
  1482. /// 直属创客交易额列表
  1483. /// </summary>
  1484. /// <returns></returns>
  1485. public IActionResult Children(Users data, string right, int ParentId = 0, string MakerCode = "")
  1486. {
  1487. ViewBag.RightInfo = RightInfo;
  1488. ViewBag.right = right;
  1489. ViewBag.ParentId = ParentId.ToString();
  1490. ViewBag.MakerCode = MakerCode;
  1491. List<Users> TopUsers = db.Users.Where(m => m.ParentUserId == 0).ToList();
  1492. ViewBag.TopUsers = TopUsers;
  1493. List<UserLevelSet> Levels = db.UserLevelSet.OrderBy(m => m.Id).ToList();
  1494. ViewBag.Levels = Levels;
  1495. List<KqProducts> Brands = db.KqProducts.OrderBy(m => m.Id).ToList();
  1496. ViewBag.Brands = Brands;
  1497. return View();
  1498. }
  1499. #endregion
  1500. #region 根据条件查询直属创客交易额列表
  1501. /// <summary>
  1502. /// 直属创客交易额列表
  1503. /// </summary>
  1504. /// <returns></returns>
  1505. public JsonResult ChildrenData(Users data, int BrandSelect, string MakerCode, string CreateDateData, int ParentId = 0, int page = 1, int limit = 30)
  1506. {
  1507. Dictionary<string, string> Fields = new Dictionary<string, string>();
  1508. WebCMSEntities db = new WebCMSEntities();
  1509. Fields.Add("MakerCode", "1"); //创客编号
  1510. int BrandId = BrandSelect;
  1511. string start = "";
  1512. string end = "";
  1513. string condition = " and Status>-1 and AuthFlag >0";
  1514. string con = " and Status>-1";
  1515. string cons = " and Status>=-1";
  1516. string sort = "Id desc";
  1517. //创客编号
  1518. if (!string.IsNullOrEmpty(MakerCode))
  1519. {
  1520. condition += " and Id in (select UserId from UserForMakerCode where MakerCode='" + MakerCode + "')";
  1521. }
  1522. if (ParentId > 0)
  1523. {
  1524. condition += " and ParentUserId=" + ParentId + " or Id=" + ParentId;
  1525. }
  1526. //时间不为空
  1527. if (!string.IsNullOrEmpty(CreateDateData))
  1528. {
  1529. string[] datelist = CreateDateData.Split(new string[] { " - " }, StringSplitOptions.None);
  1530. start = datelist[0].Replace("-", "");
  1531. end = datelist[1].Replace("-", "");
  1532. con += " and TradeDate>='" + start + "' and TradeDate<='" + end + "'";
  1533. cons += " and SeoKeyword >=" + start + " and SeoKeyword <=" + end;
  1534. }
  1535. //时间为空
  1536. else
  1537. {
  1538. start = DateTime.Now.ToString("yyyyMM") + "01";
  1539. end = DateTime.Now.AddMonths(1).ToString("yyyyMM") + "01";
  1540. con += " and TradeDate>='" + start + "' and TradeDate<'" + end + "'";
  1541. cons += " and SeoKeyword >=" + start + " and SeoKeyword <" + end;
  1542. }
  1543. if (!string.IsNullOrEmpty(BrandSelect.ToString()) && BrandId > 0)
  1544. {
  1545. con += " and BrandId='" + BrandId + "'";
  1546. cons += " and BrandId='" + BrandId + "'";
  1547. }
  1548. Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("Users", Fields, sort, "True", page, limit, condition);
  1549. List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
  1550. foreach (Dictionary<string, object> dic in diclist)
  1551. {
  1552. int UId = int.Parse(dic["Id"].ToString());
  1553. var Info = GetMonthTradeForBrand(UId, start, end, BrandId);
  1554. dic["TotalAmtfc"] = Convert.ToDecimal(Info["TotalAmtfc"].ToString()) + Convert.ToDecimal(Info["YAmtfc"].ToString());
  1555. dic["DAmtfc"] = Convert.ToDecimal(Info["DAmtfc"].ToString());
  1556. dic["JAmtfc"] = Convert.ToDecimal(Info["JAmtfc"].ToString());
  1557. dic["JfAmtfc"] = Convert.ToDecimal(Info["JfAmtfc"].ToString());
  1558. dic["JCountfc"] = Convert.ToInt32(Info["JCountfc"].ToString());
  1559. dic["YAmtfc"] = Convert.ToDecimal(Info["YAmtfc"].ToString());
  1560. dic["TotalAmtwd"] = Convert.ToDecimal(Info["TotalAmtwd"].ToString()) + Convert.ToDecimal(Info["YAmtwd"].ToString());
  1561. dic["DAmtwd"] = Convert.ToDecimal(Info["DAmtwd"].ToString());
  1562. dic["JAmtwd"] = Convert.ToDecimal(Info["JAmtwd"].ToString());
  1563. dic["JfAmtwd"] = Convert.ToDecimal(Info["JfAmtwd"].ToString());
  1564. dic["JCountwd"] = Convert.ToInt32(Info["JCountwd"].ToString());
  1565. dic["YAmtwd"] = Convert.ToDecimal(Info["YAmtwd"].ToString());
  1566. dic["TotalAmtyl"] = Convert.ToDecimal(Info["TotalAmtyl"].ToString()) + Convert.ToDecimal(Info["YAmtyl"].ToString());
  1567. dic["DAmtyl"] = Convert.ToDecimal(Info["DAmtyl"].ToString());
  1568. dic["JAmtyl"] = Convert.ToDecimal(Info["JAmtyl"].ToString());
  1569. dic["JfAmtyl"] = Convert.ToDecimal(Info["JfAmtyl"].ToString());
  1570. dic["JCountyl"] = Convert.ToInt32(Info["JCountyl"].ToString());
  1571. dic["YAmtyl"] = Convert.ToDecimal(Info["YAmtyl"].ToString());
  1572. dic["TBCount"] = Info["TBCount"].ToString();
  1573. dic["TACount"] = Info["TACount"].ToString();
  1574. }
  1575. //个人
  1576. //扶持期
  1577. decimal TotalAmtfc = 0;
  1578. decimal DAmtfc = 0;
  1579. decimal JAmtfc = 0;
  1580. decimal JfAmtfc = 0;
  1581. int JCountfc = 0;
  1582. decimal YAmtfc = 0;
  1583. //稳定期
  1584. decimal TotalAmtwd = 0;
  1585. decimal DAmtwd = 0;
  1586. decimal JAmtwd = 0;
  1587. decimal JfAmtwd = 0;
  1588. int JCountwd = 0;
  1589. decimal YAmtwd = 0;
  1590. //盈利期
  1591. decimal TotalAmtyl = 0;
  1592. decimal DAmtyl = 0;
  1593. decimal JAmtyl = 0;
  1594. decimal JfAmtyl = 0;
  1595. int JCountyl = 0;
  1596. decimal YAmtyl = 0;
  1597. //团队
  1598. //扶持期
  1599. decimal TotalAmtfc1 = 0;
  1600. decimal DAmtfc1 = 0;
  1601. decimal JAmtfc1 = 0;
  1602. decimal JfAmtfc1 = 0;
  1603. int JCountfc1 = 0;
  1604. decimal YAmtfc1 = 0;
  1605. //稳定期
  1606. decimal TotalAmtwd1 = 0;
  1607. decimal DAmtwd1 = 0;
  1608. decimal JAmtwd1 = 0;
  1609. decimal JfAmtwd1 = 0;
  1610. int JCountwd1 = 0;
  1611. decimal YAmtwd1 = 0;
  1612. //盈利期
  1613. decimal TotalAmtyl1 = 0;
  1614. decimal DAmtyl1 = 0;
  1615. decimal JAmtyl1 = 0;
  1616. decimal JfAmtyl1 = 0;
  1617. int JCountyl1 = 0;
  1618. decimal YAmtyl1 = 0;
  1619. int PBCount = 0;
  1620. int PACount = 0;
  1621. int TBCount = 0;
  1622. int TACount = 0;
  1623. Dictionary<string, object> other = new Dictionary<string, object>();
  1624. 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);
  1625. if (dt.Rows.Count > 0)
  1626. {
  1627. TotalAmtfc = Convert.ToDecimal(function.CheckNum(dt.Rows[0][0].ToString()));
  1628. DAmtfc = Convert.ToDecimal(function.CheckNum(dt.Rows[0][1].ToString()));
  1629. JAmtfc = Convert.ToDecimal(function.CheckNum(dt.Rows[0][2].ToString()));
  1630. JfAmtfc = Convert.ToDecimal(function.CheckNum(dt.Rows[0][3].ToString()));
  1631. JCountfc = Convert.ToInt32(function.CheckInt(dt.Rows[0][4].ToString()));
  1632. YAmtfc = Convert.ToDecimal(function.CheckNum(dt.Rows[0][5].ToString()));
  1633. TotalAmtwd = Convert.ToDecimal(function.CheckNum(dt.Rows[0][6].ToString()));
  1634. DAmtwd = Convert.ToDecimal(function.CheckNum(dt.Rows[0][7].ToString()));
  1635. JAmtwd = Convert.ToDecimal(function.CheckNum(dt.Rows[0][8].ToString()));
  1636. JfAmtwd = Convert.ToDecimal(function.CheckNum(dt.Rows[0][9].ToString()));
  1637. JCountwd = Convert.ToInt32(function.CheckInt(dt.Rows[0][10].ToString()));
  1638. YAmtwd = Convert.ToDecimal(function.CheckNum(dt.Rows[0][11].ToString()));
  1639. TotalAmtyl = Convert.ToDecimal(function.CheckNum(dt.Rows[0][12].ToString()));
  1640. DAmtyl = Convert.ToDecimal(function.CheckNum(dt.Rows[0][13].ToString()));
  1641. JAmtyl = Convert.ToDecimal(function.CheckNum(dt.Rows[0][14].ToString()));
  1642. JfAmtyl = Convert.ToDecimal(function.CheckNum(dt.Rows[0][15].ToString()));
  1643. JCountyl = Convert.ToInt32(function.CheckInt(dt.Rows[0][16].ToString()));
  1644. YAmtyl = Convert.ToDecimal(function.CheckNum(dt.Rows[0][17].ToString()));
  1645. }
  1646. //统计激活数(个人、团队)
  1647. dt = OtherMySqlConn.dtable("SELECT SUM(if(SeoTitle='self',ActiveBuddyMerStatus,0)),SUM(if(SeoTitle='team',ActiveBuddyMerStatus,0)) FROM UserTradeMonthSummary WHERE UserId= " + ParentId + "" + cons);
  1648. if (dt.Rows.Count > 0)
  1649. {
  1650. PACount = Convert.ToInt32(function.CheckNum(dt.Rows[0][0].ToString()));
  1651. TACount = Convert.ToInt32(function.CheckNum(dt.Rows[0][1].ToString()));
  1652. }
  1653. 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);
  1654. if (dts.Rows.Count > 0)
  1655. {
  1656. TotalAmtfc1 = Convert.ToDecimal(function.CheckNum(dts.Rows[0][0].ToString()));
  1657. DAmtfc1 = Convert.ToDecimal(function.CheckNum(dts.Rows[0][1].ToString()));
  1658. JAmtfc1 = Convert.ToDecimal(function.CheckNum(dts.Rows[0][2].ToString()));
  1659. JfAmtfc1 = Convert.ToDecimal(function.CheckNum(dts.Rows[0][3].ToString()));
  1660. JCountfc1 = Convert.ToInt32(function.CheckInt(dts.Rows[0][4].ToString()));
  1661. YAmtfc1 = Convert.ToDecimal(function.CheckNum(dts.Rows[0][5].ToString()));
  1662. TotalAmtwd1 = Convert.ToDecimal(function.CheckNum(dts.Rows[0][6].ToString()));
  1663. DAmtwd1 = Convert.ToDecimal(function.CheckNum(dts.Rows[0][7].ToString()));
  1664. JAmtwd1 = Convert.ToDecimal(function.CheckNum(dts.Rows[0][8].ToString()));
  1665. JfAmtwd1 = Convert.ToDecimal(function.CheckNum(dts.Rows[0][9].ToString()));
  1666. JCountwd1 = Convert.ToInt32(function.CheckInt(dts.Rows[0][10].ToString()));
  1667. YAmtwd1 = Convert.ToDecimal(function.CheckNum(dts.Rows[0][11].ToString()));
  1668. TotalAmtyl1 = Convert.ToDecimal(function.CheckNum(dts.Rows[0][12].ToString()));
  1669. DAmtyl1 = Convert.ToDecimal(function.CheckNum(dts.Rows[0][13].ToString()));
  1670. JAmtyl1 = Convert.ToDecimal(function.CheckNum(dts.Rows[0][14].ToString()));
  1671. JfAmtyl1 = Convert.ToDecimal(function.CheckNum(dts.Rows[0][15].ToString()));
  1672. JCountyl1 = Convert.ToInt32(function.CheckInt(dts.Rows[0][16].ToString()));
  1673. YAmtyl1 = Convert.ToDecimal(function.CheckNum(dts.Rows[0][17].ToString()));
  1674. }
  1675. other.Add("TotalAmtfc", TotalAmtfc);
  1676. other.Add("DAmtfc", DAmtfc);
  1677. other.Add("JAmtfc", JAmtfc);
  1678. other.Add("JfAmtfc", JfAmtfc);
  1679. other.Add("JCountfc", JCountfc);
  1680. other.Add("YAmtfc", YAmtfc);
  1681. other.Add("TotalAmtwd", TotalAmtwd);
  1682. other.Add("DAmtwd", DAmtwd);
  1683. other.Add("JAmtwd", JAmtwd);
  1684. other.Add("JfAmtwd", JfAmtwd);
  1685. other.Add("JCountwd", JCountwd);
  1686. other.Add("YAmtwd", YAmtwd);
  1687. other.Add("TotalAmtyl", TotalAmtyl);
  1688. other.Add("DAmtyl", DAmtyl);
  1689. other.Add("JAmtyl", JAmtyl);
  1690. other.Add("JfAmtyl", JfAmtyl);
  1691. other.Add("JCountyl", JCountyl);
  1692. other.Add("YAmtyl", YAmtyl);
  1693. other.Add("TotalAmtfc1", TotalAmtfc1);
  1694. other.Add("DAmtfc1", DAmtfc1);
  1695. other.Add("JAmtfc1", JAmtfc1);
  1696. other.Add("JfAmtfc1", JfAmtfc1);
  1697. other.Add("JCountfc1", JCountfc1);
  1698. other.Add("YAmtfc1", YAmtfc1);
  1699. other.Add("TotalAmtwd1", TotalAmtwd1);
  1700. other.Add("DAmtwd1", DAmtwd1);
  1701. other.Add("JAmtwd1", JAmtwd1);
  1702. other.Add("JfAmtwd1", JfAmtwd1);
  1703. other.Add("JCountwd1", JCountwd1);
  1704. other.Add("YAmtwd1", YAmtwd1);
  1705. other.Add("TotalAmtyl1", TotalAmtyl1);
  1706. other.Add("DAmtyl1", DAmtyl1);
  1707. other.Add("JAmtyl1", JAmtyl1);
  1708. other.Add("JfAmtyl1", JfAmtyl1);
  1709. other.Add("JCountyl1", JCountyl1);
  1710. other.Add("YAmtyl1", YAmtyl1);
  1711. other.Add("PBCount", PBCount);
  1712. other.Add("PACount", PACount);
  1713. other.Add("TBCount", TBCount);
  1714. other.Add("TACount", TACount);
  1715. db.Dispose();
  1716. obj.Add("other", other);
  1717. return Json(obj);
  1718. }
  1719. public Dictionary<string, object> GetMonthTradeForBrand(int UserId, string sTradeDate, string eTradeDate, int BrandId)
  1720. {
  1721. WebCMSEntities db = new WebCMSEntities();
  1722. string condition = " and Status>-1";
  1723. string cons = " and Status>=-1";
  1724. //产品类型
  1725. if (!string.IsNullOrEmpty(BrandId.ToString()) && BrandId > 0)
  1726. {
  1727. condition += " and BrandId =" + BrandId;
  1728. cons += " and BrandId =" + BrandId;
  1729. }
  1730. //创客Id
  1731. if (!string.IsNullOrEmpty(UserId.ToString()))
  1732. {
  1733. condition += " and UserId =" + UserId;
  1734. }
  1735. //开始时间
  1736. if (!string.IsNullOrEmpty(sTradeDate) && !string.IsNullOrEmpty(eTradeDate))
  1737. {
  1738. condition += " and TradeDate >=" + Convert.ToInt32(sTradeDate) + " and TradeDate <=" + Convert.ToInt32(eTradeDate);
  1739. cons += " and SeoKeyword >=" + Convert.ToInt32(sTradeDate) + " and SeoKeyword <=" + Convert.ToInt32(eTradeDate);
  1740. }
  1741. //结束时间
  1742. else
  1743. {
  1744. var start = DateTime.Now.ToString("yyyyMM") + "01";
  1745. condition += " and TradeDate >=" + Convert.ToInt32(start) + " and TradeDate <=" + Convert.ToInt32(eTradeDate);
  1746. cons += " and SeoKeyword >=" + Convert.ToInt32(start) + " and SeoKeyword <=" + Convert.ToInt32(eTradeDate);
  1747. }
  1748. //扶持期
  1749. decimal TotalAmtfc = 0;
  1750. decimal DAmtfc = 0;
  1751. decimal JAmtfc = 0;
  1752. decimal JfAmtfc = 0;
  1753. int JCountfc = 0;
  1754. decimal YAmtfc = 0;
  1755. //稳定期
  1756. decimal TotalAmtwd = 0;
  1757. decimal DAmtwd = 0;
  1758. decimal JAmtwd = 0;
  1759. decimal JfAmtwd = 0;
  1760. int JCountwd = 0;
  1761. decimal YAmtwd = 0;
  1762. //盈利期
  1763. decimal TotalAmtyl = 0;
  1764. decimal DAmtyl = 0;
  1765. decimal JAmtyl = 0;
  1766. decimal JfAmtyl = 0;
  1767. int JCountyl = 0;
  1768. decimal YAmtyl = 0;
  1769. int BCount = 0;
  1770. int ACount = 0;
  1771. int PBCount = 0;
  1772. int PACount = 0;
  1773. int TBCount = 0;
  1774. int TACount = 0;
  1775. Dictionary<string, object> obj = new Dictionary<string, object>();
  1776. 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);
  1777. if (dt.Rows.Count > 0)
  1778. {
  1779. TotalAmtfc = Convert.ToDecimal(function.CheckNum(dt.Rows[0][0].ToString()));
  1780. DAmtfc = Convert.ToDecimal(function.CheckNum(dt.Rows[0][1].ToString()));
  1781. JAmtfc = Convert.ToDecimal(function.CheckNum(dt.Rows[0][2].ToString()));
  1782. JfAmtfc = Convert.ToDecimal(function.CheckNum(dt.Rows[0][3].ToString()));
  1783. JCountfc = Convert.ToInt32(function.CheckInt(dt.Rows[0][4].ToString()));
  1784. YAmtfc = Convert.ToDecimal(function.CheckNum(dt.Rows[0][5].ToString()));
  1785. TotalAmtwd = Convert.ToDecimal(function.CheckNum(dt.Rows[0][6].ToString()));
  1786. DAmtwd = Convert.ToDecimal(function.CheckNum(dt.Rows[0][7].ToString()));
  1787. JAmtwd = Convert.ToDecimal(function.CheckNum(dt.Rows[0][8].ToString()));
  1788. JfAmtwd = Convert.ToDecimal(function.CheckNum(dt.Rows[0][9].ToString()));
  1789. JCountwd = Convert.ToInt32(function.CheckInt(dt.Rows[0][10].ToString()));
  1790. YAmtwd = Convert.ToDecimal(function.CheckNum(dt.Rows[0][11].ToString()));
  1791. TotalAmtyl = Convert.ToDecimal(function.CheckNum(dt.Rows[0][12].ToString()));
  1792. DAmtyl = Convert.ToDecimal(function.CheckNum(dt.Rows[0][13].ToString()));
  1793. JAmtyl = Convert.ToDecimal(function.CheckNum(dt.Rows[0][14].ToString()));
  1794. JfAmtyl = Convert.ToDecimal(function.CheckNum(dt.Rows[0][15].ToString()));
  1795. JCountyl = Convert.ToInt32(function.CheckInt(dt.Rows[0][16].ToString()));
  1796. YAmtyl = Convert.ToDecimal(function.CheckNum(dt.Rows[0][17].ToString()));
  1797. }
  1798. //统计激活数(个人、团队)
  1799. dt = OtherMySqlConn.dtable("SELECT SUM(if(SeoTitle='team',ActiveBuddyMerStatus,0)) FROM UserTradeMonthSummary WHERE UserId= " + UserId + "" + cons);
  1800. if (dt.Rows.Count > 0)
  1801. {
  1802. TACount = Convert.ToInt32(function.CheckNum(dt.Rows[0][0].ToString()));
  1803. }
  1804. obj.Add("TotalAmtfc", TotalAmtfc);
  1805. obj.Add("DAmtfc", DAmtfc);
  1806. obj.Add("JAmtfc", JAmtfc);
  1807. obj.Add("JfAmtfc", JfAmtfc);
  1808. obj.Add("JCountfc", JCountfc);
  1809. obj.Add("YAmtfc", YAmtfc);
  1810. obj.Add("TotalAmtwd", TotalAmtwd);
  1811. obj.Add("DAmtwd", DAmtwd);
  1812. obj.Add("JAmtwd", JAmtwd);
  1813. obj.Add("JfAmtwd", JfAmtwd);
  1814. obj.Add("JCountwd", JCountwd);
  1815. obj.Add("YAmtwd", YAmtwd);
  1816. obj.Add("TotalAmtyl", TotalAmtyl);
  1817. obj.Add("DAmtyl", DAmtyl);
  1818. obj.Add("JAmtyl", JAmtyl);
  1819. obj.Add("JfAmtyl", JfAmtyl);
  1820. obj.Add("JCountyl", JCountyl);
  1821. obj.Add("YAmtyl", YAmtyl);
  1822. obj.Add("BCount", BCount);
  1823. obj.Add("ACount", ACount);
  1824. obj.Add("PBCount", PBCount);
  1825. obj.Add("PACount", PACount);
  1826. obj.Add("TBCount", TBCount);
  1827. obj.Add("TACount", TACount);
  1828. db.Dispose();
  1829. return obj;
  1830. }
  1831. #endregion
  1832. #region 未实名创客列表
  1833. /// <summary>
  1834. /// 根据条件查询未实名创客列表
  1835. /// </summary>
  1836. /// <returns></returns>
  1837. public IActionResult AuthIndex(Users data, string right)
  1838. {
  1839. ViewBag.RightInfo = RightInfo;
  1840. ViewBag.right = right;
  1841. return View();
  1842. }
  1843. #endregion
  1844. #region 根据条件查询未实名创客列表
  1845. /// <summary>
  1846. /// 未实名创客列表
  1847. /// </summary>
  1848. /// <returns></returns>
  1849. public JsonResult AuthIndexData(Users data, int page = 1, int limit = 30)
  1850. {
  1851. Dictionary<string, string> Fields = new Dictionary<string, string>();
  1852. Fields.Add("MakerCode", "1"); //创客编号
  1853. string condition = " and Status>-1 and AuthFlag=0 and RealName is not null and CertId is not null and SettleBankCardNo is not null and SettleBankName is not null";
  1854. string sort = "Id desc";
  1855. Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("Users", Fields, sort, "True", page, limit, condition);
  1856. List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
  1857. foreach (Dictionary<string, object> dic in diclist)
  1858. {
  1859. dic["AuthFlagName"] = dic["AuthFlag"].ToString() == "1" ? "已实名" : "未实名";
  1860. dic["RiskFlagName"] = dic["RiskFlag"].ToString() == "1" ? "已风控" : "未风控";
  1861. dic["UserLevel"] = RelationClass.GetUserLevelSetInfo(int.Parse(dic["UserLevel"].ToString()));
  1862. dic["MerchantType"] = RelationClassForConst.GetMerchantTypeInfo(int.Parse(dic["MerchantType"].ToString()));
  1863. int ParentUserId = int.Parse(dic["ParentUserId"].ToString());
  1864. Users puser = db.Users.FirstOrDefault(m => m.Id == ParentUserId) ?? new Users();
  1865. dic["ParentMakerCode"] = puser.MakerCode;
  1866. dic["ParentRealName"] = puser.RealName;
  1867. string ParentNav = dic["ParentNav"].ToString();
  1868. if (!string.IsNullOrEmpty(ParentNav))
  1869. {
  1870. string[] list = ParentNav.Trim(',').Replace(",,", ",").Split(',');
  1871. if (list.Length > 1)
  1872. {
  1873. int TopId = int.Parse(function.CheckInt(list[1]));
  1874. Users tuser = db.Users.FirstOrDefault(m => m.Id == TopId) ?? new Users();
  1875. dic["TopMakerCode"] = tuser.MakerCode;
  1876. dic["TopRealName"] = tuser.RealName;
  1877. }
  1878. }
  1879. }
  1880. return Json(obj);
  1881. }
  1882. #endregion
  1883. #region 认证
  1884. /// <summary>
  1885. /// 认证
  1886. /// </summary>
  1887. /// <returns></returns>
  1888. public string Auth(string Id)
  1889. {
  1890. string[] idlist = Id.Split(new char[] { ',' });
  1891. AddSysLog(Id, "Users", "Auth");
  1892. foreach (string subid in idlist)
  1893. {
  1894. int id = int.Parse(subid);
  1895. Dictionary<string, object> Fields = new Dictionary<string, object>();
  1896. Fields.Add("AuthFlag", 1);
  1897. Fields.Add("AuthDate", DateTime.Now);
  1898. new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("Users", Fields, id);
  1899. }
  1900. db.SaveChanges();
  1901. return "success";
  1902. }
  1903. #endregion
  1904. #region 修改盟主金额
  1905. public IActionResult ChangeLeaderAmount(string right, int Id = 0)
  1906. {
  1907. ViewBag.RightInfo = RightInfo;
  1908. ViewBag.right = right;
  1909. Users editData = db.Users.FirstOrDefault(m => m.Id == Id) ?? new Users();
  1910. ViewBag.data = editData;
  1911. return View();
  1912. }
  1913. #endregion
  1914. #region 修改盟主金额
  1915. [HttpPost]
  1916. public string ChangeLeaderAmount(Users data, string ChangeAmount, int AmountType, string Note, int Kind)
  1917. {
  1918. int UserId = data.Id;
  1919. var Amount = Convert.ToDecimal(ChangeAmount);
  1920. UserAccount account = db.UserAccount.FirstOrDefault(m => m.Id == UserId);
  1921. if (account == null)
  1922. {
  1923. account = db.UserAccount.Add(new UserAccount()
  1924. {
  1925. Id = UserId,
  1926. UserId = UserId,
  1927. }).Entity;
  1928. db.SaveChanges();
  1929. }
  1930. //盟主储蓄金
  1931. if (AmountType == 1)
  1932. {
  1933. if ((Kind == 1 || Kind == 3) && Amount > account.LeaderReserve)
  1934. {
  1935. return "盟主储蓄金不足";
  1936. }
  1937. decimal BeforeLeaderReserve = account.LeaderReserve; //变更前盟主储蓄金
  1938. decimal BeforeLeaderBalanceAmount = account.LeaderBalanceAmount; //变更前盟主可提现余额
  1939. int ChangeType = 0;
  1940. if (Kind == 1 && Amount <= account.LeaderReserve)
  1941. {
  1942. account.LeaderReserve -= Amount;
  1943. account.TotalProfit += Amount;
  1944. string text = string.Format("修改盟主金额,操作人: '" + SysUserName + "_" + SysRealName + "',操作类型: '系统冻结(盟主储蓄金)',Time'" + DateTime.Now + "'");
  1945. function.WriteLog(text, "ChangeLeaderAmount");//修改盟主金额
  1946. }
  1947. else if (Kind == 1 && Amount > account.LeaderReserve)
  1948. {
  1949. return "冻结金额大于盟主储蓄金";
  1950. }
  1951. else if (Kind == 2 && Amount <= account.TotalProfit)
  1952. {
  1953. account.LeaderReserve += Amount;
  1954. account.TotalProfit -= Amount;
  1955. string text = string.Format("修改盟主金额,操作人: '" + SysUserName + "_" + SysRealName + "',操作类型: '系统解冻(盟主储蓄金)',Time'" + DateTime.Now + "'");
  1956. function.WriteLog(text, "ChangeLeaderAmount");//修改盟主金额
  1957. }
  1958. else if (Kind == 2 && Amount > account.TotalProfit)
  1959. {
  1960. return "解冻金额大于冻结金额";
  1961. }
  1962. else if (Kind == 3 && Amount <= account.LeaderReserve)
  1963. {
  1964. account.LeaderReserve -= Amount;
  1965. ChangeType = 4;
  1966. decimal AfterLeaderReserve = account.LeaderReserve; //变更后盟主储蓄金
  1967. decimal AfterLeaderBalanceAmount = account.LeaderBalanceAmount; //变更后盟主可提现余额
  1968. var query = db.LeaderReserveRecord.Add(new LeaderReserveRecord()
  1969. {
  1970. CreateDate = DateTime.Now, //创建时间
  1971. UserId = UserId, //创客
  1972. Remark = "系统扣减(盟主储蓄金)",
  1973. ChangeType = ChangeType,
  1974. BeforeAmt = BeforeLeaderReserve,
  1975. AfterAmt = AfterLeaderReserve,
  1976. ChangeAmt = Amount,
  1977. TradeDate = DateTime.Now.ToString("yyyyMMdd"),
  1978. TradeMonth = DateTime.Now.ToString("yyyyMM"),
  1979. }).Entity;
  1980. db.SaveChanges();
  1981. string text = string.Format("修改盟主金额,操作人: '" + SysUserName + "_" + SysRealName + "',操作类型: '系统扣减(盟主储蓄金)',Time'" + DateTime.Now + "'");
  1982. function.WriteLog(text, "ChangeLeaderAmount");//修改盟主金额
  1983. }
  1984. else if (Kind == 3 && Amount > account.LeaderReserve)
  1985. {
  1986. return "扣减金额大于盟主储蓄金";
  1987. }
  1988. else if (Kind == 4)
  1989. {
  1990. account.LeaderReserve += Amount;
  1991. ChangeType = 1;
  1992. decimal AfterLeaderReserve = account.LeaderReserve; //变更后总金额
  1993. decimal AfterLeaderBalanceAmount = account.LeaderBalanceAmount; //变更后冻结金额
  1994. var query = db.LeaderReserveRecord.Add(new LeaderReserveRecord()
  1995. {
  1996. CreateDate = DateTime.Now, //创建时间
  1997. UserId = UserId, //创客
  1998. Remark = "系统增加(盟主储蓄金)",
  1999. ChangeType = ChangeType,
  2000. BeforeAmt = BeforeLeaderReserve,
  2001. AfterAmt = AfterLeaderReserve,
  2002. ChangeAmt = Amount,
  2003. TradeDate = DateTime.Now.ToString("yyyyMMdd"),
  2004. TradeMonth = DateTime.Now.ToString("yyyyMM"),
  2005. }).Entity;
  2006. db.SaveChanges();
  2007. string text = string.Format("修改盟主金额,操作人: '" + SysUserName + "_" + SysRealName + "',操作类型: '系统增加(盟主储蓄金)',Time'" + DateTime.Now + "'");
  2008. function.WriteLog(text, "ChangeLeaderAmount");//修改盟主金额
  2009. }
  2010. AddSysLog(data.Id.ToString(), "Users", "ChangeLeaderAmount");
  2011. db.SaveChanges();
  2012. }
  2013. //盟主可提现余额
  2014. if (AmountType == 2)
  2015. {
  2016. if ((Kind == 1 || Kind == 3) && Amount > account.LeaderBalanceAmount)
  2017. {
  2018. return "盟主可提现余额不足";
  2019. }
  2020. decimal BeforeLeaderReserve = account.LeaderReserve; //变更前盟主储蓄金
  2021. decimal BeforeLeaderBalanceAmount = account.LeaderBalanceAmount; //变更前盟主可提现余额
  2022. int ChangeType = 0;
  2023. if (Kind == 1 && Amount <= account.LeaderReserve)
  2024. {
  2025. account.LeaderBalanceAmount -= Amount;
  2026. account.TotalServiceProfit += Amount;
  2027. string text = string.Format("修改盟主金额,操作人: '" + SysUserName + "_" + SysRealName + "',操作类型: '系统冻结(盟主可提现余额)',Time'" + DateTime.Now + "'");
  2028. function.WriteLog(text, "ChangeLeaderAmount");//修改盟主金额
  2029. }
  2030. else if (Kind == 1 && Amount > account.LeaderBalanceAmount)
  2031. {
  2032. return "冻结金额大于盟主可提现余额";
  2033. }
  2034. else if (Kind == 2 && Amount <= account.TotalServiceProfit)
  2035. {
  2036. account.LeaderBalanceAmount += Amount;
  2037. account.TotalServiceProfit -= Amount;
  2038. string text = string.Format("修改盟主金额,操作人: '" + SysUserName + "_" + SysRealName + "',操作类型: '系统解冻(盟主可提现余额)',Time'" + DateTime.Now + "'");
  2039. function.WriteLog(text, "ChangeLeaderAmount");//修改盟主金额
  2040. }
  2041. else if (Kind == 2 && Amount > account.TotalServiceProfit)
  2042. {
  2043. return "解冻金额大于冻结金额";
  2044. }
  2045. else if (Kind == 3 && Amount <= account.LeaderBalanceAmount)
  2046. {
  2047. account.LeaderBalanceAmount -= Amount;
  2048. ChangeType = 6;
  2049. decimal AfterLeaderReserve = account.LeaderReserve; //变更后总金额
  2050. decimal AfterLeaderBalanceAmount = account.LeaderBalanceAmount; //变更后冻结金额
  2051. var query = db.LeaderReserveRecord.Add(new LeaderReserveRecord()
  2052. {
  2053. CreateDate = DateTime.Now, //创建时间
  2054. UserId = UserId, //创客
  2055. Remark = "系统扣减(盟主可提现余额)",
  2056. ChangeType = ChangeType,
  2057. BeforeAmt = BeforeLeaderBalanceAmount,
  2058. AfterAmt = AfterLeaderBalanceAmount,
  2059. ChangeAmt = Amount,
  2060. TradeDate = DateTime.Now.ToString("yyyyMMdd"),
  2061. TradeMonth = DateTime.Now.ToString("yyyyMM"),
  2062. }).Entity;
  2063. db.SaveChanges();
  2064. string text = string.Format("修改盟主金额,操作人: '" + SysUserName + "_" + SysRealName + "',操作类型: '系统扣减(盟主可提现余额)',Time'" + DateTime.Now + "'");
  2065. function.WriteLog(text, "ChangeLeaderAmount");//修改盟主金额
  2066. }
  2067. else if (Kind == 3 && Amount > account.LeaderBalanceAmount)
  2068. {
  2069. return "扣减金额大于盟主可提现余额";
  2070. }
  2071. else if (Kind == 4)
  2072. {
  2073. account.LeaderBalanceAmount += Amount;
  2074. ChangeType = 5;
  2075. decimal AfterLeaderReserve = account.LeaderReserve; //变更后总金额
  2076. decimal AfterLeaderBalanceAmount = account.LeaderBalanceAmount; //变更后冻结金额
  2077. var query = db.LeaderReserveRecord.Add(new LeaderReserveRecord()
  2078. {
  2079. CreateDate = DateTime.Now, //创建时间
  2080. UserId = UserId, //创客
  2081. Remark = "系统增加(盟主可提现余额)",
  2082. ChangeType = ChangeType,
  2083. BeforeAmt = BeforeLeaderBalanceAmount,
  2084. AfterAmt = AfterLeaderBalanceAmount,
  2085. ChangeAmt = Amount,
  2086. TradeDate = DateTime.Now.ToString("yyyyMMdd"),
  2087. TradeMonth = DateTime.Now.ToString("yyyyMM"),
  2088. }).Entity;
  2089. db.SaveChanges();
  2090. string text = string.Format("修改盟主金额,操作人: '" + SysUserName + "_" + SysRealName + "',操作类型: '系统增加(盟主可提现余额)',Time'" + DateTime.Now + "'");
  2091. function.WriteLog(text, "ChangeLeaderAmount");//修改盟主金额
  2092. }
  2093. AddSysLog(data.Id.ToString(), "Users", "ChangeLeaderAmount");
  2094. db.SaveChanges();
  2095. }
  2096. return "success";
  2097. }
  2098. #endregion
  2099. #region 伞下创客列表
  2100. /// <summary>
  2101. /// 根据条件查询伞下创客列表
  2102. /// </summary>
  2103. /// <returns></returns>
  2104. public IActionResult SanIndex(Users data, string right)
  2105. {
  2106. ViewBag.RightInfo = RightInfo;
  2107. ViewBag.right = right;
  2108. List<Users> TopUsers = db.Users.Where(m => m.ParentUserId == 0).ToList();
  2109. ViewBag.TopUsers = TopUsers;
  2110. List<UserLevelSet> Levels = db.UserLevelSet.OrderBy(m => m.Id).ToList();
  2111. ViewBag.Levels = Levels;
  2112. return View();
  2113. }
  2114. #endregion
  2115. #region 根据条件查询伞下创客列表
  2116. /// <summary>
  2117. /// 伞下创客列表
  2118. /// </summary>
  2119. /// <returns></returns>
  2120. public JsonResult SanIndexData(Users data, string MakerCode, string IsLeader, string IsOp, string CreateDateData, string UserYsLevel, string UserLevel, int ShowFlag = 0, int page = 1, int limit = 30)
  2121. {
  2122. Dictionary<string, string> Fields = new Dictionary<string, string>();
  2123. if (ShowFlag == 0)
  2124. {
  2125. Dictionary<string, object> objs = new Dictionary<string, object>();
  2126. return Json(objs);
  2127. }
  2128. string condition = " and Status>-1";
  2129. //创客编号
  2130. if (!string.IsNullOrEmpty(MakerCode))
  2131. {
  2132. var userForMakerCode = db.UserForMakerCode.FirstOrDefault(m => m.MakerCode == MakerCode) ?? new UserForMakerCode();
  2133. if (userForMakerCode.UserId == 0)
  2134. {
  2135. return Json(new AppResultJson() { Status = "-1", Info = "未找到创客" + MakerCode + "关联数据", Data = "" });
  2136. }
  2137. var user = db.Users.FirstOrDefault(m => m.Id == userForMakerCode.UserId) ?? new Users();
  2138. if (user.Id == 0)
  2139. {
  2140. return Json(new AppResultJson() { Status = "-1", Info = "创客" + MakerCode + "不存在", Data = "" });
  2141. }
  2142. condition += " and ParentNav like '%," + user.Id + ",%'";
  2143. }
  2144. if (!string.IsNullOrEmpty(IsLeader))
  2145. {
  2146. condition += " and LeaderLevel=" + IsLeader;
  2147. }
  2148. if (!string.IsNullOrEmpty(UserYsLevel))
  2149. {
  2150. var UserIds = "";
  2151. var Rank = int.Parse(UserYsLevel);
  2152. var list = db.UserRankWhite.Where(m => m.Status > -1 && m.Rank == Rank).ToList();
  2153. foreach (var item in list)
  2154. {
  2155. UserIds += item.UserId + ",";
  2156. }
  2157. UserIds = UserIds.TrimEnd(',');
  2158. condition += " and Id IN(" + UserIds + ")";
  2159. }
  2160. if (!string.IsNullOrEmpty(UserLevel))
  2161. {
  2162. condition += " and UserLevel=" + UserLevel;
  2163. }
  2164. if (!string.IsNullOrEmpty(IsOp))
  2165. {
  2166. var UserIds = "";
  2167. DataTable dt = CustomerSqlConn.dtable("SELECT UserId FROM SysAdmin WHERE Status>-1 and Sort>0 and QueryCount>0 and AdminName!='admin'", OpConn);
  2168. foreach (DataRow item in dt.Rows)
  2169. {
  2170. UserIds += item["UserId"].ToString() + ",";
  2171. }
  2172. UserIds = UserIds.TrimEnd(',');
  2173. if (IsOp == "1")
  2174. {
  2175. condition += " and Id IN(" + UserIds + ")";
  2176. }
  2177. if (IsOp == "2")
  2178. {
  2179. condition += " and Id NOT IN(" + UserIds + ")";
  2180. }
  2181. }
  2182. if (!string.IsNullOrEmpty(CreateDateData))
  2183. {
  2184. string[] datelist = CreateDateData.Split(new string[] { " - " }, StringSplitOptions.None);
  2185. string start = datelist[0];
  2186. string end = datelist[1];
  2187. condition += " and CreateDate>='" + start + " 00:00:00' and CreateDate<='" + end + " 23:59:59'";
  2188. }
  2189. Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("Users", Fields, "Id desc", "True", page, limit, condition);
  2190. List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
  2191. foreach (Dictionary<string, object> dic in diclist)
  2192. {
  2193. dic["AuthFlagName"] = dic["AuthFlag"].ToString() == "1" ? "已实名" : "未实名";
  2194. dic["RiskFlagName"] = dic["RiskFlag"].ToString() == "1" ? "已风控" : "未风控";
  2195. dic["UserLevel"] = RelationClass.GetUserLevelSetInfo(int.Parse(dic["UserLevel"].ToString()));
  2196. int UserId = int.Parse(dic["Id"].ToString());
  2197. int ParentUserId = int.Parse(dic["ParentUserId"].ToString());
  2198. Users puser = db.Users.FirstOrDefault(m => m.Id == ParentUserId) ?? new Users();
  2199. dic["ParentMakerCode"] = puser.MakerCode;
  2200. dic["ParentRealName"] = puser.RealName;
  2201. var userRankWhite = db.UserRankWhite.FirstOrDefault(m => m.UserId == UserId) ?? new UserRankWhite();
  2202. dic["UserYsLevel"] = RelationClass.GetUserLevelSetInfo(userRankWhite.Rank);
  2203. int LeaderLevel = int.Parse(dic["LeaderLevel"].ToString());
  2204. if (LeaderLevel == 1)
  2205. {
  2206. dic["IsLeader"] = "小盟主";
  2207. }
  2208. else if (LeaderLevel == 2)
  2209. {
  2210. dic["IsLeader"] = "大盟主";
  2211. }
  2212. else
  2213. {
  2214. dic["IsLeader"] = "";
  2215. }
  2216. var sysAdmin = opdb.SysAdmin.FirstOrDefault(m => m.Status > -1 && m.Sort > 0 && m.QueryCount > 0 && m.AdminName != "admin" && m.UserId == UserId) ?? new OpModels.SysAdmin();
  2217. if (sysAdmin.Id > 0)
  2218. {
  2219. dic["IsOp"] = sysAdmin.OpCode;
  2220. }
  2221. else
  2222. {
  2223. dic["IsOp"] = "";
  2224. }
  2225. dic["MerchantType"] = RelationClassForConst.GetMerchantTypeInfo(int.Parse(dic["MerchantType"].ToString()));
  2226. }
  2227. return Json(obj);
  2228. }
  2229. #endregion
  2230. #region 重置小分仓额度
  2231. /// <summary>
  2232. /// 重置小分仓额度
  2233. /// </summary>
  2234. /// <returns></returns>
  2235. public string SycnAmountData(int Id = 0)
  2236. {
  2237. if (Id > 0)
  2238. {
  2239. var userAccount = db.UserAccount.FirstOrDefault(m => m.Id == Id) ?? new UserAccount();
  2240. RedisDbconn.Instance.AddList("ResetSmallStoreByUserIdQueue", userAccount.Id);
  2241. }
  2242. AddSysLog(Id, "UserAccount", "SycnAmountData");
  2243. db.SaveChanges();
  2244. return "success";
  2245. }
  2246. #endregion
  2247. #region 批量查询创客信息
  2248. public IActionResult BatchSeeUserInfo(string right)
  2249. {
  2250. ViewBag.RightInfo = RightInfo;
  2251. ViewBag.right = right;
  2252. return View();
  2253. }
  2254. #endregion
  2255. #region 批量查询创客信息
  2256. public JsonResult BatchSeeUserInfoDo(string PosSns, string MerNos, int page = 1, int limit = 30)
  2257. {
  2258. var error = "";
  2259. //实际押金
  2260. Dictionary<string, object> errorInfo = new Dictionary<string, object>();
  2261. List<Dictionary<string, object>> dataList = new List<Dictionary<string, object>>();
  2262. if (string.IsNullOrEmpty(PosSns) && string.IsNullOrEmpty(MerNos))
  2263. {
  2264. Dictionary<string, object> objs = new Dictionary<string, object>();
  2265. return Json(objs);
  2266. }
  2267. else if (!string.IsNullOrEmpty(PosSns) && !string.IsNullOrEmpty(MerNos))
  2268. {
  2269. Dictionary<string, object> objs = new Dictionary<string, object>();
  2270. return Json(objs);
  2271. }
  2272. else
  2273. {
  2274. if (!string.IsNullOrEmpty(PosSns))
  2275. {
  2276. string[] PosSnsList = PosSns.Replace("\r", "").Replace("\n", ",").Replace(" ", ",").Split(',');
  2277. foreach (string PosSn in PosSnsList)
  2278. {
  2279. string SeoKeyword = "0";
  2280. Dictionary<string, object> data = new Dictionary<string, object>();
  2281. var pos = db.PosMachinesTwo.FirstOrDefault(m => m.PosSn == PosSn) ?? new PosMachinesTwo();
  2282. if (pos.Id > 0)
  2283. {
  2284. // error += "机具" + PosSn + "不存在" + '\n';
  2285. // }
  2286. // else
  2287. // {
  2288. var TopMakerCode = ""; //顶级创客编号
  2289. var TopRealName = ""; //顶级创客名称
  2290. var SecondMakerCode = ""; //次顶级创客编号
  2291. var SecondRealName = ""; //次顶级创客姓名
  2292. var ThirdMakerCode = ""; //次次顶级创客编号
  2293. var ThirdRealName = ""; //次次顶级创客姓名
  2294. var mer = db.PosMerchantInfo.FirstOrDefault(m => m.Id == pos.BindMerchantId) ?? new PosMerchantInfo();
  2295. var brand = db.KqProducts.FirstOrDefault(m => m.Id == pos.BrandId) ?? new KqProducts();
  2296. if (brand.Id > 0 && brand.SingleDepositApi == 0 && !string.IsNullOrEmpty(pos.SeoKeyword))
  2297. {
  2298. SeoKeyword = (decimal.Parse(pos.SeoKeyword) / 100).ToString();
  2299. }
  2300. else
  2301. {
  2302. SeoKeyword = pos.SeoKeyword;
  2303. }
  2304. var user = db.Users.FirstOrDefault(m => m.Id == pos.BuyUserId) ?? new Users();
  2305. var userAccount = db.UserAccount.FirstOrDefault(m => m.Id == user.Id) ?? new UserAccount();
  2306. if (!string.IsNullOrEmpty(user.ParentNav))
  2307. {
  2308. string[] ParentNavList = user.ParentNav.Trim(',').Replace(",,", ",").Split(',');
  2309. var topUserInfo = new Users();
  2310. var secondUserInfo = new Users();
  2311. var thirdUserInfo = new Users();
  2312. if (ParentNavList.Length > 1)
  2313. {
  2314. topUserInfo = db.Users.FirstOrDefault(m => m.Id == (int.Parse(ParentNavList[1]))) ?? new Users();
  2315. if (ParentNavList.Length > 2)
  2316. {
  2317. secondUserInfo = db.Users.FirstOrDefault(m => m.Id == (int.Parse(ParentNavList[2]))) ?? new Users();
  2318. if (ParentNavList.Length > 3)
  2319. {
  2320. thirdUserInfo = db.Users.FirstOrDefault(m => m.Id == (int.Parse(ParentNavList[3]))) ?? new Users();
  2321. }
  2322. }
  2323. }
  2324. else
  2325. {
  2326. topUserInfo = db.Users.FirstOrDefault(m => m.Id == (int.Parse(ParentNavList[0]))) ?? new Users();
  2327. }
  2328. TopMakerCode = topUserInfo.MakerCode; //顶级创客编号
  2329. TopRealName = topUserInfo.RealName; //顶级创客名称
  2330. SecondMakerCode = secondUserInfo.MakerCode; //次顶级创客编号
  2331. SecondRealName = secondUserInfo.RealName; //次顶级创客姓名
  2332. ThirdMakerCode = thirdUserInfo.MakerCode; //次次顶级创客编号
  2333. ThirdRealName = thirdUserInfo.RealName; //次次顶级创客姓名
  2334. }
  2335. data["BrandName"] = db.KqProducts.FirstOrDefault(m => m.Id == pos.BrandId).Name; //机具类型
  2336. data["BindingTime"] = pos.BindingTime == null ? "" : pos.BindingTime.Value.ToString("yyyy-MM-dd HH:mm:ss"); //绑定时间
  2337. data["ActivationTime"] = pos.ActivationTime == null ? "" : pos.ActivationTime.Value.ToString("yyyy-MM-dd HH:mm:ss"); //激活时间
  2338. data["MerchantName"] = mer.MerchantName; //商户姓名
  2339. // data["MerchantName"] = mer.MerchantName + " " + mer.MerRealName; //商户姓名/真实姓名
  2340. data["PosSn"] = pos.PosSn; //机具Sn
  2341. data["MerNo"] = mer.KqMerNo; //商户编号
  2342. data["PosFee"] = SeoKeyword; //服务费
  2343. data["userInfo"] = user.Id > 0 ? user.MakerCode + "_" + user.RealName : ""; //创客信息
  2344. // data["MakerCode"] = user.MakerCode; //创客编号
  2345. // data["RealName"] = user.RealName; //创客姓名
  2346. data["Mobile"] = user.Mobile; //创客手机号
  2347. data["Balance"] = userAccount.BalanceAmount; //创客账户余额
  2348. data["TopMakerCode"] = TopMakerCode; //顶级创客编号
  2349. data["TopRealName"] = TopRealName; //顶级创客名称
  2350. data["SecondMakerCode"] = SecondMakerCode; //次顶级创客编号
  2351. data["SecondRealName"] = SecondRealName; //次顶级创客姓名
  2352. data["ThirdMakerCode"] = ThirdMakerCode; //次次顶级创客编号
  2353. data["ThirdRealName"] = ThirdRealName; //次次顶级创客姓名
  2354. dataList.Add(data);
  2355. }
  2356. }
  2357. }
  2358. if (!string.IsNullOrEmpty(MerNos))
  2359. {
  2360. string[] MerNosList = MerNos.Replace("\r", "").Replace("\n", ",").Replace(" ", ",").Split(',');
  2361. foreach (string MerNo in MerNosList)
  2362. {
  2363. string SeoKeyword = "0";
  2364. Dictionary<string, object> data = new Dictionary<string, object>();
  2365. var mer = db.PosMerchantInfo.FirstOrDefault(m => m.KqMerNo == MerNo) ?? new PosMerchantInfo();
  2366. if (mer.Id > 0)
  2367. {
  2368. // error += "商户" + MerNo + "不存在" + '\n';
  2369. // }
  2370. // else
  2371. // {
  2372. var TopMakerCode = ""; //顶级创客编号
  2373. var TopRealName = ""; //顶级创客名称
  2374. var SecondMakerCode = ""; //次顶级创客编号
  2375. var SecondRealName = ""; //次顶级创客姓名
  2376. var ThirdMakerCode = ""; //次次顶级创客编号
  2377. var ThirdRealName = ""; //次次顶级创客姓名
  2378. var pos = db.PosMachinesTwo.FirstOrDefault(m => m.PosSn == mer.KqSnNo) ?? new PosMachinesTwo();
  2379. var brand = db.KqProducts.FirstOrDefault(m => m.Id == pos.BrandId) ?? new KqProducts();
  2380. if (brand.Id > 0 && brand.SingleDepositApi == 0 && !string.IsNullOrEmpty(pos.SeoKeyword))
  2381. {
  2382. SeoKeyword = (decimal.Parse(pos.SeoKeyword) / 100).ToString();
  2383. }
  2384. else
  2385. {
  2386. SeoKeyword = pos.SeoKeyword;
  2387. }
  2388. var user = db.Users.FirstOrDefault(m => m.Id == pos.BuyUserId) ?? new Users();
  2389. var userAccount = db.UserAccount.FirstOrDefault(m => m.Id == user.Id) ?? new UserAccount();
  2390. if (!string.IsNullOrEmpty(user.ParentNav))
  2391. {
  2392. string[] ParentNavList = user.ParentNav.Trim(',').Replace(",,", ",").Split(',');
  2393. var topUserInfo = new Users();
  2394. var secondUserInfo = new Users();
  2395. var thirdUserInfo = new Users();
  2396. if (ParentNavList.Length > 1)
  2397. {
  2398. topUserInfo = db.Users.FirstOrDefault(m => m.Id == (int.Parse(ParentNavList[1]))) ?? new Users();
  2399. if (ParentNavList.Length > 2)
  2400. {
  2401. secondUserInfo = db.Users.FirstOrDefault(m => m.Id == (int.Parse(ParentNavList[2]))) ?? new Users();
  2402. if (ParentNavList.Length > 3)
  2403. {
  2404. thirdUserInfo = db.Users.FirstOrDefault(m => m.Id == (int.Parse(ParentNavList[3]))) ?? new Users();
  2405. }
  2406. }
  2407. }
  2408. else
  2409. {
  2410. topUserInfo = db.Users.FirstOrDefault(m => m.Id == (int.Parse(ParentNavList[0]))) ?? new Users();
  2411. }
  2412. TopMakerCode = topUserInfo.MakerCode; //顶级创客编号
  2413. TopRealName = topUserInfo.RealName; //顶级创客名称
  2414. SecondMakerCode = secondUserInfo.MakerCode; //次顶级创客编号
  2415. SecondRealName = secondUserInfo.RealName; //次顶级创客姓名
  2416. ThirdMakerCode = thirdUserInfo.MakerCode; //次次顶级创客编号
  2417. ThirdRealName = thirdUserInfo.RealName; //次次顶级创客姓名
  2418. }
  2419. data["BrandName"] = db.KqProducts.FirstOrDefault(m => m.Id == pos.BrandId).Name; //机具类型
  2420. data["BindingTime"] = pos.BindingTime == null ? "" : pos.BindingTime.Value.ToString("yyyy-MM-dd HH:mm:ss"); //绑定时间
  2421. data["ActivationTime"] = pos.ActivationTime == null ? "" : pos.ActivationTime.Value.ToString("yyyy-MM-dd HH:mm:ss"); //激活时间
  2422. data["MerchantName"] = mer.MerchantName; //商户姓名
  2423. // data["MerchantName"] = mer.MerchantName + " " + mer.MerRealName; //商户姓名/真实姓名
  2424. data["PosSn"] = pos.PosSn; //机具Sn
  2425. data["MerNo"] = mer.KqMerNo; //商户编号
  2426. data["PosFee"] = SeoKeyword; //服务费
  2427. data["userInfo"] = user.Id > 0 ? user.MakerCode + "_" + user.RealName : ""; //创客信息
  2428. // data["MakerCode"] = user.MakerCode; //创客编号
  2429. // data["RealName"] = user.RealName; //创客姓名
  2430. data["Mobile"] = user.Mobile; //创客手机号
  2431. data["Balance"] = userAccount.BalanceAmount; //创客账户余额
  2432. data["TopMakerCode"] = TopMakerCode; //顶级创客编号
  2433. data["TopRealName"] = TopRealName; //顶级创客名称
  2434. data["SecondMakerCode"] = SecondMakerCode; //次顶级创客编号
  2435. data["SecondRealName"] = SecondRealName; //次顶级创客姓名
  2436. data["ThirdMakerCode"] = ThirdMakerCode; //次次顶级创客编号
  2437. data["ThirdRealName"] = ThirdRealName; //次次顶级创客姓名
  2438. dataList.Add(data);
  2439. }
  2440. }
  2441. }
  2442. }
  2443. Dictionary<string, object> obj = new Dictionary<string, object>();
  2444. obj.Add("code", 0);
  2445. obj.Add("msg", "");
  2446. obj.Add("count", dataList.Count);
  2447. obj.Add("data", dataList);
  2448. return Json(obj);
  2449. }
  2450. #endregion
  2451. #region 批量查询创客信息快捷导出Excel
  2452. public IActionResult ExportBatchSeeUserInfoExcel(string right)
  2453. {
  2454. ViewBag.RightInfo = RightInfo;
  2455. ViewBag.right = right;
  2456. return View();
  2457. }
  2458. [HttpPost]
  2459. public string ExportBatchSeeUserInfoExcelDo(string PosSns, string MerNos)
  2460. {
  2461. var sql = "";
  2462. if (string.IsNullOrEmpty(PosSns) && string.IsNullOrEmpty(MerNos))
  2463. {
  2464. return "请输入查询内容";
  2465. }
  2466. else if (!string.IsNullOrEmpty(PosSns) && !string.IsNullOrEmpty(MerNos))
  2467. {
  2468. return "不能同时输入机具Sn和商户编号";
  2469. }
  2470. else
  2471. {
  2472. if (!string.IsNullOrEmpty(PosSns))
  2473. {
  2474. var posIds = "";
  2475. string[] PosSnsList = PosSns.Replace("\r", "").Replace("\n", ",").Replace(" ", ",").Split(',');
  2476. foreach (string PosSn in PosSnsList)
  2477. {
  2478. var pos = db.PosMachinesTwo.FirstOrDefault(m => m.PosSn == PosSn) ?? new PosMachinesTwo();
  2479. posIds += pos.Id + ",";
  2480. }
  2481. posIds = posIds.TrimEnd(',');
  2482. sql = "SELECT i.BrandName '机具类型',i.PosSn '机具SN',j.KqMerNo '商编',j.MerchantName '商户名称',(CASE WHEN i.posfee IS NULL THEN 0 ELSE i.posfee END) '服务费',DATE_FORMAT(i.BindingTime,'%Y-%m-%d %H:%i:%s') '绑定时间',DATE_FORMAT(i.ActivationTime,'%Y-%m-%d %H:%i:%s') '激活时间',i.userInfo '创客信息',i.Mobile '创客手机号',i.BalanceAmount '创客账户余额',i.topMakerCode '顶级创客编号',i.topRealname '顶级姓名',i.secondMakerCode '次顶级创客编号',i.secondRealname '次顶级姓名',i.thirdMakerCode '次次顶级创客编号',i.thirdRealname '次次顶级姓名' FROM(SELECT g.*,h.MakerCode thirdMakerCode,h.Realname thirdRealname FROM (SELECT e.*,f.MakerCode secondMakerCode,f.Realname secondRealname FROM(SELECT c.*,d.MakerCode topMakerCode,d.Realname topRealname FROM(SELECT a.*,c1.NAME BrandName,(CASE WHEN a.BrandId not in(2,7,10,11) THEN ROUND(CAST(a.SeoKeyword AS DECIMAL)/100, 2) ELSE a.SeoKeyword end) posfee,b.Id useId,CONCAT(b.MakerCode,'_',b.RealName) userInfo,b.Mobile,c2.BalanceAmount,b.RealName uRealName, SUBSTRING_INDEX(SUBSTRING_INDEX(b.ParentNav,',',4),',',-1) topId,SUBSTRING_INDEX(SUBSTRING_INDEX(b.ParentNav,',',6),',',-1) secondId,SUBSTRING_INDEX(SUBSTRING_INDEX(b.ParentNav,',',8),',',-1) thirdId FROM PosMachinesTwo a LEFT JOIN Users b ON a.BuyUserId=b.Id LEFT JOIN UserAccount c2 ON a.BuyUserId=c2.Id LEFT JOIN KqProducts c1 ON a.BrandId=c1.Id WHERE a.Id in(" + posIds + "))c LEFT JOIN Users d ON c.topId=d.Id) e LEFT JOIN Users f ON e.secondId=f.Id) g LEFT JOIN Users h ON g.thirdId=h.Id) i LEFT JOIN PosMerchantInfo j ON i.BindMerchantId=j.Id";
  2483. }
  2484. if (!string.IsNullOrEmpty(MerNos))
  2485. {
  2486. var merIds = "";
  2487. string[] MerNosList = MerNos.Replace("\r", "").Replace("\n", ",").Replace(" ", ",").Split(',');
  2488. foreach (string MerNo in MerNosList)
  2489. {
  2490. var mer = db.PosMerchantInfo.FirstOrDefault(m => m.KqMerNo == MerNo) ?? new PosMerchantInfo();
  2491. merIds += mer.Id + ",";
  2492. }
  2493. merIds = merIds.TrimEnd(',');
  2494. sql = "SELECT i.BrandName '机具类型',i.KqSnNo '机具SN',i.KqMerNo '商编',i.MerchantName '商户名称',(CASE WHEN i.SeoKeyword IS NULL THEN 0 ELSE i.SeoKeyword END) '服务费',DATE_FORMAT(i.BindingTime,'%Y-%m-%d %H:%i:%s') '绑定时间',DATE_FORMAT(i.ActivationTime,'%Y-%m-%d %H:%i:%s') '激活时间',i.userInfo '创客信息',i.Mobile '创客手机号',i.BalanceAmount '创客账户余额',i.topMakerCode '顶级创客编号',i.topRealname '顶级姓名',i.secondMakerCode '次顶级创客编号',i.secondRealname '次顶级姓名',j.MakerCode '次次顶级创客编号',j.Realname '次次顶级姓名' FROM(SELECT g.*,h.MakerCode secondMakerCode,h.Realname secondRealname FROM(SELECT e.*,f.MakerCode topMakerCode,f.RealName topRealName FROM(SELECT c.*,CONCAT(d.MakerCode,'_',d.RealName) userInfo,d.Mobile,SUBSTRING_INDEX(SUBSTRING_INDEX(d.ParentNav,',',4),',',-1) topId,SUBSTRING_INDEX(SUBSTRING_INDEX(d.ParentNav,',',6),',',-1) secondId,SUBSTRING_INDEX(SUBSTRING_INDEX(d.ParentNav,',',8),',',-1) thirdId FROM(SELECT a.KqMerNo,a.KqSnNo,a.MerchantName,(CASE WHEN b.BrandId not in(2,7,10,11) THEN ROUND(CAST(b.SeoKeyword AS DECIMAL)/100, 2) ELSE b.SeoKeyword end) SeoKeyword,b.BindingTime,b.ActivationTime,b.BuyUserId,c1.Name BrandName,c2.BalanceAmount FROM PosMerchantInfo a LEFT JOIN PosMachinesTwo b ON a.KqSnNo=b.PosSn LEFT JOIN UserAccount c2 ON b.BuyUserId=c2.Id LEFT JOIN KqProducts c1 ON b.BrandId=c1.Id WHERE a.Id in(" + merIds + "))c LEFT JOIN Users d ON c.BuyUserId=d.Id) e LEFT JOIN Users f ON e.topId=f.Id) g LEFT JOIN Users h ON g.secondId=h.Id) i LEFT JOIN Users j ON i.thirdId=j.Id";
  2495. }
  2496. }
  2497. var sysAdmin = bsdb.SysAdmin.FirstOrDefault(m => m.AdminName == SysUserName && m.Status > -1);
  2498. var FileName = "批量查询创客信息" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  2499. string SendData = "{\"Operater\":\"" + sysAdmin.Id + "\",\"SqlString\":\"" + sql + "\",\"FileName\":\"" + FileName + "\",\"MaxCount\":\"0\"}";
  2500. RedisDbconn.Instance.AddList("ExportQueue", SendData);
  2501. return "success";
  2502. }
  2503. #endregion
  2504. }
  2505. }