StoreChangeHistoryController.cs 3.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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 StoreChangeHistoryController : BaseController
  18. {
  19. public StoreChangeHistoryController(IHttpContextAccessor accessor, ILogger<BaseController> logger, IOptions<Setting> setting) : base(accessor, logger, setting)
  20. {
  21. }
  22. #region 首页-客小爽产品-机具管理-拨出记录
  23. [Authorize]
  24. public JsonResult OutRecords(string value)
  25. {
  26. value = DesDecrypt(value);
  27. JsonData data = JsonMapper.ToObject(value);
  28. List<Dictionary<string, object>> dataList = OutRecordsDo(value);
  29. return Json(new AppResultJson() { Status = "1", Info = "", Data = dataList });
  30. }
  31. public List<Dictionary<string, object>> OutRecordsDo(string value)
  32. {
  33. JsonData data = JsonMapper.ToObject(value);
  34. int UserId = int.Parse(function.CheckInt(data["UserId"].ToString())); //创客
  35. int BrandId = int.Parse(function.CheckInt(data["BrandId"].ToString())); //产品类型
  36. string SnNo = data["SnNo"].ToString(); //SN编号
  37. int PageSize = int.Parse(function.CheckInt(data["PageSize"].ToString()));
  38. int PageNum = int.Parse(function.CheckInt(data["PageNum"].ToString()));
  39. List<Dictionary<string, object>> dataList = new List<Dictionary<string, object>>();
  40. List<UserStoreChange> query = new List<UserStoreChange>();
  41. if (!string.IsNullOrEmpty(SnNo))
  42. {
  43. query = maindb.UserStoreChange.Where(m => m.SnNo == SnNo).ToList();
  44. }
  45. else
  46. {
  47. query = UserStoreChangeDbconn.Instance.GetList(UserId, BrandId, PageNum, PageSize);
  48. }
  49. foreach (var subdata in query)
  50. {
  51. Dictionary<string, object> curData = new Dictionary<string, object>();
  52. curData.Add("SnNo", subdata.SnNo); //SN编号
  53. curData.Add("SnType", RelationClass.GetPosSnTypeInfo(subdata.SnType)); //SN机具类型
  54. curData.Add("FromDate", subdata.FromDate == null ? "" : subdata.FromDate.Value.ToString("yyyy-MM-dd HH:mm:ss")); //出库时间
  55. curData.Add("Id", subdata.Id); //Id
  56. Users user = UsersDbconn.Instance.Get(subdata.ToUserId) ?? new Users();
  57. curData.Add("MakerCode", user.MakerCode); //收货创客编号
  58. curData.Add("MakerName", user.RealName); //收货创客名称
  59. dataList.Add(curData);
  60. }
  61. return dataList;
  62. }
  63. #endregion
  64. #region 检查签名是否合法,合法返回1,不合法返回提示信息
  65. /// <summary>
  66. /// 检查签名是否合法,合法返回1,不合法返回提示信息
  67. /// </summary>
  68. /// <param name="value">请求的参数(json字符串)</param>
  69. /// <param name="signField">要签名的字段</param>
  70. /// <returns></returns>
  71. private string CheckSign(string value, string[] signField)
  72. {
  73. JsonData json = JsonMapper.ToObject(value);
  74. Dictionary<string, string> dic = new Dictionary<string, string>();
  75. for (int i = 0; i < signField.Length; i++)
  76. {
  77. dic.Add(signField[i], json[signField[i]].ToString());
  78. }
  79. string sign = json["sign"].ToString(); //客户端签名字符串
  80. return new Sign().sign(dic, sign);
  81. }
  82. #endregion
  83. }
  84. }