MerchantInfoController.cs 47 KB

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