KqProductsController.cs 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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
  14. {
  15. [Area("Api")]
  16. [Route("Api/v1/[controller]/[action]")]
  17. public class KqProductsController : BaseController
  18. {
  19. public KqProductsController(IHttpContextAccessor accessor, ILogger<BaseController> logger, IOptions<Setting> setting) : base(accessor, logger, setting)
  20. {
  21. }
  22. #region 通用-产品列表
  23. [Authorize]
  24. public JsonResult List(string value)
  25. {
  26. value = DesDecrypt(value);
  27. JsonData data = JsonMapper.ToObject(value);
  28. List<Dictionary<string, object>> dataList = ListDo(value);
  29. return Json(new AppResultJson() { Status = "1", Info = "", Data = dataList });
  30. }
  31. public List<Dictionary<string, object>> ListDo(string value)
  32. {
  33. JsonData data = JsonMapper.ToObject(value);
  34. int PageSize = int.Parse(function.CheckInt(data["PageSize"].ToString()));
  35. int PageNum = int.Parse(function.CheckInt(data["PageNum"].ToString()));
  36. List<Dictionary<string, object>> dataList = new List<Dictionary<string, object>>();
  37. Dictionary<string, object> curData = new Dictionary<string, object>();
  38. curData.Add("Name", "微信"); //名称
  39. curData.Add("Id", "2"); //Id
  40. dataList.Add(curData);
  41. curData = new Dictionary<string, object>();
  42. curData.Add("Name", "支付宝"); //名称
  43. curData.Add("Id", "1"); //Id
  44. dataList.Add(curData);
  45. return dataList;
  46. }
  47. #endregion
  48. #region 首页-客小爽产品-主界面产品数据
  49. [Authorize]
  50. public JsonResult MainStatData(string value)
  51. {
  52. value = DesDecrypt(value);
  53. JsonData data = JsonMapper.ToObject(value);
  54. List<Dictionary<string, object>> Obj = MainStatDataDo(value);
  55. return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
  56. }
  57. public List<Dictionary<string, object>> MainStatDataDo(string value)
  58. {
  59. JsonData data = JsonMapper.ToObject(value);
  60. string UserId = data["UserId"].ToString(); //创客Id
  61. List<Dictionary<string, object>> list = new List<Dictionary<string, object>>();
  62. Dictionary<string, object> Obj = new Dictionary<string, object>();
  63. UserMachineData MachineData = UserMachineDataDbconn.Instance.Get(UserId + "_0") ?? new UserMachineData();
  64. Dictionary<string, object> Machine = new Dictionary<string, object>();
  65. Machine.Add("TotalMachineCount", MachineData.TotalMachineCount); //总机具数
  66. Machine.Add("UnBindCount", MachineData.UnBindCount); //未绑定机具数
  67. Machine.Add("BindCount", MachineData.BindCount); //已绑定机具数
  68. Obj.Add("Machine", Machine); //机具管理数据
  69. Dictionary<string, object> Profit = new Dictionary<string, object>();
  70. Profit.Add("TradeProfit", MachineData.TradeProfit); //交易分润
  71. Profit.Add("ActProfit", MachineData.ActProfit); //激活奖励
  72. Profit.Add("OpenProfit", MachineData.OpenProfit); //开机奖励
  73. Profit.Add("DividendsProfit", MachineData.DividendsProfit); //分红奖励
  74. Profit.Add("OtherProfit", MachineData.OtherProfit); //分润补贴
  75. Profit.Add("FluxProfit", MachineData.FluxProfit); //流量卡分佣
  76. Obj.Add("Profit", Profit); //收益查看数据
  77. List<Dictionary<string, object>> Advertisment = new List<Dictionary<string, object>>();
  78. string ColId = "";
  79. List<Models.Advertisment> ads = AdvertismentDbconn.Instance.GetList(ColId);
  80. foreach (Models.Advertisment ad in ads)
  81. {
  82. Dictionary<string, object> item = new Dictionary<string, object>();
  83. item.Add("Url", ad.Url); //跳转地址
  84. item.Add("BannerPic", DefaultPic(ad.PicPath)); //广告图片
  85. item.Add("Id", ad.Id); //Id
  86. Advertisment.Add(item);
  87. }
  88. Obj.Add("Advertisment", Advertisment);
  89. list.Add(Obj);
  90. return list;
  91. }
  92. #endregion
  93. #region 检查签名是否合法,合法返回1,不合法返回提示信息
  94. /// <summary>
  95. /// 检查签名是否合法,合法返回1,不合法返回提示信息
  96. /// </summary>
  97. /// <param name="value">请求的参数(json字符串)</param>
  98. /// <param name="signField">要签名的字段</param>
  99. /// <returns></returns>
  100. private string CheckSign(string value, string[] signField)
  101. {
  102. JsonData json = JsonMapper.ToObject(value);
  103. Dictionary<string, string> dic = new Dictionary<string, string>();
  104. for (int i = 0; i < signField.Length; i++)
  105. {
  106. dic.Add(signField[i], json[signField[i]].ToString());
  107. }
  108. string sign = json["sign"].ToString(); //客户端签名字符串
  109. return new Sign().sign(dic, sign);
  110. }
  111. #endregion
  112. }
  113. }