UsersController.cs 133 KB

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