KqProductsController.cs 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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. UserMachineData MachineData2 = UserMachineDataDbconn.Instance.Get(UserId + "_1") ?? new UserMachineData();
  65. Dictionary<string, object> Machine = new Dictionary<string, object>();
  66. Dictionary<string, object> Machine2 = new Dictionary<string, object>();
  67. Machine.Add("TotalMachineCount", MachineData.TotalMachineCount); //总机具数
  68. Machine.Add("UnBindCount", MachineData.UnBindCount); //未绑定机具数
  69. Machine.Add("BindCount", MachineData.BindCount); //已绑定机具数
  70. Obj.Add("Machine", Machine); //机具管理数据
  71. Machine2.Add("TotalMachineCount2", MachineData2.TotalMachineCount); //总机具数
  72. Machine2.Add("UnBindCount2", MachineData2.UnBindCount); //未绑定机具数
  73. Machine2.Add("BindCount2", MachineData2.BindCount); //已绑定机具数
  74. Obj.Add("Machine2", Machine2); //机具管理数据
  75. Dictionary<string, object> Profit = new Dictionary<string, object>();
  76. Profit.Add("TradeProfit", MachineData.TradeProfit); //交易分润
  77. Profit.Add("ActProfit", MachineData.ActProfit); //激活奖励
  78. Profit.Add("OpenProfit", MachineData.OpenProfit); //开机奖励
  79. Profit.Add("DividendsProfit", MachineData.DividendsProfit); //分红奖励
  80. Profit.Add("OtherProfit", MachineData.OtherProfit); //分润补贴
  81. Profit.Add("FluxProfit", MachineData.FluxProfit); //流量卡分佣
  82. Obj.Add("Profit", Profit); //收益查看数据
  83. List<Dictionary<string, object>> Advertisment = new List<Dictionary<string, object>>();
  84. string ColId = "";
  85. List<Models.Advertisment> ads = AdvertismentDbconn.Instance.GetList(ColId);
  86. foreach (Models.Advertisment ad in ads)
  87. {
  88. Dictionary<string, object> item = new Dictionary<string, object>();
  89. item.Add("Url", ad.Url); //跳转地址
  90. item.Add("BannerPic", DefaultPic(ad.PicPath)); //广告图片
  91. item.Add("Id", ad.Id); //Id
  92. Advertisment.Add(item);
  93. }
  94. Obj.Add("Advertisment", Advertisment);
  95. list.Add(Obj);
  96. return list;
  97. }
  98. #endregion
  99. #region 检查签名是否合法,合法返回1,不合法返回提示信息
  100. /// <summary>
  101. /// 检查签名是否合法,合法返回1,不合法返回提示信息
  102. /// </summary>
  103. /// <param name="value">请求的参数(json字符串)</param>
  104. /// <param name="signField">要签名的字段</param>
  105. /// <returns></returns>
  106. private string CheckSign(string value, string[] signField)
  107. {
  108. JsonData json = JsonMapper.ToObject(value);
  109. Dictionary<string, string> dic = new Dictionary<string, string>();
  110. for (int i = 0; i < signField.Length; i++)
  111. {
  112. dic.Add(signField[i], json[signField[i]].ToString());
  113. }
  114. string sign = json["sign"].ToString(); //客户端签名字符串
  115. return new Sign().sign(dic, sign);
  116. }
  117. #endregion
  118. }
  119. }