UsersController.cs 134 KB

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