MerchantInfoController.cs 47 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974
  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 MySystem.MainModels;
  11. using LitJson;
  12. using Library;
  13. namespace MySystem.Areas.Api.Controllers.v1
  14. {
  15. [Area("Api")]
  16. [Route("Api/v1/[controller]/[action]")]
  17. public class MerchantInfoController : BaseController
  18. {
  19. public MerchantInfoController(IHttpContextAccessor accessor, ILogger<BaseController> logger, IOptions<Setting> setting) : base(accessor, logger, setting)
  20. {
  21. }
  22. #region 首页-快联盟产品-我的业绩-团队业绩-商户列表
  23. [Authorize]
  24. public JsonResult TeamPerformanceMerchants(string value)
  25. {
  26. value = DesDecrypt(value);
  27. JsonData data = JsonMapper.ToObject(value);
  28. List<Dictionary<string, object>> dataList = TeamPerformanceMerchantsDo(value);
  29. return Json(new AppResultJson() { Status = "1", Info = "", Data = dataList });
  30. }
  31. public List<Dictionary<string, object>> TeamPerformanceMerchantsDo(string value)
  32. {
  33. JsonData data = JsonMapper.ToObject(value);
  34. int UserId = int.Parse(function.CheckInt(data["UserId"].ToString())); //创客
  35. int PageSize = int.Parse(function.CheckInt(data["PageSize"].ToString()));
  36. int PageNum = int.Parse(function.CheckInt(data["PageNum"].ToString()));
  37. List<Dictionary<string, object>> dataList = new List<Dictionary<string, object>>();
  38. List<int> query = MerchantInfoDbconn.Instance.GetList(UserId, PageNum, PageSize);
  39. foreach (int id in query)
  40. {
  41. MerchantInfo subdata = MerchantInfoDbconn.Instance.Get(id) ?? new MerchantInfo();
  42. Dictionary<string, object> curData = new Dictionary<string, object>();
  43. curData.Add("MerchantName", subdata.Name); //商户姓名
  44. curData.Add("Id", subdata.Id); //Id
  45. dataList.Add(curData);
  46. }
  47. return dataList;
  48. }
  49. #endregion
  50. #region 创客-首页-商户签约
  51. [Authorize]
  52. public JsonResult ContractList(string value)
  53. {
  54. value = DesDecrypt(value);
  55. JsonData data = JsonMapper.ToObject(value);
  56. List<Dictionary<string, object>> dataList = ContractListDo(value);
  57. return Json(new AppResultJson() { Status = "1", Info = "", Data = dataList });
  58. }
  59. public List<Dictionary<string, object>> ContractListDo(string value)
  60. {
  61. JsonData data = JsonMapper.ToObject(value);
  62. int UserId = int.Parse(function.CheckInt(data["UserId"].ToString())); //所属创客
  63. string Status = data["Status"].ToString(); //签约状态
  64. int PageSize = int.Parse(function.CheckInt(data["PageSize"].ToString()));
  65. int PageNum = int.Parse(function.CheckInt(data["PageNum"].ToString()));
  66. List<Dictionary<string, object>> dataList = new List<Dictionary<string, object>>();
  67. List<int> query = MerchantInfoDbconn.Instance.GetList(UserId, PageNum, PageSize);
  68. foreach (var id in query)
  69. {
  70. MerchantInfo subdata = MerchantInfoDbconn.Instance.Get(id) ?? new MerchantInfo();
  71. Dictionary<string, object> curData = new Dictionary<string, object>();
  72. curData.Add("Name", subdata.Name); //名称
  73. curData.Add("Id", subdata.Id); //Id
  74. curData.Add("CreateDate", subdata.CreateDate == null ? "" : subdata.CreateDate.Value.ToString("yyyy-MM-dd HH:mm:ss")); //CreateDate
  75. curData.Add("Status", ""); //签约状态
  76. curData.Add("MainType", ""); //主体类型
  77. dataList.Add(curData);
  78. }
  79. return dataList;
  80. }
  81. #endregion
  82. #region 创客-首页-商户签约-详情
  83. [Authorize]
  84. public JsonResult ContractDetail(string value)
  85. {
  86. value = DesDecrypt(value);
  87. JsonData data = JsonMapper.ToObject(value);
  88. Dictionary<string, object> Obj = ContractDetailDo(value);
  89. return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
  90. }
  91. public Dictionary<string, object> ContractDetailDo(string value)
  92. {
  93. JsonData data = JsonMapper.ToObject(value);
  94. Dictionary<string, object> Obj = new Dictionary<string, object>();
  95. MerchantInfo query = new MerchantInfo();
  96. int Id = int.Parse(function.CheckInt(data["Id"].ToString()));
  97. query = MerchantInfoDbconn.Instance.Get(Id) ?? new MerchantInfo();
  98. Obj.Add("Name", query.Name); //名称
  99. Obj.Add("Status", ""); //签约状态
  100. Obj.Add("Platforms", ""); //品台列表
  101. Obj.Add("CreateDate", query.CreateDate); //创建时间
  102. return Obj;
  103. }
  104. #endregion
  105. #region 创客-首页-我的商户-商户列表
  106. [Authorize]
  107. public JsonResult MyMerchant(string value)
  108. {
  109. value = DesDecrypt(value);
  110. JsonData data = JsonMapper.ToObject(value);
  111. Dictionary<string, object> Other = new Dictionary<string, object>();
  112. List<Dictionary<string, object>> dataList = MyMerchantDo(value, out Other);
  113. return Json(new AppResultJson() { Status = "1", Info = "", Data = dataList, Other = Other });
  114. }
  115. public List<Dictionary<string, object>> MyMerchantDo(string value, out Dictionary<string, object> Other)
  116. {
  117. JsonData data = JsonMapper.ToObject(value);
  118. string SearchKey = data["SearchKey"].ToString(); //搜索关键词
  119. int UserId = int.Parse(function.CheckInt(data["UserId"].ToString())); //创客
  120. int ActiveStatus = int.Parse(function.CheckInt(data["ActiveStatus"].ToString())); //商户激活状态
  121. int Kind = int.Parse(function.CheckInt(data["Kind"].ToString()));
  122. string TradeSort = data["TradeSort"].ToString(); //排序
  123. string DateSort = data["DateSort"].ToString(); //排序
  124. int PageSize = int.Parse(function.CheckInt(data["PageSize"].ToString()));
  125. int PageNum = int.Parse(function.CheckInt(data["PageNum"].ToString()));
  126. List<Dictionary<string, object>> dataList = new List<Dictionary<string, object>>();
  127. IQueryable<MerchantInfo> query = maindb.MerchantInfo.Where(m => m.UserId == UserId && (m.Status == 2 || m.QueryCount == 2));
  128. DateTime today = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd") + " 00:00:00");
  129. if (!string.IsNullOrEmpty(SearchKey))
  130. {
  131. query = query.Where(m => m.Name.Contains(SearchKey));
  132. }
  133. if(Kind > 0)
  134. {
  135. query = query.Where(m => m.QueryCount == Kind);
  136. }
  137. if (ActiveStatus > 0)
  138. {
  139. if (ActiveStatus == 2) ActiveStatus = 0;
  140. query = query.Where(m => m.ActivationStatus == ActiveStatus);
  141. }
  142. int TotalCount = query.Count();
  143. int ActCount = query.Count(m => m.ActivationDate == today);
  144. int ProductCount = query.Count();
  145. int ProductActCount = query.Count(m => m.ActivationStatus == 1);
  146. int ProductUnActCount = ProductCount - ProductActCount;
  147. if (TradeSort == "1")
  148. {
  149. if (DateSort == "1")
  150. {
  151. query = query.OrderBy(m => m.TotalAmount).ThenBy(m => m.CreateDate);
  152. }
  153. else
  154. {
  155. query = query.OrderBy(m => m.TotalAmount).ThenByDescending(m => m.CreateDate);
  156. }
  157. }
  158. else
  159. {
  160. if (DateSort == "1")
  161. {
  162. query = query.OrderByDescending(m => m.TotalAmount).ThenBy(m => m.CreateDate);
  163. }
  164. else
  165. {
  166. query = query.OrderByDescending(m => m.TotalAmount).ThenByDescending(m => m.CreateDate);
  167. }
  168. }
  169. if (PageNum == 1)
  170. {
  171. query = query.Take(PageSize);
  172. }
  173. else
  174. {
  175. int skipNum = PageSize * (PageNum - 1);
  176. query = query.Skip(skipNum).Take(PageSize);
  177. }
  178. foreach (var item in query.ToList())
  179. {
  180. Dictionary<string, object> curData = new Dictionary<string, object>();
  181. curData.Add("MerchantName", item.Name); //商户姓名
  182. curData.Add("KqRegTime", item.CreateDate == null ? "" : item.CreateDate.Value.ToString("yyyy-MM-dd")); //渠道注册时间
  183. curData.Add("Id", item.Id); //Id
  184. curData.Add("TotalAmount", item.TotalAmount.ToString("f2")); //交易额
  185. curData.Add("TodayTrade", MerchantTradeStat.Instance.Amount(item.Id, DateTime.Now.ToString("yyyyMMdd")).ToString("f2")); //今日交易额
  186. curData.Add("TradeCount", item.TotalConsumeCount); //交易笔数
  187. curData.Add("TodayTradeCount", MerchantTradeStat.Instance.Count(item.Id, DateTime.Now.ToString("yyyyMMdd"))); //今日交易笔数
  188. dataList.Add(curData);
  189. }
  190. Other = new Dictionary<string, object>();
  191. Other.Add("TotalCount", TotalCount); //商户数
  192. Other.Add("ActCount", ActCount); //商户达标数
  193. Other.Add("UnActCount", ProductUnActCount); //未达标数
  194. return dataList;
  195. }
  196. #endregion
  197. #region 创客-首页-我的商户-商户详情
  198. [Authorize]
  199. public JsonResult MyMerchantDetail(string value)
  200. {
  201. value = DesDecrypt(value);
  202. JsonData data = JsonMapper.ToObject(value);
  203. Dictionary<string, object> Obj = MyMerchantDetailDo(value);
  204. return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
  205. }
  206. public Dictionary<string, object> MyMerchantDetailDo(string value)
  207. {
  208. JsonData data = JsonMapper.ToObject(value);
  209. Dictionary<string, object> Obj = new Dictionary<string, object>();
  210. int Id = int.Parse(function.CheckInt(data["Id"].ToString()));
  211. MerchantInfo merchant = MerchantInfoDbconn.Instance.Get(Id) ?? new MerchantInfo();
  212. MerchantAddInfo addinfo = MerchantAddInfoDbconn.Instance.Get(Id) ?? new MerchantAddInfo();
  213. Obj.Add("MerchantName", merchant.Name); //商户名称
  214. Obj.Add("LegalName", addinfo.CertLegalPerson); //企业法人
  215. Obj.Add("MerchantMobile", addinfo.MobilePhone); //商户手机号
  216. Obj.Add("SubjectType", addinfo.SubjectType); //主体类型
  217. Obj.Add("CreateDate", merchant.CreateDate == null ? "" : merchant.CreateDate.Value.ToString("yyyy-MM-dd HH:mm:ss")); //注册时间
  218. Obj.Add("ActivationDate", merchant.ActivationDate == null ? "" : merchant.ActivationDate.Value.ToString("yyyy-MM-dd HH:mm:ss")); //达标时间
  219. Obj.Add("TotalAmount", merchant.TotalAmount.ToString("f2")); //总交易额
  220. Obj.Add("ActivationStatus", merchant.ActivationStatus); //达标状态
  221. return Obj;
  222. }
  223. #endregion
  224. #region 创客-首页-我的商户-商户详情-交易统计
  225. [Authorize]
  226. public JsonResult MerchantTradeList(string value)
  227. {
  228. value = DesDecrypt(value);
  229. JsonData data = JsonMapper.ToObject(value);
  230. Dictionary<string, object> other = new Dictionary<string, object>();
  231. List<Dictionary<string, object>> dataList = MerchantTradeListDo(value, out other);
  232. return Json(new AppResultJson() { Status = "1", Info = "", Data = dataList, Other = other });
  233. }
  234. public List<Dictionary<string, object>> MerchantTradeListDo(string value, out Dictionary<string, object> other)
  235. {
  236. JsonData data = JsonMapper.ToObject(value);
  237. string TradeMonth = data["TradeMonth"].ToString(); //交易月
  238. int MerchantId = int.Parse(function.CheckInt(data["MerchantId"].ToString())); //商户Id
  239. int PageSize = int.Parse(function.CheckInt(data["PageSize"].ToString()));
  240. int PageNum = int.Parse(function.CheckInt(data["PageNum"].ToString()));
  241. List<Dictionary<string, object>> dataList = new List<Dictionary<string, object>>();
  242. string limit = " limit " + PageSize;
  243. if (PageNum == 1)
  244. {
  245. int skipNum = PageSize * (PageNum - 1);
  246. limit = " limit " + skipNum + "," + PageSize;
  247. }
  248. DataTable dt = CustomerSqlConn.dtable("select TradeDate,sum(TradeAmount),sum(TradeCount),sum(if(IsAct=1, TradeAmount, 0)),sum(if(IsAct=0, TradeAmount, 0)) from MerchantAmountSummay where MerchantId=" + MerchantId + " and TradeMonth='" + TradeMonth + "' group by TradeDate order by TradeDate desc" + limit, AppConfig.Base.SqlConnStr);
  249. foreach (DataRow dr in dt.Rows)
  250. {
  251. string TradeDate = dr["TradeDate"].ToString();
  252. Dictionary<string, object> curData = new Dictionary<string, object>();
  253. curData.Add("TradeDate", TradeDate.Substring(0, 4) + "-" + TradeDate.Substring(4, 2) + "-" + TradeDate.Substring(6, 2)); //交易日
  254. curData.Add("TradeAmt", dr[1].ToString()); //交易金额
  255. curData.Add("ActTradeAmt", dr[3].ToString()); //活动交易金额
  256. curData.Add("UnActTradeAmt", dr[4].ToString()); //非活动交易金额
  257. curData.Add("TradeCount", dr[2].ToString()); //交易笔数
  258. dataList.Add(curData);
  259. }
  260. other = new Dictionary<string, object>();
  261. if(PageNum == 1)
  262. {
  263. DataTable total = CustomerSqlConn.dtable("select sum(TradeAmount),sum(TradeCount),sum(if(IsAct=1, TradeAmount, 0)),sum(if(IsAct=0, TradeAmount, 0)) from MerchantAmountSummay where MerchantId=" + MerchantId + " and TradeMonth='" + TradeMonth + "'", AppConfig.Base.SqlConnStr);
  264. decimal TradeAmt = 0;
  265. decimal ActTradeAmt = 0;
  266. decimal UnActTradeAmt = 0;
  267. int TradeCount = 0;
  268. if(total.Rows.Count > 0)
  269. {
  270. TradeAmt = decimal.Parse(function.CheckNum(total.Rows[0][0].ToString())); //交易金额
  271. ActTradeAmt = decimal.Parse(function.CheckNum(total.Rows[0][2].ToString())); //活动交易金额
  272. UnActTradeAmt = decimal.Parse(function.CheckNum(total.Rows[0][3].ToString())); //非活动交易金额
  273. TradeCount = int.Parse(function.CheckNum(total.Rows[0][1].ToString())); //交易笔数
  274. }
  275. other.Add("TradeAmt", TradeAmt.ToString("f2")); //交易金额
  276. other.Add("ActTradeAmt", ActTradeAmt.ToString("f2")); //活动交易金额
  277. other.Add("UnActTradeAmt", UnActTradeAmt.ToString("f2")); //非活动交易金额
  278. other.Add("TradeCount", TradeCount); //交易笔数
  279. }
  280. return dataList;
  281. }
  282. #endregion
  283. #region 创客-首页-我的商户-商户详情-码牌
  284. [Authorize]
  285. public JsonResult QrCodeList(string value)
  286. {
  287. value = DesDecrypt(value);
  288. JsonData data = JsonMapper.ToObject(value);
  289. int TotalCount = 0;
  290. List<Dictionary<string, object>> dataList = QrCodeListDo(value, out TotalCount);
  291. return Json(new AppResultJson() { Status = "1", Info = "", Data = dataList, Other = TotalCount });
  292. }
  293. public List<Dictionary<string, object>> QrCodeListDo(string value, out int TotalCount)
  294. {
  295. JsonData data = JsonMapper.ToObject(value);
  296. int MerchantId = int.Parse(function.CheckInt(data["MerchantId"].ToString())); //商户Id
  297. int PageSize = int.Parse(function.CheckInt(data["PageSize"].ToString()));
  298. int PageNum = int.Parse(function.CheckInt(data["PageNum"].ToString()));
  299. List<Dictionary<string, object>> dataList = new List<Dictionary<string, object>>();
  300. IQueryable<MerchantQrCode> query = maindb.MerchantQrCode.Where(m => m.MerchantId == MerchantId && m.QueryCount == 1).OrderByDescending(m => m.Id);
  301. TotalCount = query.Count();
  302. if (PageNum == 1)
  303. {
  304. query = query.Take(PageSize);
  305. }
  306. else
  307. {
  308. int skipNum = PageSize * (PageNum - 1);
  309. query = query.Skip(skipNum).Take(PageSize);
  310. }
  311. foreach (MerchantQrCode item in query.ToList())
  312. {
  313. Dictionary<string, object> curData = new Dictionary<string, object>();
  314. curData.Add("SnNo", item.SnNo); //sn
  315. curData.Add("TradeAmount", QrCodeTradeStat.Instance.Amount(item.SnNo).ToString("f2"));
  316. dataList.Add(curData);
  317. }
  318. return dataList;
  319. }
  320. #endregion
  321. #region 创客-首页-我的商户-商户详情-音响
  322. // [Authorize]
  323. public JsonResult QrCodeList2(string value)
  324. {
  325. value = DesDecrypt(value);
  326. value = value.Replace("null", "\"\"");
  327. JsonData data = JsonMapper.ToObject(value);
  328. int TotalCount = 0;
  329. List<Dictionary<string, object>> dataList = QrCodeList2Do(value, out TotalCount);
  330. return Json(new AppResultJson() { Status = "1", Info = "", Data = dataList, Other = TotalCount });
  331. }
  332. public List<Dictionary<string, object>> QrCodeList2Do(string value, out int TotalCount)
  333. {
  334. JsonData data = JsonMapper.ToObject(value);
  335. int MerchantId = int.Parse(function.CheckInt(data["MerchantId"].ToString())); //商户Id
  336. int PageSize = int.Parse(function.CheckInt(data["PageSize"].ToString()));
  337. int PageNum = int.Parse(function.CheckInt(data["PageNum"].ToString()));
  338. List<Dictionary<string, object>> dataList = new List<Dictionary<string, object>>();
  339. IQueryable<MachineForQrCode> query = maindb.MachineForQrCode.Where(m => m.MerchantId == MerchantId && m.DataId.EndsWith("_1") && m.MachineSnNo != m.SnNo && !string.IsNullOrEmpty(m.MachineSnNo)).OrderByDescending(m => m.MerchantId);
  340. TotalCount = query.Count();
  341. if (PageNum == 1)
  342. {
  343. query = query.Take(PageSize);
  344. }
  345. else
  346. {
  347. int skipNum = PageSize * (PageNum - 1);
  348. query = query.Skip(skipNum).Take(PageSize);
  349. }
  350. foreach (MachineForQrCode item in query.ToList())
  351. {
  352. Dictionary<string, object> curData = new Dictionary<string, object>();
  353. curData.Add("SnNo", item.SnNo); //sn
  354. curData.Add("TradeAmount", QrCodeTradeStat.Instance.Amount(item.SnNo).ToString("f2"));
  355. curData.Add("BindTime", item.BindDate == null ? "" : item.BindDate.Value.ToString("yyyy-MM-dd HH:mm:ss"));
  356. dataList.Add(curData);
  357. }
  358. return dataList;
  359. }
  360. #endregion
  361. #region 首页-我的商户-商户搜索
  362. [Authorize]
  363. public JsonResult MerchantSearch(string value)
  364. {
  365. value = DesDecrypt(value);
  366. JsonData data = JsonMapper.ToObject(value);
  367. List<Dictionary<string, object>> dataList = MerchantSearchDo(value);
  368. return Json(new AppResultJson() { Status = "1", Info = "", Data = dataList });
  369. }
  370. public List<Dictionary<string, object>> MerchantSearchDo(string value)
  371. {
  372. JsonData data = JsonMapper.ToObject(value);
  373. string SearchKey = data["SearchKey"].ToString(); //搜索关键词
  374. int UserId = int.Parse(function.CheckInt(data["UserId"].ToString()));
  375. // int ProductType = 1; //int.Parse(function.CheckInt(data["ProductType"].ToString()));
  376. int PageSize = int.Parse(function.CheckInt(data["PageSize"].ToString()));
  377. int PageNum = int.Parse(function.CheckInt(data["PageNum"].ToString()));
  378. List<Dictionary<string, object>> dataList = new List<Dictionary<string, object>>();
  379. IQueryable<MerchantInfo> query = maindb.MerchantInfo.Where(m => m.UserId == UserId);
  380. if (!string.IsNullOrEmpty(SearchKey))
  381. {
  382. query = query.Where(m => m.Name.Contains(SearchKey));
  383. }
  384. if (PageNum == 1)
  385. {
  386. query = query.Take(PageSize);
  387. }
  388. else
  389. {
  390. int skipNum = PageSize * (PageNum - 1);
  391. query = query.Skip(skipNum).Take(PageSize);
  392. }
  393. foreach (var item in query.ToList())
  394. {
  395. MerchantInfo subdata = MerchantInfoDbconn.Instance.Get(item.Id) ?? new MerchantInfo();
  396. Dictionary<string, object> curData = new Dictionary<string, object>();
  397. curData.Add("MerchantName", subdata.Name); //商户姓名
  398. curData.Add("KqRegTime", subdata.CreateDate == null ? "" : subdata.CreateDate.Value.ToString("yyyy-MM-dd HH:mm:ss")); //渠道注册时间
  399. curData.Add("Id", item.Id); //Id
  400. curData.Add("ThisMonthTrade", item.TotalAmount); //当月交易额
  401. dataList.Add(curData);
  402. }
  403. return dataList;
  404. }
  405. #endregion
  406. #region 创客-首页-进件查询
  407. [Authorize]
  408. public JsonResult MerchantByStatus(string value)
  409. {
  410. value = DesDecrypt(value);
  411. JsonData data = JsonMapper.ToObject(value);
  412. List<Dictionary<string, object>> dataList = MerchantByStatusDo(value);
  413. return Json(new AppResultJson() { Status = "1", Info = "", Data = dataList });
  414. }
  415. public List<Dictionary<string, object>> MerchantByStatusDo(string value)
  416. {
  417. JsonData data = JsonMapper.ToObject(value);
  418. string SearchKey = data["SearchKey"].ToString();
  419. int Status = int.Parse(function.CheckInt(data["Status"].ToString()));
  420. int UserId = int.Parse(function.CheckInt(data["UserId"].ToString())); //所属创客
  421. int PageSize = int.Parse(function.CheckInt(data["PageSize"].ToString()));
  422. int PageNum = int.Parse(function.CheckInt(data["PageNum"].ToString()));
  423. List<Dictionary<string, object>> dataList = new List<Dictionary<string, object>>();
  424. IQueryable<MerchantInfo> query = maindb.MerchantInfo.Where(m => m.UserId == UserId && m.Sort == 1);
  425. if (Status > 0)
  426. {
  427. if (Status == 1) Status = 0;
  428. if (Status == 2) Status = -1;
  429. if (Status == 3) Status = 1;
  430. if (Status == 4) Status = 2;
  431. query = query.Where(m => m.Status == Status);
  432. }
  433. if(!string.IsNullOrEmpty(SearchKey))
  434. {
  435. query = query.Where(m => m.Name.Contains(SearchKey));
  436. }
  437. if (PageNum == 1)
  438. {
  439. query = query.Take(PageSize);
  440. }
  441. else
  442. {
  443. int skipNum = PageSize * (PageNum - 1);
  444. query = query.Skip(skipNum).Take(PageSize);
  445. }
  446. foreach (var subdata in query.ToList())
  447. {
  448. MerchantAddInfo AddInfo = MerchantAddInfoDbconn.Instance.Get(subdata.Id) ?? new MerchantAddInfo();
  449. Dictionary<string, object> curData = new Dictionary<string, object>();
  450. curData.Add("Name", subdata.Name); //名称
  451. curData.Add("Id", subdata.Id); //Id
  452. curData.Add("CreateDate", subdata.CreateDate == null ? "" : subdata.CreateDate.Value.ToString("yyyy-MM-dd HH:mm:ss")); //CreateDate
  453. curData.Add("Status", AddInfo.Status); //Status
  454. curData.Add("MainType", AddInfo.SubjectType); //主体类型
  455. dataList.Add(curData);
  456. }
  457. return dataList;
  458. }
  459. #endregion
  460. #region 创客-首页-进件查询-详情
  461. [Authorize]
  462. public JsonResult MerchantDetailByStatus(string value)
  463. {
  464. value = DesDecrypt(value);
  465. JsonData data = JsonMapper.ToObject(value);
  466. Dictionary<string, object> Obj = MerchantDetailByStatusDo(value);
  467. return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
  468. }
  469. public Dictionary<string, object> MerchantDetailByStatusDo(string value)
  470. {
  471. JsonData data = JsonMapper.ToObject(value);
  472. Dictionary<string, object> Obj = new Dictionary<string, object>();
  473. int Id = int.Parse(function.CheckInt(data["Id"].ToString()));
  474. MerchantInfo query = MerchantInfoDbconn.Instance.Get(Id) ?? new MerchantInfo();
  475. MerchantAddInfo addInfo = MerchantAddInfoDbconn.Instance.Get(Id) ?? new MerchantAddInfo();
  476. Obj.Add("Name", query.Name); //名称
  477. Obj.Add("CreateDate", query.CreateDate == null ? "" : query.CreateDate.Value.ToString("yyyy-MM-dd HH:mm:ss")); //提交时间
  478. List<Dictionary<string, object>> AuditResult = new List<Dictionary<string, object>>();
  479. Dictionary<string, object> WeChat = new Dictionary<string, object>();
  480. WeChat.Add("Name", "微信");
  481. WeChat.Add("Status", addInfo.Status);
  482. WeChat.Add("DoTime", addInfo.UpdateDate == null ? "" : addInfo.UpdateDate.Value.ToString("yyyy-MM-dd HH:mm:ss"));
  483. WeChat.Add("Season", addInfo.WeChatRemark);
  484. WeChat.Add("SignUrl", addInfo.WeChatSignUrl);
  485. AuditResult.Add(WeChat);
  486. Dictionary<string, object> Alipay = new Dictionary<string, object>();
  487. Alipay.Add("Name", "支付宝");
  488. Alipay.Add("Status", addInfo.QueryCount);
  489. Alipay.Add("DoTime", addInfo.UpdateDate == null ? "" : addInfo.UpdateDate.Value.ToString("yyyy-MM-dd HH:mm:ss"));
  490. Alipay.Add("Season", addInfo.AlipayRemark);
  491. Alipay.Add("SignUrl", function.CheckNull(addInfo.AlipaySignUrl).Replace("\\", ""));
  492. AuditResult.Add(Alipay);
  493. Obj.Add("Status", GetMainStatusName(addInfo.QueryCount, query.Status)); //状态
  494. Obj.Add("AuditResult", AuditResult); //审核结果
  495. Obj.Add("SubjectType", addInfo.SubjectType);
  496. return Obj;
  497. }
  498. #endregion
  499. #region 创客-首页-进件记录-删除
  500. [Authorize]
  501. public JsonResult Delete(string value)
  502. {
  503. value = DesDecrypt(value);
  504. JsonData data = JsonMapper.ToObject(value);
  505. AppResultJson result = DeleteDo(value);
  506. return Json(new AppResultJson() { Status = result.Status, Info = result.Info, Data = result.Data });
  507. }
  508. public AppResultJson DeleteDo(string value)
  509. {
  510. JsonData data = JsonMapper.ToObject(value);
  511. int Id = int.Parse(function.CheckInt(data["Id"].ToString()));
  512. int UserId = int.Parse(function.CheckInt(data["UserId"].ToString())); //所属创客
  513. Dictionary<string, object> Obj = new Dictionary<string, object>();
  514. MerchantInfo edit = maindb.MerchantInfo.FirstOrDefault(m => m.Id == Id && m.UserId == UserId);
  515. if(edit != null)
  516. {
  517. maindb.MerchantInfo.Remove(edit);
  518. MerchantAddInfo editadd = maindb.MerchantAddInfo.FirstOrDefault(m => m.Id == Id);
  519. if(editadd != null)
  520. {
  521. maindb.MerchantAddInfo.Remove(editadd);
  522. }
  523. maindb.SaveChanges();
  524. }
  525. return new AppResultJson() { Status = "1", Info = "", Data = Obj };
  526. }
  527. #endregion
  528. #region 创客-首页-暂存商户
  529. [Authorize]
  530. public JsonResult TmpMerchantList(string value)
  531. {
  532. value = DesDecrypt(value);
  533. JsonData data = JsonMapper.ToObject(value);
  534. List<Dictionary<string, object>> dataList = TmpMerchantListDo(value);
  535. return Json(new AppResultJson() { Status = "1", Info = "", Data = dataList });
  536. }
  537. public List<Dictionary<string, object>> TmpMerchantListDo(string value)
  538. {
  539. JsonData data = JsonMapper.ToObject(value);
  540. int UserId = int.Parse(function.CheckInt(data["UserId"].ToString())); //所属创客
  541. int PageSize = int.Parse(function.CheckInt(data["PageSize"].ToString()));
  542. int PageNum = int.Parse(function.CheckInt(data["PageNum"].ToString()));
  543. List<Dictionary<string, object>> dataList = new List<Dictionary<string, object>>();
  544. List<MerchantInfo> query = maindb.MerchantInfo.Where(m => m.UserId == UserId && m.Sort == 0).ToList();
  545. foreach (var subdata in query)
  546. {
  547. Dictionary<string, object> curData = new Dictionary<string, object>();
  548. curData.Add("Name", subdata.Name); //名称
  549. curData.Add("Id", subdata.Id); //Id
  550. curData.Add("CreateDate", subdata.CreateDate == null ? "" : subdata.CreateDate.Value.ToString("yyyy-MM-dd HH:mm:ss")); //CreateDate
  551. curData.Add("SubjectType", 1); //主体类型
  552. dataList.Add(curData);
  553. }
  554. return dataList;
  555. }
  556. #endregion
  557. #region 商户-主界面统计数据
  558. [Authorize]
  559. [Route("/v1/workspace/indexstat")]
  560. public JsonResult IndexStat(string value)
  561. {
  562. value = DesDecrypt(value);
  563. JsonData data = JsonMapper.ToObject(value);
  564. Dictionary<string, object> Obj = IndexStatDo(value);
  565. return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
  566. }
  567. public Dictionary<string, object> IndexStatDo(string value)
  568. {
  569. JsonData data = JsonMapper.ToObject(value);
  570. string TimeType = data["TimeType"].ToString(); //时间范围
  571. Dictionary<string, object> Obj = new Dictionary<string, object>();
  572. int Id = int.Parse(function.CheckInt(data["MerchantId"].ToString()));
  573. decimal TotalAmount = 0;
  574. decimal TotalOrder = 0;
  575. int TotalUser = 0;
  576. decimal TotalActual = 0;
  577. DateTime Start = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd") + " 00:00:00");
  578. if (TimeType == "1")
  579. {
  580. Start = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd") + " 00:00:00");
  581. }
  582. else if (TimeType == "2")
  583. {
  584. Start = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd") + " 00:00:00").AddDays(-6);
  585. }
  586. else if (TimeType == "3")
  587. {
  588. Start = DateTime.Parse(DateTime.Now.ToString("yyyy-MM") + "-01 00:00:00");
  589. }
  590. while(Start <= DateTime.Now)
  591. {
  592. Dictionary<string, string> dic = new MerchantAmountSummayService().Sum("TradeAmount,TradeCount,TotalActual", " and MerchantId=" + Id + " and TradeDate='" + Start.ToString("yyyyMMdd") + "'");
  593. TotalAmount += decimal.Parse(dic["TradeAmount"]);
  594. TotalOrder += decimal.Parse(dic["TradeCount"]);
  595. // TotalUser += query.TotalUser;
  596. TotalActual += decimal.Parse(dic["TotalActual"]);
  597. Start = Start.AddDays(1);
  598. }
  599. Obj.Add("TotalAmount", TotalAmount); //营总收益
  600. Obj.Add("TotalOrder", TotalOrder); //累计订单
  601. Obj.Add("TotalUser", TotalUser); //会员数
  602. Obj.Add("TotalActual", TotalActual); //实收总额
  603. MerchantInfo merchant = new MerchantInfoService().Query(Id);
  604. decimal AllocationAmount = merchant.ActMaxAmount - merchant.ActCurrentAmount;
  605. if(AllocationAmount < 0) AllocationAmount = 0;
  606. Obj.Add("AllocationAmount", AllocationAmount); //未分配活动金额
  607. return Obj;
  608. }
  609. #endregion
  610. #region 商户-修改登录密码
  611. [Authorize]
  612. public JsonResult ModifyLoginPwd(string value)
  613. {
  614. value = DesDecrypt(value);
  615. JsonData data = JsonMapper.ToObject(value);
  616. AppResultJson result = ModifyLoginPwdDo(value);
  617. return Json(new AppResultJson() { Status = result.Status, Info = result.Info, Data = result.Data });
  618. }
  619. public AppResultJson ModifyLoginPwdDo(string value)
  620. {
  621. JsonData data = JsonMapper.ToObject(value);
  622. string LoginPwd = data["LoginPwd"].ToString(); //登录密码
  623. string NewLoginPwd = data["NewLoginPwd"].ToString(); //新登录密码
  624. Dictionary<string, object> Obj = new Dictionary<string, object>();
  625. MerchantInfo query = new MerchantInfo();
  626. int Id = int.Parse(function.CheckInt(data["Id"].ToString()));
  627. query = MerchantInfoDbconn.Instance.Get(Id);
  628. if (query != null)
  629. {
  630. query.UpdateDate = DateTime.Now; //修改时间
  631. query.LoginPwd = LoginPwd; //登录密码
  632. }
  633. return new AppResultJson() { Status = "1", Info = "", Data = Obj };
  634. }
  635. #endregion
  636. #region 商户-商户统计数据(个人中心主界面)
  637. [Authorize]
  638. public JsonResult StatData(string value)
  639. {
  640. value = DesDecrypt(value);
  641. JsonData data = JsonMapper.ToObject(value);
  642. Dictionary<string, object> Obj = StatDataDo(value);
  643. return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
  644. }
  645. public Dictionary<string, object> StatDataDo(string value)
  646. {
  647. JsonData data = JsonMapper.ToObject(value);
  648. Dictionary<string, object> Obj = new Dictionary<string, object>();
  649. int Id = int.Parse(function.CheckInt(data["Id"].ToString()));
  650. MerchantInfo query = MerchantInfoDbconn.Instance.Get(Id) ?? new MerchantInfo();
  651. Obj.Add("Name", query.Name); //名称
  652. Obj.Add("TotalAmount", query.TotalAmount.ToString("f2")); //营收总金额
  653. Obj.Add("TotalActual", query.TotalActual.ToString("f2")); //实收总金额
  654. Obj.Add("TotalOrder", query.TotalConsumeCount); //累计订单
  655. Obj.Add("TotalCustomer", query.TotalCustomer); //累计客户
  656. Obj.Add("Logo", DefaultPic(query.Logo)); //Logo图片
  657. int ConsumeCount = 0;
  658. decimal WeChatTotal = 0;
  659. decimal AlipayTotal = 0;
  660. for (int i = 0; i < 7; i++)
  661. {
  662. string Date = DateTime.Now.AddDays(-i).ToString("yyyyMMdd");
  663. // ConsumeCount += 0;
  664. WeChatTotal += MerchantAmountSummary.Instance.GetActualTradeByMode(Id, 2, Date);
  665. AlipayTotal += MerchantAmountSummary.Instance.GetActualTradeByMode(Id, 1, Date);
  666. }
  667. Obj.Add("SevenDayConsumer", ConsumeCount); //近7日新增会员
  668. Obj.Add("WeChatTotal", WeChatTotal.ToString("f2")); //微信实收
  669. Obj.Add("AlipayTotal", AlipayTotal.ToString("f2")); //支付宝实收
  670. Obj.Add("CreateDate", query.CreateDate == null ? "" : query.CreateDate.Value.ToString("yyyy-MM-dd"));
  671. string yesterday = DateTime.Now.AddDays(-1).ToString("yyyyMMdd");
  672. Obj.Add("YesterDayActual", decimal.Parse(function.CheckNum(UserTradeDbconn.Instance.GetTrade(Id, yesterday, "InFactAmount")["InFactAmount"].ToString())).ToString("f2")); //昨日收入
  673. Obj.Add("SettleAmount", ""); //待结算金额
  674. return Obj;
  675. }
  676. #endregion
  677. #region 商户-商户详情
  678. [Authorize]
  679. public JsonResult Detail(string value)
  680. {
  681. value = DesDecrypt(value);
  682. JsonData data = JsonMapper.ToObject(value);
  683. Dictionary<string, object> Obj = DetailDo(value);
  684. return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
  685. }
  686. public Dictionary<string, object> DetailDo(string value)
  687. {
  688. JsonData data = JsonMapper.ToObject(value);
  689. Dictionary<string, object> Obj = new Dictionary<string, object>();
  690. int Id = int.Parse(function.CheckInt(data["Id"].ToString()));
  691. MerchantInfo query = MerchantInfoDbconn.Instance.Get(Id) ?? new MerchantInfo();
  692. MerchantAddInfo merchantAddInfo = maindb.MerchantAddInfo.FirstOrDefault(m => m.Id == Id) ?? new MerchantAddInfo();
  693. Obj.Add("Name", query.Name); //名称
  694. Obj.Add("Mobile", query.Mobile); //手机号
  695. Obj.Add("IsAuth", query.IsAuth); //是否认证
  696. Obj.Add("Logo", DefaultPic(query.Logo)); //Logo图片
  697. Obj.Add("Status", GetMainStatusName(merchantAddInfo.QueryCount, merchantAddInfo.Status));
  698. Obj.Add("AlipayStatus", merchantAddInfo.QueryCount);
  699. Obj.Add("WeChatStatus", merchantAddInfo.Status);
  700. Obj.Add("CreateDate", query.CreateDate == null ? "" : query.CreateDate.Value.ToString("yyyy-MM-dd"));
  701. return Obj;
  702. }
  703. private string GetMainStatusName(int AlipayStatus, int WeChatStatus)
  704. {
  705. if(AlipayStatus == 0 && WeChatStatus == 0) return "待审核";
  706. if(AlipayStatus == 0 && WeChatStatus == -1) return "部分未通过";
  707. if(AlipayStatus == -1 && WeChatStatus == 0) return "部分未通过";
  708. if(AlipayStatus == 0 && WeChatStatus == 1) return "部分待签约";
  709. if(AlipayStatus == 1 && WeChatStatus == 0) return "部分待签约";
  710. if(AlipayStatus == 0 && WeChatStatus == 2) return "部分已通过";
  711. if(AlipayStatus == 2 && WeChatStatus == 0) return "部分已通过";
  712. if(AlipayStatus == -1 && WeChatStatus == -1) return "审核未通过";
  713. if(AlipayStatus == -1 && WeChatStatus == 1) return "部分未通过";
  714. if(AlipayStatus == 1 && WeChatStatus == -1) return "部分未通过";
  715. if(AlipayStatus == -1 && WeChatStatus == 2) return "部分未通过";
  716. if(AlipayStatus == 2 && WeChatStatus == -1) return "部分未通过";
  717. if(AlipayStatus == 1 && WeChatStatus == 1) return "待签约";
  718. if(AlipayStatus == 1 && WeChatStatus == 2) return "部分待签约";
  719. if(AlipayStatus == 2 && WeChatStatus == 1) return "部分待签约";
  720. if(AlipayStatus == 2 && WeChatStatus == 2) return "已通过";
  721. return "";
  722. }
  723. private string GetStatusName(int WeChatStatus)
  724. {
  725. if(WeChatStatus == -1) return "审核未通过";
  726. if(WeChatStatus == 0) return "待审核";
  727. if(WeChatStatus == 1) return "待签约";
  728. if(WeChatStatus == 2) return "已通过";
  729. return "";
  730. }
  731. #endregion
  732. #region 商户-通过sn获取商户详情
  733. [Authorize]
  734. public JsonResult DetailBySn(string value)
  735. {
  736. if (string.IsNullOrEmpty(value))
  737. {
  738. System.IO.StreamReader sr = new System.IO.StreamReader(Request.Body);
  739. value = sr.ReadToEnd();
  740. value = value.Split('=')[1];
  741. }
  742. value = DesDecrypt(value);
  743. JsonData data = JsonMapper.ToObject(value);
  744. Dictionary<string, object> Obj = DetailBySnDo(value);
  745. return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
  746. }
  747. public Dictionary<string, object> DetailBySnDo(string value)
  748. {
  749. function.WriteLog(value, "商户-通过sn获取商户详情");
  750. JsonData data = JsonMapper.ToObject(value);
  751. Dictionary<string, object> Obj = new Dictionary<string, object>();
  752. string Sn = data["Sn"].ToString();
  753. string Machine = data["Machine"].ToString();
  754. if(Sn.Length > 20)
  755. {
  756. Sn = System.Web.HttpUtility.UrlDecode(Sn);
  757. if(!Sn.EndsWith("="))
  758. {
  759. Sn += "=";
  760. }
  761. Sn = dbconn.Decrypt3DES(Sn, "l2k0b2#3");
  762. Sn = Sn.TrimEnd('\0');
  763. Sn = Sn.Substring(0, Sn.Length - 8);
  764. }
  765. if(Machine == Sn)
  766. {
  767. MerchantQrCode code = new MerchantQrCodeService().Query(Sn);
  768. MerchantInfo query = new MerchantInfoService().Query(code.MerchantId);
  769. MerchantParamSet set = new MerchantParamSetService().Query(code.MerchantId);
  770. Obj.Add("Name", query.Name); //名称
  771. Obj.Add("Mobile", query.Mobile); //手机号
  772. Obj.Add("IsAuth", query.IsAuth); //是否认证
  773. Obj.Add("Logo", DefaultPic(query.Logo)); //Logo图片
  774. Obj.Add("DiviPercent", set.IsAll == 1 ? 0M : set.DiviPercent);
  775. Obj.Add("MinPayMoney", set.MinPayMoney);
  776. }
  777. else
  778. {
  779. PosMachines machine = new PosMachinesService().Query(Sn);
  780. MainModels2.MerchantInfo query = new MerchantInfo2Service().Query(machine.BindMerchantId);
  781. MainModels2.MerchantParamSet set = new MerchantParamSet2Service().Query(machine.BindMerchantId);
  782. Obj.Add("Name", query.Name); //名称
  783. Obj.Add("Mobile", query.Mobile); //手机号
  784. Obj.Add("IsAuth", query.IsAuth); //是否认证
  785. Obj.Add("Logo", DefaultPic(query.Logo)); //Logo图片
  786. Obj.Add("DiviPercent", set.IsAll == 1 ? 0M : set.DiviPercent);
  787. Obj.Add("MinPayMoney", set.MinPayMoney);
  788. }
  789. return Obj;
  790. }
  791. #endregion
  792. #region 商户-忘记密码
  793. // [Authorize]
  794. public JsonResult ForgetPwd(string value)
  795. {
  796. value = DesDecrypt(value);
  797. JsonData data = JsonMapper.ToObject(value);
  798. AppResultJson result = ForgetPwdDo(value);
  799. return Json(new AppResultJson() { Status = result.Status, Info = result.Info, Data = result.Data });
  800. }
  801. public AppResultJson ForgetPwdDo(string value)
  802. {
  803. JsonData data = JsonMapper.ToObject(value);
  804. string Mobile = data["Mobile"].ToString(); //手机号
  805. string LoginPwd = data["LoginPwd"].ToString(); //登录密码
  806. string MobileCode = data["MobileCode"].ToString(); //短信验证码
  807. if (string.IsNullOrEmpty(data["Mobile"].ToString()))
  808. {
  809. return new AppResultJson() { Status = "-1", Info = "请填写手机号" };
  810. }
  811. if (data["Mobile"].ToString().Length > 11)
  812. {
  813. return new AppResultJson() { Status = "-1", Info = "手机号最多11个字符" };
  814. }
  815. MobileCodeCheck mobilecheck = RedisDbconn.Instance.Get<MobileCodeCheck>("MobileCodeCheck:" + Mobile);
  816. if (mobilecheck == null)
  817. {
  818. return new AppResultJson() { Status = "-1", Info = "短信验证码不正确" };
  819. }
  820. if (mobilecheck.CheckCode != MobileCode)
  821. {
  822. return new AppResultJson() { Status = "-1", Info = "短信验证码不正确" };
  823. }
  824. RedisDbconn.Instance.Clear("MobileCodeCheck:" + Mobile);
  825. Dictionary<string, object> Obj = new Dictionary<string, object>();
  826. // MerchantForMobile find = new MerchantForMobileService().Query(Mobile);
  827. // if (find == null)
  828. // {
  829. // return new AppResultJson() { Status = "-1", Info = "手机号不正确" };
  830. // }
  831. // MerchantInfo query = maindb.MerchantInfo.FirstOrDefault(m => m.Id == find.MerchantId);
  832. // if (query != null)
  833. // {
  834. // query.LoginPwd = function.MD532(LoginPwd); //登录密码
  835. // maindb.SaveChanges();
  836. // }
  837. MerchantLoginInfo query = maindb.MerchantLoginInfo.FirstOrDefault(m => m.LoginMobile == Mobile);
  838. if (query == null)
  839. {
  840. return new AppResultJson() { Status = "-1", Info = "手机号不正确" };
  841. }
  842. query.LoginPwd = function.MD532(LoginPwd); //登录密码
  843. maindb.SaveChanges();
  844. return new AppResultJson() { Status = "1", Info = "", Data = Obj };
  845. }
  846. #endregion
  847. #region 商户-登录
  848. // [Authorize]
  849. public JsonResult Login(string value)
  850. {
  851. value = DesDecrypt(value);
  852. JsonData data = JsonMapper.ToObject(value);
  853. string Mobile = data["Mobile"].ToString(); //手机号
  854. string LoginPwd = data["LoginPwd"].ToString(); //登录密码
  855. Dictionary<string, object> Obj = new Dictionary<string, object>();
  856. if (Mobile == "13802211996")
  857. {
  858. if (LoginPwd != "kxs2022")
  859. {
  860. return Json(new AppResultJson() { Status = "-1", Info = "登录密码不正确" });
  861. }
  862. Obj.Add("Id", 1);
  863. Obj.Add("Token", PublicFunction.AppToken(1, JwtSecret, JwtIss, "merchant"));
  864. return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
  865. }
  866. MerchantLoginInfo query = new MerchantLoginInfoService().Query(Mobile, function.MD532(LoginPwd));
  867. if (query.Id == 0)
  868. {
  869. return Json(new AppResultJson() { Status = "-1", Info = "手机号或登录密码不正确" });
  870. }
  871. Obj.Add("Id", query.Id); //Id
  872. Obj.Add("Token", PublicFunction.AppToken(query.Id, JwtSecret, JwtIss, "merchant"));
  873. Obj.Add("MerchantList", new MerchantAccountLinkInfoService().List(query.Id));
  874. return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
  875. }
  876. #endregion
  877. #region 检查签名是否合法,合法返回1,不合法返回提示信息
  878. /// <summary>
  879. /// 检查签名是否合法,合法返回1,不合法返回提示信息
  880. /// </summary>
  881. /// <param name="value">请求的参数(json字符串)</param>
  882. /// <param name="signField">要签名的字段</param>
  883. /// <returns></returns>
  884. private string CheckSign(string value, string[] signField)
  885. {
  886. JsonData json = JsonMapper.ToObject(value);
  887. Dictionary<string, string> dic = new Dictionary<string, string>();
  888. for (int i = 0; i < signField.Length; i++)
  889. {
  890. dic.Add(signField[i], json[signField[i]].ToString());
  891. }
  892. string sign = json["sign"].ToString(); //客户端签名字符串
  893. return new Sign().sign(dic, sign);
  894. }
  895. #endregion
  896. }
  897. }