using System; using System.Collections.Generic; using System.Linq; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; using Microsoft.AspNetCore.Authorization; using System.Web; using MySystem.MainModels; using LitJson; using Library; namespace MySystem.Areas.Api.Controllers.v1 { [Area("Api")] [Route("Api/v1/[controller]/[action]")] public class KqProductsController : BaseController { public KqProductsController(IHttpContextAccessor accessor, ILogger logger, IOptions setting) : base(accessor, logger, setting) { } #region 通用-产品列表 [Authorize] public JsonResult List(string value) { value = DesDecrypt(value); JsonData data = JsonMapper.ToObject(value); List> dataList = ListDo(value); return Json(new AppResultJson() { Status = "1", Info = "", Data = dataList }); } public List> ListDo(string value) { JsonData data = JsonMapper.ToObject(value); int PageSize = int.Parse(function.CheckInt(data["PageSize"].ToString())); int PageNum = int.Parse(function.CheckInt(data["PageNum"].ToString())); List> dataList = new List>(); Dictionary curData = new Dictionary(); curData.Add("Name", "微信"); //名称 curData.Add("Id", "2"); //Id dataList.Add(curData); curData = new Dictionary(); curData.Add("Name", "支付宝"); //名称 curData.Add("Id", "1"); //Id dataList.Add(curData); return dataList; } #endregion #region 首页-客小爽产品-主界面产品数据 [Authorize] public JsonResult MainStatData(string value) { value = DesDecrypt(value); JsonData data = JsonMapper.ToObject(value); List> Obj = MainStatDataDo(value); return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj }); } public List> MainStatDataDo(string value) { JsonData data = JsonMapper.ToObject(value); string UserId = data["UserId"].ToString(); //创客Id List> list = new List>(); Dictionary Obj = new Dictionary(); UserMachineData MachineData = UserMachineDataDbconn.Instance.Get(UserId + "_0") ?? new UserMachineData(); Dictionary Machine = new Dictionary(); Machine.Add("TotalMachineCount", MachineData.TotalMachineCount); //总机具数 Machine.Add("UnBindCount", MachineData.UnBindCount); //未绑定机具数 Machine.Add("BindCount", MachineData.BindCount); //已绑定机具数 Obj.Add("Machine", Machine); //机具管理数据 Dictionary Profit = new Dictionary(); Profit.Add("TradeProfit", MachineData.TradeProfit); //交易分润 Profit.Add("ActProfit", MachineData.ActProfit); //激活奖励 Profit.Add("OpenProfit", MachineData.OpenProfit); //开机奖励 Profit.Add("DividendsProfit", MachineData.DividendsProfit); //分红奖励 Profit.Add("OtherProfit", MachineData.OtherProfit); //分润补贴 Profit.Add("FluxProfit", MachineData.FluxProfit); //流量卡分佣 Obj.Add("Profit", Profit); //收益查看数据 List> Advertisment = new List>(); string ColId = ""; List ads = AdvertismentDbconn.Instance.GetList(ColId); foreach (Models.Advertisment ad in ads) { Dictionary item = new Dictionary(); item.Add("Url", ad.Url); //跳转地址 item.Add("BannerPic", DefaultPic(ad.PicPath)); //广告图片 item.Add("Id", ad.Id); //Id Advertisment.Add(item); } Obj.Add("Advertisment", Advertisment); list.Add(Obj); return list; } #endregion #region 检查签名是否合法,合法返回1,不合法返回提示信息 /// /// 检查签名是否合法,合法返回1,不合法返回提示信息 /// /// 请求的参数(json字符串) /// 要签名的字段 /// private string CheckSign(string value, string[] signField) { JsonData json = JsonMapper.ToObject(value); Dictionary dic = new Dictionary(); for (int i = 0; i < signField.Length; i++) { dic.Add(signField[i], json[signField[i]].ToString()); } string sign = json["sign"].ToString(); //客户端签名字符串 return new Sign().sign(dic, sign); } #endregion } }