UsersController.cs 112 KB

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