MerchantInfoController.cs 50 KB

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