PosMachinesController.cs 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using Microsoft.AspNetCore.Mvc;
  5. using Microsoft.AspNetCore.Http;
  6. using Microsoft.Extensions.Logging;
  7. using Microsoft.Extensions.Options;
  8. using Microsoft.AspNetCore.Authorization;
  9. using System.Web;
  10. using MySystem.MainModels;
  11. using LitJson;
  12. using Library;
  13. namespace MySystem.Areas.Api.Controllers.v1.pos
  14. {
  15. [Area("Api")]
  16. [Route("Api/v1/pos/[controller]/[action]")]
  17. public class PosMachinesController : BaseController
  18. {
  19. public PosMachinesController(IHttpContextAccessor accessor, ILogger<BaseController> logger, IOptions<Setting> setting) : base(accessor, logger, setting)
  20. {
  21. }
  22. #region 首页-客小爽产品-机具管理-已绑定机具列表
  23. [Authorize]
  24. public JsonResult MyMachinesForBind(string value)
  25. {
  26. value = DesDecrypt(value);
  27. JsonData data = JsonMapper.ToObject(value);
  28. Dictionary<string, object> Other = new Dictionary<string, object>();
  29. List<Dictionary<string, object>> dataList = MyMachinesForBindDo(value, out Other);
  30. return Json(new AppResultJson() { Status = "1", Info = "", Data = dataList, Other = Other });
  31. }
  32. public List<Dictionary<string, object>> MyMachinesForBindDo(string value, out Dictionary<string, object> Other)
  33. {
  34. JsonData data = JsonMapper.ToObject(value);
  35. int UserId = int.Parse(function.CheckInt(data["UserId"].ToString())); //所属创客
  36. int BrandId = int.Parse(function.CheckInt(data["BrandId"].ToString())); //产品类型
  37. string SnNo = data["SnNo"].ToString(); //SN号
  38. int PageSize = int.Parse(function.CheckInt(data["PageSize"].ToString()));
  39. int PageNum = int.Parse(function.CheckInt(data["PageNum"].ToString()));
  40. List<Dictionary<string, object>> dataList = new List<Dictionary<string, object>>();
  41. if (!string.IsNullOrEmpty(SnNo))
  42. {
  43. PageSize = 100000;
  44. }
  45. IQueryable<PosMachinesTwo> query = maindb.PosMachinesTwo.Where(m => m.Status > -1 && m.BuyUserId == UserId && m.BrandId == BrandId && m.BindingState == 1);
  46. if (!string.IsNullOrEmpty(SnNo))
  47. {
  48. query = query.Where(m => m.PosSn == SnNo);
  49. }
  50. Other = new Dictionary<string, object>();
  51. if (PageNum == 1)
  52. {
  53. Other.Add("count", query.Count());
  54. query = query.Take(PageSize);
  55. }
  56. else
  57. {
  58. int skipNum = PageSize * (PageNum - 1);
  59. query = query.Skip(skipNum).Take(PageSize);
  60. }
  61. foreach (var subdata in query.ToList())
  62. {
  63. Dictionary<string, object> curData = new Dictionary<string, object>();
  64. int IsLeader = 0;//是否为大盟主机(0-否 1-是)
  65. if (subdata.LeaderUserId > 0)
  66. {
  67. IsLeader = 1;
  68. }
  69. else
  70. {
  71. IsLeader = 0;
  72. }
  73. curData.Add("ActivationState", subdata.ActivationState == 1 ? "已激活" : "未激活"); //激活状态
  74. curData.Add("PosSn", subdata.PosSn); //SN编号
  75. curData.Add("PosSnType", RelationClass.GetPosSnTypeInfo(subdata.PosSnType)); //机具类型
  76. curData.Add("Id", subdata.Id); //Id
  77. decimal Deposit = 299;
  78. if (BrandId == 6)
  79. {
  80. Deposit = 249;
  81. }
  82. if (!string.IsNullOrEmpty(subdata.PrizeParams))
  83. {
  84. Deposit = decimal.Parse(function.CheckNum(subdata.PrizeParams));
  85. }
  86. curData.Add("Deposit", Deposit);
  87. curData.Add("BindedMerchant", subdata.BuyUserId != subdata.UserId ? 1 : 0); //是否已绑定商户型创客
  88. curData.Add("IsLeader",IsLeader);
  89. dataList.Add(curData);
  90. }
  91. return dataList;
  92. }
  93. #endregion
  94. #region 首页-客小爽产品-机具管理-总机具列表
  95. [Authorize]
  96. public JsonResult MyMachines(string value)
  97. {
  98. value = DesDecrypt(value);
  99. JsonData data = JsonMapper.ToObject(value);
  100. Dictionary<string, object> Other = new Dictionary<string, object>();
  101. List<Dictionary<string, object>> dataList = MyMachinesDo(value, out Other);
  102. return Json(new AppResultJson() { Status = "1", Info = "", Data = dataList, Other = Other });
  103. }
  104. public List<Dictionary<string, object>> MyMachinesDo(string value, out Dictionary<string, object> Other)
  105. {
  106. JsonData data = JsonMapper.ToObject(value);
  107. int UserId = int.Parse(function.CheckInt(data["UserId"].ToString())); //所属创客
  108. int BrandId = int.Parse(function.CheckInt(data["BrandId"].ToString())); //产品类型
  109. string SnNo = data["SnNo"].ToString(); //SN号
  110. int PageSize = int.Parse(function.CheckInt(data["PageSize"].ToString()));
  111. int PageNum = int.Parse(function.CheckInt(data["PageNum"].ToString()));
  112. List<Dictionary<string, object>> dataList = new List<Dictionary<string, object>>();
  113. if (!string.IsNullOrEmpty(SnNo))
  114. {
  115. PageSize = 100000;
  116. }
  117. IQueryable<PosMachinesTwo> query = maindb.PosMachinesTwo.Where(m => m.Status > -1 && m.BuyUserId == UserId && m.BrandId == BrandId);
  118. if (!string.IsNullOrEmpty(SnNo))
  119. {
  120. query = query.Where(m => m.PosSn == SnNo);
  121. }
  122. Other = new Dictionary<string, object>();
  123. if (PageNum == 1)
  124. {
  125. Other.Add("count", query.Count());
  126. query = query.Take(PageSize);
  127. }
  128. else
  129. {
  130. int skipNum = PageSize * (PageNum - 1);
  131. query = query.Skip(skipNum).Take(PageSize);
  132. }
  133. foreach (var subdata in query.ToList())
  134. {
  135. Dictionary<string, object> curData = new Dictionary<string, object>();
  136. int IsLeader = 0;//是否为大盟主机(0-否 1-是)
  137. if (subdata.LeaderUserId > 0)
  138. {
  139. IsLeader = 1;
  140. }
  141. else
  142. {
  143. IsLeader = 0;
  144. }
  145. curData.Add("PosSn", subdata.PosSn); //SN编号
  146. curData.Add("PosSnType", RelationClass.GetPosSnTypeInfo(subdata.PosSnType)); //机具类型
  147. curData.Add("Id", subdata.Id); //Id
  148. curData.Add("CreateDate", subdata.TransferTime == null ? "" : subdata.TransferTime.Value.ToString("yyyy-MM-dd HH:mm:ss")); //CreateDate
  149. StoreHouse store = StoreHouseDbconn.Instance.Get(subdata.StoreId) ?? new StoreHouse();
  150. curData.Add("FromStore", store.StoreName); //来自仓库
  151. decimal Deposit = 299;
  152. if (BrandId == 6)
  153. {
  154. Deposit = 249;
  155. }
  156. if (!string.IsNullOrEmpty(subdata.PrizeParams))
  157. {
  158. Deposit = decimal.Parse(function.CheckNum(subdata.PrizeParams));
  159. }
  160. curData.Add("Deposit", Deposit);
  161. curData.Add("IsLeader",IsLeader);
  162. dataList.Add(curData);
  163. }
  164. return dataList;
  165. }
  166. #endregion
  167. #region 首页-客小爽产品-机具管理-未绑定机具列表
  168. [Authorize]
  169. public JsonResult MyMachinesForUnBind(string value)
  170. {
  171. value = DesDecrypt(value);
  172. JsonData data = JsonMapper.ToObject(value);
  173. Dictionary<string, object> Other = new Dictionary<string, object>();
  174. List<Dictionary<string, object>> dataList = MyMachinesForUnBindDo(value, out Other);
  175. return Json(new AppResultJson() { Status = "1", Info = "", Data = dataList, Other = Other });
  176. }
  177. public List<Dictionary<string, object>> MyMachinesForUnBindDo(string value, out Dictionary<string, object> Other)
  178. {
  179. JsonData data = JsonMapper.ToObject(value);
  180. int UserId = int.Parse(function.CheckInt(data["UserId"].ToString())); //所属创客
  181. int BrandId = int.Parse(function.CheckInt(data["BrandId"].ToString())); //产品类型
  182. string SnNo = data["SnNo"].ToString(); //SN号
  183. int PageSize = int.Parse(function.CheckInt(data["PageSize"].ToString()));
  184. int PageNum = int.Parse(function.CheckInt(data["PageNum"].ToString()));
  185. List<Dictionary<string, object>> dataList = new List<Dictionary<string, object>>();
  186. if (!string.IsNullOrEmpty(SnNo))
  187. {
  188. PageSize = 100000;
  189. }
  190. IQueryable<PosMachinesTwo> query = maindb.PosMachinesTwo.Where(m => m.Status > -1 && m.BuyUserId == UserId && m.BrandId == BrandId && m.BindingState == 0);
  191. if (!string.IsNullOrEmpty(SnNo))
  192. {
  193. query = query.Where(m => m.PosSn == SnNo && m.PosSnType == 0);
  194. }
  195. Other = new Dictionary<string, object>();
  196. if (PageNum == 1)
  197. {
  198. Other.Add("count", query.Count());
  199. query = query.Take(PageSize);
  200. }
  201. else
  202. {
  203. int skipNum = PageSize * (PageNum - 1);
  204. query = query.Skip(skipNum).Take(PageSize);
  205. }
  206. foreach (var subdata in query.ToList())
  207. {
  208. Dictionary<string, object> curData = new Dictionary<string, object>();
  209. int IsLeader = 0;//是否为大盟主机(0-否 1-是)
  210. if (subdata.LeaderUserId > 0)
  211. {
  212. IsLeader = 1;
  213. }
  214. else
  215. {
  216. IsLeader = 0;
  217. }
  218. curData.Add("PosSn", subdata.PosSn); //SN编号
  219. curData.Add("PosSnType", RelationClass.GetPosSnTypeInfo(subdata.PosSnType)); //机具类型
  220. curData.Add("Id", subdata.Id); //Id
  221. if (subdata.RecycEndDate != null)
  222. {
  223. TimeSpan ts = subdata.RecycEndDate.Value - DateTime.Now;
  224. curData.Add("ActDays", ts.TotalDays.ToString("f0")); //活动剩余天数
  225. }
  226. else
  227. {
  228. curData.Add("ActDays", 0); //活动剩余天数
  229. }
  230. curData.Add("CreateDate", subdata.CreateDate.Value.ToString("yyyy-MM-dd")); //机具初始日期
  231. curData.Add("EndDate", subdata.RecycEndDate == null ? "" : subdata.RecycEndDate.Value.ToString("yyyy-MM-dd")); //截止日期
  232. decimal Deposit = 299;
  233. if (BrandId == 6)
  234. {
  235. Deposit = 249;
  236. }
  237. if (!string.IsNullOrEmpty(subdata.PrizeParams))
  238. {
  239. Deposit = decimal.Parse(function.CheckNum(subdata.PrizeParams));
  240. }
  241. curData.Add("Deposit", Deposit);
  242. curData.Add("IsLeader",IsLeader);
  243. dataList.Add(curData);
  244. }
  245. return dataList;
  246. }
  247. #endregion
  248. #region 首页-客小爽产品-机具管理-已绑定机具列表-设置商户型创客(立刷)
  249. [Authorize]
  250. public JsonResult SetMerchantMaker(string value)
  251. {
  252. //TODO: 要做一下判断机具是否是当前操作人本人
  253. value = DesDecrypt(value);
  254. JsonData data = JsonMapper.ToObject(value);
  255. int SnId = int.Parse(function.CheckInt(data["SnId"].ToString()));
  256. int UserId = int.Parse(function.CheckInt(data["UserId"].ToString()));
  257. Users user = maindb.Users.FirstOrDefault(m => m.Id == UserId);
  258. if (user != null)
  259. {
  260. if (user.MerchantType == 1)
  261. {
  262. return Json(new AppResultJson() { Status = "-1", Info = "创客" + user.MakerCode + "已是商户型创客,请勿重复设置" });
  263. }
  264. if (user.AuthFlag != 1)
  265. {
  266. return Json(new AppResultJson() { Status = "-1", Info = "创客" + user.MakerCode + "未实名认证" });
  267. }
  268. bool checkPos = maindb.PosMachinesTwo.Any(m => m.Status > -1 && m.UserId == user.Id);
  269. if (checkPos)
  270. {
  271. return Json(new AppResultJson() { Status = "-1", Info = "创客" + user.MakerCode + "已拥有机具" });
  272. }
  273. PosMachinesTwo pos = maindb.PosMachinesTwo.FirstOrDefault(m => m.Status > -1 && m.Id == SnId);
  274. if (pos != null)
  275. {
  276. if (!function.CheckNull(user.ParentNav).Contains("," + pos.BuyUserId + ","))
  277. {
  278. return Json(new AppResultJson() { Status = "-1", Info = "创客" + user.MakerCode + "不在您可操作的系统内" });
  279. }
  280. pos.UserId = user.Id;
  281. user.MerchantType = 1;
  282. string MerNo = "";
  283. PosMerchantInfo merchant = maindb.PosMerchantInfo.FirstOrDefault(m => m.Id == pos.BindMerchantId);
  284. if (merchant != null)
  285. {
  286. merchant.UserId = user.Id;
  287. merchant.MerUserType = 1;
  288. MerNo = merchant.MerchantName;
  289. }
  290. pos.SeoTitle = user.Id.ToString(); // 记录商户型创客的Id
  291. maindb.SetMerchantTypeRecord.Add(new SetMerchantTypeRecord()
  292. {
  293. CreateDate = DateTime.Now,
  294. IsRecyc = (ulong)pos.IsPurchase,
  295. CreditAmount = pos.CreditTrade,
  296. PosSnType = pos.PosSnType,
  297. ActDate = pos.ActivationTime,
  298. BindDate = pos.BindingTime,
  299. ActStatus = (ulong)pos.ActivationState,
  300. BindStatus = (ulong)pos.BindingState,
  301. MerNo = MerNo,
  302. PosSn = pos.PosSn,
  303. Note = "设置商户型创客",
  304. ToUserId = user.Id,
  305. FromUserId = pos.BuyUserId,
  306. });
  307. maindb.SaveChanges();
  308. }
  309. }
  310. return Json(new AppResultJson() { Status = "1", Info = "" });
  311. }
  312. #endregion
  313. #region 首页-客小爽产品-机具管理-已绑定机具列表-设置商户型创客(无创客编号)
  314. [Authorize]
  315. public JsonResult SetMerchantMakerWithoutUser(string value)
  316. {
  317. value = DesDecrypt(value);
  318. JsonData data = JsonMapper.ToObject(value);
  319. int SnId = int.Parse(function.CheckInt(data["SnId"].ToString()));
  320. int UserId = int.Parse(function.CheckInt(data["UserId"].ToString()));
  321. string path = function.CreateQRCode2(SourceHost + "/p/user-inviteregist-1?Id=" + UserId + "&SnId=" + SnId, function.MD5_16(SnId.ToString()), "/static/MerQrCode/");
  322. path = path.Replace("//", "/");
  323. return Json(new AppResultJson() { Status = "1", Info = "", Data = SourceHost + path });
  324. }
  325. #endregion
  326. #region 首页-客小爽产品-机具管理-整箱划拨搜索
  327. [Authorize]
  328. public JsonResult WholeSearchByUser(string value)
  329. {
  330. value = DesDecrypt(value);
  331. JsonData data = JsonMapper.ToObject(value);
  332. List<Dictionary<string, object>> dataList = WholeSearchByUserDo(value);
  333. return Json(new AppResultJson() { Status = "1", Info = "", Data = dataList });
  334. }
  335. public List<Dictionary<string, object>> WholeSearchByUserDo(string value)
  336. {
  337. JsonData data = JsonMapper.ToObject(value);
  338. int UserId = int.Parse(function.CheckInt(data["UserId"].ToString())); //所在仓库
  339. int BrandId = int.Parse(function.CheckInt(data["BrandId"].ToString()));
  340. int BrandSubId = int.Parse(function.CheckInt(data["BrandSubId"].ToString()));
  341. string SnNo = data["SnNo"].ToString(); //搜索关键词
  342. int PageSize = int.Parse(function.CheckInt(data["PageSize"].ToString()));
  343. int PageNum = int.Parse(function.CheckInt(data["PageNum"].ToString()));
  344. List<Dictionary<string, object>> dataList = new List<Dictionary<string, object>>();
  345. if (string.IsNullOrEmpty(SnNo))
  346. {
  347. return dataList;
  348. }
  349. List<MachineForSnNo> MachineSnNos = maindb.MachineForSnNo.Where(m => m.SnNo.Contains(SnNo)).ToList();
  350. List<int> SnIds = MachineSnNos.Select(m => m.SnId).ToList();
  351. List<PosMachinesTwo> query = maindb.PosMachinesTwo.Where(m => SnIds.Contains(m.Id) && m.Status > -1 && m.BuyUserId == UserId && m.BrandId == BrandId && m.BindingState == 0 && m.ActivationState == 0 && m.PreUserId == 0).OrderBy(m => m.PosSn).ToList();
  352. foreach (var subdata in query)
  353. {
  354. Dictionary<string, object> curData = new Dictionary<string, object>();
  355. curData.Add("PosSn", subdata.PosSn); //SN编号
  356. curData.Add("Id", subdata.Id); //Id
  357. curData.Add("ProductType", RelationClass.GetKqProductBrandInfo(subdata.BrandId)); //产品类型
  358. int day = 0;
  359. if (subdata.RecycEndDate != null)
  360. {
  361. TimeSpan ts = subdata.RecycEndDate.Value - DateTime.Now;
  362. day = ts.Days;
  363. }
  364. curData.Add("ActDays", day);
  365. curData.Add("EndDate", subdata.RecycEndDate == null ? "" : subdata.RecycEndDate.Value.ToString("yyyy-MM-dd"));
  366. dataList.Add(curData);
  367. }
  368. return dataList;
  369. }
  370. #endregion
  371. #region 首页-仓库管理-整箱划拨搜索
  372. [Authorize]
  373. public JsonResult WholeSearch(string value)
  374. {
  375. value = DesDecrypt(value);
  376. JsonData data = JsonMapper.ToObject(value);
  377. List<Dictionary<string, object>> dataList = WholeSearchDo(value);
  378. return Json(new AppResultJson() { Status = "1", Info = "", Data = dataList });
  379. }
  380. public List<Dictionary<string, object>> WholeSearchDo(string value)
  381. {
  382. JsonData data = JsonMapper.ToObject(value);
  383. int StoreId = int.Parse(function.CheckInt(data["StoreId"].ToString())); //所在仓库
  384. int BrandId = int.Parse(function.CheckInt(data["BrandId"].ToString()));
  385. string SearchKey = data["SearchKey"].ToString(); //搜索关键词
  386. int PageSize = int.Parse(function.CheckInt(data["PageSize"].ToString()));
  387. int PageNum = int.Parse(function.CheckInt(data["PageNum"].ToString()));
  388. List<Dictionary<string, object>> dataList = new List<Dictionary<string, object>>();
  389. if (string.IsNullOrEmpty(SearchKey))
  390. {
  391. return dataList;
  392. }
  393. List<string> SnNos = new List<string>();
  394. int start = int.Parse(SearchKey.Substring(SearchKey.Length - 4));
  395. for (int i = start; i < start + 100; i++)
  396. {
  397. string EndNo = i.ToString();
  398. for (int j = 0; j < 4 - i.ToString().Length; j++)
  399. {
  400. EndNo = "0" + EndNo;
  401. }
  402. string SnNo = SearchKey.Substring(0, SearchKey.Length - 4) + EndNo;
  403. SnNos.Add(SnNo);
  404. }
  405. List<MachineForSnNo> MachineSnNos = maindb.MachineForSnNo.Where(m => SnNos.Contains(m.SnNo)).ToList();
  406. List<int> SnIds = MachineSnNos.Select(m => m.SnId).ToList();
  407. List<PosMachinesTwo> query = maindb.PosMachinesTwo.Where(m => SnIds.Contains(m.Id) && m.Status > -1 && m.StoreId == StoreId && m.BrandId == BrandId && m.UserId == 0 && m.PosSnType == 0 && m.BindingState == 0 && m.ActivationState == 0 && m.PreUserId == 0).OrderBy(m => m.PosSn).ToList();
  408. foreach (var subdata in query)
  409. {
  410. Dictionary<string, object> curData = new Dictionary<string, object>();
  411. curData.Add("PosSn", subdata.PosSn); //SN编号
  412. curData.Add("Id", subdata.Id); //Id
  413. curData.Add("ProductType", RelationClass.GetKqProductBrandInfo(subdata.BrandId)); //产品类型
  414. dataList.Add(curData);
  415. }
  416. return dataList;
  417. }
  418. #endregion
  419. #region 首页-仓库管理-逐台划拨搜索
  420. [Authorize]
  421. public JsonResult OneSearch(string value)
  422. {
  423. value = DesDecrypt(value);
  424. JsonData data = JsonMapper.ToObject(value);
  425. List<Dictionary<string, object>> dataList = OneSearchDo(value);
  426. return Json(new AppResultJson() { Status = "1", Info = "", Data = dataList });
  427. }
  428. public List<Dictionary<string, object>> OneSearchDo(string value)
  429. {
  430. JsonData data = JsonMapper.ToObject(value);
  431. int StoreId = int.Parse(function.CheckInt(data["StoreId"].ToString())); //所在仓库
  432. int BrandId = int.Parse(function.CheckInt(data["BrandId"].ToString()));
  433. string SearchKey = data["SearchKey"].ToString(); //搜索关键词
  434. int PageSize = int.Parse(function.CheckInt(data["PageSize"].ToString()));
  435. int PageNum = int.Parse(function.CheckInt(data["PageNum"].ToString()));
  436. List<Dictionary<string, object>> dataList = new List<Dictionary<string, object>>();
  437. List<PosMachinesTwo> query = maindb.PosMachinesTwo.Where(m => m.Status > -1 && m.StoreId == StoreId && m.BrandId == BrandId && m.UserId == 0 && m.PreUserId == 0).OrderBy(m => m.PosSn).ToList();
  438. if (!string.IsNullOrEmpty(SearchKey))
  439. {
  440. query = query.Where(m => m.PosSn.EndsWith(SearchKey)).ToList();
  441. }
  442. if (PageNum == 1)
  443. {
  444. query = query.Take(PageSize).ToList();
  445. }
  446. else
  447. {
  448. int skipNum = PageSize * (PageNum - 1);
  449. query = query.Skip(skipNum).Take(PageSize).ToList();
  450. }
  451. foreach (var subdata in query)
  452. {
  453. Dictionary<string, object> curData = new Dictionary<string, object>();
  454. curData.Add("PosSn", subdata.PosSn); //SN编号
  455. curData.Add("Id", subdata.Id); //Id
  456. curData.Add("ProductType", RelationClass.GetKqProductBrandInfo(subdata.BrandId)); //产品类型
  457. dataList.Add(curData);
  458. }
  459. return dataList;
  460. }
  461. #endregion
  462. #region 检查签名是否合法,合法返回1,不合法返回提示信息
  463. /// <summary>
  464. /// 检查签名是否合法,合法返回1,不合法返回提示信息
  465. /// </summary>
  466. /// <param name="value">请求的参数(json字符串)</param>
  467. /// <param name="signField">要签名的字段</param>
  468. /// <returns></returns>
  469. private string CheckSign(string value, string[] signField)
  470. {
  471. JsonData json = JsonMapper.ToObject(value);
  472. Dictionary<string, string> dic = new Dictionary<string, string>();
  473. for (int i = 0; i < signField.Length; i++)
  474. {
  475. dic.Add(signField[i], json[signField[i]].ToString());
  476. }
  477. string sign = json["sign"].ToString(); //客户端签名字符串
  478. return new Sign().sign(dic, sign);
  479. }
  480. #endregion
  481. }
  482. }