KqProductsController.cs 6.2 KB

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