UsersController.cs 89 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981
  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. UserForMobile forMobile = db.UserForMobile.FirstOrDefault(m => m.Mobile == user.Mobile);
  507. if (forMobile != null)
  508. {
  509. db.Remove(forMobile);
  510. }
  511. user.Status = -1;
  512. user.Mobile += "d";
  513. user.CertId += "d";
  514. }
  515. else
  516. {
  517. UserForMobile forMobile = db.UserForMobile.FirstOrDefault(m => m.Mobile == user.Mobile);
  518. if (forMobile != null)
  519. {
  520. db.Remove(forMobile);
  521. }
  522. user.Status = -1;
  523. user.Mobile += "d";
  524. user.CertId += "d";
  525. }
  526. function.WriteLog(user.Id + "于" + DateTime.Now.ToString() + "注销账号", "创客注销日志");
  527. // TODO: 每月扫描一次注销的创客,把注销创客伞下创客全部挂到注销创客的上级
  528. // TODO: 清除token,token登录返回
  529. db.SaveChanges();
  530. }
  531. return "success";
  532. }
  533. #endregion
  534. #region 开启
  535. /// <summary>
  536. /// 开启
  537. /// </summary>
  538. /// <returns></returns>
  539. public string Open(string Id)
  540. {
  541. string[] idlist = Id.Split(new char[] { ',' });
  542. AddSysLog(Id, "Users", "open");
  543. foreach (string subid in idlist)
  544. {
  545. int id = int.Parse(subid);
  546. Dictionary<string, object> Fields = new Dictionary<string, object>();
  547. Fields.Add("Status", 1);
  548. new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("Users", Fields, id);
  549. }
  550. db.SaveChanges();
  551. return "success";
  552. }
  553. #endregion
  554. #region 关闭
  555. /// <summary>
  556. /// 关闭
  557. /// </summary>
  558. /// <returns></returns>
  559. public string Close(string Id)
  560. {
  561. string[] idlist = Id.Split(new char[] { ',' });
  562. AddSysLog(Id, "Users", "close");
  563. foreach (string subid in idlist)
  564. {
  565. int id = int.Parse(subid);
  566. Dictionary<string, object> Fields = new Dictionary<string, object>();
  567. Fields.Add("Status", 0);
  568. new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("Users", Fields, id);
  569. }
  570. db.SaveChanges();
  571. return "success";
  572. }
  573. #endregion
  574. #region 一键企业创客
  575. /// <summary>
  576. /// 一键企业创客
  577. /// </summary>
  578. /// <returns></returns>
  579. public string OpenEnterpriseMaker(string Id)
  580. {
  581. string[] idlist = Id.Split(new char[] { ',' });
  582. AddSysLog(Id, "Users", "OpenEnterpriseMaker");
  583. foreach (string subid in idlist)
  584. {
  585. int id = int.Parse(subid);
  586. Dictionary<string, object> Fields = new Dictionary<string, object>();
  587. Fields.Add("BusinessFlag", 1);
  588. new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("Users", Fields, id);
  589. }
  590. db.SaveChanges();
  591. return "success";
  592. }
  593. #endregion
  594. #region 关闭企业创客
  595. /// <summary>
  596. /// 关闭企业创客
  597. /// </summary>
  598. /// <returns></returns>
  599. public string CloseEnterpriseMaker(string Id)
  600. {
  601. string[] idlist = Id.Split(new char[] { ',' });
  602. AddSysLog(Id, "Users", "CloseEnterpriseMaker");
  603. foreach (string subid in idlist)
  604. {
  605. int id = int.Parse(subid);
  606. Dictionary<string, object> Fields = new Dictionary<string, object>();
  607. Fields.Add("BusinessFlag", 0);
  608. new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("Users", Fields, id);
  609. }
  610. db.SaveChanges();
  611. return "success";
  612. }
  613. #endregion
  614. #region 一键大盟主
  615. /// <summary>
  616. /// 一键大盟主
  617. /// </summary>
  618. /// <returns></returns>
  619. public string SetBigLeader(string Id)
  620. {
  621. string[] idlist = Id.Split(new char[] { ',' });
  622. AddSysLog(Id, "Users", "SetBigLeader");
  623. foreach (string subid in idlist)
  624. {
  625. int id = int.Parse(subid);
  626. Dictionary<string, object> Fields = new Dictionary<string, object>();
  627. Fields.Add("LeaderLevel", 2);
  628. new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("Users", Fields, id);
  629. }
  630. db.SaveChanges();
  631. return "success";
  632. }
  633. #endregion
  634. #region 一键小盟主
  635. /// <summary>
  636. /// 一键小盟主
  637. /// </summary>
  638. /// <returns></returns>
  639. public string SetSmallLeader(string Id)
  640. {
  641. string[] idlist = Id.Split(new char[] { ',' });
  642. AddSysLog(Id, "Users", "SetSmallLeader");
  643. foreach (string subid in idlist)
  644. {
  645. int id = int.Parse(subid);
  646. Dictionary<string, object> Fields = new Dictionary<string, object>();
  647. Fields.Add("LeaderLevel", 1);
  648. new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("Users", Fields, id);
  649. }
  650. db.SaveChanges();
  651. return "success";
  652. }
  653. #endregion
  654. #region 风控
  655. public IActionResult Risk(string right, int Id = 0)
  656. {
  657. ViewBag.RightInfo = RightInfo;
  658. ViewBag.right = right;
  659. Users editData = db.Users.FirstOrDefault(m => m.Id == Id) ?? new Users();
  660. ViewBag.data = editData;
  661. return View();
  662. }
  663. #endregion
  664. #region 风控
  665. [HttpPost]
  666. public string Risk(Users data)
  667. {
  668. Users user = db.Users.FirstOrDefault(m => m.Id == data.Id);
  669. if (user != null)
  670. {
  671. user.RiskFlag = data.RiskFlag;
  672. user.RiskRemark = data.RiskRemark;
  673. db.SaveChanges();
  674. }
  675. return "success";
  676. }
  677. #endregion
  678. #region 解除风控
  679. public string UnRisk(string Id)
  680. {
  681. string[] idlist = Id.Split(new char[] { ',' });
  682. AddSysLog(Id, "Users", "UnRisk");
  683. foreach (string subid in idlist)
  684. {
  685. int id = int.Parse(subid);
  686. Dictionary<string, object> Fields = new Dictionary<string, object>();
  687. Fields.Add("RiskFlag", 0);
  688. new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("Users", Fields, id);
  689. }
  690. db.SaveChanges();
  691. return "success";
  692. }
  693. #endregion
  694. #region 重置密码
  695. public string ResetPwd(int Id)
  696. {
  697. string NewPwd = function.get_Random(6);
  698. Dictionary<string, object> Fields = new Dictionary<string, object>();
  699. Fields.Add("LoginPwd", function.MD532(NewPwd));
  700. new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("Users", Fields, Id);
  701. AddSysLog(Id, "Users", "ResetPwd");
  702. RedisDbconn.Instance.Clear("Users:" + Id);
  703. return "success|" + NewPwd;
  704. }
  705. #endregion
  706. #region 排序
  707. /// <summary>
  708. /// 排序
  709. /// </summary>
  710. /// <param name="Id"></param>
  711. public string Sort(int Id, int Sort)
  712. {
  713. new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Sort("Users", Sort, Id);
  714. AddSysLog(Id.ToString(), "Users", "sort");
  715. return "success";
  716. }
  717. #endregion
  718. #region 导入数据
  719. /// <summary>
  720. /// 导入数据
  721. /// </summary>
  722. /// <param name="ExcelData"></param>
  723. public string Import(string ExcelData, int Kind = 0)
  724. {
  725. ExcelData = HttpUtility.UrlDecode(ExcelData);
  726. JsonData list = JsonMapper.ToObject(ExcelData);
  727. if (Kind == 1)
  728. {
  729. for (int i = 1; i < list.Count; i++)
  730. {
  731. JsonData dr = list[i];
  732. string MakerCode = dr[0].ToString();
  733. string SettleAmount = dr[2].ToString();
  734. UserForMakerCode UserCode = db.UserForMakerCode.FirstOrDefault(m => m.MakerCode == MakerCode);
  735. if (UserCode != null)
  736. {
  737. Users User = db.Users.FirstOrDefault(m => m.Id == UserCode.UserId);
  738. if (User != null)
  739. {
  740. User.SettleAmount = decimal.Parse(function.CheckInt(SettleAmount));
  741. }
  742. }
  743. }
  744. db.SaveChanges();
  745. }
  746. else if (Kind == 2)
  747. {
  748. for (int i = 1; i < list.Count; i++)
  749. {
  750. JsonData dr = list[i];
  751. string MakerCode = dr[0].ToString();
  752. string CashFreezeAmt = dr[2].ToString();
  753. UserForMakerCode UserCode = db.UserForMakerCode.FirstOrDefault(m => m.MakerCode == MakerCode);
  754. if (UserCode != null)
  755. {
  756. Users User = db.Users.FirstOrDefault(m => m.Id == UserCode.UserId);
  757. if (User != null)
  758. {
  759. User.CashFreezeAmt = decimal.Parse(function.CheckInt(CashFreezeAmt));
  760. }
  761. }
  762. }
  763. db.SaveChanges();
  764. }
  765. else if (Kind == 3)
  766. {
  767. for (int i = 1; i < list.Count; i++)
  768. {
  769. JsonData dr = list[i];
  770. string MakerCode = dr[0].ToString();
  771. string RiskFlag = dr[2].ToString();
  772. string RiskNote = dr[3].ToString();
  773. UserForMakerCode UserCode = db.UserForMakerCode.FirstOrDefault(m => m.MakerCode == MakerCode);
  774. if (UserCode != null)
  775. {
  776. Users User = db.Users.FirstOrDefault(m => m.Id == UserCode.UserId);
  777. if (User != null)
  778. {
  779. User.RiskFlag = ulong.Parse(function.CheckInt(RiskFlag));
  780. User.RiskRemark = RiskNote;
  781. }
  782. }
  783. }
  784. db.SaveChanges();
  785. }
  786. else if (Kind == 4)
  787. {
  788. string error = "";
  789. for (int i = 1; i < list.Count; i++)
  790. {
  791. JsonData dr = list[i];
  792. string MakerCode = dr[0].ToString();
  793. string OperationAmt = dr[2].ToString();//操作金额
  794. string OperationType = dr[3].ToString();//操作类型
  795. UserForMakerCode UserCode = db.UserForMakerCode.FirstOrDefault(m => m.MakerCode == MakerCode);
  796. if (UserCode != null)
  797. {
  798. Users User = db.Users.FirstOrDefault(m => m.Id == UserCode.UserId);
  799. UserAccount account = db.UserAccount.FirstOrDefault(m => m.Id == User.Id);
  800. if (account == null)
  801. {
  802. account = db.UserAccount.Add(new UserAccount()
  803. {
  804. Id = User.Id,
  805. UserId = User.Id,
  806. }).Entity;
  807. db.SaveChanges();
  808. }
  809. if (User != null)
  810. {
  811. decimal BeforeTotalAmount = account.TotalAmount; //变更前总金额
  812. decimal BeforeFreezeAmount = account.FreezeAmount; //变更前冻结金额
  813. decimal BeforeBalanceAmount = account.BalanceAmount; //变更前余额
  814. int ChangeType = 0;
  815. if (OperationType == "1" && Convert.ToDecimal(OperationAmt) <= account.BalanceAmount)
  816. {
  817. account.BalanceAmount -= Convert.ToDecimal(OperationAmt);
  818. account.FreezeAmount += Convert.ToDecimal(OperationAmt);
  819. ChangeType = 61;
  820. }
  821. else if (OperationType == "1" && Convert.ToDecimal(OperationAmt) > account.BalanceAmount)
  822. {
  823. error += "以下操作失败" + User.MakerCode + ',' + User.RealName + "冻结金额大于余额" + '|' + '\n';
  824. }
  825. else if (OperationType == "2" && Convert.ToDecimal(OperationAmt) <= account.FreezeAmount)
  826. {
  827. account.BalanceAmount += Convert.ToDecimal(OperationAmt);
  828. account.FreezeAmount -= Convert.ToDecimal(OperationAmt);
  829. ChangeType = 62;
  830. }
  831. else if (OperationType == "2" && Convert.ToDecimal(OperationAmt) > account.FreezeAmount)
  832. {
  833. error += "以下操作失败" + User.MakerCode + ',' + User.RealName + "解冻金额大于冻结金额" + '|' + '\n';
  834. }
  835. else if (OperationType == "3" && Convert.ToDecimal(OperationAmt) <= account.BalanceAmount)
  836. {
  837. account.TotalAmount -= Convert.ToDecimal(OperationAmt);
  838. account.BalanceAmount -= Convert.ToDecimal(OperationAmt);
  839. ChangeType = 63;
  840. }
  841. else if (OperationType == "3" && Convert.ToDecimal(OperationAmt) > account.BalanceAmount)
  842. {
  843. error += "以下操作失败" + User.MakerCode + ',' + User.RealName + "扣减金额大于余额" + '|' + '\n';
  844. }
  845. else if (OperationType == "4")
  846. {
  847. account.TotalAmount += Convert.ToDecimal(OperationAmt);
  848. account.BalanceAmount += Convert.ToDecimal(OperationAmt);
  849. ChangeType = 64;
  850. }
  851. decimal AfterTotalAmount = account.TotalAmount; //变更后总金额
  852. decimal AfterFreezeAmount = account.FreezeAmount; //变更后冻结金额
  853. decimal AfterBalanceAmount = account.BalanceAmount; //变更后余额
  854. UserAccountRecord userAccountRecord = db.UserAccountRecord.Add(new UserAccountRecord()
  855. {
  856. CreateDate = DateTime.Now,
  857. UpdateDate = DateTime.Now,
  858. UserId = User.Id, //创客
  859. ChangeType = ChangeType, //变动类型
  860. ChangeAmount = Convert.ToDecimal(OperationAmt), //变更金额
  861. BeforeTotalAmount = BeforeTotalAmount, //变更前总金额
  862. AfterTotalAmount = AfterTotalAmount, //变更后总金额
  863. BeforeFreezeAmount = BeforeFreezeAmount, //变更前冻结金额
  864. AfterFreezeAmount = AfterFreezeAmount, //变更后冻结金额
  865. BeforeBalanceAmount = BeforeBalanceAmount, //变更前余额
  866. AfterBalanceAmount = AfterBalanceAmount, //变更后余额
  867. Remark = dr[4].ToString(),
  868. }).Entity;
  869. db.SaveChanges();
  870. AddSysLog(User.Id.ToString(), "Users", "ChangeCashFreezeAmts");
  871. db.SaveChanges();
  872. }
  873. }
  874. }
  875. db.SaveChanges();
  876. return "warning" + error;
  877. }
  878. AddSysLog("0", "Users", "Import");
  879. return "success";
  880. }
  881. #endregion
  882. #region 导出Excel
  883. /// <summary>
  884. /// 导出Excel
  885. /// </summary>
  886. /// <returns></returns>
  887. 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)
  888. {
  889. Dictionary<string, string> Fields = new Dictionary<string, string>();
  890. Fields.Add("MakerCode", "1"); //创客编号
  891. Fields.Add("RealName", "1"); //创客名称
  892. Fields.Add("Mobile", "1"); //手机号
  893. Fields.Add("CertId", "1"); //身份证号码
  894. Fields.Add("CreateDate", "3"); //注册时间
  895. Fields.Add("SettleAmount", "3"); //结算金额
  896. Fields.Add("CashFreezeAmt", "3"); //冻结金额
  897. Fields.Add("UserLevel", "0"); //创客等级
  898. string condition = " and Status>-1";
  899. //直属创客编号
  900. if (!string.IsNullOrEmpty(ParentMakerCode))
  901. {
  902. condition += " and Id in (select UserId from UserForMakerCode where MakerCode='" + ParentMakerCode + "')";
  903. }
  904. //直属创客名称
  905. if (!string.IsNullOrEmpty(ParentRealName))
  906. {
  907. condition += " and Id in (select UserId from UserForRealName where RealName='" + ParentRealName + "')";
  908. }
  909. //实名状态
  910. if (!string.IsNullOrEmpty(AuthFlagSelect))
  911. {
  912. condition += " and AuthFlag=" + AuthFlagSelect;
  913. }
  914. //顶级创客
  915. if (TopUserId > 0)
  916. {
  917. condition += " and ParentNav like '," + TopUserId + ",%'";
  918. }
  919. //风控标识
  920. if (!string.IsNullOrEmpty(RiskFlagSelect))
  921. {
  922. condition += " and RiskFlag=" + RiskFlagSelect;
  923. }
  924. //商户创客类型
  925. if (!string.IsNullOrEmpty(MerchantTypeSelect))
  926. {
  927. condition += " and MerchantType=" + MerchantTypeSelect;
  928. }
  929. if (SelfId > 0)
  930. {
  931. Users self = db.Users.FirstOrDefault(m => m.Id == SelfId);
  932. if (self != null)
  933. {
  934. string ParentNav = function.CheckNull(self.ParentNav);
  935. condition += " and Id in (" + ParentNav.Trim(',').Replace(",,", ",") + ")";
  936. }
  937. }
  938. if (ParentId > 0)
  939. {
  940. condition += " and ParentUserId=" + ParentId;
  941. }
  942. 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);
  943. List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
  944. foreach (Dictionary<string, object> dic in diclist)
  945. {
  946. dic["AuthFlag"] = dic["AuthFlag"].ToString() == "1" ? "已实名" : "未实名";
  947. dic["RiskFlag"] = dic["RiskFlag"].ToString() == "1" ? "已风控" : "未风控";
  948. dic["UserLevel"] = RelationClass.GetUserLevelSetInfo(int.Parse(dic["UserLevel"].ToString()));
  949. dic["MerchantType"] = RelationClassForConst.GetMerchantTypeInfo(int.Parse(dic["MerchantType"].ToString()));
  950. int ParentUserId = int.Parse(dic["ParentUserId"].ToString());
  951. Users puser = db.Users.FirstOrDefault(m => m.Id == ParentUserId) ?? new Users();
  952. dic["ParentMakerCode"] = puser.MakerCode;
  953. dic["ParentRealName"] = puser.RealName;
  954. string ParentNav = dic["ParentNav"].ToString();
  955. if (!string.IsNullOrEmpty(ParentNav))
  956. {
  957. string[] list = ParentNav.Trim(',').Replace(",,", ",").Split(',');
  958. if (list.Length > 1)
  959. {
  960. int TopId = int.Parse(function.CheckInt(list[1]));
  961. Users tuser = db.Users.FirstOrDefault(m => m.Id == TopId) ?? new Users();
  962. dic["TopMakerCode"] = tuser.MakerCode;
  963. dic["TopRealName"] = tuser.RealName;
  964. }
  965. }
  966. dic.Remove("ParentUserId");
  967. dic.Remove("ParentNav");
  968. }
  969. Dictionary<string, object> result = new Dictionary<string, object>();
  970. result.Add("Status", "1");
  971. result.Add("Info", "Excel报表-" + DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss") + ".xlsx");
  972. result.Add("Obj", diclist);
  973. Dictionary<string, object> ReturnFields = new Dictionary<string, object>();
  974. ReturnFields.Add("MakerCode", "创客编号");
  975. ReturnFields.Add("RealName", "创客姓名");
  976. ReturnFields.Add("UserLevel", "创客等级");
  977. ReturnFields.Add("SettleAmount", "提现金额(元)");
  978. ReturnFields.Add("CashFreezeAmt", "冻结金额(元)");
  979. ReturnFields.Add("CertId", "身份证号");
  980. ReturnFields.Add("Mobile", "联系手机");
  981. ReturnFields.Add("MerchantType", "商户创客类型");
  982. ReturnFields.Add("MerchantDate", "成为商户创客时间");
  983. ReturnFields.Add("ParentMakerCode", "直属创客编号");
  984. ReturnFields.Add("ParentRealName", "直属创客名称");
  985. ReturnFields.Add("TopMakerCode", "顶级创客编号");
  986. ReturnFields.Add("TopRealName", "顶级创客名称");
  987. ReturnFields.Add("AuthFlag", "实名状态");
  988. ReturnFields.Add("RiskFlag", "风控状态");
  989. ReturnFields.Add("CreateDate", "注册时间");
  990. result.Add("Fields", ReturnFields);
  991. AddSysLog("0", "Users", "ExportExcel");
  992. return Json(result);
  993. }
  994. #endregion
  995. #region 直属创客导出Excel
  996. /// <summary>
  997. /// 直属创客导出Excel
  998. /// </summary>
  999. /// <returns></returns>
  1000. public JsonResult ExportZSExcel(Users data, string MakerCode, string ParentMakerCode)
  1001. {
  1002. Dictionary<string, string> Fields = new Dictionary<string, string>();
  1003. string condition = " and Status>-1";
  1004. //创客编号
  1005. if (!string.IsNullOrEmpty(MakerCode))
  1006. {
  1007. condition += " and ParentUserId in (select UserId from UserForMakerCode where MakerCode='" + MakerCode + "')";
  1008. }
  1009. //直属创客编号
  1010. if (!string.IsNullOrEmpty(ParentMakerCode))
  1011. {
  1012. condition += " and ParentUserId in (select UserId from UserForMakerCode where MakerCode='" + ParentMakerCode + "')";
  1013. }
  1014. Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("Users", Fields, "Id desc", "True", 1, 20000, condition, "Id,MakerCode,RealName,UserLevel", false);
  1015. List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
  1016. foreach (Dictionary<string, object> dic in diclist)
  1017. {
  1018. int Id = int.Parse(dic["Id"].ToString());
  1019. Users userZS = db.Users.FirstOrDefault(m => m.Id == Id) ?? new Users();
  1020. dic["MakerCode"] = userZS.MakerCode;
  1021. dic["RealName"] = userZS.RealName;
  1022. dic["UserLevel"] = RelationClass.GetUserLevelSetInfo(int.Parse(dic["UserLevel"].ToString()));
  1023. }
  1024. Dictionary<string, object> result = new Dictionary<string, object>();
  1025. result.Add("Status", "1");
  1026. result.Add("Info", "Excel报表-" + DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss") + ".xlsx");
  1027. result.Add("Obj", diclist);
  1028. Dictionary<string, object> ReturnFields = new Dictionary<string, object>();
  1029. ReturnFields.Add("Id", "Id");
  1030. ReturnFields.Add("MakerCode", "创客编号");
  1031. ReturnFields.Add("RealName", "创客姓名");
  1032. ReturnFields.Add("UserLevel", "创客等级");
  1033. result.Add("Fields", ReturnFields);
  1034. AddSysLog("0", "Users", "ExportZSExcel");
  1035. return Json(result);
  1036. }
  1037. #endregion
  1038. #region 上级创客导出Excel
  1039. /// <summary>
  1040. /// 上级创客导出Excel
  1041. /// </summary>
  1042. /// <returns></returns>
  1043. public JsonResult ExportSJExcel(Users data, string MakerCode, string ParentMakerCode)
  1044. {
  1045. Dictionary<string, string> Fields = new Dictionary<string, string>();
  1046. string condition = " and Status>-1";
  1047. //创客编号
  1048. if (!string.IsNullOrEmpty(MakerCode))
  1049. {
  1050. var query = db.UserForMakerCode.FirstOrDefault(m => m.MakerCode == MakerCode);
  1051. Users self = db.Users.FirstOrDefault(m => m.Id == query.UserId);
  1052. if (self != null)
  1053. {
  1054. string ParentNav = function.CheckNull(self.ParentNav);
  1055. condition += " and Id in (" + ParentNav.Trim(',').Replace(",,", ",") + ")";
  1056. }
  1057. }
  1058. //直属创客编号
  1059. if (!string.IsNullOrEmpty(ParentMakerCode))
  1060. {
  1061. var query = db.UserForMakerCode.FirstOrDefault(m => m.MakerCode == ParentMakerCode);
  1062. Users self = db.Users.FirstOrDefault(m => m.Id == query.UserId);
  1063. if (self != null)
  1064. {
  1065. string ParentNav = function.CheckNull(self.ParentNav);
  1066. condition += " and Id in (" + ParentNav.Trim(',').Replace(",,", ",") + ")";
  1067. }
  1068. }
  1069. Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("Users", Fields, "Id desc", "True", 1, 20000, condition, "Id,MakerCode,RealName,UserLevel", false);
  1070. List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
  1071. foreach (Dictionary<string, object> dic in diclist)
  1072. {
  1073. int Id = int.Parse(dic["Id"].ToString());
  1074. Users userSJ = db.Users.FirstOrDefault(m => m.Id == Id) ?? new Users();
  1075. dic["MakerCode"] = userSJ.MakerCode;
  1076. dic["RealName"] = userSJ.RealName;
  1077. dic["UserLevel"] = RelationClass.GetUserLevelSetInfo(int.Parse(dic["UserLevel"].ToString()));
  1078. }
  1079. Dictionary<string, object> result = new Dictionary<string, object>();
  1080. result.Add("Status", "1");
  1081. result.Add("Info", "Excel报表-" + DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss") + ".xlsx");
  1082. result.Add("Obj", diclist);
  1083. Dictionary<string, object> ReturnFields = new Dictionary<string, object>();
  1084. ReturnFields.Add("Id", "Id");
  1085. ReturnFields.Add("MakerCode", "创客编号");
  1086. ReturnFields.Add("RealName", "创客姓名");
  1087. ReturnFields.Add("UserLevel", "创客等级");
  1088. result.Add("Fields", ReturnFields);
  1089. AddSysLog("0", "Users", "ExportExcel");
  1090. return Json(result);
  1091. }
  1092. #endregion
  1093. #region 同步数据
  1094. /// <summary>
  1095. /// 同步数据
  1096. /// </summary>
  1097. /// <returns></returns>
  1098. public string SycnData(int Id = 0)
  1099. {
  1100. var Brands = db.KqProducts.Where(m => m.Status == 1).ToList();
  1101. foreach (var Brand in Brands)
  1102. {
  1103. PublicFunction.SycnMachineCount(Id, Brand.Id);
  1104. // RedisDbconn.Instance.Set("UserMachineData:" + IdBrand, machineData);
  1105. // RedisDbconn.Instance.SetExpire("UserMachineData:" + IdBrand, function.get_Random(1800, 5400));
  1106. }
  1107. AddSysLog(Id, "Users", "SycnData");
  1108. db.SaveChanges();
  1109. return "success";
  1110. }
  1111. #endregion
  1112. #region 同步交易额
  1113. public IActionResult SycnTradeAmount(string right, int Id = 0)
  1114. {
  1115. ViewBag.RightInfo = RightInfo;
  1116. ViewBag.right = right;
  1117. Users editData = db.Users.FirstOrDefault(m => m.Id == Id) ?? new Users();
  1118. ViewBag.data = editData;
  1119. return View();
  1120. }
  1121. #endregion
  1122. #region 同步交易额
  1123. [HttpPost]
  1124. public string SycnTradeAmountDo(DateTime sdate, DateTime edate, int UserId, int BrandId)
  1125. {
  1126. if (sdate.AddMonths(1) < edate)
  1127. {
  1128. return "时间间隔不能超过1个月";
  1129. }
  1130. if (edate >= DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd") + " 00:00:00"))
  1131. {
  1132. return "结束时间只能是今天之前";
  1133. }
  1134. string check = RedisDbconn.Instance.Get<string>("ResetUserTradeQueue:" + UserId + ":" + BrandId);
  1135. if (!string.IsNullOrEmpty(check))
  1136. {
  1137. return "请稍后再试";
  1138. }
  1139. try
  1140. {
  1141. 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);
  1142. RedisDbconn.Instance.Set("ResetUserTradeQueue:" + UserId + ":" + BrandId, "wait");
  1143. RedisDbconn.Instance.SetExpire("ResetUserTradeQueue:" + UserId + ":" + BrandId, 3600);
  1144. }
  1145. catch (Exception ex)
  1146. {
  1147. function.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString(), "统计创客的交易额异常");
  1148. return "同步异常";
  1149. }
  1150. return "success";
  1151. }
  1152. #endregion
  1153. #region 创客展业城市
  1154. public IActionResult City(Users data, string right)
  1155. {
  1156. ViewBag.RightInfo = RightInfo;
  1157. ViewBag.right = right;
  1158. List<Users> TopUsers = db.Users.Where(m => m.ParentUserId == 0).ToList();
  1159. ViewBag.TopUsers = TopUsers;
  1160. return View();
  1161. }
  1162. #endregion
  1163. #region 根据条件查询创客展业城市
  1164. public JsonResult CityData(Users data, string ParentMakerCode, string ParentRealName, int TopUserId, string Areas, int page = 1, int limit = 30)
  1165. {
  1166. Dictionary<string, string> Fields = new Dictionary<string, string>();
  1167. Fields.Add("MakerCode", "1"); //创客编号
  1168. Fields.Add("RealName", "1"); //创客名称
  1169. Fields.Add("CitySetDate", "3"); //创建时间
  1170. Fields.Add("Areas", "2"); //省市
  1171. string condition = " and Status>-1";
  1172. //直属创客编号
  1173. if (!string.IsNullOrEmpty(ParentMakerCode))
  1174. {
  1175. condition += " and Id in (select UserId from UserForMakerCode where MakerCode='" + ParentMakerCode + "')";
  1176. }
  1177. //直属创客名称
  1178. if (!string.IsNullOrEmpty(ParentRealName))
  1179. {
  1180. condition += " and Id in (select UserId from UserForRealName where RealName='" + ParentRealName + "')";
  1181. }
  1182. //顶级创客
  1183. if (TopUserId > 0)
  1184. {
  1185. condition += " and ParentNav like '," + TopUserId + ",%'";
  1186. }
  1187. Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("Users", Fields, "Id desc", "True", page, limit, condition);
  1188. List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
  1189. foreach (Dictionary<string, object> dic in diclist)
  1190. {
  1191. int ParentUserId = int.Parse(dic["ParentUserId"].ToString());
  1192. Users puser = db.Users.FirstOrDefault(m => m.Id == ParentUserId) ?? new Users();
  1193. dic["ParentMakerCode"] = puser.MakerCode;
  1194. dic["ParentRealName"] = puser.RealName;
  1195. string ParentNav = dic["ParentNav"].ToString();
  1196. if (!string.IsNullOrEmpty(ParentNav))
  1197. {
  1198. int TopId = int.Parse(ParentNav.Trim(',').Replace(",,", ",").Split(',')[0]);
  1199. Users tuser = db.Users.FirstOrDefault(m => m.Id == TopId) ?? new Users();
  1200. dic["TopMakerCode"] = tuser.MakerCode;
  1201. dic["TopRealName"] = tuser.RealName;
  1202. }
  1203. }
  1204. return Json(obj);
  1205. }
  1206. #endregion
  1207. #region 导出展业城市
  1208. public JsonResult ExportCity(Users data, string CreateDate, string ParentMakerCode, string ParentRealName, string AuthFlagSelect, int TopUserId, string RiskFlagSelect, string MerchantTypeSelect)
  1209. {
  1210. Dictionary<string, string> Fields = new Dictionary<string, string>();
  1211. Fields.Add("MakerCode", "1"); //创客编号
  1212. Fields.Add("RealName", "1"); //创客名称
  1213. Fields.Add("Mobile", "1"); //手机号
  1214. Fields.Add("CertId", "1"); //身份证号码
  1215. Fields.Add("CreateDate", "3"); //注册时间
  1216. Fields.Add("SettleAmount", "3"); //结算金额
  1217. Fields.Add("CashFreezeAmt", "3"); //冻结金额
  1218. Fields.Add("UserLevel", "0"); //创客等级
  1219. string condition = " and Status>-1";
  1220. //直属创客编号
  1221. if (!string.IsNullOrEmpty(ParentMakerCode))
  1222. {
  1223. condition += " and Id in (select UserId from UserForMakerCode where MakerCode='" + ParentMakerCode + "')";
  1224. }
  1225. //直属创客名称
  1226. if (!string.IsNullOrEmpty(ParentRealName))
  1227. {
  1228. condition += " and Id in (select UserId from UserForRealName where RealName='" + ParentRealName + "')";
  1229. }
  1230. //实名状态
  1231. if (!string.IsNullOrEmpty(AuthFlagSelect))
  1232. {
  1233. condition += " and AuthFlag=" + AuthFlagSelect;
  1234. }
  1235. //顶级创客
  1236. if (TopUserId > 0)
  1237. {
  1238. condition += " and ParentNav like '," + TopUserId + ",%'";
  1239. }
  1240. //风控标识
  1241. if (!string.IsNullOrEmpty(RiskFlagSelect))
  1242. {
  1243. condition += " and RiskFlag=" + RiskFlagSelect;
  1244. }
  1245. //商户创客类型
  1246. if (!string.IsNullOrEmpty(MerchantTypeSelect))
  1247. {
  1248. condition += " and MerchantType=" + MerchantTypeSelect;
  1249. }
  1250. 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);
  1251. List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
  1252. foreach (Dictionary<string, object> dic in diclist)
  1253. {
  1254. dic["AuthFlag"] = dic["AuthFlag"].ToString() == "1" ? "已实名" : "未实名";
  1255. dic["RiskFlag"] = dic["RiskFlag"].ToString() == "1" ? "已风控" : "未风控";
  1256. dic["UserLevel"] = RelationClass.GetUserLevelSetInfo(int.Parse(dic["UserLevel"].ToString()));
  1257. dic["MerchantType"] = RelationClassForConst.GetMerchantTypeInfo(int.Parse(dic["MerchantType"].ToString()));
  1258. int ParentUserId = int.Parse(dic["ParentUserId"].ToString());
  1259. Users puser = db.Users.FirstOrDefault(m => m.Id == ParentUserId) ?? new Users();
  1260. dic["ParentMakerCode"] = puser.MakerCode;
  1261. dic["ParentRealName"] = puser.RealName;
  1262. string ParentNav = dic["ParentNav"].ToString();
  1263. if (!string.IsNullOrEmpty(ParentNav))
  1264. {
  1265. int TopId = int.Parse(ParentNav.Trim(',').Replace(",,", ",").Split(',')[0]);
  1266. Users tuser = db.Users.FirstOrDefault(m => m.Id == TopId) ?? new Users();
  1267. dic["TopMakerCode"] = tuser.MakerCode;
  1268. dic["TopRealName"] = tuser.RealName;
  1269. }
  1270. dic.Remove("ParentUserId");
  1271. dic.Remove("ParentNav");
  1272. }
  1273. Dictionary<string, object> result = new Dictionary<string, object>();
  1274. result.Add("Status", "1");
  1275. result.Add("Info", "Excel报表-" + DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss") + ".xlsx");
  1276. result.Add("Obj", diclist);
  1277. Dictionary<string, object> ReturnFields = new Dictionary<string, object>();
  1278. ReturnFields.Add("MakerCode", "创客编号");
  1279. ReturnFields.Add("RealName", "创客姓名");
  1280. ReturnFields.Add("UserLevel", "创客等级");
  1281. ReturnFields.Add("SettleAmount", "提现金额(元)");
  1282. ReturnFields.Add("CashFreezeAmt", "冻结金额(元)");
  1283. ReturnFields.Add("CertId", "身份证号");
  1284. ReturnFields.Add("Mobile", "联系手机");
  1285. ReturnFields.Add("MerchantType", "商户创客类型");
  1286. ReturnFields.Add("MerchantDate", "成为商户创客时间");
  1287. ReturnFields.Add("ParentMakerCode", "直属创客编号");
  1288. ReturnFields.Add("ParentRealName", "直属创客名称");
  1289. ReturnFields.Add("TopMakerCode", "顶级创客编号");
  1290. ReturnFields.Add("TopRealName", "顶级创客名称");
  1291. ReturnFields.Add("AuthFlag", "实名状态");
  1292. ReturnFields.Add("RiskFlag", "风控状态");
  1293. ReturnFields.Add("CreateDate", "注册时间");
  1294. result.Add("Fields", ReturnFields);
  1295. AddSysLog("0", "Users", "ExportExcel");
  1296. return Json(result);
  1297. }
  1298. #endregion
  1299. #region 根据条件查询直属创客交易额列表
  1300. /// <summary>
  1301. /// 直属创客交易额列表
  1302. /// </summary>
  1303. /// <returns></returns>
  1304. public IActionResult Children(Users data, string right, int ParentId = 0, string MakerCode = "")
  1305. {
  1306. ViewBag.RightInfo = RightInfo;
  1307. ViewBag.right = right;
  1308. ViewBag.ParentId = ParentId.ToString();
  1309. ViewBag.MakerCode = MakerCode;
  1310. List<Users> TopUsers = db.Users.Where(m => m.ParentUserId == 0).ToList();
  1311. ViewBag.TopUsers = TopUsers;
  1312. List<UserLevelSet> Levels = db.UserLevelSet.OrderBy(m => m.Id).ToList();
  1313. ViewBag.Levels = Levels;
  1314. List<KqProducts> Brands = db.KqProducts.OrderBy(m => m.Id).ToList();
  1315. ViewBag.Brands = Brands;
  1316. return View();
  1317. }
  1318. #endregion
  1319. #region 根据条件查询直属创客交易额列表
  1320. /// <summary>
  1321. /// 直属创客交易额列表
  1322. /// </summary>
  1323. /// <returns></returns>
  1324. public JsonResult ChildrenData(Users data, int BrandSelect, string MakerCode, string CreateDateData, int ParentId = 0, int page = 1, int limit = 30)
  1325. {
  1326. Dictionary<string, string> Fields = new Dictionary<string, string>();
  1327. Fields.Add("MakerCode", "1"); //创客编号
  1328. int BrandId = BrandSelect;
  1329. string start = "";
  1330. string end = "";
  1331. string condition = "";
  1332. string con = "";
  1333. string cons = "";
  1334. string sort = "Id desc";
  1335. if (!string.IsNullOrEmpty(BrandSelect.ToString()) || !string.IsNullOrEmpty(MakerCode) || !string.IsNullOrEmpty(CreateDateData))
  1336. {
  1337. condition = " and Status>-1 and AuthFlag >0";
  1338. con = " and Status>-1";
  1339. cons = " and Status>=-1";
  1340. }
  1341. //创客编号
  1342. if (!string.IsNullOrEmpty(MakerCode))
  1343. {
  1344. condition += " and Id in (select UserId from UserForMakerCode where MakerCode='" + MakerCode + "')";
  1345. }
  1346. if (ParentId > 0)
  1347. {
  1348. condition += " and ParentUserId=" + ParentId + " or Id=" + ParentId;
  1349. }
  1350. //时间不为空
  1351. if (!string.IsNullOrEmpty(CreateDateData))
  1352. {
  1353. string[] datelist = CreateDateData.Split(new string[] { " - " }, StringSplitOptions.None);
  1354. start = datelist[0].Replace("-", "");
  1355. end = datelist[1].Replace("-", "");
  1356. con += " and TradeDate>='" + start + "' and TradeDate<='" + end + "'";
  1357. cons += " and DATE_FORMAT(BindingTime,'%Y%m%d') >=" + start + " and DATE_FORMAT(BindingTime,'%Y%m%d') <=" + end;
  1358. }
  1359. //时间为空
  1360. if (string.IsNullOrEmpty(CreateDateData))
  1361. {
  1362. start = DateTime.Now.ToString("yyyyMM") + "01";
  1363. end = DateTime.Now.AddMonths(1).ToString("yyyyMM") + "01";
  1364. con += " and TradeDate>='" + start + "' and TradeDate<'" + end + "'";
  1365. cons += " and DATE_FORMAT(BindingTime,'%Y%m%d') >=" + start + " and DATE_FORMAT(BindingTime,'%Y%m%d') <" + end;
  1366. }
  1367. if (!string.IsNullOrEmpty(BrandSelect.ToString()) && BrandId > 0)
  1368. {
  1369. con += " and BrandId='" + BrandId + "'";
  1370. cons += " and BrandId='" + BrandId + "'";
  1371. }
  1372. Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("Users", Fields, sort, "True", page, limit, condition);
  1373. List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
  1374. foreach (Dictionary<string, object> dic in diclist)
  1375. {
  1376. int UId = int.Parse(dic["Id"].ToString());
  1377. var Info = GetMonthTradeForBrand(UId, start, end, BrandId);
  1378. dic["TotalAmtfc"] = Convert.ToDecimal(Info["TotalAmtfc"].ToString()) + Convert.ToDecimal(Info["YAmtfc"].ToString());
  1379. dic["DAmtfc"] = Convert.ToDecimal(Info["DAmtfc"].ToString());
  1380. dic["JAmtfc"] = Convert.ToDecimal(Info["JAmtfc"].ToString());
  1381. dic["JfAmtfc"] = Convert.ToDecimal(Info["JfAmtfc"].ToString());
  1382. dic["JCountfc"] = Convert.ToInt32(Info["JCountfc"].ToString());
  1383. dic["YAmtfc"] = Convert.ToDecimal(Info["YAmtfc"].ToString());
  1384. dic["TotalAmtwd"] = Convert.ToDecimal(Info["TotalAmtwd"].ToString()) + Convert.ToDecimal(Info["YAmtwd"].ToString());
  1385. dic["DAmtwd"] = Convert.ToDecimal(Info["DAmtwd"].ToString());
  1386. dic["JAmtwd"] = Convert.ToDecimal(Info["JAmtwd"].ToString());
  1387. dic["JfAmtwd"] = Convert.ToDecimal(Info["JfAmtwd"].ToString());
  1388. dic["JCountwd"] = Convert.ToInt32(Info["JCountwd"].ToString());
  1389. dic["YAmtwd"] = Convert.ToDecimal(Info["YAmtwd"].ToString());
  1390. dic["TBCount"] = Info["TBCount"].ToString();
  1391. dic["TACount"] = Info["TACount"].ToString();
  1392. // dic["BCount"] = Info["BCount"].ToString();
  1393. // dic["ACount"] = Info["ACount"].ToString();
  1394. }
  1395. //个人
  1396. //扶持期
  1397. decimal TotalAmtfc = 0;
  1398. decimal DAmtfc = 0;
  1399. decimal JAmtfc = 0;
  1400. decimal JfAmtfc = 0;
  1401. int JCountfc = 0;
  1402. decimal YAmtfc = 0;
  1403. //稳定期
  1404. decimal TotalAmtwd = 0;
  1405. decimal DAmtwd = 0;
  1406. decimal JAmtwd = 0;
  1407. decimal JfAmtwd = 0;
  1408. int JCountwd = 0;
  1409. decimal YAmtwd = 0;
  1410. //团队
  1411. //扶持期
  1412. decimal TotalAmtfc1 = 0;
  1413. decimal DAmtfc1 = 0;
  1414. decimal JAmtfc1 = 0;
  1415. decimal JfAmtfc1 = 0;
  1416. int JCountfc1 = 0;
  1417. decimal YAmtfc1 = 0;
  1418. //稳定期
  1419. decimal TotalAmtwd1 = 0;
  1420. decimal DAmtwd1 = 0;
  1421. decimal JAmtwd1 = 0;
  1422. decimal JfAmtwd1 = 0;
  1423. int JCountwd1 = 0;
  1424. decimal YAmtwd1 = 0;
  1425. int PBCount = 0;
  1426. int PACount = 0;
  1427. int TBCount = 0;
  1428. int TACount = 0;
  1429. WebCMSEntities db = new WebCMSEntities();
  1430. Dictionary<string, object> other = new Dictionary<string, object>();
  1431. DataTable dt = OtherMySqlConn.dtable("select Sum(HelpDirectTradeAmt + HelpDirectDebitTradeAmt) from TradeDaySummary where SeoTitle='self' and UserId= '" + ParentId + "'" + con);
  1432. if (dt.Rows.Count > 0)
  1433. {
  1434. TotalAmtfc = Convert.ToDecimal(function.CheckNum(dt.Rows[0][0].ToString()));
  1435. }
  1436. dt = OtherMySqlConn.dtable("select Sum(HelpDirectTradeAmt) from TradeDaySummary where QueryCount=0 and SeoTitle='self' and UserId= '" + ParentId + "'" + con);
  1437. if (dt.Rows.Count > 0)
  1438. {
  1439. DAmtfc = Convert.ToDecimal(function.CheckNum(dt.Rows[0][0].ToString()));
  1440. }
  1441. dt = OtherMySqlConn.dtable("select Sum(HelpDirectDebitTradeAmt),Sum(HelpDirectDebitCapTradeAmt) from TradeDaySummary where QueryCount=0 and SeoTitle='self' and UserId= '" + ParentId + "'" + con);
  1442. if (dt.Rows.Count > 0)
  1443. {
  1444. JAmtfc = Convert.ToDecimal(function.CheckNum(dt.Rows[0][0].ToString())) - Convert.ToDecimal(function.CheckNum(dt.Rows[0][1].ToString()));
  1445. }
  1446. dt = OtherMySqlConn.dtable("select Sum(HelpDirectDebitCapTradeAmt) from TradeDaySummary where QueryCount=0 and SeoTitle='self' and UserId= '" + ParentId + "'" + con);
  1447. if (dt.Rows.Count > 0)
  1448. {
  1449. JfAmtfc = Convert.ToDecimal(function.CheckNum(dt.Rows[0][0].ToString()));
  1450. }
  1451. dt = OtherMySqlConn.dtable("select Sum(HelpDirectDebitCapNum) from TradeDaySummary where QueryCount=0 and SeoTitle='self' and UserId= '" + ParentId + "'" + con);
  1452. if (dt.Rows.Count > 0)
  1453. {
  1454. JCountfc = Convert.ToInt32(function.CheckInt(dt.Rows[0][0].ToString()));
  1455. }
  1456. dt = OtherMySqlConn.dtable("select Sum(HelpDirectTradeAmt) from TradeDaySummary where QueryCount=1 and SeoTitle='self' and UserId= '" + ParentId + "'" + con);
  1457. if (dt.Rows.Count > 0)
  1458. {
  1459. YAmtfc = Convert.ToDecimal(function.CheckNum(dt.Rows[0][0].ToString()));
  1460. }
  1461. dt = OtherMySqlConn.dtable("select Sum(NotHelpDirectTradeAmt + NotHelpDirectDebitTradeAmt) from TradeDaySummary where SeoTitle='self' and UserId= '" + ParentId + "'" + con);
  1462. if (dt.Rows.Count > 0)
  1463. {
  1464. TotalAmtwd = Convert.ToDecimal(function.CheckNum(dt.Rows[0][0].ToString()));
  1465. }
  1466. dt = OtherMySqlConn.dtable("select Sum(NotHelpDirectTradeAmt) from TradeDaySummary where QueryCount=0 and SeoTitle='self' and UserId= '" + ParentId + "'" + con);
  1467. if (dt.Rows.Count > 0)
  1468. {
  1469. DAmtwd = Convert.ToDecimal(function.CheckNum(dt.Rows[0][0].ToString()));
  1470. }
  1471. dt = OtherMySqlConn.dtable("select Sum(NotHelpDirectDebitTradeAmt),Sum(NotHelpDirectDebitCapTradeAmt) from TradeDaySummary where QueryCount=0 and SeoTitle='self' and UserId= '" + ParentId + "'" + con);
  1472. if (dt.Rows.Count > 0)
  1473. {
  1474. JAmtwd = Convert.ToDecimal(function.CheckNum(dt.Rows[0][0].ToString())) - Convert.ToDecimal(function.CheckNum(dt.Rows[0][1].ToString()));
  1475. }
  1476. dt = OtherMySqlConn.dtable("select Sum(NotHelpDirectDebitCapTradeAmt) from TradeDaySummary where QueryCount=0 and SeoTitle='self' and UserId= '" + ParentId + "'" + con);
  1477. if (dt.Rows.Count > 0)
  1478. {
  1479. JfAmtwd = Convert.ToDecimal(function.CheckNum(dt.Rows[0][0].ToString()));
  1480. }
  1481. dt = OtherMySqlConn.dtable("select Sum(NotHelpDirectDebitCapNum) from TradeDaySummary where QueryCount=0 and SeoTitle='self' and UserId= '" + ParentId + "'" + con);
  1482. if (dt.Rows.Count > 0)
  1483. {
  1484. JCountwd = Convert.ToInt32(function.CheckInt(dt.Rows[0][0].ToString()));
  1485. }
  1486. dt = OtherMySqlConn.dtable("select Sum(NotHelpDirectTradeAmt) from TradeDaySummary where QueryCount=1 and SeoTitle='self' and UserId= '" + ParentId + "'" + con);
  1487. if (dt.Rows.Count > 0)
  1488. {
  1489. YAmtwd = Convert.ToDecimal(function.CheckNum(dt.Rows[0][0].ToString()));
  1490. }
  1491. //TODO: 统计激活绑定数(个人)
  1492. dt = OtherMySqlConn.dtable("SELECT COUNT(0) count FROM PosMachinesTwo WHERE BindingState=1 AND BuyUserId= '" + ParentId + "'" + cons);
  1493. if (dt.Rows.Count > 0)
  1494. {
  1495. PBCount = Convert.ToInt32(function.CheckNum(dt.Rows[0][0].ToString()));
  1496. }
  1497. dt = OtherMySqlConn.dtable("SELECT SUM(DirectDebitCapNum) sum FROM UserTradeDaySummary WHERE SeoTitle='self' AND UserId= '" + ParentId + "'" + con);
  1498. if (dt.Rows.Count > 0)
  1499. {
  1500. PACount = Convert.ToInt32(function.CheckNum(dt.Rows[0][0].ToString()));
  1501. }
  1502. //TODO: 统计激活绑定数(团队)
  1503. 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);
  1504. if (dt.Rows.Count > 0)
  1505. {
  1506. TBCount = Convert.ToInt32(function.CheckNum(dt.Rows[0][0].ToString()));
  1507. }
  1508. dt = OtherMySqlConn.dtable("SELECT SUM(NonDirectDebitCapNum) sum FROM UserTradeDaySummary WHERE SeoTitle='team' AND UserId= '" + ParentId + "'" + con);
  1509. if (dt.Rows.Count > 0)
  1510. {
  1511. TACount = Convert.ToInt32(function.CheckNum(dt.Rows[0][0].ToString()));
  1512. }
  1513. DataTable dts = OtherMySqlConn.dtable("select Sum(HelpNonDirectTradeAmt + HelpNonDirectDebitTradeAmt) from TradeDaySummary where SeoTitle='team' and UserId= '" + ParentId + "'" + con);
  1514. if (dts.Rows.Count > 0)
  1515. {
  1516. TotalAmtfc1 = Convert.ToDecimal(function.CheckNum(dts.Rows[0][0].ToString()));
  1517. }
  1518. dts = OtherMySqlConn.dtable("select Sum(HelpNonDirectTradeAmt) from TradeDaySummary where QueryCount=0 and SeoTitle='team' and UserId= '" + ParentId + "'" + con);
  1519. if (dt.Rows.Count > 0)
  1520. {
  1521. DAmtfc1 = Convert.ToDecimal(function.CheckNum(dts.Rows[0][0].ToString()));
  1522. }
  1523. dts = OtherMySqlConn.dtable("select Sum(HelpNonDirectDebitTradeAmt),Sum(HelpNonDirectDebitCapTradeAmt) from TradeDaySummary where QueryCount=0 and SeoTitle='team' and UserId= '" + ParentId + "'" + con);
  1524. if (dt.Rows.Count > 0)
  1525. {
  1526. JAmtfc1 = Convert.ToDecimal(function.CheckNum(dts.Rows[0][0].ToString())) - Convert.ToDecimal(function.CheckNum(dts.Rows[0][1].ToString()));
  1527. }
  1528. dts = OtherMySqlConn.dtable("select Sum(HelpNonDirectDebitCapTradeAmt) from TradeDaySummary where QueryCount=0 and SeoTitle='team' and UserId= '" + ParentId + "'" + con);
  1529. if (dts.Rows.Count > 0)
  1530. {
  1531. JfAmtfc1 = Convert.ToDecimal(function.CheckNum(dts.Rows[0][0].ToString()));
  1532. }
  1533. dts = OtherMySqlConn.dtable("select Sum(HelpNoonDirectDebitCapNum) from TradeDaySummary where QueryCount=0 and SeoTitle='team' and UserId= '" + ParentId + "'" + con);
  1534. if (dts.Rows.Count > 0)
  1535. {
  1536. JCountfc1 = Convert.ToInt32(function.CheckInt(dts.Rows[0][0].ToString()));
  1537. }
  1538. dts = OtherMySqlConn.dtable("select Sum(HelpNonDirectTradeAmt) from TradeDaySummary where QueryCount=1 and SeoTitle='team' and UserId= '" + ParentId + "'" + con);
  1539. if (dts.Rows.Count > 0)
  1540. {
  1541. YAmtfc1 = Convert.ToDecimal(function.CheckNum(dts.Rows[0][0].ToString()));
  1542. }
  1543. dts = OtherMySqlConn.dtable("select Sum(NotHelpNonDirectTradeAmt + NotHelpNonDirectDebitTradeAmt) from TradeDaySummary where SeoTitle='team' and UserId= '" + ParentId + "'" + con);
  1544. if (dts.Rows.Count > 0)
  1545. {
  1546. TotalAmtwd1 = Convert.ToDecimal(function.CheckNum(dts.Rows[0][0].ToString()));
  1547. }
  1548. dts = OtherMySqlConn.dtable("select Sum(NotHelpNonDirectTradeAmt) from TradeDaySummary where QueryCount=0 and SeoTitle='team' and UserId= '" + ParentId + "'" + con);
  1549. if (dts.Rows.Count > 0)
  1550. {
  1551. DAmtwd1 = Convert.ToDecimal(function.CheckNum(dts.Rows[0][0].ToString()));
  1552. }
  1553. dts = OtherMySqlConn.dtable("select Sum(NotHelpNonDirectDebitTradeAmt),Sum(NotHelpDirectDebitCapTradeAmt) from TradeDaySummary where QueryCount=0 and SeoTitle='team' and UserId= '" + ParentId + "'" + con);
  1554. if (dts.Rows.Count > 0)
  1555. {
  1556. JAmtwd1 = Convert.ToDecimal(function.CheckNum(dts.Rows[0][0].ToString())) - Convert.ToDecimal(function.CheckNum(dts.Rows[0][1].ToString()));
  1557. }
  1558. dts = OtherMySqlConn.dtable("select Sum(NotHelpNonDirectDebitCapTradeAmt) from TradeDaySummary where QueryCount=0 and SeoTitle='team' and UserId= '" + ParentId + "'" + con);
  1559. if (dts.Rows.Count > 0)
  1560. {
  1561. JfAmtwd1 = Convert.ToDecimal(function.CheckNum(dts.Rows[0][0].ToString()));
  1562. }
  1563. dts = OtherMySqlConn.dtable("select Sum(NotHelpNonDirectDebitCapNum) from TradeDaySummary where QueryCount=0 and SeoTitle='team' and UserId= '" + ParentId + "'" + con);
  1564. if (dts.Rows.Count > 0)
  1565. {
  1566. JCountwd1 = Convert.ToInt32(function.CheckInt(dts.Rows[0][0].ToString()));
  1567. }
  1568. dts = OtherMySqlConn.dtable("select Sum(NotHelpNonDirectTradeAmt) from TradeDaySummary where QueryCount=1 and SeoTitle='team' and UserId= '" + ParentId + "'" + con);
  1569. if (dts.Rows.Count > 0)
  1570. {
  1571. YAmtwd1 = Convert.ToDecimal(function.CheckNum(dts.Rows[0][0].ToString()));
  1572. }
  1573. other.Add("TotalAmtfc", TotalAmtfc);
  1574. other.Add("DAmtfc", DAmtfc);
  1575. other.Add("JAmtfc", JAmtfc);
  1576. other.Add("JfAmtfc", JfAmtfc);
  1577. other.Add("JCountfc", JCountfc);
  1578. other.Add("YAmtfc", YAmtfc);
  1579. other.Add("TotalAmtwd", TotalAmtwd);
  1580. other.Add("DAmtwd", DAmtwd);
  1581. other.Add("JAmtwd", JAmtwd);
  1582. other.Add("JfAmtwd", JfAmtwd);
  1583. other.Add("JCountwd", JCountwd);
  1584. other.Add("YAmtwd", YAmtwd);
  1585. other.Add("TotalAmtfc1", TotalAmtfc1);
  1586. other.Add("DAmtfc1", DAmtfc1);
  1587. other.Add("JAmtfc1", JAmtfc1);
  1588. other.Add("JfAmtfc1", JfAmtfc1);
  1589. other.Add("JCountfc1", JCountfc1);
  1590. other.Add("YAmtfc1", YAmtfc1);
  1591. other.Add("TotalAmtwd1", TotalAmtwd1);
  1592. other.Add("DAmtwd1", DAmtwd1);
  1593. other.Add("JAmtwd1", JAmtwd1);
  1594. other.Add("JfAmtwd1", JfAmtwd1);
  1595. other.Add("JCountwd1", JCountwd1);
  1596. other.Add("YAmtwd1", YAmtwd1);
  1597. other.Add("PBCount", PBCount);
  1598. other.Add("PACount", PACount);
  1599. other.Add("TBCount", TBCount);
  1600. other.Add("TACount", TACount);
  1601. db.Dispose();
  1602. obj.Add("other", other);
  1603. return Json(obj);
  1604. }
  1605. public Dictionary<string, object> GetMonthTradeForBrand(int UserId, string sTradeDate, string eTradeDate, int BrandId)
  1606. {
  1607. string condition = " and Status>-1";
  1608. string cons = " and Status>=-1";
  1609. string con = " and Status>=-1";
  1610. //产品类型
  1611. if (!string.IsNullOrEmpty(BrandId.ToString()) && BrandId > 0)
  1612. {
  1613. condition += " and BrandId =" + BrandId;
  1614. cons += " and BrandId =" + BrandId;
  1615. con += " and BrandId =" + BrandId;
  1616. }
  1617. //创客Id
  1618. if (!string.IsNullOrEmpty(UserId.ToString()))
  1619. {
  1620. condition += " and UserId =" + UserId;
  1621. }
  1622. //开始时间
  1623. if (!string.IsNullOrEmpty(sTradeDate))
  1624. {
  1625. condition += " and TradeDate >=" + Convert.ToInt32(sTradeDate);
  1626. cons += " and DATE_FORMAT(BindingTime,'%Y%m%d') >=" + Convert.ToInt32(sTradeDate);
  1627. con += " and TradeDate >=" + Convert.ToInt32(sTradeDate);
  1628. }
  1629. //结束时间
  1630. if (!string.IsNullOrEmpty(eTradeDate))
  1631. {
  1632. condition += " and TradeDate <=" + Convert.ToInt32(eTradeDate);
  1633. cons += " and DATE_FORMAT(BindingTime,'%Y%m%d') <=" + Convert.ToInt32(eTradeDate);
  1634. con += " and TradeDate <=" + Convert.ToInt32(eTradeDate);
  1635. }
  1636. //扶持期
  1637. decimal TotalAmtfc = 0;
  1638. decimal DAmtfc = 0;
  1639. decimal JAmtfc = 0;
  1640. decimal JfAmtfc = 0;
  1641. int JCountfc = 0;
  1642. decimal YAmtfc = 0;
  1643. //稳定期
  1644. decimal TotalAmtwd = 0;
  1645. decimal DAmtwd = 0;
  1646. decimal JAmtwd = 0;
  1647. decimal JfAmtwd = 0;
  1648. int JCountwd = 0;
  1649. decimal YAmtwd = 0;
  1650. int BCount = 0;
  1651. int ACount = 0;
  1652. int PBCount = 0;
  1653. int PACount = 0;
  1654. int TBCount = 0;
  1655. int TACount = 0;
  1656. WebCMSEntities db = new WebCMSEntities();
  1657. Dictionary<string, object> obj = new Dictionary<string, object>();
  1658. DataTable dt = OtherMySqlConn.dtable("select Sum(HelpNonDirectTradeAmt + HelpNonDirectDebitTradeAmt) from TradeDaySummary where SeoTitle='team'" + condition);
  1659. if (dt.Rows.Count > 0)
  1660. {
  1661. TotalAmtfc = Convert.ToDecimal(function.CheckNum(dt.Rows[0][0].ToString()));
  1662. }
  1663. dt = OtherMySqlConn.dtable("select Sum(HelpNonDirectTradeAmt) from TradeDaySummary where QueryCount=0 and SeoTitle='team'" + condition);
  1664. if (dt.Rows.Count > 0)
  1665. {
  1666. DAmtfc = Convert.ToDecimal(function.CheckNum(dt.Rows[0][0].ToString()));
  1667. }
  1668. dt = OtherMySqlConn.dtable("select Sum(HelpNonDirectDebitTradeAmt),Sum(HelpDirectDebitCapTradeAmt) from TradeDaySummary where QueryCount=0 and SeoTitle='team'" + condition);
  1669. if (dt.Rows.Count > 0)
  1670. {
  1671. JAmtfc = Convert.ToDecimal(function.CheckNum(dt.Rows[0][0].ToString())) - Convert.ToDecimal(function.CheckNum(dt.Rows[0][1].ToString()));
  1672. }
  1673. dt = OtherMySqlConn.dtable("select Sum(HelpDirectDebitCapTradeAmt) from TradeDaySummary where QueryCount=0 and SeoTitle='team'" + condition);
  1674. if (dt.Rows.Count > 0)
  1675. {
  1676. JfAmtfc = Convert.ToDecimal(function.CheckNum(dt.Rows[0][0].ToString()));
  1677. }
  1678. dt = OtherMySqlConn.dtable("select Sum(HelpDirectDebitCapNum) from TradeDaySummary where QueryCount=0 and SeoTitle='team'" + condition);
  1679. if (dt.Rows.Count > 0)
  1680. {
  1681. JCountfc = Convert.ToInt32(function.CheckInt(dt.Rows[0][0].ToString()));
  1682. }
  1683. dt = OtherMySqlConn.dtable("select Sum(HelpNonDirectTradeAmt) from TradeDaySummary where QueryCount=1 and SeoTitle='team'" + condition);
  1684. if (dt.Rows.Count > 0)
  1685. {
  1686. YAmtfc = Convert.ToDecimal(function.CheckNum(dt.Rows[0][0].ToString()));
  1687. }
  1688. dt = OtherMySqlConn.dtable("select Sum(NotHelpNonDirectTradeAmt + NotHelpNonDirectDebitTradeAmt) from TradeDaySummary where SeoTitle='team'" + condition);
  1689. if (dt.Rows.Count > 0)
  1690. {
  1691. TotalAmtwd = Convert.ToDecimal(function.CheckNum(dt.Rows[0][0].ToString()));
  1692. }
  1693. dt = OtherMySqlConn.dtable("select Sum(NotHelpNonDirectTradeAmt) from TradeDaySummary where QueryCount=0 and SeoTitle='team'" + condition);
  1694. if (dt.Rows.Count > 0)
  1695. {
  1696. DAmtwd = Convert.ToDecimal(function.CheckNum(dt.Rows[0][0].ToString()));
  1697. }
  1698. dt = OtherMySqlConn.dtable("select Sum(NotHelpNonDirectDebitTradeAmt),Sum(NotHelpDirectDebitCapTradeAmt) from TradeDaySummary where QueryCount=0 and SeoTitle='team'" + condition);
  1699. if (dt.Rows.Count > 0)
  1700. {
  1701. JAmtwd = Convert.ToDecimal(function.CheckNum(dt.Rows[0][0].ToString())) - Convert.ToDecimal(function.CheckNum(dt.Rows[0][1].ToString()));
  1702. }
  1703. dt = OtherMySqlConn.dtable("select Sum(NotHelpDirectDebitCapTradeAmt) from TradeDaySummary where QueryCount=0 and SeoTitle='team'" + condition);
  1704. if (dt.Rows.Count > 0)
  1705. {
  1706. JfAmtwd = Convert.ToDecimal(function.CheckNum(dt.Rows[0][0].ToString()));
  1707. }
  1708. dt = OtherMySqlConn.dtable("select Sum(NotHelpDirectDebitCapNum) from TradeDaySummary where QueryCount=0 and SeoTitle='team'" + condition);
  1709. if (dt.Rows.Count > 0)
  1710. {
  1711. JCountwd = Convert.ToInt32(function.CheckInt(dt.Rows[0][0].ToString()));
  1712. }
  1713. dt = OtherMySqlConn.dtable("select Sum(NotHelpNonDirectTradeAmt) from TradeDaySummary where QueryCount=1 and SeoTitle='team'" + condition);
  1714. if (dt.Rows.Count > 0)
  1715. {
  1716. YAmtwd = Convert.ToDecimal(function.CheckNum(dt.Rows[0][0].ToString()));
  1717. }
  1718. dt = OtherMySqlConn.dtable("SELECT SUM(NonDirectDebitCapNum) sum FROM UserTradeDaySummary WHERE SeoTitle='team' AND UserId= '" + UserId + "'" + cons);
  1719. if (dt.Rows.Count > 0)
  1720. {
  1721. BCount = Convert.ToInt32(function.CheckNum(dt.Rows[0][0].ToString()));
  1722. }
  1723. dt = OtherMySqlConn.dtable("SELECT SUM(NonDirectDebitCapNum) sum FROM UserTradeDaySummary WHERE SeoTitle='team' AND UserId= '" + UserId + "'" + cons);
  1724. if (dt.Rows.Count > 0)
  1725. {
  1726. ACount = Convert.ToInt32(function.CheckNum(dt.Rows[0][0].ToString()));
  1727. }
  1728. //TODO: 统计激活绑定数(个人)
  1729. dt = OtherMySqlConn.dtable("SELECT COUNT(0) count FROM PosMachinesTwo WHERE BindingState=1 AND BuyUserId= '" + UserId + "'" + cons);
  1730. if (dt.Rows.Count > 0)
  1731. {
  1732. PBCount = Convert.ToInt32(function.CheckNum(dt.Rows[0][0].ToString()));
  1733. }
  1734. dt = OtherMySqlConn.dtable("SELECT SUM(DirectDebitCapNum) sum FROM UserTradeDaySummary WHERE SeoTitle='self' AND UserId= '" + UserId + "'" + con);
  1735. if (dt.Rows.Count > 0)
  1736. {
  1737. PACount = Convert.ToInt32(function.CheckNum(dt.Rows[0][0].ToString()));
  1738. }
  1739. //TODO: 统计激活绑定数(团队)
  1740. 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);
  1741. if (dt.Rows.Count > 0)
  1742. {
  1743. TBCount = Convert.ToInt32(function.CheckNum(dt.Rows[0][0].ToString()));
  1744. }
  1745. dt = OtherMySqlConn.dtable("SELECT SUM(NonDirectDebitCapNum) sum FROM UserTradeDaySummary WHERE SeoTitle='team' AND UserId= '" + UserId + "'" + con);
  1746. if (dt.Rows.Count > 0)
  1747. {
  1748. TACount = Convert.ToInt32(function.CheckNum(dt.Rows[0][0].ToString()));
  1749. }
  1750. obj.Add("TotalAmtfc", TotalAmtfc);
  1751. obj.Add("DAmtfc", DAmtfc);
  1752. obj.Add("JAmtfc", JAmtfc);
  1753. obj.Add("JfAmtfc", JfAmtfc);
  1754. obj.Add("JCountfc", JCountfc);
  1755. obj.Add("YAmtfc", YAmtfc);
  1756. obj.Add("TotalAmtwd", TotalAmtwd);
  1757. obj.Add("DAmtwd", DAmtwd);
  1758. obj.Add("JAmtwd", JAmtwd);
  1759. obj.Add("JfAmtwd", JfAmtwd);
  1760. obj.Add("JCountwd", JCountwd);
  1761. obj.Add("YAmtwd", YAmtwd);
  1762. obj.Add("BCount", BCount);
  1763. obj.Add("ACount", ACount);
  1764. obj.Add("PBCount", PBCount);
  1765. obj.Add("PACount", PACount);
  1766. obj.Add("TBCount", TBCount);
  1767. obj.Add("TACount", TACount);
  1768. db.Dispose();
  1769. return obj;
  1770. }
  1771. #endregion
  1772. }
  1773. }