123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144 |
- 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.Models.Models;
- 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) : base(accessor)
- {
- }
- #region 通用-产品列表
- // [Authorize]
- public JsonResult List(string value)
- {
- value = DesDecrypt(value);
- value = value.Replace("null", "\"\"");
- JsonData data = JsonMapper.ToObject(value);
- List<Dictionary<string, object>> dataList = ListDo(value);
- return Json(new AppResultJson() { Status = "1", Info = "", Data = dataList });
- }
- public List<Dictionary<string, object>> ListDo(string value)
- {
- JsonData data = JsonMapper.ToObject(value);
- int PageSize = int.Parse(function.CheckInt(data.getItem("PageSize").ToString()));
- int PageNum = int.Parse(function.CheckInt(data.getItem("PageNum").ToString()));
- List<Dictionary<string, object>> dataList = new List<Dictionary<string, object>>();
- Dictionary<string, object> curData = new Dictionary<string, object>();
- curData.Add("Name", "微信"); //名称
- curData.Add("Id", "2"); //Id
- dataList.Add(curData);
- curData = new Dictionary<string, object>();
- curData.Add("Name", "支付宝"); //名称
- curData.Add("Id", "1"); //Id
- dataList.Add(curData);
- return dataList;
- }
- #endregion
- #region 首页-客小爽产品-主界面产品数据(码牌)
- // [Authorize]
- public JsonResult MainStatData(string value)
- {
- value = DesDecrypt(value);
- value = value.Replace("null", "\"\"");
- JsonData data = JsonMapper.ToObject(value);
- List<Dictionary<string, object>> Obj = MainStatDataDo(value);
- return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
- }
- public List<Dictionary<string, object>> MainStatDataDo(string value)
- {
- JsonData data = JsonMapper.ToObject(value);
- string UserId = data.getItem("UserId").ToString(); //创客Id
-
- List<Dictionary<string, object>> list = new List<Dictionary<string, object>>();
- Dictionary<string, object> Obj = new Dictionary<string, object>();
- Models.Main.UserMachineData MachineData = UserMachineDataDbconn.Instance.Get(UserId + "_0") ?? new Models.Main.UserMachineData();
- Models.Main.UserMachineData MachineData2 = UserMachineDataDbconn.Instance.Get(UserId + "_1") ?? new Models.Main.UserMachineData();
- Dictionary<string, object> Machine = new Dictionary<string, object>();
- Dictionary<string, object> Machine2 = new Dictionary<string, object>();
- //码牌
- Machine.Add("TotalMachineCount", MachineData.TotalMachineCount); //总机具数
- Machine.Add("UnBindCount", MachineData.UnBindCount); //未绑定机具数
- Machine.Add("BindCount", MachineData.BindCount); //已绑定机具数
- Obj.Add("Machine", Machine); //机具管理数据
- //音响
- Machine2.Add("TotalMachineCount2", MachineData2.TotalMachineCount); //总机具数
- Machine2.Add("UnBindCount2", MachineData2.UnBindCount); //未绑定机具数
- Machine2.Add("BindCount2", MachineData2.BindCount); //已绑定机具数
- Obj.Add("Machine2", Machine2); //机具管理数据
- Dictionary<string, object> Profit = new Dictionary<string, object>();
- Profit.Add("TradeProfit", MachineData2.TradeProfit); //交易分润
- Profit.Add("ActProfit", MachineData2.ActProfit); //激活奖励
- Profit.Add("OpenProfit", MachineData2.OpenProfit); //开机奖励
- Profit.Add("DividendsProfit", MachineData2.DividendsProfit); //分红奖励
- Profit.Add("OtherProfit", MachineData2.OtherProfit); //分润补贴
- Profit.Add("FluxProfit", MachineData2.FluxProfit); //流量卡分佣
- Obj.Add("Profit", Profit); //收益查看数据
- List<Dictionary<string, object>> Advertisment = new List<Dictionary<string, object>>();
- string ColId = "";
- List<Models.Models.Advertisment> ads = AdvertismentDbconn.Instance.GetList(ColId);
- foreach (Models.Models.Advertisment ad in ads)
- {
- Dictionary<string, object> item = new Dictionary<string, object>();
- 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,不合法返回提示信息
- /// <summary>
- /// 检查签名是否合法,合法返回1,不合法返回提示信息
- /// </summary>
- /// <param name="value">请求的参数(json字符串)</param>
- /// <param name="signField">要签名的字段</param>
- /// <returns></returns>
- private string CheckSign(string value, string[] signField)
- {
- JsonData json = JsonMapper.ToObject(value);
- Dictionary<string, string> dic = new Dictionary<string, string>();
- 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
- }
- }
|