UsersController.cs 102 KB

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