UsersController.cs 88 KB

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