MerchantInfoController.cs 48 KB

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