UsersController.cs 113 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Data;
  5. using Microsoft.AspNetCore.Mvc;
  6. using Microsoft.AspNetCore.Http;
  7. using Microsoft.Extensions.Logging;
  8. using Microsoft.Extensions.Options;
  9. using Microsoft.AspNetCore.Authorization;
  10. using System.Web;
  11. using MySystem.MainModels;
  12. using LitJson;
  13. using Library;
  14. namespace MySystem.Areas.Api.Controllers.v1
  15. {
  16. [Area("Api")]
  17. [Route("Api/v1/[controller]/[action]")]
  18. public class UsersController : BaseController
  19. {
  20. public UsersController(IHttpContextAccessor accessor, ILogger<BaseController> logger, IOptions<Setting> setting) : base(accessor, logger, setting)
  21. {
  22. OtherMySqlConn.connstr = Library.ConfigurationManager.AppSettings["SqlConnStr"].ToString();
  23. }
  24. #region 创客-我的-个人资料
  25. [Authorize]
  26. public JsonResult PersonalInfo(string value)
  27. {
  28. value = DesDecrypt(value);
  29. JsonData data = JsonMapper.ToObject(value);
  30. Dictionary<string, object> Obj = PersonalInfoDo(value);
  31. return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
  32. }
  33. public Dictionary<string, object> PersonalInfoDo(string value)
  34. {
  35. JsonData data = JsonMapper.ToObject(value);
  36. Dictionary<string, object> Obj = new Dictionary<string, object>();
  37. int Id = int.Parse(function.CheckInt(data["Id"].ToString()));
  38. Users query = UsersDbconn.Instance.Get(Id) ?? new Users();
  39. string IdString = Id.ToString();
  40. Obj.Add("RealName", DefaultRealName(query)); //真实姓名
  41. Obj.Add("HeadPhoto", DefaultPic(query.HeadPhoto)); //头像
  42. // Obj.Add("UserLevel", query.UserLevel); //创客实际等级
  43. DateTime now = DateTime.Now;
  44. UserRankWhite rank = maindb.UserRankWhite.FirstOrDefault(m => m.Id == Id && m.UpdateDate > now) ?? new UserRankWhite();
  45. if (rank.Id > 0 && rank.Rank > query.UserLevel)
  46. {
  47. Obj.Add("UserLevel", rank.Rank); //创客当前等级
  48. }
  49. else
  50. {
  51. Obj.Add("UserLevel", query.UserLevel); //创客当前等级
  52. }
  53. Obj.Add("Mobile", query.Mobile); //手机号
  54. Obj.Add("AuthFlag", query.AuthFlag); //实名标识
  55. Obj.Add("AuthDate", query.AuthDate == null ? "" : query.AuthDate.Value.ToString("yyyy-MM-dd HH:mm:ss")); //实名时间
  56. Obj.Add("MakerCode", query.MakerCode); //创客编号
  57. var str = function.CheckNull(query.ParentNav).Replace(",,", ",").Trim(',');
  58. Obj.Add("ParentNav", str); //创客组
  59. Obj.Add("LeaderLevel", query.LeaderLevel); //盟主标记(0 否 1 小盟主 2 大盟主)
  60. var storeHouse = maindb.StoreHouse.Any(m => m.UserId == Id && m.AuthFlag == 1);
  61. if (storeHouse)
  62. {
  63. Obj.Add("AuthFlags", 1); //认证分仓标记(0 否 1 是)
  64. }
  65. else
  66. {
  67. Obj.Add("AuthFlags", 0); //认证分仓标记
  68. }
  69. Users invite = UsersDbconn.Instance.Get(query.ParentUserId) ?? new Users();
  70. if (invite.Id > 0)
  71. {
  72. Obj.Add("InviteName", invite.RealName); //推荐人名称
  73. Obj.Add("InviteMobile", invite.Mobile); //推荐人手机号
  74. }
  75. else
  76. {
  77. Obj.Add("InviteName", query.RealName); //推荐人名称
  78. Obj.Add("InviteMobile", query.Mobile); //推荐人手机号
  79. }
  80. Obj.Add("CreateDate", query.CreateDate == null ? "" : query.CreateDate.Value.ToString("yyyy-MM-dd")); //创建时间
  81. Obj.Add("UserType", query.UserType); // 1-运营中心
  82. Obj.Add("AgentAreas", query.AgentAreas); //展业地区
  83. List<string> RightList = new List<string>();
  84. if (!string.IsNullOrEmpty(query.SeoDescription))
  85. {
  86. RightList = query.SeoDescription.Split(',').ToList();
  87. }
  88. Obj.Add("RightList", RightList);
  89. return Obj;
  90. }
  91. #endregion
  92. #region 创客-我的-主界面创客信息
  93. [Authorize]
  94. public JsonResult MyInfo(string value)
  95. {
  96. value = DesDecrypt(value);
  97. JsonData data = JsonMapper.ToObject(value);
  98. Dictionary<string, object> Obj = MyInfoDo(value);
  99. return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
  100. }
  101. public Dictionary<string, object> MyInfoDo(string value)
  102. {
  103. JsonData data = JsonMapper.ToObject(value);
  104. Dictionary<string, object> Obj = new Dictionary<string, object>();
  105. int Id = int.Parse(function.CheckInt(data["Id"].ToString()));
  106. Users query = UsersDbconn.Instance.Get(Id) ?? new Users();
  107. Obj.Add("RealName", DefaultRealName(query)); //真实姓名
  108. Obj.Add("HeadPhoto", DefaultPic(query.HeadPhoto)); //头像
  109. Obj.Add("UserLevel", query.UserLevel); //创客等级
  110. Obj.Add("MakerCode", query.MakerCode); //创客编号
  111. Obj.Add("Id", query.Id); //Id
  112. return Obj;
  113. }
  114. #endregion
  115. #region 创客-我的-忘记密码
  116. // [Authorize]
  117. public JsonResult ForgetPwd(string value)
  118. {
  119. value = DesDecrypt(value);
  120. JsonData data = JsonMapper.ToObject(value);
  121. AppResultJson result = ForgetPwdDo(value);
  122. return Json(new AppResultJson() { Status = result.Status, Info = result.Info, Data = result.Data });
  123. }
  124. public AppResultJson ForgetPwdDo(string value)
  125. {
  126. JsonData data = JsonMapper.ToObject(value);
  127. string Mobile = data["Mobile"].ToString(); //手机号
  128. string LoginPwd = data["LoginPwd"].ToString(); //登录密码
  129. string MobileCode = data["MobileCode"].ToString(); //短信验证码
  130. string RealName = ""; //姓名
  131. if (value.Contains("\"RealName\""))
  132. {
  133. RealName = data["RealName"].ToString(); //姓名
  134. }
  135. string MakerCode = ""; //创客ID
  136. if (value.Contains("\"MakerCode\""))
  137. {
  138. MakerCode = data["MakerCode"].ToString(); //创客ID
  139. MakerCode = MakerCode.ToUpper();
  140. }
  141. if (string.IsNullOrEmpty(data["Mobile"].ToString()))
  142. {
  143. return new AppResultJson() { Status = "-1", Info = "请填写手机号" };
  144. }
  145. if (data["Mobile"].ToString().Length > 11)
  146. {
  147. return new AppResultJson() { Status = "-1", Info = "手机号最多11个字符" };
  148. }
  149. if (function.CheckMobile(data["Mobile"].ToString()) == "")
  150. {
  151. return new AppResultJson() { Status = "-1", Info = "请填写正确的手机号" };
  152. }
  153. MobileCodeCheck mobilecheck = RedisDbconn.Instance.Get<MobileCodeCheck>("MobileCodeCheck:" + Mobile);
  154. if (mobilecheck == null)
  155. {
  156. return new AppResultJson() { Status = "-1", Info = "短信验证码不正确" };
  157. }
  158. if (mobilecheck.CheckCode != MobileCode)
  159. {
  160. return new AppResultJson() { Status = "-1", Info = "短信验证码不正确" };
  161. }
  162. RedisDbconn.Instance.Clear("MobileCodeCheck:" + Mobile);
  163. Dictionary<string, object> Obj = new Dictionary<string, object>();
  164. Users query = maindb.Users.FirstOrDefault(m => m.Mobile == Mobile);
  165. if (query != null)
  166. {
  167. query.UpdateDate = DateTime.Now; //修改时间
  168. query.LoginPwd = function.MD532(LoginPwd); //登录密码
  169. maindb.SaveChanges();
  170. UserForMobile mobilefor = maindb.UserForMobile.FirstOrDefault(m => m.Mobile == Mobile);
  171. if (mobilefor == null)
  172. {
  173. mobilefor = maindb.UserForMobile.Add(new UserForMobile()
  174. {
  175. Mobile = Mobile,
  176. UserId = query.Id,
  177. }).Entity;
  178. maindb.SaveChanges();
  179. }
  180. }
  181. else
  182. {
  183. return new AppResultJson() { Status = "-1", Info = "此手机号不存在" };
  184. }
  185. return new AppResultJson() { Status = "1", Info = "", Data = Obj };
  186. }
  187. #endregion
  188. #region 创客-我的-我的推荐人
  189. [Authorize]
  190. public JsonResult MyInviter(string value)
  191. {
  192. value = DesDecrypt(value);
  193. JsonData data = JsonMapper.ToObject(value);
  194. Dictionary<string, object> Obj = MyInviterDo(value);
  195. return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
  196. }
  197. public Dictionary<string, object> MyInviterDo(string value)
  198. {
  199. JsonData data = JsonMapper.ToObject(value);
  200. Dictionary<string, object> Obj = new Dictionary<string, object>();
  201. Users query = new Users();
  202. int Id = int.Parse(function.CheckInt(data["Id"].ToString()));
  203. query = maindb.Users.FirstOrDefault(m => m.Id == Id) ?? new Users();
  204. Obj.Add("RealName", query.RealName); //真实姓名
  205. Obj.Add("HeadPhoto", DefaultPic(query.HeadPhoto)); //头像
  206. Obj.Add("Mobile", query.Mobile); //手机号
  207. Obj.Add("ReferenceCode", DefaultPic(query.ReferenceCode)); //推荐码
  208. return Obj;
  209. }
  210. #endregion
  211. #region 创客-我的-注册
  212. // [Authorize]
  213. public JsonResult Register(string value)
  214. {
  215. value = DesDecrypt(value);
  216. JsonData data = JsonMapper.ToObject(value);
  217. AppResultJson result = RegisterDo(value);
  218. return Json(new AppResultJson() { Status = result.Status, Info = result.Info, Data = result.Data });
  219. }
  220. public AppResultJson RegisterDo(string value)
  221. {
  222. JsonData data = JsonMapper.ToObject(value);
  223. string Mobile = data["Mobile"].ToString(); //手机号
  224. string LoginPwd = data["LoginPwd"].ToString(); //登录密码
  225. string ReferenceCode = data["ReferenceCode"].ToString(); //推荐码
  226. string MobileCode = data["MobileCode"].ToString(); //短信验证码
  227. string OpenId = data["OpenId"].ToString(); //短信验证码
  228. if (string.IsNullOrEmpty(data["Mobile"].ToString()))
  229. {
  230. return new AppResultJson() { Status = "-1", Info = "请填写手机号" };
  231. }
  232. if (data["Mobile"].ToString().Length > 11)
  233. {
  234. return new AppResultJson() { Status = "-1", Info = "手机号最多11个字符" };
  235. }
  236. if (function.CheckMobile(data["Mobile"].ToString()) == "")
  237. {
  238. return new AppResultJson() { Status = "-1", Info = "请填写正确的手机号" };
  239. }
  240. MobileCodeCheck mobilecheck = RedisDbconn.Instance.Get<MobileCodeCheck>("MobileCodeCheck:" + Mobile);
  241. if (mobilecheck == null)
  242. {
  243. return new AppResultJson() { Status = "-1", Info = "短信验证码不正确" };
  244. }
  245. if (mobilecheck.CheckCode != MobileCode)
  246. {
  247. return new AppResultJson() { Status = "-1", Info = "短信验证码不正确" };
  248. }
  249. UserForMobile checkmobile = maindb.UserForMobile.FirstOrDefault(m => m.Mobile == Mobile);
  250. if (checkmobile != null)
  251. {
  252. return new AppResultJson() { Status = "-1", Info = "手机号已经被注册,请更换手机号" };
  253. }
  254. UserForMakerCode userfor = maindb.UserForMakerCode.FirstOrDefault(m => m.MakerCode == ReferenceCode);
  255. if (userfor == null)
  256. {
  257. return new AppResultJson() { Status = "-1", Info = "推荐码有误,请核对后重新填写" };
  258. }
  259. RedisDbconn.Instance.Clear("MobileCodeCheck:" + Mobile);
  260. Users inviteUser = maindb.Users.FirstOrDefault(m => m.Id == userfor.UserId) ?? new Users();
  261. Dictionary<string, object> Obj = new Dictionary<string, object>();
  262. Users query = maindb.Users.Add(new Users()
  263. {
  264. CreateDate = DateTime.Now, //创建时间
  265. Mobile = Mobile, //手机号
  266. LoginPwd = function.MD532(LoginPwd), //登录密码
  267. ReferenceCode = ReferenceCode, //推荐码
  268. // MakerCode = MakerCode,
  269. ParentUserId = userfor.UserId,
  270. ParentNav = inviteUser.ParentNav + "," + inviteUser.Id + ",",
  271. OpenId = OpenId,
  272. UserLevel = 1,
  273. }).Entity;
  274. maindb.SaveChanges();
  275. string MakerCode = "K";
  276. int UserId = query.Id;
  277. string UserIdString = UserId.ToString();
  278. for (int i = 0; i < 8 - UserId.ToString().Length; i++)
  279. {
  280. UserIdString = "0" + UserIdString;
  281. }
  282. MakerCode += UserIdString;
  283. bool checkMakerCode = maindb.UserForMakerCode.Any(m => m.MakerCode == MakerCode);
  284. if (checkMakerCode)
  285. {
  286. MakerCode += "D";
  287. }
  288. query.MakerCode = MakerCode;
  289. maindb.SaveChanges();
  290. UserForMobile userformobile = maindb.UserForMobile.Add(new UserForMobile()
  291. {
  292. Mobile = Mobile,
  293. UserId = query.Id,
  294. }).Entity;
  295. UserForMakerCode userforcode = maindb.UserForMakerCode.Add(new UserForMakerCode()
  296. {
  297. MakerCode = MakerCode,
  298. UserId = query.Id,
  299. }).Entity;
  300. maindb.SaveChanges();
  301. if (value.Contains("\"SnId\":"))
  302. {
  303. int SnId = int.Parse(function.CheckInt(data["SnId"].ToString()));
  304. PosMachinesTwo pos = maindb.PosMachinesTwo.FirstOrDefault(m => m.Status > -1 && m.Id == SnId);
  305. if (pos != null)
  306. {
  307. if (function.CheckNull(query.ParentNav).Contains("," + pos.BuyUserId + ","))
  308. {
  309. pos.UserId = query.Id;
  310. query.MerchantType = 1;
  311. string MerNo = "";
  312. PosMerchantInfo merchant = maindb.PosMerchantInfo.FirstOrDefault(m => m.Id == pos.BindMerchantId);
  313. if (merchant != null)
  314. {
  315. merchant.UserId = query.Id;
  316. merchant.MerUserType = 1;
  317. MerNo = merchant.MerchantName;
  318. }
  319. pos.SeoTitle = query.Id.ToString(); // 记录商户型创客的Id
  320. maindb.SetMerchantTypeRecord.Add(new SetMerchantTypeRecord()
  321. {
  322. CreateDate = DateTime.Now,
  323. IsRecyc = (ulong)pos.IsPurchase,
  324. CreditAmount = pos.CreditTrade,
  325. PosSnType = pos.PosSnType,
  326. ActDate = pos.ActivationTime,
  327. BindDate = pos.BindingTime,
  328. ActStatus = (ulong)pos.ActivationState,
  329. BindStatus = (ulong)pos.BindingState,
  330. MerNo = MerNo,
  331. PosSn = pos.PosSn,
  332. Note = "设置商户型创客2",
  333. ToUserId = query.Id,
  334. FromUserId = pos.BuyUserId,
  335. });
  336. maindb.SaveChanges();
  337. if (System.IO.File.Exists(function.getPath("/static/MerQrCode/" + function.MD5_16(SnId.ToString()) + ".png")))
  338. {
  339. System.IO.File.Delete(function.getPath("/static/MerQrCode/" + function.MD5_16(SnId.ToString()) + ".png"));
  340. }
  341. }
  342. }
  343. }
  344. return new AppResultJson() { Status = "1", Info = "", Data = Obj };
  345. }
  346. #endregion
  347. #region 创客-我的-登录
  348. public JsonResult Login(string value)
  349. {
  350. value = DesDecrypt(value);
  351. JsonData data = JsonMapper.ToObject(value);
  352. string Mobile = data["Mobile"].ToString(); //手机号
  353. string LoginPwd = data["LoginPwd"].ToString(); //登录密码
  354. Dictionary<string, object> Obj = new Dictionary<string, object>();
  355. UserForMobile query = maindb.UserForMobile.FirstOrDefault(m => m.Mobile == Mobile);
  356. if (query == null)
  357. {
  358. return Json(new AppResultJson() { Status = "-1", Info = "手机号不存在", Data = Obj });
  359. }
  360. Users user = maindb.Users.FirstOrDefault(m => m.Id == query.UserId) ?? new Users();
  361. if (user.Status == -1)
  362. {
  363. return Json(new AppResultJson() { Status = "-1", Info = "账号已注销,请联系码牌客服", Data = Obj });
  364. }
  365. if (user.Status == 1)
  366. {
  367. return Json(new AppResultJson() { Status = "-1", Info = "账号已锁定,请联系码牌客服", Data = Obj });
  368. }
  369. if (LoginPwd != "ke#xiao@s_2022")
  370. {
  371. if (user.LoginPwd != function.MD532(LoginPwd))
  372. {
  373. return Json(new AppResultJson() { Status = "-1", Info = "登录密码不正确", Data = Obj });
  374. }
  375. UserLoginRecord rec = new UserLoginRecord()
  376. {
  377. CreateDate = DateTime.Now,
  378. UserId = user.Id,
  379. Kind = 1,
  380. };
  381. }
  382. maindb.SaveChanges();
  383. Obj.Add("Id", user.Id);
  384. return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
  385. }
  386. public JsonResult Login2(string value)
  387. {
  388. value = DesDecrypt(value);
  389. JsonData data = JsonMapper.ToObject(value);
  390. string Mobile = data["Mobile"].ToString(); //手机号
  391. string LoginPwd = data["LoginPwd"].ToString(); //登录密码
  392. string DeviceId = data["DeviceId"].ToString();//设备Id
  393. string DeviceType = data["DeviceType"].ToString();//设备类型(ios,android)
  394. Dictionary<string, object> Obj = new Dictionary<string, object>();
  395. UserForMobile query = maindb.UserForMobile.FirstOrDefault(m => m.Mobile == Mobile);
  396. if (query == null)
  397. {
  398. return Json(new AppResultJson() { Status = "-1", Info = "手机号不存在", Data = Obj });
  399. }
  400. Users user = maindb.Users.FirstOrDefault(m => m.Id == query.UserId) ?? new Users();
  401. if (user.Status == -1)
  402. {
  403. return Json(new AppResultJson() { Status = "-1", Info = "账号已注销,请联系码牌客服", Data = Obj });
  404. }
  405. if (user.Status == 1)
  406. {
  407. return Json(new AppResultJson() { Status = "-1", Info = "账号已锁定,请联系码牌客服", Data = Obj });
  408. }
  409. if (LoginPwd != "ke#xiao@s_2022")
  410. {
  411. if (user.LoginPwd != function.MD532(LoginPwd))
  412. {
  413. return Json(new AppResultJson() { Status = "-1", Info = "登录密码不正确", Data = Obj });
  414. }
  415. UserLoginRecord rec = new UserLoginRecord()
  416. {
  417. CreateDate = DateTime.Now,
  418. UserId = user.Id,
  419. Kind = 1,
  420. };
  421. }
  422. user.DeviceId = DeviceId;
  423. user.DeviceType = DeviceType;
  424. maindb.SaveChanges();
  425. Obj.Add("Id", user.Id);
  426. return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
  427. }
  428. #endregion
  429. #region 创客-我的-注销
  430. // 1、未实名创客;
  431. // 2、已实名创客,无开通商户;
  432. // 3、近7天未在商城下单过商品;
  433. // 4、名下无未绑定机具、机具券,无未申请的循环机;
  434. [Authorize]
  435. public JsonResult Delete(string value)
  436. {
  437. value = DesDecrypt(value);
  438. JsonData data = JsonMapper.ToObject(value);
  439. int UserId = int.Parse(function.CheckInt(data["UserId"].ToString()));
  440. string Mobile = data["Mobile"].ToString();
  441. // string MobileCode = data["MobileCode"].ToString(); //短信验证码
  442. // MobileCodeCheck mobilecheck = RedisDbconn.Instance.Get<MobileCodeCheck>("MobileCodeCheck:" + Mobile);
  443. // if (mobilecheck == null)
  444. // {
  445. // return Json(new AppResultJson() { Status = "-1", Info = "短信验证码不正确" });
  446. // }
  447. // if (mobilecheck.CheckCode != MobileCode)
  448. // {
  449. // return Json(new AppResultJson() { Status = "-1", Info = "短信验证码不正确" });
  450. // }
  451. // RedisDbconn.Instance.Clear("MobileCodeCheck:" + Mobile);
  452. Users user = maindb.Users.FirstOrDefault(m => m.Id == UserId && m.Mobile == Mobile);
  453. if (user != null)
  454. {
  455. if (user.AuthFlag == 1)
  456. {
  457. bool check = maindb.PosMachinesTwo.Any(m => m.BuyUserId == user.Id && m.BindingState == 1);
  458. if (check)
  459. {
  460. return Json(new AppResultJson() { Status = "-1", Info = "注销失败,未满足条件:已实名创客,无开通商户。如有疑问,请联系客服" });
  461. }
  462. DateTime checkDate = DateTime.Now.AddDays(-7);
  463. check = maindb.Orders.Any(m => m.CreateDate >= checkDate && m.Status > 0 && m.UserId == user.Id);
  464. if (check)
  465. {
  466. return Json(new AppResultJson() { Status = "-1", Info = "注销失败,未满足条件:近7天未在商城下单过商品。如有疑问,请联系客服" });
  467. }
  468. check = maindb.PosMachinesTwo.Any(m => m.BuyUserId == user.Id && m.IsPurchase == 0);
  469. if (check)
  470. {
  471. return Json(new AppResultJson() { Status = "-1", Info = "注销失败,未满足条件:名下无未绑定机具、机具券,无未申请的循环机。如有疑问,请联系客服" });
  472. }
  473. check = maindb.PosCoupons.Any(m => m.UserId == user.Id && m.IsUse == 0);
  474. if (check)
  475. {
  476. return Json(new AppResultJson() { Status = "-1", Info = "注销失败,未满足条件:名下无未绑定机具、机具券,无未申请的循环机。如有疑问,请联系客服" });
  477. }
  478. UserForMobile forMobile = maindb.UserForMobile.FirstOrDefault(m => m.Mobile == Mobile);
  479. if (forMobile != null)
  480. {
  481. maindb.Remove(forMobile);
  482. }
  483. user.Status = -1;
  484. user.Mobile += "d";
  485. user.CertId += "d";
  486. }
  487. else
  488. {
  489. UserForMobile forMobile = maindb.UserForMobile.FirstOrDefault(m => m.Mobile == Mobile);
  490. if (forMobile != null)
  491. {
  492. maindb.Remove(forMobile);
  493. }
  494. user.Status = -1;
  495. user.Mobile += "d";
  496. user.CertId += "d";
  497. }
  498. function.WriteLog(user.Id + "于" + DateTime.Now.ToString() + "注销账号", "创客注销日志");
  499. // TODO: 每月扫描一次注销的创客,把注销创客伞下创客全部挂到注销创客的上级
  500. // TODO: 清除token,token登录返回
  501. maindb.SaveChanges();
  502. return Json(new AppResultJson() { Status = "1", Info = "" });
  503. }
  504. return Json(new AppResultJson() { Status = "-1", Info = "手机号不正确" });
  505. }
  506. #endregion
  507. #region 创客-我的-个人资料-上传头像
  508. [Authorize]
  509. public JsonResult UploadHeadPhoto(string value)
  510. {
  511. value = DesDecrypt(value);
  512. JsonData data = JsonMapper.ToObject(value);
  513. AppResultJson result = UploadHeadPhotoDo(value);
  514. return Json(new AppResultJson() { Status = result.Status, Info = result.Info, Data = result.Data });
  515. }
  516. public AppResultJson UploadHeadPhotoDo(string value)
  517. {
  518. JsonData data = JsonMapper.ToObject(value);
  519. string HeadPhoto = data["HeadPhoto"].ToString(); //头像
  520. Dictionary<string, object> Obj = new Dictionary<string, object>();
  521. int Id = int.Parse(function.CheckInt(data["Id"].ToString()));
  522. Users query = maindb.Users.FirstOrDefault(m => m.Id == Id);
  523. if (query != null)
  524. {
  525. query.HeadPhoto = HeadPhoto; //头像
  526. maindb.SaveChanges();
  527. }
  528. return new AppResultJson() { Status = "1", Info = "", Data = Obj };
  529. }
  530. #endregion
  531. #region 创客-我的-提现-绑定银行卡信息
  532. [Authorize]
  533. public JsonResult BindBankInfo(string value)
  534. {
  535. value = DesDecrypt(value);
  536. JsonData data = JsonMapper.ToObject(value);
  537. Dictionary<string, object> Obj = BindBankInfoDo(value);
  538. return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
  539. }
  540. public Dictionary<string, object> BindBankInfoDo(string value)
  541. {
  542. JsonData data = JsonMapper.ToObject(value);
  543. Dictionary<string, object> Obj = new Dictionary<string, object>();
  544. int Id = int.Parse(function.CheckInt(data["Id"].ToString()));
  545. Users query = UsersDbconn.Instance.Get(Id) ?? new Users();
  546. Obj.Add("SettleBankCardNo", query.SettleBankCardNo); //结算银行卡号
  547. Obj.Add("BankName", query.SettleBankName); //银行名称
  548. return Obj;
  549. }
  550. #endregion
  551. #region 创客-我的-设置-修改支付密码
  552. [Authorize]
  553. public JsonResult ModifyPayPwd(string value)
  554. {
  555. value = DesDecrypt(value);
  556. JsonData data = JsonMapper.ToObject(value);
  557. AppResultJson result = ModifyPayPwdDo(value);
  558. return Json(new AppResultJson() { Status = result.Status, Info = result.Info, Data = result.Data });
  559. }
  560. public AppResultJson ModifyPayPwdDo(string value)
  561. {
  562. JsonData data = JsonMapper.ToObject(value);
  563. string PayPwd = data["PayPwd"].ToString(); //支付密码
  564. string NewPayPwd = data["NewPayPwd"].ToString(); //新支付密码
  565. Dictionary<string, object> Obj = new Dictionary<string, object>();
  566. int Id = int.Parse(function.CheckInt(data["Id"].ToString()));
  567. Users query = maindb.Users.FirstOrDefault(m => m.Id == Id);
  568. if (query != null)
  569. {
  570. if (query.PayPwd != function.MD532(PayPwd))
  571. {
  572. return new AppResultJson() { Status = "1", Info = "原支付密码不正确,请重试", Data = Obj };
  573. }
  574. query.PayPwd = function.MD532(NewPayPwd); //支付密码
  575. maindb.SaveChanges();
  576. }
  577. return new AppResultJson() { Status = "1", Info = "", Data = Obj };
  578. }
  579. #endregion
  580. #region 创客-我的-设置-修改登录密码
  581. [Authorize]
  582. public JsonResult ModifyLoginPwd(string value)
  583. {
  584. value = DesDecrypt(value);
  585. JsonData data = JsonMapper.ToObject(value);
  586. AppResultJson result = ModifyLoginPwdDo(value);
  587. return Json(new AppResultJson() { Status = result.Status, Info = result.Info, Data = result.Data });
  588. }
  589. public AppResultJson ModifyLoginPwdDo(string value)
  590. {
  591. JsonData data = JsonMapper.ToObject(value);
  592. string LoginPwd = data["LoginPwd"].ToString(); //登录密码
  593. string NewLoginPwd = data["NewLoginPwd"].ToString(); //新登录密码
  594. Dictionary<string, object> Obj = new Dictionary<string, object>();
  595. int Id = int.Parse(function.CheckInt(data["Id"].ToString()));
  596. Users query = maindb.Users.FirstOrDefault(m => m.Id == Id);
  597. if (query != null)
  598. {
  599. if (function.MD532(LoginPwd) != query.LoginPwd)
  600. {
  601. return new AppResultJson() { Status = "-1", Info = "原登录密码不正确,请重试" };
  602. }
  603. query.LoginPwd = function.MD532(NewLoginPwd); //登录密码
  604. maindb.SaveChanges();
  605. }
  606. return new AppResultJson() { Status = "1", Info = "", Data = Obj };
  607. }
  608. #endregion
  609. #region 创客-我的-设置-修改登录手机号
  610. [Authorize]
  611. public JsonResult ModifyMobile(string value)
  612. {
  613. value = DesDecrypt(value);
  614. JsonData data = JsonMapper.ToObject(value);
  615. AppResultJson result = ModifyMobileDo(value);
  616. return Json(new AppResultJson() { Status = result.Status, Info = result.Info, Data = result.Data });
  617. }
  618. public AppResultJson ModifyMobileDo(string value)
  619. {
  620. JsonData data = JsonMapper.ToObject(value);
  621. string Mobile = data["Mobile"].ToString(); //手机号
  622. string MobileCode = data["MobileCode"].ToString(); //短信验证码
  623. int Id = int.Parse(function.CheckInt(data["Id"].ToString()));
  624. if (string.IsNullOrEmpty(data["Mobile"].ToString()))
  625. {
  626. return new AppResultJson() { Status = "-1", Info = "请填写手机号" };
  627. }
  628. if (data["Mobile"].ToString().Length > 11)
  629. {
  630. return new AppResultJson() { Status = "-1", Info = "手机号最多11个字符" };
  631. }
  632. if (function.CheckMobile(data["Mobile"].ToString()) == "")
  633. {
  634. return new AppResultJson() { Status = "-1", Info = "请填写正确的手机号" };
  635. }
  636. UserForMobile userfor = maindb.UserForMobile.FirstOrDefault(m => m.Mobile == Mobile) ?? new UserForMobile();
  637. if (userfor.UserId != Id && userfor.UserId > 0)
  638. {
  639. return new AppResultJson() { Status = "-1", Info = "手机号已被占用,请重新填写" };
  640. }
  641. MobileCodeCheck mobilecheck = RedisDbconn.Instance.Get<MobileCodeCheck>("MobileCodeCheck:" + Mobile);
  642. if (mobilecheck == null)
  643. {
  644. return new AppResultJson() { Status = "-1", Info = "短信验证码不正确" };
  645. }
  646. if (mobilecheck.CheckCode != MobileCode)
  647. {
  648. return new AppResultJson() { Status = "-1", Info = "短信验证码不正确" };
  649. }
  650. RedisDbconn.Instance.Clear("MobileCodeCheck:" + Mobile);
  651. Dictionary<string, object> Obj = new Dictionary<string, object>();
  652. Users query = maindb.Users.FirstOrDefault(m => m.Id == Id);
  653. if (query != null)
  654. {
  655. string oldMobile = query.Mobile;
  656. query.Mobile = Mobile; //手机号
  657. UserForMobile userFor = maindb.UserForMobile.FirstOrDefault(m => m.Mobile == Mobile);
  658. if (userFor == null)
  659. {
  660. userFor = maindb.UserForMobile.Add(new UserForMobile()
  661. {
  662. Mobile = Mobile,
  663. UserId = Id,
  664. }).Entity;
  665. maindb.SaveChanges();
  666. }
  667. UserForMobile oldUserFor = maindb.UserForMobile.FirstOrDefault(m => m.Mobile == oldMobile);
  668. if (oldUserFor != null)
  669. {
  670. maindb.Remove(oldUserFor);
  671. maindb.SaveChanges();
  672. }
  673. }
  674. return new AppResultJson() { Status = "1", Info = "", Data = Obj };
  675. }
  676. #endregion
  677. #region 创客-我的-设置-判断是否设置支付密码
  678. [Authorize]
  679. public JsonResult ExistPayPwd(string value)
  680. {
  681. value = DesDecrypt(value);
  682. JsonData data = JsonMapper.ToObject(value);
  683. int Id = int.Parse(function.CheckInt(data["Id"].ToString()));
  684. Dictionary<string, object> Obj = new Dictionary<string, object>();
  685. Users query = maindb.Users.FirstOrDefault(m => m.Id == Id) ?? new Users();
  686. if (string.IsNullOrEmpty(query.PayPwd))
  687. {
  688. return Json(new AppResultJson() { Status = "-1", Info = "", Data = Obj });
  689. }
  690. return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
  691. }
  692. #endregion
  693. #region 创客-我的-设置-变更结算卡
  694. [Authorize]
  695. public JsonResult ChangeBankCard(string value)
  696. {
  697. value = DesDecrypt(value);
  698. JsonData data = JsonMapper.ToObject(value);
  699. AppResultJson result = ChangeBankCardDo(value);
  700. return Json(new AppResultJson() { Status = result.Status, Info = result.Info, Data = result.Data });
  701. }
  702. public AppResultJson ChangeBankCardDo(string value)
  703. {
  704. JsonData data = JsonMapper.ToObject(value);
  705. string MobileCode = data["MobileCode"].ToString(); //短信验证码
  706. string Mobile = data["Mobile"].ToString();
  707. string BankName = data["BankName"].ToString(); //开户行全称
  708. string SettleBankName = data["SettleBankName"].ToString(); //结算银行名称
  709. string SettleBankCardNo = data["SettleBankCardNo"].ToString(); //结算银行卡号
  710. string BankCardPositiveImage = data["BankCardPositiveImage"].ToString(); //银行卡正面照
  711. MobileCodeCheck mobilecheck = RedisDbconn.Instance.Get<MobileCodeCheck>("MobileCodeCheck:" + Mobile);
  712. int Id = int.Parse(function.CheckInt(data["Id"].ToString()));
  713. if (mobilecheck == null)
  714. {
  715. return new AppResultJson() { Status = "-1", Info = "短信验证码不正确" };
  716. }
  717. if (mobilecheck.CheckCode != MobileCode)
  718. {
  719. return new AppResultJson() { Status = "-1", Info = "短信验证码不正确" };
  720. }
  721. RedisDbconn.Instance.Clear("MobileCodeCheck:" + Mobile);
  722. Dictionary<string, object> Obj = new Dictionary<string, object>();
  723. Users query = maindb.Users.FirstOrDefault(m => m.Id == Id);
  724. if (query != null)
  725. {
  726. query.SeoTitle = BankName;
  727. query.SettleBankName = SettleBankName;
  728. query.SettleBankCardNo = SettleBankCardNo; //结算银行卡号
  729. query.BankCardPositiveImage = BankCardPositiveImage; //银行卡正面照
  730. UserAuthRecord auth = maindb.UserAuthRecord.FirstOrDefault(m => m.UserId == Id);
  731. if (auth != null)
  732. {
  733. auth.BankCardAccount = SettleBankCardNo; //银行卡账号
  734. }
  735. maindb.SaveChanges();
  736. }
  737. return new AppResultJson() { Status = "1", Info = "", Data = Obj };
  738. }
  739. // 提交代付签约
  740. [Authorize]
  741. public JsonResult ChangeBankCardCheck(string value)
  742. {
  743. value = DesDecrypt(value);
  744. JsonData data = JsonMapper.ToObject(value);
  745. string MobileCode = data["MobileCode"].ToString(); //短信验证码
  746. string Mobile = data["Mobile"].ToString();
  747. string BankName = data["BankName"].ToString(); //开户行全称
  748. string SettleBankName = data["SettleBankName"].ToString(); //结算银行名称
  749. string SettleBankCardNo = data["SettleBankCardNo"].ToString(); //结算银行卡号
  750. string BankCardPositiveImage = data["BankCardPositiveImage"].ToString(); //银行卡正面照
  751. MobileCodeCheck mobilecheck = RedisDbconn.Instance.Get<MobileCodeCheck>("MobileCodeCheck:" + Mobile);
  752. int Id = int.Parse(function.CheckInt(data["Id"].ToString()));
  753. if (mobilecheck == null)
  754. {
  755. return Json(new AppResultJson() { Status = "-1", Info = "短信验证码不正确" });
  756. }
  757. if (mobilecheck.CheckCode != MobileCode)
  758. {
  759. return Json(new AppResultJson() { Status = "-1", Info = "短信验证码不正确" });
  760. }
  761. RedisDbconn.Instance.Clear("MobileCodeCheck:" + Mobile);
  762. Dictionary<string, object> Obj = new Dictionary<string, object>();
  763. Users query = maindb.Users.FirstOrDefault(m => m.Id == Id);
  764. if (query != null)
  765. {
  766. query.SeoTitle = BankName;
  767. query.SettleBankName = SettleBankName;
  768. query.SettleBankCardNo = SettleBankCardNo; //结算银行卡号
  769. query.BankCardPositiveImage = BankCardPositiveImage; //银行卡正面照
  770. maindb.SaveChanges();
  771. return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
  772. }
  773. return Json(new AppResultJson() { Status = "-1", Info = "认证失败,请重试", Data = Obj });
  774. }
  775. [Authorize]
  776. public JsonResult ChangeBankCard2(string value)
  777. {
  778. value = DesDecrypt(value);
  779. JsonData data = JsonMapper.ToObject(value);
  780. AppResultJson result = ChangeBankCard2Do(value);
  781. return Json(new AppResultJson() { Status = result.Status, Info = result.Info, Data = result.Data });
  782. }
  783. public AppResultJson ChangeBankCard2Do(string value)
  784. {
  785. JsonData data = JsonMapper.ToObject(value);
  786. int Id = int.Parse(function.CheckInt(data["Id"].ToString()));
  787. string MobileCode = data["MobileCode"].ToString(); //短信验证码
  788. string Mobile = data["Mobile"].ToString();
  789. string BankName = data["BankName"].ToString(); //开户行全称
  790. string SettleBankName = data["SettleBankName"].ToString(); //结算银行名称
  791. string SettleBankCardNo = data["SettleBankCardNo"].ToString(); //结算银行卡号
  792. string BankCardPositiveImage = data["BankCardPositiveImage"].ToString(); //银行卡正面照
  793. MobileCodeCheck mobilecheck = RedisDbconn.Instance.Get<MobileCodeCheck>("MobileCodeCheck:" + Mobile);
  794. if (mobilecheck == null)
  795. {
  796. return new AppResultJson() { Status = "-1", Info = "短信验证码不正确" };
  797. }
  798. if (mobilecheck.CheckCode != MobileCode)
  799. {
  800. return new AppResultJson() { Status = "-1", Info = "短信验证码不正确" };
  801. }
  802. RedisDbconn.Instance.Clear("MobileCodeCheck:" + Mobile);
  803. Dictionary<string, object> Obj = new Dictionary<string, object>();
  804. Users query = maindb.Users.FirstOrDefault(m => m.Id == Id);
  805. if (query != null)
  806. {
  807. query.SeoTitle = BankName;
  808. query.SettleBankName = SettleBankName;
  809. query.SettleBankCardNo = SettleBankCardNo; //结算银行卡号
  810. query.BankCardPositiveImage = BankCardPositiveImage; //银行卡正面照
  811. UserAuthRecord auth = maindb.UserAuthRecord.FirstOrDefault(m => m.UserId == Id);
  812. if (auth != null)
  813. {
  814. auth.BankCardAccount = SettleBankCardNo; //银行卡账号
  815. }
  816. maindb.SaveChanges();
  817. }
  818. return new AppResultJson() { Status = "1", Info = "", Data = Obj };
  819. }
  820. #endregion
  821. #region 创客-我的-设置-安全退出
  822. [Authorize]
  823. public JsonResult Logout(string value)
  824. {
  825. value = DesDecrypt(value);
  826. JsonData data = JsonMapper.ToObject(value);
  827. AppResultJson result = LogoutDo(value);
  828. return Json(new AppResultJson() { Status = result.Status, Info = result.Info, Data = result.Data });
  829. }
  830. public AppResultJson LogoutDo(string value)
  831. {
  832. JsonData data = JsonMapper.ToObject(value);
  833. string UserId = data["UserId"].ToString(); //创客Id
  834. Dictionary<string, object> Obj = new Dictionary<string, object>();
  835. // TODO:退出登录需要处理的逻辑,待定
  836. return new AppResultJson() { Status = "1", Info = "", Data = Obj };
  837. }
  838. #endregion
  839. #region 创客-我的-设置-忘记支付密码验证
  840. [Authorize]
  841. public JsonResult CheckForgetPwd(string value)
  842. {
  843. value = DesDecrypt(value);
  844. JsonData data = JsonMapper.ToObject(value);
  845. AppResultJson result = CheckForgetPwdDo(value);
  846. return Json(new AppResultJson() { Status = result.Status, Info = result.Info, Data = result.Data });
  847. }
  848. public AppResultJson CheckForgetPwdDo(string value)
  849. {
  850. JsonData data = JsonMapper.ToObject(value);
  851. string RealName = data["RealName"].ToString(); //真实姓名
  852. string CertId = data["CertId"].ToString(); //身份证号
  853. string Mobile = data["Mobile"].ToString(); //手机号
  854. string MobileCode = data["MobileCode"].ToString(); //短信验证码
  855. if (string.IsNullOrEmpty(data["Mobile"].ToString()))
  856. {
  857. return new AppResultJson() { Status = "-1", Info = "请填写手机号" };
  858. }
  859. if (data["Mobile"].ToString().Length > 11)
  860. {
  861. return new AppResultJson() { Status = "-1", Info = "手机号最多11个字符" };
  862. }
  863. if (function.CheckMobile(data["Mobile"].ToString()) == "")
  864. {
  865. return new AppResultJson() { Status = "-1", Info = "请填写正确的手机号" };
  866. }
  867. MobileCodeCheck mobilecheck = RedisDbconn.Instance.Get<MobileCodeCheck>("MobileCodeCheck:" + Mobile);
  868. if (mobilecheck == null)
  869. {
  870. return new AppResultJson() { Status = "-1", Info = "短信验证码不正确" };
  871. }
  872. if (mobilecheck.CheckCode != MobileCode)
  873. {
  874. return new AppResultJson() { Status = "-1", Info = "短信验证码不正确" };
  875. }
  876. RedisDbconn.Instance.Clear("MobileCodeCheck:" + Mobile);
  877. Dictionary<string, object> Obj = new Dictionary<string, object>();
  878. // TODO:验证接口,待定
  879. return new AppResultJson() { Status = "1", Info = "", Data = Obj };
  880. }
  881. #endregion
  882. #region 创客-我的-设置-提交实名认证资料
  883. [Authorize]
  884. public JsonResult PostAuth(string value)
  885. {
  886. value = DesDecrypt(value);
  887. JsonData data = JsonMapper.ToObject(value);
  888. AppResultJson result = PostAuthDo(value);
  889. return Json(new AppResultJson() { Status = result.Status, Info = result.Info, Data = result.Data });
  890. }
  891. public AppResultJson PostAuthDo(string value)
  892. {
  893. JsonData data = JsonMapper.ToObject(value);
  894. int Id = int.Parse(function.CheckInt(data["Id"].ToString()));
  895. string RealName = data["RealName"].ToString(); //真实姓名
  896. string CertId = data["CertId"].ToString(); //身份证号
  897. string Areas = data["Areas"].ToString(); //所在地区
  898. string Mobile = data["Mobile"].ToString(); //手机号
  899. string BankName = data["BankName"].ToString(); //开户行全称
  900. string SettleBankName = data["SettleBankName"].ToString(); //结算银行名称
  901. string SettleBankCardNo = data["SettleBankCardNo"].ToString(); //结算银行卡号
  902. string CertFrontImage = data["CertFrontImage"].ToString(); //身份证正面照
  903. string CertReverseImage = data["CertReverseImage"].ToString(); //身份证反面照
  904. string HandCertImage = data["HandCertImage"].ToString(); //手持身份证
  905. string BankCardPositiveImage = data["BankCardPositiveImage"].ToString(); //银行卡正面照
  906. string BankMobile = data["BankMobile"].ToString(); //银行预留手机号
  907. string Distribute = "";
  908. if (value.Contains("\"Distribute\""))
  909. {
  910. Distribute = data["Distribute"].ToString();
  911. }
  912. if (string.IsNullOrEmpty(data["BankMobile"].ToString()))
  913. {
  914. return new AppResultJson() { Status = "-1", Info = "请填写手机号" };
  915. }
  916. if (data["BankMobile"].ToString().Length > 11)
  917. {
  918. return new AppResultJson() { Status = "-1", Info = "手机号最多11个字符" };
  919. }
  920. if (function.CheckMobile(data["BankMobile"].ToString()) == "")
  921. {
  922. return new AppResultJson() { Status = "-1", Info = "请填写正确的手机号" };
  923. }
  924. Dictionary<string, object> Obj = new Dictionary<string, object>();
  925. bool checkCertId = maindb.Users.Any(m => m.CertId == CertId);
  926. if (checkCertId)
  927. {
  928. return new AppResultJson() { Status = "-1", Info = "您输入的身份证号已经认证过了,请更换身份证" };
  929. }
  930. Users query = maindb.Users.FirstOrDefault(m => m.Id == Id);
  931. if (query != null)
  932. {
  933. string result = BankCardCheckForThree.Instance.Do(SettleBankCardNo, CertId, RealName);
  934. JsonData jsonObj = JsonMapper.ToObject(result);
  935. if (jsonObj["code"].ToString() == "200")
  936. {
  937. if (jsonObj["data"]["result"].ToString() == "0")
  938. {
  939. query.AuthFlag = 1;
  940. query.AuthDate = DateTime.Now;
  941. query.RealName = RealName; //真实姓名
  942. query.CertId = CertId; //身份证号
  943. query.Areas = Areas; //所在地区
  944. query.SeoTitle = BankName;
  945. query.SettleBankCardNo = SettleBankCardNo; //结算银行卡号
  946. query.SettleBankName = SettleBankName; //结算银行名称
  947. query.CertFrontImage = CertFrontImage; //身份证正面照
  948. query.CertReverseImage = CertReverseImage; //身份证反面照
  949. query.HandCertImage = HandCertImage; //手持身份证
  950. query.BankCardPositiveImage = BankCardPositiveImage; //银行卡正面照
  951. maindb.SaveChanges();
  952. UserAuthRecord auth = maindb.UserAuthRecord.Add(new UserAuthRecord()
  953. {
  954. CreateDate = DateTime.Now,
  955. UserId = Id, //创客
  956. RealName = RealName, //真实姓名
  957. IdcardNo = CertId, //身份证号码
  958. BankCardAccount = SettleBankCardNo, //银行卡账号
  959. BankMobile = BankMobile, //银行预留手机号码
  960. }).Entity;
  961. maindb.SaveChanges();
  962. //实名认证成功后消息推送
  963. Users users = maindb.Users.FirstOrDefault(m => m.Id == query.ParentUserId);
  964. RedisDbconn.Instance.AddList("MsgPersonalQueue", Newtonsoft.Json.JsonConvert.SerializeObject(new MsgPersonal()
  965. {
  966. UserId = users.Id, //创客Id
  967. MsgType = 2,
  968. Title = "来新人啦", //标题
  969. Summary = "您的码牌系统有新人加入了,请进入码牌-我的创客中查看!",//简介
  970. CreateDate = DateTime.Now,
  971. }));
  972. return new AppResultJson() { Status = "1", Info = "", Data = Obj };
  973. }
  974. else
  975. {
  976. return new AppResultJson() { Status = "-1", Info = jsonObj["data"]["desc"].ToString() };
  977. }
  978. }
  979. else
  980. {
  981. return new AppResultJson() { Status = "-1", Info = jsonObj["msg"].ToString() };
  982. }
  983. }
  984. return new AppResultJson() { Status = "-1", Info = "认证失败,请重试" };
  985. }
  986. [Authorize]
  987. public JsonResult PostAuth2(string value, string CertFrontBase64, string CertReverseBase64)
  988. {
  989. value = DesDecrypt(value);
  990. JsonData data = JsonMapper.ToObject(value);
  991. AppResultJson result = PostAuth2Do(value, CertFrontBase64, CertReverseBase64);
  992. return Json(new AppResultJson() { Status = result.Status, Info = result.Info, Data = result.Data });
  993. }
  994. public AppResultJson PostAuth2Do(string value, string CertFrontBase64, string CertReverseBase64)
  995. {
  996. JsonData data = JsonMapper.ToObject(value);
  997. int Id = int.Parse(function.CheckInt(data["Id"].ToString()));
  998. string RealName = data["RealName"].ToString(); //真实姓名
  999. string CertId = data["CertId"].ToString(); //身份证号
  1000. string Areas = data["Areas"].ToString(); //所在地区
  1001. string Mobile = data["Mobile"].ToString(); //手机号
  1002. string BankName = data["BankName"].ToString(); //开户行全称
  1003. string SettleBankName = data["SettleBankName"].ToString(); //结算银行名称
  1004. string SettleBankCardNo = data["SettleBankCardNo"].ToString(); //结算银行卡号
  1005. string CertFrontImage = data["CertFrontImage"].ToString(); //身份证正面照
  1006. string CertReverseImage = data["CertReverseImage"].ToString(); //身份证反面照
  1007. // string CertFrontBase64 = data["CertFrontBase64"].ToString(); //身份证正面照
  1008. // string CertReverseBase64 = data["CertReverseBase64"].ToString(); //身份证反面照
  1009. string HandCertImage = data["HandCertImage"].ToString(); //手持身份证
  1010. string BankCardPositiveImage = data["BankCardPositiveImage"].ToString(); //银行卡正面照
  1011. string BankMobile = data["BankMobile"].ToString(); //银行预留手机号
  1012. string Distribute = "";
  1013. if (value.Contains("\"Distribute\""))
  1014. {
  1015. Distribute = data["Distribute"].ToString();
  1016. }
  1017. if (string.IsNullOrEmpty(data["BankMobile"].ToString()))
  1018. {
  1019. return new AppResultJson() { Status = "-1", Info = "请填写手机号" };
  1020. }
  1021. if (data["BankMobile"].ToString().Length > 11)
  1022. {
  1023. return new AppResultJson() { Status = "-1", Info = "手机号最多11个字符" };
  1024. }
  1025. if (function.CheckMobile(data["BankMobile"].ToString()) == "")
  1026. {
  1027. return new AppResultJson() { Status = "-1", Info = "请填写正确的手机号" };
  1028. }
  1029. Dictionary<string, object> Obj = new Dictionary<string, object>();
  1030. bool checkCertId = maindb.Users.Any(m => m.CertId == CertId);
  1031. if (checkCertId)
  1032. {
  1033. return new AppResultJson() { Status = "-1", Info = "您输入的身份证号已经认证过了,请更换身份证" };
  1034. }
  1035. Users query = maindb.Users.FirstOrDefault(m => m.Id == Id);
  1036. if (query != null)
  1037. {
  1038. string result = BankCardCheckForThree.Instance.Do(SettleBankCardNo, CertId, RealName);
  1039. JsonData jsonObj = JsonMapper.ToObject(result);
  1040. if (jsonObj["code"].ToString() == "200")
  1041. {
  1042. if (jsonObj["data"]["result"].ToString() == "0")
  1043. {
  1044. query.AuthFlag = 1;
  1045. query.AuthDate = DateTime.Now;
  1046. query.RealName = RealName; //真实姓名
  1047. query.CertId = CertId; //身份证号
  1048. query.Areas = Areas; //所在地区
  1049. query.SeoTitle = BankName;
  1050. query.SettleBankCardNo = SettleBankCardNo; //结算银行卡号
  1051. query.SettleBankName = SettleBankName; //结算银行名称
  1052. query.CertFrontImage = CertFrontImage; //身份证正面照
  1053. query.CertReverseImage = CertReverseImage; //身份证反面照
  1054. query.HandCertImage = HandCertImage; //手持身份证
  1055. query.BankCardPositiveImage = BankCardPositiveImage; //银行卡正面照
  1056. maindb.SaveChanges();
  1057. UserAuthRecord auth = maindb.UserAuthRecord.Add(new UserAuthRecord()
  1058. {
  1059. CreateDate = DateTime.Now,
  1060. UserId = Id, //创客
  1061. RealName = RealName, //真实姓名
  1062. IdcardNo = CertId, //身份证号码
  1063. BankCardAccount = SettleBankCardNo, //银行卡账号
  1064. BankMobile = BankMobile, //银行预留手机号码
  1065. }).Entity;
  1066. maindb.SaveChanges();
  1067. //实名认证成功后消息推送
  1068. Users users = maindb.Users.FirstOrDefault(m => m.Id == query.ParentUserId);
  1069. RedisDbconn.Instance.AddList("MsgPersonalQueue", Newtonsoft.Json.JsonConvert.SerializeObject(new MsgPersonal()
  1070. {
  1071. UserId = users.Id, //创客Id
  1072. MsgType = 2,
  1073. Title = "来新人啦", //标题
  1074. Summary = "您的码牌系统有新人加入了,请进入码牌-我的创客中查看!",//简介
  1075. CreateDate = DateTime.Now,
  1076. }));
  1077. return new AppResultJson() { Status = "1", Info = "", Data = Obj };
  1078. }
  1079. else
  1080. {
  1081. return new AppResultJson() { Status = "-1", Info = jsonObj["data"]["desc"].ToString() };
  1082. }
  1083. }
  1084. else
  1085. {
  1086. return new AppResultJson() { Status = "-1", Info = jsonObj["msg"].ToString() };
  1087. }
  1088. }
  1089. return new AppResultJson() { Status = "-1", Info = "认证失败,请重试" };
  1090. }
  1091. #endregion
  1092. #region 创客-我的-提现实名认证资料
  1093. [Authorize]
  1094. public JsonResult CashAuth(string value)
  1095. {
  1096. value = DesDecrypt(value);
  1097. JsonData data = JsonMapper.ToObject(value);
  1098. AppResultJson result = CashAuthDo(value);
  1099. return Json(new AppResultJson() { Status = result.Status, Info = result.Info, Data = result.Data });
  1100. }
  1101. public AppResultJson CashAuthDo(string value)
  1102. {
  1103. JsonData data = JsonMapper.ToObject(value);
  1104. int Id = int.Parse(function.CheckInt(data["Id"].ToString()));
  1105. string CertFrontImage = data["CertFrontImage"].ToString(); //身份证正面照
  1106. string CertReverseImage = data["CertReverseImage"].ToString(); //身份证反面照
  1107. // string BankName = data["BankName"].ToString(); //开户行全称
  1108. string SettleBankName = data["SettleBankName"].ToString(); //结算银行名称
  1109. string SettleBankCardNo = data["SettleBankCardNo"].ToString(); //结算银行卡号
  1110. string BankMobile = data["BankMobile"].ToString(); //银行预留手机号
  1111. if (string.IsNullOrEmpty(data["BankMobile"].ToString()))
  1112. {
  1113. return new AppResultJson() { Status = "-1", Info = "请填写手机号" };
  1114. }
  1115. if (data["BankMobile"].ToString().Length > 11)
  1116. {
  1117. return new AppResultJson() { Status = "-1", Info = "手机号最多11个字符" };
  1118. }
  1119. if (function.CheckMobile(data["BankMobile"].ToString()) == "")
  1120. {
  1121. return new AppResultJson() { Status = "-1", Info = "请填写正确的手机号" };
  1122. }
  1123. Dictionary<string, object> Obj = new Dictionary<string, object>();
  1124. string check = RedisDbconn.Instance.Get<string>("CashAuth:" + Id);
  1125. if (!string.IsNullOrEmpty(check))
  1126. {
  1127. return new AppResultJson() { Status = "-1", Info = "资料审核中, 请稍后再试" };
  1128. }
  1129. RedisDbconn.Instance.Set("CashAuth:" + Id, "1");
  1130. RedisDbconn.Instance.SetExpire("CashAuth:" + Id, 300);
  1131. Users query = maindb.Users.FirstOrDefault(m => m.Id == Id);
  1132. if (query != null)
  1133. {
  1134. query.SettleBankCardNo = SettleBankCardNo; //结算银行卡号
  1135. query.SettleBankName = SettleBankName; //结算银行名称
  1136. query.CertFrontImage = CertFrontImage; //身份证正面照
  1137. query.CertReverseImage = CertReverseImage; //身份证反面照
  1138. UserAuthRecord auth = maindb.UserAuthRecord.FirstOrDefault(m => m.UserId == Id);
  1139. if (auth != null)
  1140. {
  1141. auth.BankCardAccount = SettleBankCardNo; //银行卡账号
  1142. auth.BankMobile = BankMobile; //银行预留手机号码
  1143. }
  1144. maindb.SaveChanges();
  1145. return new AppResultJson() { Status = "1", Info = "", Data = Obj };
  1146. }
  1147. return new AppResultJson() { Status = "-1", Info = "认证失败,请重试" };
  1148. }
  1149. [Authorize]
  1150. public JsonResult CashAuth2(string value, string CertFrontBase64, string CertReverseBase64)
  1151. {
  1152. value = DesDecrypt(value);
  1153. JsonData data = JsonMapper.ToObject(value);
  1154. AppResultJson result = CashAuth2Do(value, CertFrontBase64, CertReverseBase64);
  1155. return Json(new AppResultJson() { Status = result.Status, Info = result.Info, Data = result.Data });
  1156. }
  1157. public AppResultJson CashAuth2Do(string value, string CertFrontBase64, string CertReverseBase64)
  1158. {
  1159. JsonData data = JsonMapper.ToObject(value);
  1160. int Id = int.Parse(function.CheckInt(data["Id"].ToString()));
  1161. string CertFrontImage = data["CertFrontImage"].ToString(); //身份证正面照
  1162. string CertReverseImage = data["CertReverseImage"].ToString(); //身份证反面照
  1163. // string CertFrontBase64 = data["CertFrontBase64"].ToString(); //身份证正面照
  1164. // string CertReverseBase64 = data["CertReverseBase64"].ToString(); //身份证反面照
  1165. // string BankName = data["BankName"].ToString(); //开户行全称
  1166. string SettleBankName = data["SettleBankName"].ToString(); //结算银行名称
  1167. string SettleBankCardNo = data["SettleBankCardNo"].ToString(); //结算银行卡号
  1168. string BankMobile = data["BankMobile"].ToString(); //银行预留手机号
  1169. if (string.IsNullOrEmpty(data["BankMobile"].ToString()))
  1170. {
  1171. return new AppResultJson() { Status = "-1", Info = "请填写手机号" };
  1172. }
  1173. if (data["BankMobile"].ToString().Length > 11)
  1174. {
  1175. return new AppResultJson() { Status = "-1", Info = "手机号最多11个字符" };
  1176. }
  1177. if (function.CheckMobile(data["BankMobile"].ToString()) == "")
  1178. {
  1179. return new AppResultJson() { Status = "-1", Info = "请填写正确的手机号" };
  1180. }
  1181. Dictionary<string, object> Obj = new Dictionary<string, object>();
  1182. string check = RedisDbconn.Instance.Get<string>("CashAuth:" + Id);
  1183. if (!string.IsNullOrEmpty(check))
  1184. {
  1185. return new AppResultJson() { Status = "-1", Info = "资料审核中, 请稍后再试" };
  1186. }
  1187. RedisDbconn.Instance.Set("CashAuth:" + Id, "1", 600);
  1188. Users query = maindb.Users.FirstOrDefault(m => m.Id == Id);
  1189. if (query != null)
  1190. {
  1191. query.SettleBankCardNo = SettleBankCardNo; //结算银行卡号
  1192. query.SettleBankName = SettleBankName; //结算银行名称
  1193. query.CertFrontImage = CertFrontImage; //身份证正面照
  1194. query.CertReverseImage = CertReverseImage; //身份证反面照
  1195. UserAuthRecord auth = maindb.UserAuthRecord.FirstOrDefault(m => m.UserId == Id);
  1196. if (auth != null)
  1197. {
  1198. auth.BankCardAccount = SettleBankCardNo; //银行卡账号
  1199. auth.BankMobile = BankMobile; //银行预留手机号码
  1200. }
  1201. maindb.SaveChanges();
  1202. return new AppResultJson() { Status = "1", Info = "", Data = Obj };
  1203. }
  1204. return new AppResultJson() { Status = "-1", Info = "认证失败,请重试" };
  1205. }
  1206. #endregion
  1207. #region 创客-我的-获取提现认证失败原因
  1208. [Authorize]
  1209. public JsonResult CashAuthFailInfo(string value)
  1210. {
  1211. value = DesDecrypt(value);
  1212. JsonData data = JsonMapper.ToObject(value);
  1213. Dictionary<string, object> Obj = new Dictionary<string, object>();
  1214. int Id = int.Parse(function.CheckInt(data["Id"].ToString()));
  1215. Users query = UsersDbconn.Instance.Get(Id) ?? new Users();
  1216. string Remark = function.CheckNull(query.Remark);
  1217. if (Remark.StartsWith("代付失败原因:"))
  1218. {
  1219. return Json(new AppResultJson() { Status = "-1", Info = Remark.Replace("代付失败原因:", "") });
  1220. }
  1221. return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
  1222. }
  1223. #endregion
  1224. #region 创客-我的-设置-提交忘记支付密码
  1225. [Authorize]
  1226. public JsonResult ForgetPayPwd(string value)
  1227. {
  1228. value = DesDecrypt(value);
  1229. JsonData data = JsonMapper.ToObject(value);
  1230. AppResultJson result = ForgetPayPwdDo(value);
  1231. return Json(new AppResultJson() { Status = result.Status, Info = result.Info, Data = result.Data });
  1232. }
  1233. public AppResultJson ForgetPayPwdDo(string value)
  1234. {
  1235. JsonData data = JsonMapper.ToObject(value);
  1236. string PayPwd = data["PayPwd"].ToString(); //支付密码
  1237. Dictionary<string, object> Obj = new Dictionary<string, object>();
  1238. Users query = new Users();
  1239. int Id = int.Parse(function.CheckInt(data["Id"].ToString()));
  1240. query = maindb.Users.FirstOrDefault(m => m.Id == Id);
  1241. if (query != null)
  1242. {
  1243. query.PayPwd = function.MD532(PayPwd); //支付密码
  1244. maindb.SaveChanges();
  1245. }
  1246. return new AppResultJson() { Status = "1", Info = "", Data = Obj };
  1247. }
  1248. #endregion
  1249. #region 创客-我的-设置-设置支付密码
  1250. [Authorize]
  1251. public JsonResult SetPayPwd(string value)
  1252. {
  1253. value = DesDecrypt(value);
  1254. JsonData data = JsonMapper.ToObject(value);
  1255. AppResultJson result = SetPayPwdDo(value);
  1256. return Json(new AppResultJson() { Status = result.Status, Info = result.Info, Data = result.Data });
  1257. }
  1258. public AppResultJson SetPayPwdDo(string value)
  1259. {
  1260. JsonData data = JsonMapper.ToObject(value);
  1261. string PayPwd = data["PayPwd"].ToString(); //支付密码
  1262. Dictionary<string, object> Obj = new Dictionary<string, object>();
  1263. int Id = int.Parse(function.CheckInt(data["Id"].ToString()));
  1264. Users query = maindb.Users.FirstOrDefault(m => m.Id == Id);
  1265. if (query != null)
  1266. {
  1267. query.UpdateDate = DateTime.Now; //修改时间
  1268. query.PayPwd = function.MD532(PayPwd); //支付密码\
  1269. maindb.SaveChanges();
  1270. }
  1271. return new AppResultJson() { Status = "1", Info = "", Data = Obj };
  1272. }
  1273. #endregion
  1274. #region 创客-我的-设置-验证原支付密码
  1275. [Authorize]
  1276. public JsonResult CheckPayPwd(string value)
  1277. {
  1278. value = DesDecrypt(value);
  1279. JsonData data = JsonMapper.ToObject(value);
  1280. string PayPwd = data["PayPwd"].ToString(); //支付密码
  1281. Dictionary<string, object> Obj = new Dictionary<string, object>();
  1282. int Id = int.Parse(function.CheckInt(data["Id"].ToString()));
  1283. Users query = maindb.Users.FirstOrDefault(m => m.Id == Id) ?? new Users();
  1284. if (string.IsNullOrEmpty(query.PayPwd))
  1285. {
  1286. return Json(new AppResultJson() { Status = "-1", Info = "请设置支付密码" });
  1287. }
  1288. if (query.PayPwd != function.MD532(PayPwd))
  1289. {
  1290. return Json(new AppResultJson() { Status = "-1", Info = "原支付密码不正确" });
  1291. }
  1292. return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
  1293. }
  1294. #endregion
  1295. #region 创客-我的-设置-验证登录密码
  1296. [Authorize]
  1297. public JsonResult CheckLoginPwd(string value)
  1298. {
  1299. value = DesDecrypt(value);
  1300. JsonData data = JsonMapper.ToObject(value);
  1301. string LoginPwd = data["LoginPwd"].ToString(); //支付密码
  1302. Dictionary<string, object> Obj = new Dictionary<string, object>();
  1303. Users query = new Users();
  1304. int Id = int.Parse(function.CheckInt(data["Id"].ToString()));
  1305. query = UsersDbconn.Instance.Get(Id) ?? new Users();
  1306. if (query.LoginPwd != function.MD532(LoginPwd))
  1307. {
  1308. return Json(new AppResultJson() { Status = "-1", Info = "登录密码不正确" });
  1309. }
  1310. return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
  1311. }
  1312. #endregion
  1313. #region 我的-设置-获取实名认证四要素
  1314. [Authorize]
  1315. public JsonResult AuthInfo(string value)
  1316. {
  1317. value = DesDecrypt(value);
  1318. JsonData data = JsonMapper.ToObject(value);
  1319. Dictionary<string, object> Obj = AuthInfoDo(value);
  1320. return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
  1321. }
  1322. public Dictionary<string, object> AuthInfoDo(string value)
  1323. {
  1324. JsonData data = JsonMapper.ToObject(value);
  1325. Dictionary<string, object> Obj = new Dictionary<string, object>();
  1326. int Id = int.Parse(function.CheckInt(data["Id"].ToString()));
  1327. Users query = UsersDbconn.Instance.Get(Id) ?? new Users();
  1328. Obj.Add("RealName", DefaultRealName(query)); //真实姓名
  1329. Obj.Add("CertId", query.CertId); //身份证号
  1330. Obj.Add("Mobile", query.Mobile); //手机号
  1331. Obj.Add("SettleBankCardNo", query.SettleBankCardNo); //结算银行卡号
  1332. Obj.Add("SettleBankName", query.SettleBankName); //结算银行卡名称
  1333. Obj.Add("BankName", query.SeoTitle); //开户行全称
  1334. return Obj;
  1335. }
  1336. #endregion
  1337. #region 创客-首页-交易分析-个人业绩-趋势图
  1338. [Authorize]
  1339. public JsonResult PersonalPerformanceTrend(string value)
  1340. {
  1341. value = DesDecrypt(value);
  1342. JsonData data = JsonMapper.ToObject(value);
  1343. Dictionary<string, object> Obj = PersonalPerformanceTrendDo(value);
  1344. return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
  1345. }
  1346. public Dictionary<string, object> PersonalPerformanceTrendDo(string value)
  1347. {
  1348. JsonData data = JsonMapper.ToObject(value);
  1349. string UserId = data["UserId"].ToString(); //创客Id
  1350. string Kind = data["Kind"].ToString(); //查询类别
  1351. Dictionary<string, object> Obj = new Dictionary<string, object>();
  1352. //总交易趋势数据
  1353. List<Dictionary<string, object>> MainTradeList = new List<Dictionary<string, object>>();
  1354. if (Kind == "1")
  1355. {
  1356. for (int i = 7; i >= 1; i--)
  1357. {
  1358. DateTime Date = DateTime.Now.AddDays(-i);
  1359. var date = Date.ToString("yyyyMMdd");
  1360. decimal HelpAmount = 0;
  1361. DataTable dt = OtherMySqlConn.dtable("SELECT SUM(TradeAmount) TradeAmount FROM HelpProfitMerTradeSummay WHERE MerchantId IN(SELECT MerchantId FROM HelpProfitMerIds WHERE UserId=" + UserId + ") AND TradeDate=" + date + "");
  1362. foreach (DataRow items in dt.Rows)
  1363. {
  1364. HelpAmount = decimal.Parse(function.CheckNum(items["TradeAmount"].ToString()));
  1365. }
  1366. var amount = UserTradeDaySummaryDbconn.Instance.GetDateTrade(int.Parse(UserId), Date.ToString("yyyyMMdd"));
  1367. var total = amount + HelpAmount;
  1368. Dictionary<string, object> item = new Dictionary<string, object>();
  1369. item.Add("Time", Date.ToString("MMdd")); //日期/月份
  1370. item.Add("TradeAmt", UserTradeDaySummaryDbconn.Instance.GetDateTrade(int.Parse(UserId), Date.ToString("yyyyMMdd"))); //交易额
  1371. MainTradeList.Add(item);
  1372. }
  1373. }
  1374. else
  1375. {
  1376. for (int i = 6; i >= 1; i--)
  1377. {
  1378. DateTime Month = DateTime.Now.AddMonths(-i);
  1379. var month = Month.ToString("yyyyMM");
  1380. decimal HelpAmount = 0;
  1381. DataTable dt = OtherMySqlConn.dtable("SELECT SUM(TradeAmount) TradeAmount FROM HelpProfitMerTradeSummay WHERE MerchantId IN(SELECT MerchantId FROM HelpProfitMerIds WHERE UserId=" + UserId + ") AND TradeMonth=" + month + "");
  1382. foreach (DataRow items in dt.Rows)
  1383. {
  1384. HelpAmount = decimal.Parse(function.CheckNum(items["TradeAmount"].ToString()));
  1385. }
  1386. var amount = UserTradeDaySummaryDbconn.Instance.GetMonthTrade(int.Parse(UserId), Month.ToString("yyyyMM"));
  1387. var total = amount + HelpAmount;
  1388. Dictionary<string, object> item = new Dictionary<string, object>();
  1389. item.Add("Time", Month.ToString("yyyyMM")); //日期/月份
  1390. item.Add("TradeAmt", total); //交易额
  1391. MainTradeList.Add(item);
  1392. }
  1393. }
  1394. Obj.Add("MainTrade", MainTradeList);
  1395. //新增创客总数趋势数据
  1396. List<Dictionary<string, object>> AddMakerList = new List<Dictionary<string, object>>();
  1397. if (Kind == "1")
  1398. {
  1399. for (int i = 7; i >= 1; i--)
  1400. {
  1401. DateTime Date = DateTime.Now.AddDays(-i);
  1402. Dictionary<string, object> item = new Dictionary<string, object>();
  1403. item.Add("Time", Date.ToString("MMdd")); //日期/月份
  1404. item.Add("Count", UsersDbconn.Instance.GetNewUserCount(int.Parse(UserId), Date.ToString("yyyyMMdd"))); //交易额
  1405. AddMakerList.Add(item);
  1406. }
  1407. }
  1408. else
  1409. {
  1410. for (int i = 6; i >= 1; i--)
  1411. {
  1412. DateTime Month = DateTime.Now.AddMonths(-i);
  1413. Dictionary<string, object> item = new Dictionary<string, object>();
  1414. item.Add("Time", Month.ToString("yyyyMM")); //日期/月份
  1415. item.Add("Count", UsersDbconn.Instance.GetNewUserCount(int.Parse(UserId), Month.ToString("yyyyMM"))); //交易额
  1416. AddMakerList.Add(item);
  1417. }
  1418. }
  1419. Obj.Add("AddMaker", AddMakerList);
  1420. //新增激活商户总数趋势数据
  1421. List<Dictionary<string, object>> AddActMerchantList = new List<Dictionary<string, object>>();
  1422. for (int i = 7; i >= 1; i--)
  1423. {
  1424. Dictionary<string, object> item = new Dictionary<string, object>();
  1425. if (Kind == "1")
  1426. {
  1427. DateTime time = DateTime.Now.AddDays(-i);
  1428. string Date = time.ToString("MMdd");
  1429. item.Add("Time", Date); //日期/月份
  1430. item.Add("Count", UserDataDbconn.Instance.GetPosActCount(int.Parse(UserId), time.ToString("yyyyMMdd"))); //数量
  1431. }
  1432. else
  1433. {
  1434. string Month = DateTime.Now.AddMonths(-i).ToString("yyyyMM");
  1435. item.Add("Time", Month); //日期/月份
  1436. item.Add("Count", UserDataDbconn.Instance.GetPosActCount(int.Parse(UserId), Month)); //数量
  1437. }
  1438. AddActMerchantList.Add(item);
  1439. }
  1440. Obj.Add("AddActMerchant", AddActMerchantList);
  1441. return Obj;
  1442. }
  1443. #endregion
  1444. #region 创客-首页-交易分析-团队业绩-趋势图
  1445. [Authorize]
  1446. public JsonResult TeamPerformanceTrend(string value)
  1447. {
  1448. value = DesDecrypt(value);
  1449. JsonData data = JsonMapper.ToObject(value);
  1450. Dictionary<string, object> Obj = TeamPerformanceTrendDo(value);
  1451. return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
  1452. }
  1453. public Dictionary<string, object> TeamPerformanceTrendDo(string value)
  1454. {
  1455. JsonData data = JsonMapper.ToObject(value);
  1456. string UserId = data["UserId"].ToString(); //创客Id
  1457. string Kind = data["Kind"].ToString(); //查询类别
  1458. Dictionary<string, object> Obj = new Dictionary<string, object>();
  1459. //总交易趋势数据
  1460. List<Dictionary<string, object>> MainTradeList = new List<Dictionary<string, object>>();
  1461. if (Kind == "1")
  1462. {
  1463. for (int i = 7; i >= 1; i--)
  1464. {
  1465. DateTime Date = DateTime.Now.AddDays(-i);
  1466. var date = Date.ToString("yyyyMMdd");
  1467. decimal HelpAmount = 0;
  1468. DataTable dt = OtherMySqlConn.dtable("SELECT SUM(TradeAmount) TradeAmount FROM HelpProfitMerTradeSummay WHERE MerchantId IN(SELECT MerchantId FROM HelpProfitMerIds WHERE UserId IN(SELECT Id from Users WHERE ParentNav like '%," + UserId + ",%' OR Id=" + UserId + ")) AND TradeDate=" + date + "");
  1469. foreach (DataRow items in dt.Rows)
  1470. {
  1471. HelpAmount = decimal.Parse(function.CheckNum(items["TradeAmount"].ToString()));
  1472. }
  1473. var amount = UserTradeDaySummaryDbconn.Instance.GetDateTrade(int.Parse(UserId), Date.ToString("yyyyMMdd"), "team");
  1474. var total = amount + HelpAmount;
  1475. Dictionary<string, object> item = new Dictionary<string, object>();
  1476. item.Add("Time", Date.ToString("MMdd")); //日期/月份
  1477. item.Add("TradeAmt", total); //交易额
  1478. MainTradeList.Add(item);
  1479. }
  1480. }
  1481. else
  1482. {
  1483. for (int i = 6; i >= 1; i--)
  1484. {
  1485. DateTime Month = DateTime.Now.AddMonths(-i);
  1486. var month = Month.ToString("yyyyMM");
  1487. decimal HelpAmount = 0;
  1488. DataTable dt = OtherMySqlConn.dtable("SELECT SUM(TradeAmount) TradeAmount FROM HelpProfitMerTradeSummay WHERE MerchantId IN(SELECT MerchantId FROM HelpProfitMerIds WHERE UserId IN(SELECT Id from Users WHERE ParentNav like '%," + UserId + ",%' OR Id=" + UserId + ")) AND TradeMonth=" + month + "");
  1489. foreach (DataRow items in dt.Rows)
  1490. {
  1491. HelpAmount = decimal.Parse(function.CheckNum(items["TradeAmount"].ToString()));
  1492. }
  1493. var amount = UserTradeDaySummaryDbconn.Instance.GetMonthTrade(int.Parse(UserId), Month.ToString("yyyyMM"), "team");
  1494. var total = amount + HelpAmount;
  1495. Dictionary<string, object> item = new Dictionary<string, object>();
  1496. item.Add("Time", Month.ToString("yyyyMM")); //日期/月份
  1497. item.Add("TradeAmt", total); //交易额
  1498. MainTradeList.Add(item);
  1499. }
  1500. }
  1501. Obj.Add("MainTrade", MainTradeList);
  1502. //新增创客总数趋势数据
  1503. List<Dictionary<string, object>> AddMakerList = new List<Dictionary<string, object>>();
  1504. if (Kind == "1")
  1505. {
  1506. for (int i = 7; i >= 1; i--)
  1507. {
  1508. DateTime Date = DateTime.Now.AddDays(-i);
  1509. Dictionary<string, object> item = new Dictionary<string, object>();
  1510. item.Add("Time", Date.ToString("MMdd")); //日期/月份
  1511. item.Add("Count", UsersDbconn.Instance.GetTeamNewUserCount(int.Parse(UserId), Date.ToString("yyyyMMdd"))); //交易额
  1512. AddMakerList.Add(item);
  1513. }
  1514. }
  1515. else
  1516. {
  1517. for (int i = 6; i >= 1; i--)
  1518. {
  1519. DateTime Month = DateTime.Now.AddMonths(-i);
  1520. Dictionary<string, object> item = new Dictionary<string, object>();
  1521. item.Add("Time", Month.ToString("yyyyMM")); //日期/月份
  1522. item.Add("Count", UsersDbconn.Instance.GetTeamNewUserCount(int.Parse(UserId), Month.ToString("yyyyMM"))); //交易额
  1523. AddMakerList.Add(item);
  1524. }
  1525. }
  1526. Obj.Add("AddMaker", AddMakerList);
  1527. //新增激活商户总数趋势数据
  1528. List<Dictionary<string, object>> AddActMerchantList = new List<Dictionary<string, object>>();
  1529. if (Kind == "1")
  1530. {
  1531. for (int i = 7; i >= 1; i--)
  1532. {
  1533. Dictionary<string, object> item = new Dictionary<string, object>();
  1534. DateTime time = DateTime.Now.AddDays(-i);
  1535. string Date = time.ToString("MMdd");
  1536. item.Add("Time", Date); //日期/月份
  1537. item.Add("Count", UserDataDbconn.Instance.GetTeamPosActCount(int.Parse(UserId), time.ToString("yyyyMMdd"))); //数量
  1538. AddActMerchantList.Add(item);
  1539. }
  1540. }
  1541. else
  1542. {
  1543. for (int i = 6; i >= 1; i--)
  1544. {
  1545. Dictionary<string, object> item = new Dictionary<string, object>();
  1546. string Month = DateTime.Now.AddMonths(-i).ToString("yyyyMM");
  1547. item.Add("Time", Month); //日期/月份
  1548. item.Add("Count", UserDataDbconn.Instance.GetTeamPosActCount(int.Parse(UserId), Month)); //数量
  1549. AddActMerchantList.Add(item);
  1550. }
  1551. }
  1552. Obj.Add("AddActMerchant", AddActMerchantList);
  1553. return Obj;
  1554. }
  1555. #endregion
  1556. #region 创客-首页-我的创客-主界面创客列表
  1557. [Authorize]
  1558. public JsonResult MyMakerList(string value)
  1559. {
  1560. value = DesDecrypt(value);
  1561. JsonData data = JsonMapper.ToObject(value);
  1562. List<Dictionary<string, object>> dataList = MyMakerListDo(value);
  1563. return Json(new AppResultJson() { Status = "1", Info = "", Data = dataList });
  1564. }
  1565. public List<Dictionary<string, object>> MyMakerListDo(string value)
  1566. {
  1567. JsonData data = JsonMapper.ToObject(value);
  1568. string RealName = data["RealName"].ToString(); //真实姓名
  1569. int UserLevel = int.Parse(function.CheckInt(data["UserLevel"].ToString())); //创客等级
  1570. int UserId = int.Parse(function.CheckInt(data["UserId"].ToString())); //创客Id
  1571. string Sort = data["Sort"].ToString(); //排序方式
  1572. int PageSize = int.Parse(function.CheckInt(data["PageSize"].ToString()));
  1573. int PageNum = int.Parse(function.CheckInt(data["PageNum"].ToString()));
  1574. List<Dictionary<string, object>> dataList = new List<Dictionary<string, object>>();
  1575. IQueryable<Users> query = maindb.Users.Where(m => m.ParentUserId == UserId && m.AuthFlag == 1 && !m.Mobile.EndsWith("d"));
  1576. if (!string.IsNullOrEmpty(RealName))
  1577. {
  1578. query = query.Where(m => (m.RealName == RealName || m.MakerCode == RealName));
  1579. }
  1580. if (Sort == "ThisMonthTrade")
  1581. {
  1582. query = query.OrderByDescending(m => m.ThisMonthTrade);
  1583. }
  1584. if (Sort == "AuthDate")
  1585. {
  1586. query = query.OrderByDescending(m => m.AuthDate);
  1587. }
  1588. if (PageNum == 1)
  1589. {
  1590. query = query.Take(PageSize);
  1591. }
  1592. else
  1593. {
  1594. int skipNum = PageSize * (PageNum - 1);
  1595. query = query.Skip(skipNum).Take(PageSize);
  1596. }
  1597. foreach (var subdata in query.ToList())
  1598. {
  1599. Dictionary<string, object> curData = new Dictionary<string, object>();
  1600. curData.Add("RealName", DefaultRealName(subdata)); //真实姓名
  1601. curData.Add("HeadPhoto", DefaultPic(subdata.HeadPhoto)); //头像
  1602. curData.Add("Id", subdata.Id); //Id
  1603. curData.Add("CreateDate", subdata.AuthDate == null ? "" : subdata.AuthDate.Value.ToString("yyyy-MM-dd")); //CreateDate
  1604. curData.Add("ThisMonthTrade", subdata.ThisMonthTrade); //本月交易额
  1605. dataList.Add(curData);
  1606. }
  1607. return dataList;
  1608. }
  1609. #endregion
  1610. #region 创客-首页-我的创客-搜索创客列表
  1611. [Authorize]
  1612. public JsonResult SearchMakerList(string value)
  1613. {
  1614. value = DesDecrypt(value);
  1615. JsonData data = JsonMapper.ToObject(value);
  1616. List<Dictionary<string, object>> dataList = SearchMakerListDo(value);
  1617. return Json(new AppResultJson() { Status = "1", Info = "", Data = dataList });
  1618. }
  1619. public List<Dictionary<string, object>> SearchMakerListDo(string value)
  1620. {
  1621. JsonData data = JsonMapper.ToObject(value);
  1622. string RealName = data["RealName"].ToString(); //真实姓名
  1623. int UserLevel = int.Parse(function.CheckInt(data["UserLevel"].ToString())); //创客等级
  1624. int UserId = int.Parse(function.CheckInt(data["UserId"].ToString())); //创客Id
  1625. string Sort = data["Sort"].ToString(); //排序方式
  1626. int PageSize = int.Parse(function.CheckInt(data["PageSize"].ToString()));
  1627. int PageNum = int.Parse(function.CheckInt(data["PageNum"].ToString()));
  1628. List<Dictionary<string, object>> dataList = new List<Dictionary<string, object>>();
  1629. string UserIdString = "," + UserId + ",";
  1630. IQueryable<Users> query = maindb.Users.Where(m => m.ParentNav.Contains(UserIdString) && m.AuthFlag == 1);
  1631. if (!string.IsNullOrEmpty(RealName))
  1632. {
  1633. query = query.Where(m => (m.RealName == RealName || m.MakerCode == RealName));
  1634. }
  1635. // if (UserLevel > 0)
  1636. // {
  1637. // query = query.Where(m => m.UserLevel == UserLevel);
  1638. // }
  1639. if (PageNum == 1)
  1640. {
  1641. query = query.Take(PageSize);
  1642. }
  1643. else
  1644. {
  1645. int skipNum = PageSize * (PageNum - 1);
  1646. query = query.Skip(skipNum).Take(PageSize);
  1647. }
  1648. foreach (var subdata in query.ToList())
  1649. {
  1650. // Users subdata = UsersDbconn.Instance.Get(item.UserId) ?? new Users();
  1651. Dictionary<string, object> curData = new Dictionary<string, object>();
  1652. curData.Add("RealName", DefaultRealName(subdata)); //真实姓名
  1653. curData.Add("HeadPhoto", DefaultPic(subdata.HeadPhoto)); //头像
  1654. curData.Add("Id", subdata.Id); //Id
  1655. curData.Add("CreateDate", subdata.CreateDate == null ? "" : subdata.CreateDate.Value.ToString("yyyy-MM-dd")); //CreateDate
  1656. curData.Add("ThisMonthTrade", UserTradeDaySummaryDbconn.Instance.GetMonthTrade(subdata.Id, DateTime.Now.ToString("yyyyMM"), "team")); //本月交易额
  1657. dataList.Add(curData);
  1658. }
  1659. return dataList;
  1660. }
  1661. #endregion
  1662. #region 创客-首页-我的创客-创客详情
  1663. [Authorize]
  1664. public JsonResult MyMakerDetail(string value)
  1665. {
  1666. value = DesDecrypt(value);
  1667. JsonData data = JsonMapper.ToObject(value);
  1668. Dictionary<string, object> Obj = MyMakerDetailDo(value);
  1669. return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
  1670. }
  1671. public Dictionary<string, object> MyMakerDetailDo(string value)
  1672. {
  1673. JsonData data = JsonMapper.ToObject(value);
  1674. string UserId = data["UserId"].ToString(); //创客Id
  1675. string DateKind = data["DateKind"].ToString(); //查询时间
  1676. Dictionary<string, object> Obj = new Dictionary<string, object>();
  1677. decimal TradeTotal = 0;
  1678. int ActTotal = 0;
  1679. if (DateKind == "1")
  1680. {
  1681. for (int i = 0; i <= 7; i++)
  1682. {
  1683. string Date = DateTime.Now.AddDays(-i).ToString("yyyyMMdd");
  1684. TradeTotal += UserTradeDaySummaryDbconn.Instance.GetDateTrade(int.Parse(UserId), Date, "team");
  1685. ActTotal += UserDataDbconn.Instance.GetTeamPosActCount(int.Parse(UserId), Date);
  1686. }
  1687. }
  1688. else if (DateKind == "2")
  1689. {
  1690. for (int i = 0; i <= 6; i++)
  1691. {
  1692. string Month = DateTime.Now.AddMonths(-i).ToString("yyyyMM");
  1693. TradeTotal += UserTradeDaySummaryDbconn.Instance.GetMonthTrade(int.Parse(UserId), Month, "team");
  1694. ActTotal += UserDataDbconn.Instance.GetTeamPosActCount(int.Parse(UserId), Month);
  1695. }
  1696. }
  1697. Obj.Add("TradeTotal", TradeTotal); //总交易
  1698. Obj.Add("ActTotal", ActTotal); //总激活数
  1699. List<KqProducts> products = new KqProductsService().List(new List<FieldItem>(), "", 1, 100);
  1700. List<KqProducts> productall = products.Prepend(new KqProducts()
  1701. {
  1702. Id = 0,
  1703. Name = "全部",
  1704. }).ToList();
  1705. //交易分类占比
  1706. List<Dictionary<string, object>> TradePercentList = new List<Dictionary<string, object>>();
  1707. foreach (KqProducts product in products)
  1708. {
  1709. decimal Total = 0;
  1710. if (DateKind == "1")
  1711. {
  1712. for (int i = 0; i <= 7; i++)
  1713. {
  1714. string Date = DateTime.Now.AddDays(-i).ToString("yyyyMMdd");
  1715. Total += UserTradeDaySummaryDbconn.Instance.GetDateTradeForBrand(int.Parse(UserId), Date, product.Id, "team");
  1716. }
  1717. }
  1718. else if (DateKind == "2")
  1719. {
  1720. for (int i = 0; i <= 6; i++)
  1721. {
  1722. string Month = DateTime.Now.AddMonths(-i).ToString("yyyyMM");
  1723. Total += UserTradeDaySummaryDbconn.Instance.GetMonthTradeForBrand(int.Parse(UserId), Month, product.Id, "team");
  1724. }
  1725. }
  1726. if (Total > 0)
  1727. {
  1728. Dictionary<string, object> item = new Dictionary<string, object>();
  1729. item.Add("Name", product.Name); //产品名称
  1730. item.Add("TradeAmt", Total); //交易额
  1731. TradePercentList.Add(item);
  1732. }
  1733. }
  1734. Obj.Add("TradePercent", TradePercentList);
  1735. //交易趋势图
  1736. List<Dictionary<string, object>> TradeTrendList = new List<Dictionary<string, object>>();
  1737. foreach (KqProducts product in productall)
  1738. {
  1739. Dictionary<string, object> item = new Dictionary<string, object>();
  1740. item.Add("Name", product.Name); //产品名称
  1741. List<Dictionary<string, object>> TimeList = new List<Dictionary<string, object>>();
  1742. if (DateKind == "1")
  1743. {
  1744. for (int i = 7; i >= 0; i--)
  1745. {
  1746. DateTime Date = DateTime.Now.AddDays(-i);
  1747. Dictionary<string, object> subitem = new Dictionary<string, object>();
  1748. subitem.Add("TimeString", Date.ToString("MMdd")); //交易日期/月份
  1749. if (product.Id > 0)
  1750. {
  1751. subitem.Add("TradeAmt", UserTradeDaySummaryDbconn.Instance.GetDateTradeForBrand(int.Parse(UserId), Date.ToString("yyyyMMdd"), product.Id, "team")); //交易额
  1752. }
  1753. else
  1754. {
  1755. subitem.Add("TradeAmt", UserTradeDaySummaryDbconn.Instance.GetDateTrade(int.Parse(UserId), Date.ToString("yyyyMMdd"), "team")); //交易额
  1756. }
  1757. TimeList.Add(subitem);
  1758. }
  1759. }
  1760. else if (DateKind == "2")
  1761. {
  1762. for (int i = 6; i >= 0; i--)
  1763. {
  1764. DateTime Month = DateTime.Now.AddMonths(-i);
  1765. Dictionary<string, object> subitem = new Dictionary<string, object>();
  1766. subitem.Add("TimeString", Month.ToString("yyyyMM")); //交易日期/月份
  1767. if (product.Id > 0)
  1768. {
  1769. subitem.Add("TradeAmt", UserTradeDaySummaryDbconn.Instance.GetMonthTradeForBrand(int.Parse(UserId), Month.ToString("yyyyMM"), product.Id, "team")); //交易额
  1770. }
  1771. else
  1772. {
  1773. subitem.Add("TradeAmt", UserTradeDaySummaryDbconn.Instance.GetMonthTrade(int.Parse(UserId), Month.ToString("yyyyMM"), "team")); //交易额
  1774. }
  1775. TimeList.Add(subitem);
  1776. }
  1777. }
  1778. item.Add("Times", TimeList); //交易额
  1779. TradeTrendList.Add(item);
  1780. }
  1781. Obj.Add("TradeTrend", TradeTrendList);
  1782. //新增激活商户分类占比
  1783. List<Dictionary<string, object>> ActMerchantPercentList = new List<Dictionary<string, object>>();
  1784. foreach (KqProducts product in products)
  1785. {
  1786. int Total = 0;
  1787. if (DateKind == "1")
  1788. {
  1789. for (int i = 0; i <= 7; i++)
  1790. {
  1791. string Date = DateTime.Now.AddDays(-i).ToString("yyyyMMdd");
  1792. Total += UserDataDbconn.Instance.GetTeamBrandPosActCount(int.Parse(UserId), product.Id, Date);
  1793. }
  1794. }
  1795. else if (DateKind == "2")
  1796. {
  1797. for (int i = 0; i <= 6; i++)
  1798. {
  1799. string Month = DateTime.Now.AddMonths(-i).ToString("yyyyMM");
  1800. Total += UserDataDbconn.Instance.GetTeamBrandPosActCount(int.Parse(UserId), product.Id, Month);
  1801. }
  1802. }
  1803. if (Total > 0)
  1804. {
  1805. Dictionary<string, object> item = new Dictionary<string, object>();
  1806. item.Add("Name", product.Name); //产品名称
  1807. item.Add("ActCount", Total); //激活数
  1808. ActMerchantPercentList.Add(item);
  1809. }
  1810. }
  1811. Obj.Add("ActMerchantPercent", ActMerchantPercentList);
  1812. //新增激活商户趋势图
  1813. List<Dictionary<string, object>> ActMerchantTrendList = new List<Dictionary<string, object>>();
  1814. foreach (KqProducts product in productall)
  1815. {
  1816. Dictionary<string, object> item = new Dictionary<string, object>();
  1817. item.Add("Name", product.Name); //产品名称
  1818. List<Dictionary<string, object>> TimeList = new List<Dictionary<string, object>>();
  1819. if (DateKind == "1")
  1820. {
  1821. for (int i = 7; i >= 0; i--)
  1822. {
  1823. DateTime Date = DateTime.Now.AddDays(-i);
  1824. Dictionary<string, object> subitem = new Dictionary<string, object>();
  1825. subitem.Add("TimeString", Date.ToString("MMdd")); //统计日期/月份
  1826. if (product.Id > 0)
  1827. {
  1828. subitem.Add("ActCount", UserDataDbconn.Instance.GetTeamBrandPosActCount(int.Parse(UserId), product.Id, Date.ToString("yyyyMMdd"))); //激活数
  1829. }
  1830. else
  1831. {
  1832. subitem.Add("ActCount", UserDataDbconn.Instance.GetTeamPosActCount(int.Parse(UserId), Date.ToString("yyyyMMdd"))); //激活数
  1833. }
  1834. TimeList.Add(subitem);
  1835. }
  1836. }
  1837. else if (DateKind == "2")
  1838. {
  1839. for (int i = 6; i >= 0; i--)
  1840. {
  1841. string Month = DateTime.Now.AddMonths(-i).ToString("yyyyMM");
  1842. Dictionary<string, object> subitem = new Dictionary<string, object>();
  1843. subitem.Add("TimeString", Month); //统计日期/月份
  1844. if (product.Id > 0)
  1845. {
  1846. subitem.Add("ActCount", UserDataDbconn.Instance.GetTeamBrandPosActCount(int.Parse(UserId), product.Id, Month)); //激活数
  1847. }
  1848. else
  1849. {
  1850. subitem.Add("ActCount", UserDataDbconn.Instance.GetTeamPosActCount(int.Parse(UserId), Month)); //激活数
  1851. }
  1852. TimeList.Add(subitem);
  1853. }
  1854. }
  1855. item.Add("Times", TimeList); //交易额
  1856. ActMerchantTrendList.Add(item);
  1857. }
  1858. Obj.Add("ActMerchantTrend", ActMerchantTrendList);
  1859. //创客新增趋势图
  1860. List<Dictionary<string, object>> MakerAddList = new List<Dictionary<string, object>>();
  1861. if (DateKind == "1")
  1862. {
  1863. for (int i = 7; i >= 0; i--)
  1864. {
  1865. string Date = DateTime.Now.AddDays(-i).ToString("yyyyMMdd");
  1866. Dictionary<string, object> item = new Dictionary<string, object>();
  1867. item.Add("TimeString", Date);
  1868. item.Add("AddCount", UsersDbconn.Instance.GetTeamNewUserCount(int.Parse(UserId), Date));
  1869. MakerAddList.Add(item);
  1870. }
  1871. }
  1872. else if (DateKind == "2")
  1873. {
  1874. for (int i = 6; i >= 0; i--)
  1875. {
  1876. string Month = DateTime.Now.AddMonths(-i).ToString("yyyyMM");
  1877. Dictionary<string, object> item = new Dictionary<string, object>();
  1878. item.Add("TimeString", Month);
  1879. item.Add("AddCount", UsersDbconn.Instance.GetTeamNewUserCount(int.Parse(UserId), Month));
  1880. MakerAddList.Add(item);
  1881. }
  1882. }
  1883. Obj.Add("MakerAdd", MakerAddList);
  1884. return Obj;
  1885. }
  1886. #endregion
  1887. #region 首页-我的创客-未实名创客
  1888. [Authorize]
  1889. public JsonResult MyMakerForNotAuth(string value)
  1890. {
  1891. value = DesDecrypt(value);
  1892. JsonData data = JsonMapper.ToObject(value);
  1893. long TotalCount = 0;
  1894. List<Dictionary<string, object>> dataList = MyMakerForNotAuthDo(value, out TotalCount);
  1895. Dictionary<string, object> Other = new Dictionary<string, object>();
  1896. Other.Add("TotalCount", TotalCount);
  1897. return Json(new AppResultJson() { Status = "1", Info = "", Data = dataList, Other = Other });
  1898. }
  1899. public List<Dictionary<string, object>> MyMakerForNotAuthDo(string value, out long TotalCount)
  1900. {
  1901. JsonData data = JsonMapper.ToObject(value);
  1902. int UserId = int.Parse(function.CheckInt(data["UserId"].ToString())); //创客Id
  1903. int PageSize = int.Parse(function.CheckInt(data["PageSize"].ToString()));
  1904. int PageNum = int.Parse(function.CheckInt(data["PageNum"].ToString()));
  1905. List<Dictionary<string, object>> dataList = new List<Dictionary<string, object>>();
  1906. IQueryable<Users> query = maindb.Users.Where(m => m.ParentUserId == UserId && m.AuthFlag == 0);
  1907. TotalCount = query.Count();
  1908. if (PageNum == 1)
  1909. {
  1910. query = query.Take(PageSize);
  1911. }
  1912. else
  1913. {
  1914. int skipNum = PageSize * (PageNum - 1);
  1915. query = query.Skip(skipNum).Take(PageSize);
  1916. }
  1917. foreach (var subdata in query.ToList())
  1918. {
  1919. // Users subdata = UsersDbconn.Instance.Get(item.UserId) ?? new Users();
  1920. Dictionary<string, object> curData = new Dictionary<string, object>();
  1921. string RealName = DefaultRealName(subdata);
  1922. if (string.IsNullOrEmpty(RealName))
  1923. {
  1924. RealName = subdata.SeoTitle;
  1925. }
  1926. curData.Add("RealName", RealName); //真实姓名
  1927. curData.Add("HeadPhoto", DefaultPic(subdata.HeadPhoto)); //头像
  1928. curData.Add("Mobile", subdata.Mobile); //手机号
  1929. curData.Add("Id", subdata.Id); //Id
  1930. curData.Add("CreateDate", subdata.CreateDate == null ? "" : subdata.CreateDate.Value.ToString("yyyy-MM-dd HH:mm:ss")); //CreateDate
  1931. dataList.Add(curData);
  1932. }
  1933. return dataList;
  1934. }
  1935. #endregion
  1936. #region 创客-首页-我的创客-主界面数据
  1937. [Authorize]
  1938. public JsonResult MyMakerData(string value)
  1939. {
  1940. value = DesDecrypt(value);
  1941. JsonData data = JsonMapper.ToObject(value);
  1942. Dictionary<string, object> Obj = MyMakerDataDo(value);
  1943. return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
  1944. }
  1945. public Dictionary<string, object> MyMakerDataDo(string value)
  1946. {
  1947. JsonData data = JsonMapper.ToObject(value);
  1948. int UserId = int.Parse(function.CheckInt(data["UserId"].ToString())); //创客Id
  1949. Dictionary<string, object> Obj = new Dictionary<string, object>();
  1950. int MakerTotal = maindb.Users.Count(m => m.ParentUserId == UserId);
  1951. int AuthCount = maindb.Users.Count(m => m.ParentUserId == UserId && m.AuthFlag == 1);
  1952. int NotAuthCount = MakerTotal - AuthCount;
  1953. DateTime start = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd") + " 00:00:00");
  1954. int ThisMonthCount = maindb.Users.Count(m => m.ParentUserId == UserId && m.AuthFlag == 1 && m.AuthDate >= start);
  1955. Obj.Add("MakerTotal", MakerTotal); //创客总数
  1956. Obj.Add("AuthCount", AuthCount); //已实名总数
  1957. Obj.Add("NotAuthCount", NotAuthCount); //未实名总数
  1958. Obj.Add("ThisMonthCount", ThisMonthCount); //当月新增
  1959. return Obj;
  1960. }
  1961. #endregion
  1962. #region 创客-我的-个人资料-我的名片
  1963. [Authorize]
  1964. public JsonResult MyCard(string value)
  1965. {
  1966. value = DesDecrypt(value);
  1967. JsonData data = JsonMapper.ToObject(value);
  1968. Dictionary<string, object> Obj = MyCardDo(value);
  1969. return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
  1970. }
  1971. public Dictionary<string, object> MyCardDo(string value)
  1972. {
  1973. JsonData data = JsonMapper.ToObject(value);
  1974. Dictionary<string, object> Obj = new Dictionary<string, object>();
  1975. int Id = int.Parse(function.CheckInt(data["Id"].ToString()));
  1976. Users query = maindb.Users.FirstOrDefault(m => m.Id == Id) ?? new Users();
  1977. string filename = function.MD5_16(Id + "2022");
  1978. string filepath = "/static/ReferenceQrCode/";
  1979. if (!System.IO.File.Exists(function.getPath(filepath + filename + ".png")))
  1980. {
  1981. string path = function.CreateQRCode2(ConfigurationManager.AppSettings["SourceHost"].ToString() + "/p/user-inviteregist-1?Id=" + Id, filename, filepath);
  1982. path = path.Replace("//", "/");
  1983. query.ReferenceQrCode = filepath + filename + ".png";
  1984. maindb.SaveChanges();
  1985. }
  1986. Obj.Add("RealName", DefaultRealName(query)); //真实姓名
  1987. Obj.Add("HeadPhoto", DefaultPic(query.HeadPhoto)); //头像
  1988. Obj.Add("ReferenceQrCode", Host + filepath.TrimStart('/') + filename + ".png"); //推广二维码地址
  1989. Obj.Add("MakerCode", query.MakerCode); //创客编号
  1990. Obj.Add("InvitePhoto", Host + filepath.TrimStart('/') + filename + ".png"); //DefaultPic(query.SignImgUrl)); //邀请图片
  1991. return Obj;
  1992. }
  1993. #endregion
  1994. #region 创客-首页-检测是否有级别
  1995. [Authorize]
  1996. public JsonResult CheckUserLevel(string value)
  1997. {
  1998. value = DesDecrypt(value);
  1999. JsonData data = JsonMapper.ToObject(value);
  2000. int UserId = int.Parse(function.CheckInt(data["UserId"].ToString())); //创客Id
  2001. Dictionary<string, object> Obj = new Dictionary<string, object>();
  2002. UserRank rank = maindb.UserRank.FirstOrDefault(m => m.UserId == UserId && m.Status == 0);
  2003. if (rank != null)
  2004. {
  2005. Obj.Add("BeforeLevel", rank.WhiteRank);
  2006. Obj.Add("AfterLevel", rank.Rank);
  2007. rank.Status = 1;
  2008. maindb.SaveChanges();
  2009. return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
  2010. }
  2011. return Json(new AppResultJson() { Status = "-1", Info = "" });
  2012. }
  2013. #endregion
  2014. #region 创客-我的-盟主中心-盟主信息详情
  2015. [Authorize]
  2016. public JsonResult LeaderInfo(string value)
  2017. {
  2018. value = DesDecrypt(value);
  2019. JsonData data = JsonMapper.ToObject(value);
  2020. Dictionary<string, object> Obj = LeaderInfoDo(value);
  2021. return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
  2022. }
  2023. public Dictionary<string, object> LeaderInfoDo(string value)
  2024. {
  2025. JsonData data = JsonMapper.ToObject(value);
  2026. Dictionary<string, object> Obj = new Dictionary<string, object>();
  2027. int UserId = int.Parse(function.CheckInt(data["UserId"].ToString()));
  2028. Users query = maindb.Users.FirstOrDefault(m => m.Id == UserId) ?? new Users();
  2029. UserAccount account = maindb.UserAccount.FirstOrDefault(m => m.Id == UserId) ?? new UserAccount();
  2030. Obj.Add("LeaderLevel", query.LeaderLevel); //盟主等级(0 无 1 小盟主 2 大盟主)
  2031. Obj.Add("LeaderReserve", account.LeaderReserve); //盟主储备金
  2032. Obj.Add("LeaderBalanceAmount", account.LeaderBalanceAmount); //可提现金额
  2033. return Obj;
  2034. }
  2035. #endregion
  2036. #region 创客-提交签名图片
  2037. [Authorize]
  2038. public JsonResult UploadSignPic(string value)
  2039. {
  2040. value = DesDecrypt(value);
  2041. JsonData data = JsonMapper.ToObject(value);
  2042. AppResultJson result = UploadSignPicDo(value);
  2043. return Json(new AppResultJson() { Status = result.Status, Info = result.Info, Data = result.Data });
  2044. }
  2045. public AppResultJson UploadSignPicDo(string value)
  2046. {
  2047. JsonData data = JsonMapper.ToObject(value);
  2048. int Id = int.Parse(function.CheckInt(data["Id"].ToString()));
  2049. string SignPic = data["SignPic"].ToString(); //签名图片
  2050. if(string.IsNullOrEmpty(SignPic))
  2051. {
  2052. return new AppResultJson() { Status = "-1", Info = "签名图片不能为空" };
  2053. }
  2054. Dictionary<string, object> Obj = new Dictionary<string, object>();
  2055. Users query = maindb.Users.FirstOrDefault(m => m.Id == Id);
  2056. if (query != null)
  2057. {
  2058. query.IsSign = 1;
  2059. query.SignDate = DateTime.Now;
  2060. query.SignPic = SignPic; //签名图片
  2061. maindb.SaveChanges();
  2062. }
  2063. return new AppResultJson() { Status = "1", Info = "", Data = Obj };
  2064. }
  2065. #endregion
  2066. #region 创客-是否签名
  2067. [Authorize]
  2068. public JsonResult SignCheck(string value)
  2069. {
  2070. value = DesDecrypt(value);
  2071. JsonData data = JsonMapper.ToObject(value);
  2072. Dictionary<string, object> Obj = SignCheckDo(value);
  2073. return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
  2074. }
  2075. public Dictionary<string, object> SignCheckDo(string value)
  2076. {
  2077. JsonData data = JsonMapper.ToObject(value);
  2078. Dictionary<string, object> Obj = new Dictionary<string, object>();
  2079. int Id = int.Parse(function.CheckInt(data["Id"].ToString()));
  2080. Users query = maindb.Users.FirstOrDefault(m => m.Id == Id) ?? new Users();
  2081. Obj.Add("IsSign", query.IsSign); //是否签名
  2082. return Obj;
  2083. }
  2084. #endregion
  2085. #region 通用-通过创客编号查询
  2086. [Authorize]
  2087. public JsonResult ForCode(string value)
  2088. {
  2089. value = DesDecrypt(value);
  2090. JsonData data = JsonMapper.ToObject(value);
  2091. string MakerCode = data["MakerCode"].ToString(); //创客编号
  2092. Dictionary<string, object> Obj = new Dictionary<string, object>();
  2093. UserForMakerCode userfor = UserForMakerCodeDbconn.Instance.Get(MakerCode) ?? new UserForMakerCode();
  2094. Users query = UsersDbconn.Instance.Get(userfor.UserId) ?? new Users();
  2095. if (query.AuthFlag != 1)
  2096. {
  2097. return Json(new AppResultJson() { Status = "-1", Info = "创客未认证" });
  2098. }
  2099. Obj.Add("Id", query.Id); //创客Id
  2100. Obj.Add("RealName", query.RealName); //真实姓名
  2101. return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
  2102. }
  2103. #endregion
  2104. #region 通用-灰度测试UserId集合
  2105. [Authorize]
  2106. public JsonResult UserIdForGrayTest(string value)
  2107. {
  2108. value = DesDecrypt(value);
  2109. JsonData data = JsonMapper.ToObject(value);
  2110. List<string> Obj = UserIdForGrayTestDo(value);
  2111. return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
  2112. }
  2113. public List<string> UserIdForGrayTestDo(string value)
  2114. {
  2115. JsonData data = JsonMapper.ToObject(value);
  2116. List<string> Obj = new List<string>();
  2117. SystemSet set = maindb.SystemSet.FirstOrDefault() ?? new SystemSet();
  2118. if (!string.IsNullOrEmpty(set.RightInfo))
  2119. {
  2120. string[] RightInfos = set.RightInfo.Split('\n');
  2121. foreach (string sub in RightInfos)
  2122. {
  2123. UserForMakerCode code = maindb.UserForMakerCode.FirstOrDefault(m => m.MakerCode == sub);
  2124. if (code != null)
  2125. {
  2126. Obj.Add(code.UserId.ToString());
  2127. }
  2128. }
  2129. }
  2130. return Obj;
  2131. }
  2132. #endregion
  2133. #region 企业创客-个人中心主界面
  2134. [Authorize]
  2135. public JsonResult BusinessMain(string value)
  2136. {
  2137. value = DesDecrypt(value);
  2138. JsonData data = JsonMapper.ToObject(value);
  2139. Dictionary<string, object> Obj = BusinessMainDo(value);
  2140. return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
  2141. }
  2142. public Dictionary<string, object> BusinessMainDo(string value)
  2143. {
  2144. JsonData data = JsonMapper.ToObject(value);
  2145. string PartnerCount = data["PartnerCount"].ToString(); //伙伴总数
  2146. string ThisMonthTrade = data["ThisMonthTrade"].ToString(); //本月交易额
  2147. string ThisMonthAct = data["ThisMonthAct"].ToString(); //本月激活商户
  2148. Dictionary<string, object> Obj = new Dictionary<string, object>();
  2149. Users query = new Users();
  2150. int Id = int.Parse(function.CheckInt(data["Id"].ToString()));
  2151. query = maindb.Users.FirstOrDefault(m => m.Id == Id) ?? new Users();
  2152. return Obj;
  2153. }
  2154. #endregion
  2155. #region 创客-我的-添加展业地区
  2156. [Authorize]
  2157. public JsonResult AddAgentAreas(string value)
  2158. {
  2159. value = DesDecrypt(value);
  2160. JsonData data = JsonMapper.ToObject(value);
  2161. AppResultJson result = AddAgentAreasDo(value);
  2162. return Json(new AppResultJson() { Status = result.Status, Info = result.Info, Data = result.Data });
  2163. }
  2164. public AppResultJson AddAgentAreasDo(string value)
  2165. {
  2166. JsonData data = JsonMapper.ToObject(value);
  2167. int UserId = int.Parse(function.CheckInt(data["UserId"].ToString()));
  2168. string AgentAreas = data["AgentAreas"].ToString(); //展业地区
  2169. if(string.IsNullOrEmpty(AgentAreas))
  2170. {
  2171. return new AppResultJson() { Status = "-1", Info = "展业地区不能为空" };
  2172. }
  2173. Dictionary<string, object> Obj = new Dictionary<string, object>();
  2174. Users query = maindb.Users.FirstOrDefault(m => m.Id == UserId);
  2175. if (query != null)
  2176. {
  2177. query.UpdateDate = DateTime.Now;
  2178. query.AgentAreas = AgentAreas; //展业地区
  2179. maindb.SaveChanges();
  2180. }
  2181. return new AppResultJson() { Status = "1", Info = "", Data = Obj };
  2182. }
  2183. #endregion
  2184. #region 检查签名是否合法,合法返回1,不合法返回提示信息
  2185. /// <summary>
  2186. /// 检查签名是否合法,合法返回1,不合法返回提示信息
  2187. /// </summary>
  2188. /// <param name="value">请求的参数(json字符串)</param>
  2189. /// <param name="signField">要签名的字段</param>
  2190. /// <returns></returns>
  2191. private string CheckSign(string value, string[] signField)
  2192. {
  2193. JsonData json = JsonMapper.ToObject(value);
  2194. Dictionary<string, string> dic = new Dictionary<string, string>();
  2195. for (int i = 0; i < signField.Length; i++)
  2196. {
  2197. dic.Add(signField[i], json[signField[i]].ToString());
  2198. }
  2199. string sign = json["sign"].ToString(); //客户端签名字符串
  2200. return new Sign().sign(dic, sign);
  2201. }
  2202. #endregion
  2203. }
  2204. }