UsersController.cs 101 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096
  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. KxsMainModels.Users query = kxsdb.Users.FirstOrDefault(m => m.Id == Id) ?? new KxsMainModels.Users();
  39. string IdString = Id.ToString();
  40. Obj.Add("RealName", query.RealName); //真实姓名
  41. Obj.Add("HeadPhoto", 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 NickName = data["NickName"].ToString();
  354. string HeadPhoto = data["HeadPhoto"].ToString();
  355. string MakerCode = data["MakerCode"].ToString();
  356. string KxsOpenId = data["KxsOpenId"].ToString();
  357. Dictionary<string, object> Obj = new Dictionary<string, object>();
  358. MiniModels.UserForProject miniuser = minidb.UserForProject.FirstOrDefault(m => m.OpenId == KxsOpenId) ?? new MiniModels.UserForProject();
  359. Users user = maindb.Users.FirstOrDefault(m => m.Id == miniuser.PlateformUserId && m.Tags == KxsOpenId);
  360. if (user == null)
  361. {
  362. user = maindb.Users.Add(new Users()
  363. {
  364. Id = miniuser.PlateformUserId,
  365. CreateDate = DateTime.Now,
  366. Tags = KxsOpenId,
  367. NickName = NickName,
  368. HeadPhoto = HeadPhoto,
  369. Mobile = Mobile,
  370. MakerCode = MakerCode,
  371. }).Entity;
  372. maindb.SaveChanges();
  373. }
  374. else
  375. {
  376. user.UpdateDate = DateTime.Now;
  377. user.NickName = NickName;
  378. user.HeadPhoto = HeadPhoto;
  379. user.MakerCode = MakerCode;
  380. user.Mobile = Mobile;
  381. maindb.SaveChanges();
  382. }
  383. UserForMobile query = maindb.UserForMobile.FirstOrDefault(m => m.Mobile == Mobile);
  384. if (query == null)
  385. {
  386. query = maindb.UserForMobile.Add(new UserForMobile()
  387. {
  388. Mobile = Mobile,
  389. UserId = user.Id,
  390. }).Entity;
  391. maindb.SaveChanges();
  392. }
  393. else
  394. {
  395. query.UserId = user.Id;
  396. maindb.SaveChanges();
  397. }
  398. Obj.Add("Id", user.Id);
  399. Obj.Add("Token", PublicFunction.AppToken(user.Id, JwtSecret, JwtIss));
  400. return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
  401. }
  402. #endregion
  403. #region 创客-我的-注销
  404. // 1、未实名创客;
  405. // 2、已实名创客,无开通商户;
  406. // 3、近7天未在商城下单过商品;
  407. // 4、名下无未绑定机具、机具券,无未申请的循环机;
  408. [Authorize]
  409. public JsonResult Delete(string value)
  410. {
  411. value = DesDecrypt(value);
  412. JsonData data = JsonMapper.ToObject(value);
  413. int UserId = int.Parse(function.CheckInt(data["UserId"].ToString()));
  414. string Mobile = data["Mobile"].ToString();
  415. // string MobileCode = data["MobileCode"].ToString(); //短信验证码
  416. // MobileCodeCheck mobilecheck = RedisDbconn.Instance.Get<MobileCodeCheck>("MobileCodeCheck:" + Mobile);
  417. // if (mobilecheck == null)
  418. // {
  419. // return Json(new AppResultJson() { Status = "-1", Info = "短信验证码不正确" });
  420. // }
  421. // if (mobilecheck.CheckCode != MobileCode)
  422. // {
  423. // return Json(new AppResultJson() { Status = "-1", Info = "短信验证码不正确" });
  424. // }
  425. // RedisDbconn.Instance.Clear("MobileCodeCheck:" + Mobile);
  426. Users user = maindb.Users.FirstOrDefault(m => m.Id == UserId && m.Mobile == Mobile);
  427. if (user != null)
  428. {
  429. if (user.AuthFlag == 1)
  430. {
  431. bool check = maindb.PosMachinesTwo.Any(m => m.BuyUserId == user.Id && m.BindingState == 1);
  432. if (check)
  433. {
  434. return Json(new AppResultJson() { Status = "-1", Info = "注销失败,未满足条件:已实名创客,无开通商户。如有疑问,请联系客服" });
  435. }
  436. DateTime checkDate = DateTime.Now.AddDays(-7);
  437. check = maindb.Orders.Any(m => m.CreateDate >= checkDate && m.Status > 0 && m.UserId == user.Id);
  438. if (check)
  439. {
  440. return Json(new AppResultJson() { Status = "-1", Info = "注销失败,未满足条件:近7天未在商城下单过商品。如有疑问,请联系客服" });
  441. }
  442. check = maindb.PosMachinesTwo.Any(m => m.BuyUserId == user.Id && m.IsPurchase == 0);
  443. if (check)
  444. {
  445. return Json(new AppResultJson() { Status = "-1", Info = "注销失败,未满足条件:名下无未绑定机具、机具券,无未申请的循环机。如有疑问,请联系客服" });
  446. }
  447. check = maindb.PosCoupons.Any(m => m.UserId == user.Id && m.IsUse == 0);
  448. if (check)
  449. {
  450. return Json(new AppResultJson() { Status = "-1", Info = "注销失败,未满足条件:名下无未绑定机具、机具券,无未申请的循环机。如有疑问,请联系客服" });
  451. }
  452. UserForMobile forMobile = maindb.UserForMobile.FirstOrDefault(m => m.Mobile == Mobile);
  453. if (forMobile != null)
  454. {
  455. maindb.Remove(forMobile);
  456. }
  457. user.Status = -1;
  458. user.Mobile += "d";
  459. user.CertId += "d";
  460. }
  461. else
  462. {
  463. UserForMobile forMobile = maindb.UserForMobile.FirstOrDefault(m => m.Mobile == Mobile);
  464. if (forMobile != null)
  465. {
  466. maindb.Remove(forMobile);
  467. }
  468. user.Status = -1;
  469. user.Mobile += "d";
  470. user.CertId += "d";
  471. }
  472. function.WriteLog(user.Id + "于" + DateTime.Now.ToString() + "注销账号", "创客注销日志");
  473. // TODO: 每月扫描一次注销的创客,把注销创客伞下创客全部挂到注销创客的上级
  474. // TODO: 清除token,token登录返回
  475. maindb.SaveChanges();
  476. return Json(new AppResultJson() { Status = "1", Info = "" });
  477. }
  478. return Json(new AppResultJson() { Status = "-1", Info = "手机号不正确" });
  479. }
  480. #endregion
  481. #region 创客-我的-个人资料-上传头像
  482. [Authorize]
  483. public JsonResult UploadHeadPhoto(string value)
  484. {
  485. value = DesDecrypt(value);
  486. JsonData data = JsonMapper.ToObject(value);
  487. AppResultJson result = UploadHeadPhotoDo(value);
  488. return Json(new AppResultJson() { Status = result.Status, Info = result.Info, Data = result.Data });
  489. }
  490. public AppResultJson UploadHeadPhotoDo(string value)
  491. {
  492. JsonData data = JsonMapper.ToObject(value);
  493. string HeadPhoto = data["HeadPhoto"].ToString(); //头像
  494. Dictionary<string, object> Obj = new Dictionary<string, object>();
  495. int Id = int.Parse(function.CheckInt(data["Id"].ToString()));
  496. Users query = maindb.Users.FirstOrDefault(m => m.Id == Id);
  497. if (query != null)
  498. {
  499. query.HeadPhoto = HeadPhoto; //头像
  500. maindb.SaveChanges();
  501. }
  502. return new AppResultJson() { Status = "1", Info = "", Data = Obj };
  503. }
  504. #endregion
  505. #region 创客-我的-提现-绑定银行卡信息
  506. [Authorize]
  507. public JsonResult BindBankInfo(string value)
  508. {
  509. value = DesDecrypt(value);
  510. JsonData data = JsonMapper.ToObject(value);
  511. Dictionary<string, object> Obj = BindBankInfoDo(value);
  512. return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
  513. }
  514. public Dictionary<string, object> BindBankInfoDo(string value)
  515. {
  516. JsonData data = JsonMapper.ToObject(value);
  517. Dictionary<string, object> Obj = new Dictionary<string, object>();
  518. int Id = int.Parse(function.CheckInt(data["Id"].ToString()));
  519. Users query = UsersDbconn.Instance.Get(Id) ?? new Users();
  520. Obj.Add("SettleBankCardNo", query.SettleBankCardNo); //结算银行卡号
  521. Obj.Add("BankName", query.SettleBankName); //银行名称
  522. return Obj;
  523. }
  524. #endregion
  525. #region 创客-我的-设置-修改支付密码
  526. [Authorize]
  527. public JsonResult ModifyPayPwd(string value)
  528. {
  529. value = DesDecrypt(value);
  530. JsonData data = JsonMapper.ToObject(value);
  531. AppResultJson result = ModifyPayPwdDo(value);
  532. return Json(new AppResultJson() { Status = result.Status, Info = result.Info, Data = result.Data });
  533. }
  534. public AppResultJson ModifyPayPwdDo(string value)
  535. {
  536. JsonData data = JsonMapper.ToObject(value);
  537. string PayPwd = data["PayPwd"].ToString(); //支付密码
  538. string NewPayPwd = data["NewPayPwd"].ToString(); //新支付密码
  539. Dictionary<string, object> Obj = new Dictionary<string, object>();
  540. int Id = int.Parse(function.CheckInt(data["Id"].ToString()));
  541. Users query = maindb.Users.FirstOrDefault(m => m.Id == Id);
  542. if (query != null)
  543. {
  544. if (query.PayPwd != function.MD532(PayPwd))
  545. {
  546. return new AppResultJson() { Status = "1", Info = "原支付密码不正确,请重试", Data = Obj };
  547. }
  548. query.PayPwd = function.MD532(NewPayPwd); //支付密码
  549. maindb.SaveChanges();
  550. }
  551. return new AppResultJson() { Status = "1", Info = "", Data = Obj };
  552. }
  553. #endregion
  554. #region 创客-我的-设置-修改登录密码
  555. [Authorize]
  556. public JsonResult ModifyLoginPwd(string value)
  557. {
  558. value = DesDecrypt(value);
  559. JsonData data = JsonMapper.ToObject(value);
  560. AppResultJson result = ModifyLoginPwdDo(value);
  561. return Json(new AppResultJson() { Status = result.Status, Info = result.Info, Data = result.Data });
  562. }
  563. public AppResultJson ModifyLoginPwdDo(string value)
  564. {
  565. JsonData data = JsonMapper.ToObject(value);
  566. string LoginPwd = data["LoginPwd"].ToString(); //登录密码
  567. string NewLoginPwd = data["NewLoginPwd"].ToString(); //新登录密码
  568. Dictionary<string, object> Obj = new Dictionary<string, object>();
  569. int Id = int.Parse(function.CheckInt(data["Id"].ToString()));
  570. Users query = maindb.Users.FirstOrDefault(m => m.Id == Id);
  571. if (query != null)
  572. {
  573. if (function.MD532(LoginPwd) != query.LoginPwd)
  574. {
  575. return new AppResultJson() { Status = "-1", Info = "原登录密码不正确,请重试" };
  576. }
  577. query.LoginPwd = function.MD532(NewLoginPwd); //登录密码
  578. maindb.SaveChanges();
  579. }
  580. return new AppResultJson() { Status = "1", Info = "", Data = Obj };
  581. }
  582. #endregion
  583. #region 创客-我的-设置-修改登录手机号
  584. [Authorize]
  585. public JsonResult ModifyMobile(string value)
  586. {
  587. value = DesDecrypt(value);
  588. JsonData data = JsonMapper.ToObject(value);
  589. AppResultJson result = ModifyMobileDo(value);
  590. return Json(new AppResultJson() { Status = result.Status, Info = result.Info, Data = result.Data });
  591. }
  592. public AppResultJson ModifyMobileDo(string value)
  593. {
  594. JsonData data = JsonMapper.ToObject(value);
  595. string Mobile = data["Mobile"].ToString(); //手机号
  596. string MobileCode = data["MobileCode"].ToString(); //短信验证码
  597. int Id = int.Parse(function.CheckInt(data["Id"].ToString()));
  598. if (string.IsNullOrEmpty(data["Mobile"].ToString()))
  599. {
  600. return new AppResultJson() { Status = "-1", Info = "请填写手机号" };
  601. }
  602. if (data["Mobile"].ToString().Length > 11)
  603. {
  604. return new AppResultJson() { Status = "-1", Info = "手机号最多11个字符" };
  605. }
  606. if (function.CheckMobile(data["Mobile"].ToString()) == "")
  607. {
  608. return new AppResultJson() { Status = "-1", Info = "请填写正确的手机号" };
  609. }
  610. UserForMobile userfor = maindb.UserForMobile.FirstOrDefault(m => m.Mobile == Mobile) ?? new UserForMobile();
  611. if (userfor.UserId != Id && userfor.UserId > 0)
  612. {
  613. return new AppResultJson() { Status = "-1", Info = "手机号已被占用,请重新填写" };
  614. }
  615. MobileCodeCheck mobilecheck = RedisDbconn.Instance.Get<MobileCodeCheck>("MobileCodeCheck:" + Mobile);
  616. if (mobilecheck == null)
  617. {
  618. return new AppResultJson() { Status = "-1", Info = "短信验证码不正确" };
  619. }
  620. if (mobilecheck.CheckCode != MobileCode)
  621. {
  622. return new AppResultJson() { Status = "-1", Info = "短信验证码不正确" };
  623. }
  624. RedisDbconn.Instance.Clear("MobileCodeCheck:" + Mobile);
  625. Dictionary<string, object> Obj = new Dictionary<string, object>();
  626. Users query = maindb.Users.FirstOrDefault(m => m.Id == Id);
  627. if (query != null)
  628. {
  629. string oldMobile = query.Mobile;
  630. query.Mobile = Mobile; //手机号
  631. UserForMobile userFor = maindb.UserForMobile.FirstOrDefault(m => m.Mobile == Mobile);
  632. if (userFor == null)
  633. {
  634. userFor = maindb.UserForMobile.Add(new UserForMobile()
  635. {
  636. Mobile = Mobile,
  637. UserId = Id,
  638. }).Entity;
  639. maindb.SaveChanges();
  640. }
  641. UserForMobile oldUserFor = maindb.UserForMobile.FirstOrDefault(m => m.Mobile == oldMobile);
  642. if (oldUserFor != null)
  643. {
  644. maindb.Remove(oldUserFor);
  645. maindb.SaveChanges();
  646. }
  647. }
  648. return new AppResultJson() { Status = "1", Info = "", Data = Obj };
  649. }
  650. #endregion
  651. #region 创客-我的-设置-判断是否设置支付密码
  652. [Authorize]
  653. public JsonResult ExistPayPwd(string value)
  654. {
  655. value = DesDecrypt(value);
  656. JsonData data = JsonMapper.ToObject(value);
  657. int Id = int.Parse(function.CheckInt(data["Id"].ToString()));
  658. Dictionary<string, object> Obj = new Dictionary<string, object>();
  659. Users query = maindb.Users.FirstOrDefault(m => m.Id == Id) ?? new Users();
  660. if (string.IsNullOrEmpty(query.PayPwd))
  661. {
  662. return Json(new AppResultJson() { Status = "-1", Info = "", Data = Obj });
  663. }
  664. return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
  665. }
  666. #endregion
  667. #region 创客-我的-设置-变更结算卡
  668. [Authorize]
  669. public JsonResult ChangeBankCard(string value)
  670. {
  671. value = DesDecrypt(value);
  672. JsonData data = JsonMapper.ToObject(value);
  673. AppResultJson result = ChangeBankCardDo(value);
  674. return Json(new AppResultJson() { Status = result.Status, Info = result.Info, Data = result.Data });
  675. }
  676. public AppResultJson ChangeBankCardDo(string value)
  677. {
  678. JsonData data = JsonMapper.ToObject(value);
  679. string MobileCode = data["MobileCode"].ToString(); //短信验证码
  680. string Mobile = data["Mobile"].ToString();
  681. string BankName = data["BankName"].ToString(); //开户行全称
  682. string SettleBankName = data["SettleBankName"].ToString(); //结算银行名称
  683. string SettleBankCardNo = data["SettleBankCardNo"].ToString(); //结算银行卡号
  684. string BankCardPositiveImage = data["BankCardPositiveImage"].ToString(); //银行卡正面照
  685. MobileCodeCheck mobilecheck = RedisDbconn.Instance.Get<MobileCodeCheck>("MobileCodeCheck:" + Mobile);
  686. int Id = int.Parse(function.CheckInt(data["Id"].ToString()));
  687. if (mobilecheck == null)
  688. {
  689. return new AppResultJson() { Status = "-1", Info = "短信验证码不正确" };
  690. }
  691. if (mobilecheck.CheckCode != MobileCode)
  692. {
  693. return new AppResultJson() { Status = "-1", Info = "短信验证码不正确" };
  694. }
  695. RedisDbconn.Instance.Clear("MobileCodeCheck:" + Mobile);
  696. Dictionary<string, object> Obj = new Dictionary<string, object>();
  697. Users query = maindb.Users.FirstOrDefault(m => m.Id == Id);
  698. if (query != null)
  699. {
  700. query.SeoTitle = BankName;
  701. query.SettleBankName = SettleBankName;
  702. query.SettleBankCardNo = SettleBankCardNo; //结算银行卡号
  703. query.BankCardPositiveImage = BankCardPositiveImage; //银行卡正面照
  704. UserAuthRecord auth = maindb.UserAuthRecord.FirstOrDefault(m => m.UserId == Id);
  705. if (auth != null)
  706. {
  707. auth.BankCardAccount = SettleBankCardNo; //银行卡账号
  708. }
  709. maindb.SaveChanges();
  710. }
  711. return new AppResultJson() { Status = "1", Info = "", Data = Obj };
  712. }
  713. // 提交代付签约
  714. [Authorize]
  715. public JsonResult ChangeBankCardCheck(string value)
  716. {
  717. value = DesDecrypt(value);
  718. JsonData data = JsonMapper.ToObject(value);
  719. string MobileCode = data["MobileCode"].ToString(); //短信验证码
  720. string Mobile = data["Mobile"].ToString();
  721. string BankName = data["BankName"].ToString(); //开户行全称
  722. string SettleBankName = data["SettleBankName"].ToString(); //结算银行名称
  723. string SettleBankCardNo = data["SettleBankCardNo"].ToString(); //结算银行卡号
  724. string BankCardPositiveImage = data["BankCardPositiveImage"].ToString(); //银行卡正面照
  725. MobileCodeCheck mobilecheck = RedisDbconn.Instance.Get<MobileCodeCheck>("MobileCodeCheck:" + Mobile);
  726. int Id = int.Parse(function.CheckInt(data["Id"].ToString()));
  727. if (mobilecheck == null)
  728. {
  729. return Json(new AppResultJson() { Status = "-1", Info = "短信验证码不正确" });
  730. }
  731. if (mobilecheck.CheckCode != MobileCode)
  732. {
  733. return Json(new AppResultJson() { Status = "-1", Info = "短信验证码不正确" });
  734. }
  735. RedisDbconn.Instance.Clear("MobileCodeCheck:" + Mobile);
  736. Dictionary<string, object> Obj = new Dictionary<string, object>();
  737. Users query = maindb.Users.FirstOrDefault(m => m.Id == Id);
  738. if (query != null)
  739. {
  740. query.SeoTitle = BankName;
  741. query.SettleBankName = SettleBankName;
  742. query.SettleBankCardNo = SettleBankCardNo; //结算银行卡号
  743. query.BankCardPositiveImage = BankCardPositiveImage; //银行卡正面照
  744. maindb.SaveChanges();
  745. return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
  746. }
  747. return Json(new AppResultJson() { Status = "-1", Info = "认证失败,请重试", Data = Obj });
  748. }
  749. [Authorize]
  750. public JsonResult ChangeBankCard2(string value)
  751. {
  752. value = DesDecrypt(value);
  753. JsonData data = JsonMapper.ToObject(value);
  754. AppResultJson result = ChangeBankCard2Do(value);
  755. return Json(new AppResultJson() { Status = result.Status, Info = result.Info, Data = result.Data });
  756. }
  757. public AppResultJson ChangeBankCard2Do(string value)
  758. {
  759. JsonData data = JsonMapper.ToObject(value);
  760. int Id = int.Parse(function.CheckInt(data["Id"].ToString()));
  761. string MobileCode = data["MobileCode"].ToString(); //短信验证码
  762. string Mobile = data["Mobile"].ToString();
  763. string BankName = data["BankName"].ToString(); //开户行全称
  764. string SettleBankName = data["SettleBankName"].ToString(); //结算银行名称
  765. string SettleBankCardNo = data["SettleBankCardNo"].ToString(); //结算银行卡号
  766. string BankCardPositiveImage = data["BankCardPositiveImage"].ToString(); //银行卡正面照
  767. MobileCodeCheck mobilecheck = RedisDbconn.Instance.Get<MobileCodeCheck>("MobileCodeCheck:" + Mobile);
  768. if (mobilecheck == null)
  769. {
  770. return new AppResultJson() { Status = "-1", Info = "短信验证码不正确" };
  771. }
  772. if (mobilecheck.CheckCode != MobileCode)
  773. {
  774. return new AppResultJson() { Status = "-1", Info = "短信验证码不正确" };
  775. }
  776. RedisDbconn.Instance.Clear("MobileCodeCheck:" + Mobile);
  777. Dictionary<string, object> Obj = new Dictionary<string, object>();
  778. Users query = maindb.Users.FirstOrDefault(m => m.Id == Id);
  779. if (query != null)
  780. {
  781. query.SeoTitle = BankName;
  782. query.SettleBankName = SettleBankName;
  783. query.SettleBankCardNo = SettleBankCardNo; //结算银行卡号
  784. query.BankCardPositiveImage = BankCardPositiveImage; //银行卡正面照
  785. UserAuthRecord auth = maindb.UserAuthRecord.FirstOrDefault(m => m.UserId == Id);
  786. if (auth != null)
  787. {
  788. auth.BankCardAccount = SettleBankCardNo; //银行卡账号
  789. }
  790. maindb.SaveChanges();
  791. }
  792. return new AppResultJson() { Status = "1", Info = "", Data = Obj };
  793. }
  794. #endregion
  795. #region 创客-我的-设置-安全退出
  796. [Authorize]
  797. public JsonResult Logout(string value)
  798. {
  799. value = DesDecrypt(value);
  800. JsonData data = JsonMapper.ToObject(value);
  801. AppResultJson result = LogoutDo(value);
  802. return Json(new AppResultJson() { Status = result.Status, Info = result.Info, Data = result.Data });
  803. }
  804. public AppResultJson LogoutDo(string value)
  805. {
  806. JsonData data = JsonMapper.ToObject(value);
  807. string UserId = data["UserId"].ToString(); //创客Id
  808. Dictionary<string, object> Obj = new Dictionary<string, object>();
  809. // TODO:退出登录需要处理的逻辑,待定
  810. return new AppResultJson() { Status = "1", Info = "", Data = Obj };
  811. }
  812. #endregion
  813. #region 创客-我的-设置-忘记支付密码验证
  814. [Authorize]
  815. public JsonResult CheckForgetPwd(string value)
  816. {
  817. value = DesDecrypt(value);
  818. JsonData data = JsonMapper.ToObject(value);
  819. AppResultJson result = CheckForgetPwdDo(value);
  820. return Json(new AppResultJson() { Status = result.Status, Info = result.Info, Data = result.Data });
  821. }
  822. public AppResultJson CheckForgetPwdDo(string value)
  823. {
  824. JsonData data = JsonMapper.ToObject(value);
  825. string RealName = data["RealName"].ToString(); //真实姓名
  826. string CertId = data["CertId"].ToString(); //身份证号
  827. string Mobile = data["Mobile"].ToString(); //手机号
  828. string MobileCode = data["MobileCode"].ToString(); //短信验证码
  829. if (string.IsNullOrEmpty(data["Mobile"].ToString()))
  830. {
  831. return new AppResultJson() { Status = "-1", Info = "请填写手机号" };
  832. }
  833. if (data["Mobile"].ToString().Length > 11)
  834. {
  835. return new AppResultJson() { Status = "-1", Info = "手机号最多11个字符" };
  836. }
  837. if (function.CheckMobile(data["Mobile"].ToString()) == "")
  838. {
  839. return new AppResultJson() { Status = "-1", Info = "请填写正确的手机号" };
  840. }
  841. MobileCodeCheck mobilecheck = RedisDbconn.Instance.Get<MobileCodeCheck>("MobileCodeCheck:" + Mobile);
  842. if (mobilecheck == null)
  843. {
  844. return new AppResultJson() { Status = "-1", Info = "短信验证码不正确" };
  845. }
  846. if (mobilecheck.CheckCode != MobileCode)
  847. {
  848. return new AppResultJson() { Status = "-1", Info = "短信验证码不正确" };
  849. }
  850. RedisDbconn.Instance.Clear("MobileCodeCheck:" + Mobile);
  851. Dictionary<string, object> Obj = new Dictionary<string, object>();
  852. // TODO:验证接口,待定
  853. return new AppResultJson() { Status = "1", Info = "", Data = Obj };
  854. }
  855. #endregion
  856. #region 创客-我的-设置-提交实名认证资料
  857. [Authorize]
  858. public JsonResult PostAuth(string value)
  859. {
  860. value = DesDecrypt(value);
  861. JsonData data = JsonMapper.ToObject(value);
  862. AppResultJson result = PostAuthDo(value);
  863. return Json(new AppResultJson() { Status = result.Status, Info = result.Info, Data = result.Data });
  864. }
  865. public AppResultJson PostAuthDo(string value)
  866. {
  867. JsonData data = JsonMapper.ToObject(value);
  868. int Id = int.Parse(function.CheckInt(data["Id"].ToString()));
  869. string RealName = data["RealName"].ToString(); //真实姓名
  870. string CertId = data["CertId"].ToString(); //身份证号
  871. string Areas = data["Areas"].ToString(); //所在地区
  872. string Mobile = data["Mobile"].ToString(); //手机号
  873. string BankName = data["BankName"].ToString(); //开户行全称
  874. string SettleBankName = data["SettleBankName"].ToString(); //结算银行名称
  875. string SettleBankCardNo = data["SettleBankCardNo"].ToString(); //结算银行卡号
  876. string CertFrontImage = data["CertFrontImage"].ToString(); //身份证正面照
  877. string CertReverseImage = data["CertReverseImage"].ToString(); //身份证反面照
  878. string HandCertImage = data["HandCertImage"].ToString(); //手持身份证
  879. string BankCardPositiveImage = data["BankCardPositiveImage"].ToString(); //银行卡正面照
  880. string BankMobile = data["BankMobile"].ToString(); //银行预留手机号
  881. string Distribute = "";
  882. if (value.Contains("\"Distribute\""))
  883. {
  884. Distribute = data["Distribute"].ToString();
  885. }
  886. if (string.IsNullOrEmpty(data["BankMobile"].ToString()))
  887. {
  888. return new AppResultJson() { Status = "-1", Info = "请填写手机号" };
  889. }
  890. if (data["BankMobile"].ToString().Length > 11)
  891. {
  892. return new AppResultJson() { Status = "-1", Info = "手机号最多11个字符" };
  893. }
  894. if (function.CheckMobile(data["BankMobile"].ToString()) == "")
  895. {
  896. return new AppResultJson() { Status = "-1", Info = "请填写正确的手机号" };
  897. }
  898. Dictionary<string, object> Obj = new Dictionary<string, object>();
  899. bool checkCertId = maindb.Users.Any(m => m.CertId == CertId);
  900. if (checkCertId)
  901. {
  902. return new AppResultJson() { Status = "-1", Info = "您输入的身份证号已经认证过了,请更换身份证" };
  903. }
  904. Users query = maindb.Users.FirstOrDefault(m => m.Id == Id);
  905. if (query != null)
  906. {
  907. string result = BankCardCheckForThree.Instance.Do(SettleBankCardNo, CertId, RealName);
  908. JsonData jsonObj = JsonMapper.ToObject(result);
  909. if (jsonObj["code"].ToString() == "200")
  910. {
  911. if (jsonObj["data"]["result"].ToString() == "0")
  912. {
  913. query.AuthFlag = 1;
  914. query.AuthDate = DateTime.Now;
  915. query.RealName = RealName; //真实姓名
  916. query.CertId = CertId; //身份证号
  917. query.Areas = Areas; //所在地区
  918. query.SeoTitle = BankName;
  919. query.SettleBankCardNo = SettleBankCardNo; //结算银行卡号
  920. query.SettleBankName = SettleBankName; //结算银行名称
  921. query.CertFrontImage = CertFrontImage; //身份证正面照
  922. query.CertReverseImage = CertReverseImage; //身份证反面照
  923. query.HandCertImage = HandCertImage; //手持身份证
  924. query.BankCardPositiveImage = BankCardPositiveImage; //银行卡正面照
  925. maindb.SaveChanges();
  926. UserAuthRecord auth = maindb.UserAuthRecord.Add(new UserAuthRecord()
  927. {
  928. CreateDate = DateTime.Now,
  929. UserId = Id, //创客
  930. RealName = RealName, //真实姓名
  931. IdcardNo = CertId, //身份证号码
  932. BankCardAccount = SettleBankCardNo, //银行卡账号
  933. BankMobile = BankMobile, //银行预留手机号码
  934. }).Entity;
  935. maindb.SaveChanges();
  936. //实名认证成功后消息推送
  937. Users users = maindb.Users.FirstOrDefault(m => m.Id == query.ParentUserId);
  938. RedisDbconn.Instance.AddList("MsgPersonalQueue", Newtonsoft.Json.JsonConvert.SerializeObject(new MsgPersonal()
  939. {
  940. UserId = users.Id, //创客Id
  941. MsgType = 2,
  942. Title = "来新人啦", //标题
  943. Summary = "您的码牌系统有新人加入了,请进入码牌-我的创客中查看!",//简介
  944. CreateDate = DateTime.Now,
  945. }));
  946. return new AppResultJson() { Status = "1", Info = "", Data = Obj };
  947. }
  948. else
  949. {
  950. return new AppResultJson() { Status = "-1", Info = jsonObj["data"]["desc"].ToString() };
  951. }
  952. }
  953. else
  954. {
  955. return new AppResultJson() { Status = "-1", Info = jsonObj["msg"].ToString() };
  956. }
  957. }
  958. return new AppResultJson() { Status = "-1", Info = "认证失败,请重试" };
  959. }
  960. [Authorize]
  961. public JsonResult PostAuth2(string value, string CertFrontBase64, string CertReverseBase64)
  962. {
  963. value = DesDecrypt(value);
  964. JsonData data = JsonMapper.ToObject(value);
  965. AppResultJson result = PostAuth2Do(value, CertFrontBase64, CertReverseBase64);
  966. return Json(new AppResultJson() { Status = result.Status, Info = result.Info, Data = result.Data });
  967. }
  968. public AppResultJson PostAuth2Do(string value, string CertFrontBase64, string CertReverseBase64)
  969. {
  970. JsonData data = JsonMapper.ToObject(value);
  971. int Id = int.Parse(function.CheckInt(data["Id"].ToString()));
  972. string RealName = data["RealName"].ToString(); //真实姓名
  973. string CertId = data["CertId"].ToString(); //身份证号
  974. string Areas = data["Areas"].ToString(); //所在地区
  975. string Mobile = data["Mobile"].ToString(); //手机号
  976. string BankName = data["BankName"].ToString(); //开户行全称
  977. string SettleBankName = data["SettleBankName"].ToString(); //结算银行名称
  978. string SettleBankCardNo = data["SettleBankCardNo"].ToString(); //结算银行卡号
  979. string CertFrontImage = data["CertFrontImage"].ToString(); //身份证正面照
  980. string CertReverseImage = data["CertReverseImage"].ToString(); //身份证反面照
  981. // string CertFrontBase64 = data["CertFrontBase64"].ToString(); //身份证正面照
  982. // string CertReverseBase64 = data["CertReverseBase64"].ToString(); //身份证反面照
  983. string HandCertImage = data["HandCertImage"].ToString(); //手持身份证
  984. string BankCardPositiveImage = data["BankCardPositiveImage"].ToString(); //银行卡正面照
  985. string BankMobile = data["BankMobile"].ToString(); //银行预留手机号
  986. string Distribute = "";
  987. if (value.Contains("\"Distribute\""))
  988. {
  989. Distribute = data["Distribute"].ToString();
  990. }
  991. if (string.IsNullOrEmpty(data["BankMobile"].ToString()))
  992. {
  993. return new AppResultJson() { Status = "-1", Info = "请填写手机号" };
  994. }
  995. if (data["BankMobile"].ToString().Length > 11)
  996. {
  997. return new AppResultJson() { Status = "-1", Info = "手机号最多11个字符" };
  998. }
  999. if (function.CheckMobile(data["BankMobile"].ToString()) == "")
  1000. {
  1001. return new AppResultJson() { Status = "-1", Info = "请填写正确的手机号" };
  1002. }
  1003. Dictionary<string, object> Obj = new Dictionary<string, object>();
  1004. bool checkCertId = maindb.Users.Any(m => m.CertId == CertId);
  1005. if (checkCertId)
  1006. {
  1007. return new AppResultJson() { Status = "-1", Info = "您输入的身份证号已经认证过了,请更换身份证" };
  1008. }
  1009. Users query = maindb.Users.FirstOrDefault(m => m.Id == Id);
  1010. if (query != null)
  1011. {
  1012. string result = BankCardCheckForThree.Instance.Do(SettleBankCardNo, CertId, RealName);
  1013. JsonData jsonObj = JsonMapper.ToObject(result);
  1014. if (jsonObj["code"].ToString() == "200")
  1015. {
  1016. if (jsonObj["data"]["result"].ToString() == "0")
  1017. {
  1018. query.AuthFlag = 1;
  1019. query.AuthDate = DateTime.Now;
  1020. query.RealName = RealName; //真实姓名
  1021. query.CertId = CertId; //身份证号
  1022. query.Areas = Areas; //所在地区
  1023. query.SeoTitle = BankName;
  1024. query.SettleBankCardNo = SettleBankCardNo; //结算银行卡号
  1025. query.SettleBankName = SettleBankName; //结算银行名称
  1026. query.CertFrontImage = CertFrontImage; //身份证正面照
  1027. query.CertReverseImage = CertReverseImage; //身份证反面照
  1028. query.HandCertImage = HandCertImage; //手持身份证
  1029. query.BankCardPositiveImage = BankCardPositiveImage; //银行卡正面照
  1030. maindb.SaveChanges();
  1031. UserAuthRecord auth = maindb.UserAuthRecord.Add(new UserAuthRecord()
  1032. {
  1033. CreateDate = DateTime.Now,
  1034. UserId = Id, //创客
  1035. RealName = RealName, //真实姓名
  1036. IdcardNo = CertId, //身份证号码
  1037. BankCardAccount = SettleBankCardNo, //银行卡账号
  1038. BankMobile = BankMobile, //银行预留手机号码
  1039. }).Entity;
  1040. maindb.SaveChanges();
  1041. //实名认证成功后消息推送
  1042. Users users = maindb.Users.FirstOrDefault(m => m.Id == query.ParentUserId);
  1043. RedisDbconn.Instance.AddList("MsgPersonalQueue", Newtonsoft.Json.JsonConvert.SerializeObject(new MsgPersonal()
  1044. {
  1045. UserId = users.Id, //创客Id
  1046. MsgType = 2,
  1047. Title = "来新人啦", //标题
  1048. Summary = "您的码牌系统有新人加入了,请进入码牌-我的创客中查看!",//简介
  1049. CreateDate = DateTime.Now,
  1050. }));
  1051. return new AppResultJson() { Status = "1", Info = "", Data = Obj };
  1052. }
  1053. else
  1054. {
  1055. return new AppResultJson() { Status = "-1", Info = jsonObj["data"]["desc"].ToString() };
  1056. }
  1057. }
  1058. else
  1059. {
  1060. return new AppResultJson() { Status = "-1", Info = jsonObj["msg"].ToString() };
  1061. }
  1062. }
  1063. return new AppResultJson() { Status = "-1", Info = "认证失败,请重试" };
  1064. }
  1065. #endregion
  1066. #region 创客-我的-提现实名认证资料
  1067. [Authorize]
  1068. public JsonResult CashAuth(string value)
  1069. {
  1070. value = DesDecrypt(value);
  1071. JsonData data = JsonMapper.ToObject(value);
  1072. AppResultJson result = CashAuthDo(value);
  1073. return Json(new AppResultJson() { Status = result.Status, Info = result.Info, Data = result.Data });
  1074. }
  1075. public AppResultJson CashAuthDo(string value)
  1076. {
  1077. JsonData data = JsonMapper.ToObject(value);
  1078. int Id = int.Parse(function.CheckInt(data["Id"].ToString()));
  1079. string CertFrontImage = data["CertFrontImage"].ToString(); //身份证正面照
  1080. string CertReverseImage = data["CertReverseImage"].ToString(); //身份证反面照
  1081. // string BankName = data["BankName"].ToString(); //开户行全称
  1082. string SettleBankName = data["SettleBankName"].ToString(); //结算银行名称
  1083. string SettleBankCardNo = data["SettleBankCardNo"].ToString(); //结算银行卡号
  1084. string BankMobile = data["BankMobile"].ToString(); //银行预留手机号
  1085. if (string.IsNullOrEmpty(data["BankMobile"].ToString()))
  1086. {
  1087. return new AppResultJson() { Status = "-1", Info = "请填写手机号" };
  1088. }
  1089. if (data["BankMobile"].ToString().Length > 11)
  1090. {
  1091. return new AppResultJson() { Status = "-1", Info = "手机号最多11个字符" };
  1092. }
  1093. if (function.CheckMobile(data["BankMobile"].ToString()) == "")
  1094. {
  1095. return new AppResultJson() { Status = "-1", Info = "请填写正确的手机号" };
  1096. }
  1097. Dictionary<string, object> Obj = new Dictionary<string, object>();
  1098. string check = RedisDbconn.Instance.Get<string>("CashAuth:" + Id);
  1099. if (!string.IsNullOrEmpty(check))
  1100. {
  1101. return new AppResultJson() { Status = "-1", Info = "资料审核中, 请稍后再试" };
  1102. }
  1103. RedisDbconn.Instance.Set("CashAuth:" + Id, "1");
  1104. RedisDbconn.Instance.SetExpire("CashAuth:" + Id, 300);
  1105. Users query = maindb.Users.FirstOrDefault(m => m.Id == Id);
  1106. if (query != null)
  1107. {
  1108. query.SettleBankCardNo = SettleBankCardNo; //结算银行卡号
  1109. query.SettleBankName = SettleBankName; //结算银行名称
  1110. query.CertFrontImage = CertFrontImage; //身份证正面照
  1111. query.CertReverseImage = CertReverseImage; //身份证反面照
  1112. UserAuthRecord auth = maindb.UserAuthRecord.FirstOrDefault(m => m.UserId == Id);
  1113. if (auth != null)
  1114. {
  1115. auth.BankCardAccount = SettleBankCardNo; //银行卡账号
  1116. auth.BankMobile = BankMobile; //银行预留手机号码
  1117. }
  1118. maindb.SaveChanges();
  1119. return new AppResultJson() { Status = "1", Info = "", Data = Obj };
  1120. }
  1121. return new AppResultJson() { Status = "-1", Info = "认证失败,请重试" };
  1122. }
  1123. [Authorize]
  1124. public JsonResult CashAuth2(string value, string CertFrontBase64, string CertReverseBase64)
  1125. {
  1126. value = DesDecrypt(value);
  1127. JsonData data = JsonMapper.ToObject(value);
  1128. AppResultJson result = CashAuth2Do(value, CertFrontBase64, CertReverseBase64);
  1129. return Json(new AppResultJson() { Status = result.Status, Info = result.Info, Data = result.Data });
  1130. }
  1131. public AppResultJson CashAuth2Do(string value, string CertFrontBase64, string CertReverseBase64)
  1132. {
  1133. JsonData data = JsonMapper.ToObject(value);
  1134. int Id = int.Parse(function.CheckInt(data["Id"].ToString()));
  1135. string CertFrontImage = data["CertFrontImage"].ToString(); //身份证正面照
  1136. string CertReverseImage = data["CertReverseImage"].ToString(); //身份证反面照
  1137. // string CertFrontBase64 = data["CertFrontBase64"].ToString(); //身份证正面照
  1138. // string CertReverseBase64 = data["CertReverseBase64"].ToString(); //身份证反面照
  1139. // string BankName = data["BankName"].ToString(); //开户行全称
  1140. string SettleBankName = data["SettleBankName"].ToString(); //结算银行名称
  1141. string SettleBankCardNo = data["SettleBankCardNo"].ToString(); //结算银行卡号
  1142. string BankMobile = data["BankMobile"].ToString(); //银行预留手机号
  1143. if (string.IsNullOrEmpty(data["BankMobile"].ToString()))
  1144. {
  1145. return new AppResultJson() { Status = "-1", Info = "请填写手机号" };
  1146. }
  1147. if (data["BankMobile"].ToString().Length > 11)
  1148. {
  1149. return new AppResultJson() { Status = "-1", Info = "手机号最多11个字符" };
  1150. }
  1151. if (function.CheckMobile(data["BankMobile"].ToString()) == "")
  1152. {
  1153. return new AppResultJson() { Status = "-1", Info = "请填写正确的手机号" };
  1154. }
  1155. Dictionary<string, object> Obj = new Dictionary<string, object>();
  1156. string check = RedisDbconn.Instance.Get<string>("CashAuth:" + Id);
  1157. if (!string.IsNullOrEmpty(check))
  1158. {
  1159. return new AppResultJson() { Status = "-1", Info = "资料审核中, 请稍后再试" };
  1160. }
  1161. RedisDbconn.Instance.Set("CashAuth:" + Id, "1", 600);
  1162. Users query = maindb.Users.FirstOrDefault(m => m.Id == Id);
  1163. if (query != null)
  1164. {
  1165. query.SettleBankCardNo = SettleBankCardNo; //结算银行卡号
  1166. query.SettleBankName = SettleBankName; //结算银行名称
  1167. query.CertFrontImage = CertFrontImage; //身份证正面照
  1168. query.CertReverseImage = CertReverseImage; //身份证反面照
  1169. UserAuthRecord auth = maindb.UserAuthRecord.FirstOrDefault(m => m.UserId == Id);
  1170. if (auth != null)
  1171. {
  1172. auth.BankCardAccount = SettleBankCardNo; //银行卡账号
  1173. auth.BankMobile = BankMobile; //银行预留手机号码
  1174. }
  1175. maindb.SaveChanges();
  1176. return new AppResultJson() { Status = "1", Info = "", Data = Obj };
  1177. }
  1178. return new AppResultJson() { Status = "-1", Info = "认证失败,请重试" };
  1179. }
  1180. #endregion
  1181. #region 创客-我的-获取提现认证失败原因
  1182. [Authorize]
  1183. public JsonResult CashAuthFailInfo(string value)
  1184. {
  1185. value = DesDecrypt(value);
  1186. JsonData data = JsonMapper.ToObject(value);
  1187. Dictionary<string, object> Obj = new Dictionary<string, object>();
  1188. int Id = int.Parse(function.CheckInt(data["Id"].ToString()));
  1189. Users query = UsersDbconn.Instance.Get(Id) ?? new Users();
  1190. string Remark = function.CheckNull(query.Remark);
  1191. if (Remark.StartsWith("代付失败原因:"))
  1192. {
  1193. return Json(new AppResultJson() { Status = "-1", Info = Remark.Replace("代付失败原因:", "") });
  1194. }
  1195. return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
  1196. }
  1197. #endregion
  1198. #region 创客-我的-设置-提交忘记支付密码
  1199. [Authorize]
  1200. public JsonResult ForgetPayPwd(string value)
  1201. {
  1202. value = DesDecrypt(value);
  1203. JsonData data = JsonMapper.ToObject(value);
  1204. AppResultJson result = ForgetPayPwdDo(value);
  1205. return Json(new AppResultJson() { Status = result.Status, Info = result.Info, Data = result.Data });
  1206. }
  1207. public AppResultJson ForgetPayPwdDo(string value)
  1208. {
  1209. JsonData data = JsonMapper.ToObject(value);
  1210. string PayPwd = data["PayPwd"].ToString(); //支付密码
  1211. Dictionary<string, object> Obj = new Dictionary<string, object>();
  1212. Users query = new Users();
  1213. int Id = int.Parse(function.CheckInt(data["Id"].ToString()));
  1214. query = maindb.Users.FirstOrDefault(m => m.Id == Id);
  1215. if (query != null)
  1216. {
  1217. query.PayPwd = function.MD532(PayPwd); //支付密码
  1218. maindb.SaveChanges();
  1219. }
  1220. return new AppResultJson() { Status = "1", Info = "", Data = Obj };
  1221. }
  1222. #endregion
  1223. #region 创客-我的-设置-设置支付密码
  1224. [Authorize]
  1225. public JsonResult SetPayPwd(string value)
  1226. {
  1227. value = DesDecrypt(value);
  1228. JsonData data = JsonMapper.ToObject(value);
  1229. AppResultJson result = SetPayPwdDo(value);
  1230. return Json(new AppResultJson() { Status = result.Status, Info = result.Info, Data = result.Data });
  1231. }
  1232. public AppResultJson SetPayPwdDo(string value)
  1233. {
  1234. JsonData data = JsonMapper.ToObject(value);
  1235. string PayPwd = data["PayPwd"].ToString(); //支付密码
  1236. Dictionary<string, object> Obj = new Dictionary<string, object>();
  1237. int Id = int.Parse(function.CheckInt(data["Id"].ToString()));
  1238. Users query = maindb.Users.FirstOrDefault(m => m.Id == Id);
  1239. if (query != null)
  1240. {
  1241. query.UpdateDate = DateTime.Now; //修改时间
  1242. query.PayPwd = function.MD532(PayPwd); //支付密码\
  1243. maindb.SaveChanges();
  1244. }
  1245. return new AppResultJson() { Status = "1", Info = "", Data = Obj };
  1246. }
  1247. #endregion
  1248. #region 创客-我的-设置-验证原支付密码
  1249. [Authorize]
  1250. public JsonResult CheckPayPwd(string value)
  1251. {
  1252. value = DesDecrypt(value);
  1253. JsonData data = JsonMapper.ToObject(value);
  1254. string PayPwd = data["PayPwd"].ToString(); //支付密码
  1255. Dictionary<string, object> Obj = new Dictionary<string, object>();
  1256. int Id = int.Parse(function.CheckInt(data["Id"].ToString()));
  1257. Users query = maindb.Users.FirstOrDefault(m => m.Id == Id) ?? new Users();
  1258. if (string.IsNullOrEmpty(query.PayPwd))
  1259. {
  1260. return Json(new AppResultJson() { Status = "-1", Info = "请设置支付密码" });
  1261. }
  1262. if (query.PayPwd != function.MD532(PayPwd))
  1263. {
  1264. return Json(new AppResultJson() { Status = "-1", Info = "原支付密码不正确" });
  1265. }
  1266. return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
  1267. }
  1268. #endregion
  1269. #region 创客-我的-设置-验证登录密码
  1270. [Authorize]
  1271. public JsonResult CheckLoginPwd(string value)
  1272. {
  1273. value = DesDecrypt(value);
  1274. JsonData data = JsonMapper.ToObject(value);
  1275. string LoginPwd = data["LoginPwd"].ToString(); //支付密码
  1276. Dictionary<string, object> Obj = new Dictionary<string, object>();
  1277. Users query = new Users();
  1278. int Id = int.Parse(function.CheckInt(data["Id"].ToString()));
  1279. query = UsersDbconn.Instance.Get(Id) ?? new Users();
  1280. if (query.LoginPwd != function.MD532(LoginPwd))
  1281. {
  1282. return Json(new AppResultJson() { Status = "-1", Info = "登录密码不正确" });
  1283. }
  1284. return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
  1285. }
  1286. #endregion
  1287. #region 我的-设置-获取实名认证四要素
  1288. [Authorize]
  1289. public JsonResult AuthInfo(string value)
  1290. {
  1291. value = DesDecrypt(value);
  1292. JsonData data = JsonMapper.ToObject(value);
  1293. Dictionary<string, object> Obj = AuthInfoDo(value);
  1294. return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
  1295. }
  1296. public Dictionary<string, object> AuthInfoDo(string value)
  1297. {
  1298. JsonData data = JsonMapper.ToObject(value);
  1299. Dictionary<string, object> Obj = new Dictionary<string, object>();
  1300. int Id = int.Parse(function.CheckInt(data["Id"].ToString()));
  1301. Users query = UsersDbconn.Instance.Get(Id) ?? new Users();
  1302. Obj.Add("RealName", DefaultRealName(query)); //真实姓名
  1303. Obj.Add("CertId", query.CertId); //身份证号
  1304. Obj.Add("Mobile", query.Mobile); //手机号
  1305. Obj.Add("SettleBankCardNo", query.SettleBankCardNo); //结算银行卡号
  1306. Obj.Add("SettleBankName", query.SettleBankName); //结算银行卡名称
  1307. Obj.Add("BankName", query.SeoTitle); //开户行全称
  1308. return Obj;
  1309. }
  1310. #endregion
  1311. #region 创客-首页-交易分析-个人业绩-趋势图
  1312. [Authorize]
  1313. public JsonResult PersonalPerformanceTrend(string value)
  1314. {
  1315. value = DesDecrypt(value);
  1316. JsonData data = JsonMapper.ToObject(value);
  1317. Dictionary<string, object> Obj = PersonalPerformanceTrendDo(value);
  1318. return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
  1319. }
  1320. public Dictionary<string, object> PersonalPerformanceTrendDo(string value)
  1321. {
  1322. JsonData data = JsonMapper.ToObject(value);
  1323. string UserId = data["UserId"].ToString(); //创客Id
  1324. string Kind = data["Kind"].ToString(); //查询类别
  1325. Dictionary<string, object> Obj = new Dictionary<string, object>();
  1326. //总交易趋势数据
  1327. List<Dictionary<string, object>> MainTradeList = new List<Dictionary<string, object>>();
  1328. if (Kind == "1")
  1329. {
  1330. for (int i = 7; i >= 1; i--)
  1331. {
  1332. DateTime Date = DateTime.Now.AddDays(-i);
  1333. var date = Date.ToString("yyyyMMdd");
  1334. decimal HelpAmount = 0;
  1335. DataTable dt = OtherMySqlConn.dtable("SELECT SUM(TradeAmount) TradeAmount FROM HelpProfitMerTradeSummay WHERE MerchantId IN(SELECT MerchantId FROM HelpProfitMerIds WHERE UserId=" + UserId + ") AND TradeDate=" + date + "");
  1336. foreach (DataRow items in dt.Rows)
  1337. {
  1338. HelpAmount = decimal.Parse(function.CheckNum(items["TradeAmount"].ToString()));
  1339. }
  1340. var amount = UserTradeDaySummaryDbconn.Instance.GetDateTrade(int.Parse(UserId), Date.ToString("yyyyMMdd"));
  1341. var total = amount + HelpAmount;
  1342. Dictionary<string, object> item = new Dictionary<string, object>();
  1343. item.Add("Time", Date.ToString("MMdd")); //日期/月份
  1344. item.Add("TradeAmt", UserTradeDaySummaryDbconn.Instance.GetDateTrade(int.Parse(UserId), Date.ToString("yyyyMMdd"))); //交易额
  1345. MainTradeList.Add(item);
  1346. }
  1347. }
  1348. else
  1349. {
  1350. for (int i = 6; i >= 1; i--)
  1351. {
  1352. DateTime Month = DateTime.Now.AddMonths(-i);
  1353. var month = Month.ToString("yyyyMM");
  1354. decimal HelpAmount = 0;
  1355. DataTable dt = OtherMySqlConn.dtable("SELECT SUM(TradeAmount) TradeAmount FROM HelpProfitMerTradeSummay WHERE MerchantId IN(SELECT MerchantId FROM HelpProfitMerIds WHERE UserId=" + UserId + ") AND TradeMonth=" + month + "");
  1356. foreach (DataRow items in dt.Rows)
  1357. {
  1358. HelpAmount = decimal.Parse(function.CheckNum(items["TradeAmount"].ToString()));
  1359. }
  1360. var amount = UserTradeDaySummaryDbconn.Instance.GetMonthTrade(int.Parse(UserId), Month.ToString("yyyyMM"));
  1361. var total = amount + HelpAmount;
  1362. Dictionary<string, object> item = new Dictionary<string, object>();
  1363. item.Add("Time", Month.ToString("yyyyMM")); //日期/月份
  1364. item.Add("TradeAmt", total); //交易额
  1365. MainTradeList.Add(item);
  1366. }
  1367. }
  1368. Obj.Add("MainTrade", MainTradeList);
  1369. //新增创客总数趋势数据
  1370. List<Dictionary<string, object>> AddMakerList = new List<Dictionary<string, object>>();
  1371. if (Kind == "1")
  1372. {
  1373. for (int i = 7; i >= 1; i--)
  1374. {
  1375. DateTime Date = DateTime.Now.AddDays(-i);
  1376. Dictionary<string, object> item = new Dictionary<string, object>();
  1377. item.Add("Time", Date.ToString("MMdd")); //日期/月份
  1378. item.Add("Count", UsersDbconn.Instance.GetNewUserCount(int.Parse(UserId), Date.ToString("yyyyMMdd"))); //交易额
  1379. AddMakerList.Add(item);
  1380. }
  1381. }
  1382. else
  1383. {
  1384. for (int i = 6; i >= 1; i--)
  1385. {
  1386. DateTime Month = DateTime.Now.AddMonths(-i);
  1387. Dictionary<string, object> item = new Dictionary<string, object>();
  1388. item.Add("Time", Month.ToString("yyyyMM")); //日期/月份
  1389. item.Add("Count", UsersDbconn.Instance.GetNewUserCount(int.Parse(UserId), Month.ToString("yyyyMM"))); //交易额
  1390. AddMakerList.Add(item);
  1391. }
  1392. }
  1393. Obj.Add("AddMaker", AddMakerList);
  1394. //新增激活商户总数趋势数据
  1395. List<Dictionary<string, object>> AddActMerchantList = new List<Dictionary<string, object>>();
  1396. for (int i = 7; i >= 1; i--)
  1397. {
  1398. Dictionary<string, object> item = new Dictionary<string, object>();
  1399. if (Kind == "1")
  1400. {
  1401. DateTime time = DateTime.Now.AddDays(-i);
  1402. string Date = time.ToString("MMdd");
  1403. item.Add("Time", Date); //日期/月份
  1404. item.Add("Count", UserDataDbconn.Instance.GetPosActCount(int.Parse(UserId), time.ToString("yyyyMMdd"))); //数量
  1405. }
  1406. else
  1407. {
  1408. string Month = DateTime.Now.AddMonths(-i).ToString("yyyyMM");
  1409. item.Add("Time", Month); //日期/月份
  1410. item.Add("Count", UserDataDbconn.Instance.GetPosActCount(int.Parse(UserId), Month)); //数量
  1411. }
  1412. AddActMerchantList.Add(item);
  1413. }
  1414. Obj.Add("AddActMerchant", AddActMerchantList);
  1415. return Obj;
  1416. }
  1417. #endregion
  1418. #region 创客-首页-交易分析-团队业绩-趋势图
  1419. [Authorize]
  1420. public JsonResult TeamPerformanceTrend(string value)
  1421. {
  1422. value = DesDecrypt(value);
  1423. JsonData data = JsonMapper.ToObject(value);
  1424. Dictionary<string, object> Obj = TeamPerformanceTrendDo(value);
  1425. return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
  1426. }
  1427. public Dictionary<string, object> TeamPerformanceTrendDo(string value)
  1428. {
  1429. JsonData data = JsonMapper.ToObject(value);
  1430. string UserId = data["UserId"].ToString(); //创客Id
  1431. string Kind = data["Kind"].ToString(); //查询类别
  1432. Dictionary<string, object> Obj = new Dictionary<string, object>();
  1433. //总交易趋势数据
  1434. List<Dictionary<string, object>> MainTradeList = new List<Dictionary<string, object>>();
  1435. if (Kind == "1")
  1436. {
  1437. for (int i = 7; i >= 1; i--)
  1438. {
  1439. DateTime Date = DateTime.Now.AddDays(-i);
  1440. var date = Date.ToString("yyyyMMdd");
  1441. decimal HelpAmount = 0;
  1442. 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 + "");
  1443. foreach (DataRow items in dt.Rows)
  1444. {
  1445. HelpAmount = decimal.Parse(function.CheckNum(items["TradeAmount"].ToString()));
  1446. }
  1447. var amount = UserTradeDaySummaryDbconn.Instance.GetDateTrade(int.Parse(UserId), Date.ToString("yyyyMMdd"), "team");
  1448. var total = amount + HelpAmount;
  1449. Dictionary<string, object> item = new Dictionary<string, object>();
  1450. item.Add("Time", Date.ToString("MMdd")); //日期/月份
  1451. item.Add("TradeAmt", total); //交易额
  1452. MainTradeList.Add(item);
  1453. }
  1454. }
  1455. else
  1456. {
  1457. for (int i = 6; i >= 1; i--)
  1458. {
  1459. DateTime Month = DateTime.Now.AddMonths(-i);
  1460. var month = Month.ToString("yyyyMM");
  1461. decimal HelpAmount = 0;
  1462. 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 + "");
  1463. foreach (DataRow items in dt.Rows)
  1464. {
  1465. HelpAmount = decimal.Parse(function.CheckNum(items["TradeAmount"].ToString()));
  1466. }
  1467. var amount = UserTradeDaySummaryDbconn.Instance.GetMonthTrade(int.Parse(UserId), Month.ToString("yyyyMM"), "team");
  1468. var total = amount + HelpAmount;
  1469. Dictionary<string, object> item = new Dictionary<string, object>();
  1470. item.Add("Time", Month.ToString("yyyyMM")); //日期/月份
  1471. item.Add("TradeAmt", total); //交易额
  1472. MainTradeList.Add(item);
  1473. }
  1474. }
  1475. Obj.Add("MainTrade", MainTradeList);
  1476. //新增创客总数趋势数据
  1477. List<Dictionary<string, object>> AddMakerList = new List<Dictionary<string, object>>();
  1478. if (Kind == "1")
  1479. {
  1480. for (int i = 7; i >= 1; i--)
  1481. {
  1482. DateTime Date = DateTime.Now.AddDays(-i);
  1483. Dictionary<string, object> item = new Dictionary<string, object>();
  1484. item.Add("Time", Date.ToString("MMdd")); //日期/月份
  1485. item.Add("Count", UsersDbconn.Instance.GetTeamNewUserCount(int.Parse(UserId), Date.ToString("yyyyMMdd"))); //交易额
  1486. AddMakerList.Add(item);
  1487. }
  1488. }
  1489. else
  1490. {
  1491. for (int i = 6; i >= 1; i--)
  1492. {
  1493. DateTime Month = DateTime.Now.AddMonths(-i);
  1494. Dictionary<string, object> item = new Dictionary<string, object>();
  1495. item.Add("Time", Month.ToString("yyyyMM")); //日期/月份
  1496. item.Add("Count", UsersDbconn.Instance.GetTeamNewUserCount(int.Parse(UserId), Month.ToString("yyyyMM"))); //交易额
  1497. AddMakerList.Add(item);
  1498. }
  1499. }
  1500. Obj.Add("AddMaker", AddMakerList);
  1501. //新增激活商户总数趋势数据
  1502. List<Dictionary<string, object>> AddActMerchantList = new List<Dictionary<string, object>>();
  1503. if (Kind == "1")
  1504. {
  1505. for (int i = 7; i >= 1; i--)
  1506. {
  1507. Dictionary<string, object> item = new Dictionary<string, object>();
  1508. DateTime time = DateTime.Now.AddDays(-i);
  1509. string Date = time.ToString("MMdd");
  1510. item.Add("Time", Date); //日期/月份
  1511. item.Add("Count", UserDataDbconn.Instance.GetTeamPosActCount(int.Parse(UserId), time.ToString("yyyyMMdd"))); //数量
  1512. AddActMerchantList.Add(item);
  1513. }
  1514. }
  1515. else
  1516. {
  1517. for (int i = 6; i >= 1; i--)
  1518. {
  1519. Dictionary<string, object> item = new Dictionary<string, object>();
  1520. string Month = DateTime.Now.AddMonths(-i).ToString("yyyyMM");
  1521. item.Add("Time", Month); //日期/月份
  1522. item.Add("Count", UserDataDbconn.Instance.GetTeamPosActCount(int.Parse(UserId), Month)); //数量
  1523. AddActMerchantList.Add(item);
  1524. }
  1525. }
  1526. Obj.Add("AddActMerchant", AddActMerchantList);
  1527. return Obj;
  1528. }
  1529. #endregion
  1530. #region 创客-首页-我的创客-主界面创客列表
  1531. [Authorize]
  1532. public JsonResult MyMakerList(string value)
  1533. {
  1534. value = DesDecrypt(value);
  1535. JsonData data = JsonMapper.ToObject(value);
  1536. List<Dictionary<string, object>> dataList = MyMakerListDo(value);
  1537. return Json(new AppResultJson() { Status = "1", Info = "", Data = dataList });
  1538. }
  1539. public List<Dictionary<string, object>> MyMakerListDo(string value)
  1540. {
  1541. JsonData data = JsonMapper.ToObject(value);
  1542. string RealName = data["RealName"].ToString(); //真实姓名
  1543. int UserLevel = int.Parse(function.CheckInt(data["UserLevel"].ToString())); //创客等级
  1544. int UserId = int.Parse(function.CheckInt(data["UserId"].ToString())); //创客Id
  1545. string Sort = data["Sort"].ToString(); //排序方式
  1546. int PageSize = int.Parse(function.CheckInt(data["PageSize"].ToString()));
  1547. int PageNum = int.Parse(function.CheckInt(data["PageNum"].ToString()));
  1548. List<Dictionary<string, object>> dataList = new List<Dictionary<string, object>>();
  1549. IQueryable<Users> query = maindb.Users.Where(m => m.ParentUserId == UserId && m.AuthFlag == 1 && !m.Mobile.EndsWith("d"));
  1550. if (!string.IsNullOrEmpty(RealName))
  1551. {
  1552. query = query.Where(m => (m.RealName == RealName || m.MakerCode == RealName));
  1553. }
  1554. if (Sort == "ThisMonthTrade")
  1555. {
  1556. query = query.OrderByDescending(m => m.ThisMonthTrade);
  1557. }
  1558. if (Sort == "AuthDate")
  1559. {
  1560. query = query.OrderByDescending(m => m.AuthDate);
  1561. }
  1562. if (PageNum == 1)
  1563. {
  1564. query = query.Take(PageSize);
  1565. }
  1566. else
  1567. {
  1568. int skipNum = PageSize * (PageNum - 1);
  1569. query = query.Skip(skipNum).Take(PageSize);
  1570. }
  1571. foreach (var subdata in query.ToList())
  1572. {
  1573. Dictionary<string, object> curData = new Dictionary<string, object>();
  1574. curData.Add("RealName", DefaultRealName(subdata)); //真实姓名
  1575. curData.Add("HeadPhoto", DefaultPic(subdata.HeadPhoto)); //头像
  1576. curData.Add("Id", subdata.Id); //Id
  1577. curData.Add("CreateDate", subdata.AuthDate == null ? "" : subdata.AuthDate.Value.ToString("yyyy-MM-dd")); //CreateDate
  1578. curData.Add("ThisMonthTrade", subdata.ThisMonthTrade); //本月交易额
  1579. dataList.Add(curData);
  1580. }
  1581. return dataList;
  1582. }
  1583. #endregion
  1584. #region 创客-首页-我的创客-搜索创客列表
  1585. [Authorize]
  1586. public JsonResult SearchMakerList(string value)
  1587. {
  1588. value = DesDecrypt(value);
  1589. JsonData data = JsonMapper.ToObject(value);
  1590. List<Dictionary<string, object>> dataList = SearchMakerListDo(value);
  1591. return Json(new AppResultJson() { Status = "1", Info = "", Data = dataList });
  1592. }
  1593. public List<Dictionary<string, object>> SearchMakerListDo(string value)
  1594. {
  1595. JsonData data = JsonMapper.ToObject(value);
  1596. string RealName = data["RealName"].ToString(); //真实姓名
  1597. int UserLevel = int.Parse(function.CheckInt(data["UserLevel"].ToString())); //创客等级
  1598. int UserId = int.Parse(function.CheckInt(data["UserId"].ToString())); //创客Id
  1599. string Sort = data["Sort"].ToString(); //排序方式
  1600. int PageSize = int.Parse(function.CheckInt(data["PageSize"].ToString()));
  1601. int PageNum = int.Parse(function.CheckInt(data["PageNum"].ToString()));
  1602. List<Dictionary<string, object>> dataList = new List<Dictionary<string, object>>();
  1603. string UserIdString = "," + UserId + ",";
  1604. IQueryable<Users> query = maindb.Users.Where(m => m.ParentNav.Contains(UserIdString) && m.AuthFlag == 1);
  1605. if (!string.IsNullOrEmpty(RealName))
  1606. {
  1607. query = query.Where(m => (m.RealName == RealName || m.MakerCode == RealName));
  1608. }
  1609. // if (UserLevel > 0)
  1610. // {
  1611. // query = query.Where(m => m.UserLevel == UserLevel);
  1612. // }
  1613. if (PageNum == 1)
  1614. {
  1615. query = query.Take(PageSize);
  1616. }
  1617. else
  1618. {
  1619. int skipNum = PageSize * (PageNum - 1);
  1620. query = query.Skip(skipNum).Take(PageSize);
  1621. }
  1622. foreach (var subdata in query.ToList())
  1623. {
  1624. // Users subdata = UsersDbconn.Instance.Get(item.UserId) ?? new Users();
  1625. Dictionary<string, object> curData = new Dictionary<string, object>();
  1626. curData.Add("RealName", DefaultRealName(subdata)); //真实姓名
  1627. curData.Add("HeadPhoto", DefaultPic(subdata.HeadPhoto)); //头像
  1628. curData.Add("Id", subdata.Id); //Id
  1629. curData.Add("CreateDate", subdata.CreateDate == null ? "" : subdata.CreateDate.Value.ToString("yyyy-MM-dd")); //CreateDate
  1630. curData.Add("ThisMonthTrade", UserTradeDaySummaryDbconn.Instance.GetMonthTrade(subdata.Id, DateTime.Now.ToString("yyyyMM"), "team")); //本月交易额
  1631. dataList.Add(curData);
  1632. }
  1633. return dataList;
  1634. }
  1635. #endregion
  1636. #region 首页-我的创客-未实名创客
  1637. [Authorize]
  1638. public JsonResult MyMakerForNotAuth(string value)
  1639. {
  1640. value = DesDecrypt(value);
  1641. JsonData data = JsonMapper.ToObject(value);
  1642. long TotalCount = 0;
  1643. List<Dictionary<string, object>> dataList = MyMakerForNotAuthDo(value, out TotalCount);
  1644. Dictionary<string, object> Other = new Dictionary<string, object>();
  1645. Other.Add("TotalCount", TotalCount);
  1646. return Json(new AppResultJson() { Status = "1", Info = "", Data = dataList, Other = Other });
  1647. }
  1648. public List<Dictionary<string, object>> MyMakerForNotAuthDo(string value, out long TotalCount)
  1649. {
  1650. JsonData data = JsonMapper.ToObject(value);
  1651. int UserId = int.Parse(function.CheckInt(data["UserId"].ToString())); //创客Id
  1652. int PageSize = int.Parse(function.CheckInt(data["PageSize"].ToString()));
  1653. int PageNum = int.Parse(function.CheckInt(data["PageNum"].ToString()));
  1654. List<Dictionary<string, object>> dataList = new List<Dictionary<string, object>>();
  1655. IQueryable<Users> query = maindb.Users.Where(m => m.ParentUserId == UserId && m.AuthFlag == 0);
  1656. TotalCount = query.Count();
  1657. if (PageNum == 1)
  1658. {
  1659. query = query.Take(PageSize);
  1660. }
  1661. else
  1662. {
  1663. int skipNum = PageSize * (PageNum - 1);
  1664. query = query.Skip(skipNum).Take(PageSize);
  1665. }
  1666. foreach (var subdata in query.ToList())
  1667. {
  1668. // Users subdata = UsersDbconn.Instance.Get(item.UserId) ?? new Users();
  1669. Dictionary<string, object> curData = new Dictionary<string, object>();
  1670. string RealName = DefaultRealName(subdata);
  1671. if (string.IsNullOrEmpty(RealName))
  1672. {
  1673. RealName = subdata.SeoTitle;
  1674. }
  1675. curData.Add("RealName", RealName); //真实姓名
  1676. curData.Add("HeadPhoto", DefaultPic(subdata.HeadPhoto)); //头像
  1677. curData.Add("Mobile", subdata.Mobile); //手机号
  1678. curData.Add("Id", subdata.Id); //Id
  1679. curData.Add("CreateDate", subdata.CreateDate == null ? "" : subdata.CreateDate.Value.ToString("yyyy-MM-dd HH:mm:ss")); //CreateDate
  1680. dataList.Add(curData);
  1681. }
  1682. return dataList;
  1683. }
  1684. #endregion
  1685. #region 创客-首页-我的创客-主界面数据
  1686. [Authorize]
  1687. public JsonResult MyMakerData(string value)
  1688. {
  1689. value = DesDecrypt(value);
  1690. JsonData data = JsonMapper.ToObject(value);
  1691. Dictionary<string, object> Obj = MyMakerDataDo(value);
  1692. return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
  1693. }
  1694. public Dictionary<string, object> MyMakerDataDo(string value)
  1695. {
  1696. JsonData data = JsonMapper.ToObject(value);
  1697. int UserId = int.Parse(function.CheckInt(data["UserId"].ToString())); //创客Id
  1698. Dictionary<string, object> Obj = new Dictionary<string, object>();
  1699. int MakerTotal = maindb.Users.Count(m => m.ParentUserId == UserId);
  1700. int AuthCount = maindb.Users.Count(m => m.ParentUserId == UserId && m.AuthFlag == 1);
  1701. int NotAuthCount = MakerTotal - AuthCount;
  1702. DateTime start = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd") + " 00:00:00");
  1703. int ThisMonthCount = maindb.Users.Count(m => m.ParentUserId == UserId && m.AuthFlag == 1 && m.AuthDate >= start);
  1704. Obj.Add("MakerTotal", MakerTotal); //创客总数
  1705. Obj.Add("AuthCount", AuthCount); //已实名总数
  1706. Obj.Add("NotAuthCount", NotAuthCount); //未实名总数
  1707. Obj.Add("ThisMonthCount", ThisMonthCount); //当月新增
  1708. return Obj;
  1709. }
  1710. #endregion
  1711. #region 创客-我的-个人资料-我的名片
  1712. [Authorize]
  1713. public JsonResult MyCard(string value)
  1714. {
  1715. value = DesDecrypt(value);
  1716. JsonData data = JsonMapper.ToObject(value);
  1717. Dictionary<string, object> Obj = MyCardDo(value);
  1718. return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
  1719. }
  1720. public Dictionary<string, object> MyCardDo(string value)
  1721. {
  1722. JsonData data = JsonMapper.ToObject(value);
  1723. Dictionary<string, object> Obj = new Dictionary<string, object>();
  1724. int Id = int.Parse(function.CheckInt(data["Id"].ToString()));
  1725. Users query = maindb.Users.FirstOrDefault(m => m.Id == Id) ?? new Users();
  1726. string filename = function.MD5_16(Id + "2022");
  1727. string filepath = "/static/ReferenceQrCode/";
  1728. if (!System.IO.File.Exists(function.getPath(filepath + filename + ".png")))
  1729. {
  1730. string path = function.CreateQRCode2(ConfigurationManager.AppSettings["SourceHost"].ToString() + "/p/user-inviteregist-1?Id=" + Id, filename, filepath);
  1731. path = path.Replace("//", "/");
  1732. query.ReferenceQrCode = filepath + filename + ".png";
  1733. maindb.SaveChanges();
  1734. }
  1735. Obj.Add("RealName", DefaultRealName(query)); //真实姓名
  1736. Obj.Add("HeadPhoto", DefaultPic(query.HeadPhoto)); //头像
  1737. Obj.Add("ReferenceQrCode", Host + filepath.TrimStart('/') + filename + ".png"); //推广二维码地址
  1738. Obj.Add("MakerCode", query.MakerCode); //创客编号
  1739. Obj.Add("InvitePhoto", Host + filepath.TrimStart('/') + filename + ".png"); //DefaultPic(query.SignImgUrl)); //邀请图片
  1740. return Obj;
  1741. }
  1742. #endregion
  1743. #region 创客-首页-检测是否有级别
  1744. [Authorize]
  1745. public JsonResult CheckUserLevel(string value)
  1746. {
  1747. value = DesDecrypt(value);
  1748. JsonData data = JsonMapper.ToObject(value);
  1749. int UserId = int.Parse(function.CheckInt(data["UserId"].ToString())); //创客Id
  1750. Dictionary<string, object> Obj = new Dictionary<string, object>();
  1751. UserRank rank = maindb.UserRank.FirstOrDefault(m => m.UserId == UserId && m.Status == 0);
  1752. if (rank != null)
  1753. {
  1754. Obj.Add("BeforeLevel", rank.WhiteRank);
  1755. Obj.Add("AfterLevel", rank.Rank);
  1756. rank.Status = 1;
  1757. maindb.SaveChanges();
  1758. return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
  1759. }
  1760. return Json(new AppResultJson() { Status = "-1", Info = "" });
  1761. }
  1762. #endregion
  1763. #region 创客-我的-盟主中心-盟主信息详情
  1764. [Authorize]
  1765. public JsonResult LeaderInfo(string value)
  1766. {
  1767. value = DesDecrypt(value);
  1768. JsonData data = JsonMapper.ToObject(value);
  1769. Dictionary<string, object> Obj = LeaderInfoDo(value);
  1770. return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
  1771. }
  1772. public Dictionary<string, object> LeaderInfoDo(string value)
  1773. {
  1774. JsonData data = JsonMapper.ToObject(value);
  1775. Dictionary<string, object> Obj = new Dictionary<string, object>();
  1776. int UserId = int.Parse(function.CheckInt(data["UserId"].ToString()));
  1777. Users query = maindb.Users.FirstOrDefault(m => m.Id == UserId) ?? new Users();
  1778. UserAccount account = maindb.UserAccount.FirstOrDefault(m => m.Id == UserId) ?? new UserAccount();
  1779. Obj.Add("LeaderLevel", query.LeaderLevel); //盟主等级(0 无 1 小盟主 2 大盟主)
  1780. Obj.Add("LeaderReserve", account.LeaderReserve); //盟主储备金
  1781. Obj.Add("LeaderBalanceAmount", account.LeaderBalanceAmount); //可提现金额
  1782. return Obj;
  1783. }
  1784. #endregion
  1785. #region 创客-提交签名图片
  1786. [Authorize]
  1787. public JsonResult UploadSignPic(string value)
  1788. {
  1789. value = DesDecrypt(value);
  1790. JsonData data = JsonMapper.ToObject(value);
  1791. AppResultJson result = UploadSignPicDo(value);
  1792. return Json(new AppResultJson() { Status = result.Status, Info = result.Info, Data = result.Data });
  1793. }
  1794. public AppResultJson UploadSignPicDo(string value)
  1795. {
  1796. JsonData data = JsonMapper.ToObject(value);
  1797. int Id = int.Parse(function.CheckInt(data["Id"].ToString()));
  1798. string SignPic = data["SignPic"].ToString(); //签名图片
  1799. if(string.IsNullOrEmpty(SignPic))
  1800. {
  1801. return new AppResultJson() { Status = "-1", Info = "签名图片不能为空" };
  1802. }
  1803. Dictionary<string, object> Obj = new Dictionary<string, object>();
  1804. Users query = maindb.Users.FirstOrDefault(m => m.Id == Id);
  1805. if (query != null)
  1806. {
  1807. query.IsSign = 1;
  1808. query.SignDate = DateTime.Now;
  1809. query.SignPic = SignPic; //签名图片
  1810. maindb.SaveChanges();
  1811. }
  1812. return new AppResultJson() { Status = "1", Info = "", Data = Obj };
  1813. }
  1814. #endregion
  1815. #region 创客-是否签名
  1816. [Authorize]
  1817. public JsonResult SignCheck(string value)
  1818. {
  1819. value = DesDecrypt(value);
  1820. JsonData data = JsonMapper.ToObject(value);
  1821. Dictionary<string, object> Obj = SignCheckDo(value);
  1822. return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
  1823. }
  1824. public Dictionary<string, object> SignCheckDo(string value)
  1825. {
  1826. JsonData data = JsonMapper.ToObject(value);
  1827. Dictionary<string, object> Obj = new Dictionary<string, object>();
  1828. int Id = int.Parse(function.CheckInt(data["Id"].ToString()));
  1829. Users query = maindb.Users.FirstOrDefault(m => m.Id == Id) ?? new Users();
  1830. Obj.Add("IsSign", query.IsSign); //是否签名
  1831. return Obj;
  1832. }
  1833. #endregion
  1834. #region 通用-通过创客编号查询
  1835. [Authorize]
  1836. public JsonResult ForCode(string value)
  1837. {
  1838. value = DesDecrypt(value);
  1839. JsonData data = JsonMapper.ToObject(value);
  1840. string MakerCode = data["MakerCode"].ToString(); //创客编号
  1841. Dictionary<string, object> Obj = new Dictionary<string, object>();
  1842. KxsMainModels.UserForMakerCode userfor = kxsdb.UserForMakerCode.FirstOrDefault(m => m.MakerCode == MakerCode) ?? new KxsMainModels.UserForMakerCode();
  1843. KxsMainModels.Users query = kxsdb.Users.FirstOrDefault(m => m.Id == userfor.UserId) ?? new KxsMainModels.Users();
  1844. if (query.AuthFlag != 1)
  1845. {
  1846. return Json(new AppResultJson() { Status = "-1", Info = "创客未认证" });
  1847. }
  1848. Obj.Add("Id", query.Id); //创客Id
  1849. Obj.Add("RealName", query.RealName); //真实姓名
  1850. return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
  1851. }
  1852. #endregion
  1853. #region 通用-灰度测试UserId集合
  1854. [Authorize]
  1855. public JsonResult UserIdForGrayTest(string value)
  1856. {
  1857. value = DesDecrypt(value);
  1858. JsonData data = JsonMapper.ToObject(value);
  1859. List<string> Obj = UserIdForGrayTestDo(value);
  1860. return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
  1861. }
  1862. public List<string> UserIdForGrayTestDo(string value)
  1863. {
  1864. JsonData data = JsonMapper.ToObject(value);
  1865. List<string> Obj = new List<string>();
  1866. SystemSet set = maindb.SystemSet.FirstOrDefault() ?? new SystemSet();
  1867. if (!string.IsNullOrEmpty(set.RightInfo))
  1868. {
  1869. string[] RightInfos = set.RightInfo.Split('\n');
  1870. foreach (string sub in RightInfos)
  1871. {
  1872. UserForMakerCode code = maindb.UserForMakerCode.FirstOrDefault(m => m.MakerCode == sub);
  1873. if (code != null)
  1874. {
  1875. Obj.Add(code.UserId.ToString());
  1876. }
  1877. }
  1878. }
  1879. return Obj;
  1880. }
  1881. #endregion
  1882. #region 企业创客-个人中心主界面
  1883. [Authorize]
  1884. public JsonResult BusinessMain(string value)
  1885. {
  1886. value = DesDecrypt(value);
  1887. JsonData data = JsonMapper.ToObject(value);
  1888. Dictionary<string, object> Obj = BusinessMainDo(value);
  1889. return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
  1890. }
  1891. public Dictionary<string, object> BusinessMainDo(string value)
  1892. {
  1893. JsonData data = JsonMapper.ToObject(value);
  1894. string PartnerCount = data["PartnerCount"].ToString(); //伙伴总数
  1895. string ThisMonthTrade = data["ThisMonthTrade"].ToString(); //本月交易额
  1896. string ThisMonthAct = data["ThisMonthAct"].ToString(); //本月激活商户
  1897. Dictionary<string, object> Obj = new Dictionary<string, object>();
  1898. Users query = new Users();
  1899. int Id = int.Parse(function.CheckInt(data["Id"].ToString()));
  1900. query = maindb.Users.FirstOrDefault(m => m.Id == Id) ?? new Users();
  1901. return Obj;
  1902. }
  1903. #endregion
  1904. #region 创客-我的-添加展业地区
  1905. [Authorize]
  1906. public JsonResult AddAgentAreas(string value)
  1907. {
  1908. value = DesDecrypt(value);
  1909. JsonData data = JsonMapper.ToObject(value);
  1910. AppResultJson result = AddAgentAreasDo(value);
  1911. return Json(new AppResultJson() { Status = result.Status, Info = result.Info, Data = result.Data });
  1912. }
  1913. public AppResultJson AddAgentAreasDo(string value)
  1914. {
  1915. JsonData data = JsonMapper.ToObject(value);
  1916. int UserId = int.Parse(function.CheckInt(data["UserId"].ToString()));
  1917. string AgentAreas = data["AgentAreas"].ToString(); //展业地区
  1918. if(string.IsNullOrEmpty(AgentAreas))
  1919. {
  1920. return new AppResultJson() { Status = "-1", Info = "展业地区不能为空" };
  1921. }
  1922. Dictionary<string, object> Obj = new Dictionary<string, object>();
  1923. Users query = maindb.Users.FirstOrDefault(m => m.Id == UserId);
  1924. if (query != null)
  1925. {
  1926. query.UpdateDate = DateTime.Now;
  1927. query.AgentAreas = AgentAreas; //展业地区
  1928. maindb.SaveChanges();
  1929. }
  1930. return new AppResultJson() { Status = "1", Info = "", Data = Obj };
  1931. }
  1932. #endregion
  1933. #region 检查签名是否合法,合法返回1,不合法返回提示信息
  1934. /// <summary>
  1935. /// 检查签名是否合法,合法返回1,不合法返回提示信息
  1936. /// </summary>
  1937. /// <param name="value">请求的参数(json字符串)</param>
  1938. /// <param name="signField">要签名的字段</param>
  1939. /// <returns></returns>
  1940. private string CheckSign(string value, string[] signField)
  1941. {
  1942. JsonData json = JsonMapper.ToObject(value);
  1943. Dictionary<string, string> dic = new Dictionary<string, string>();
  1944. for (int i = 0; i < signField.Length; i++)
  1945. {
  1946. dic.Add(signField[i], json[signField[i]].ToString());
  1947. }
  1948. string sign = json["sign"].ToString(); //客户端签名字符串
  1949. return new Sign().sign(dic, sign);
  1950. }
  1951. #endregion
  1952. }
  1953. }