UsersController.cs 133 KB

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