UsersController.cs 133 KB

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