123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149 |
- 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.pos
- {
- [Area("Api")]
- [Route("Api/v1/pos/[controller]/[action]")]
- public class FluxProfitSummaryController : BaseController
- {
- public FluxProfitSummaryController(IHttpContextAccessor accessor, ILogger<BaseController> logger, IOptions<Setting> setting) : base(accessor, logger, setting)
- {
- }
- #region 首页-客小爽产品-收益查看-流量卡分佣
- [Authorize]
- public JsonResult List(string value)
- {
- value = DesDecrypt(value);
- 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 UserId = int.Parse(function.CheckInt(data["UserId"].ToString())); //创客
- int BrandId = int.Parse(function.CheckInt(data["ProductType"].ToString()));//产品类型
- int PageSize = int.Parse(function.CheckInt(data["PageSize"].ToString()));
- int PageNum = int.Parse(function.CheckInt(data["PageNum"].ToString()));
- List<Dictionary<string, object>> dataList = new List<Dictionary<string, object>>();
- IQueryable<FluxProfitSummary> query = maindb.FluxProfitSummary.Where(m => m.UserId == UserId && m.BrandId == BrandId).OrderByDescending(m => m.Id);
- if (PageNum == 1)
- {
- query = query.Take(PageSize);
- }
- else
- {
- int skipNum = PageSize * (PageNum - 1);
- query = query.Skip(skipNum).Take(PageSize);
- }
- foreach (var subdata in query.ToList())
- {
- string TradeMonth = subdata.TradeMonth;
- Dictionary<string, object> curData = new Dictionary<string, object>();
- curData.Add("TradeMonth", TradeMonth.Substring(0, 4) + "-" + TradeMonth.Substring(4, 2)); //交易月
- curData.Add("TradeMonthValue", TradeMonth);
- curData.Add("FluxProfitAmt", subdata.FluxProfitAmt); //流量分润总金额
- dataList.Add(curData);
- }
- return dataList;
- }
- #endregion
- #region 首页-客小爽产品-收益查看-流量卡分佣详细
- [Authorize]
- public JsonResult ByDate(string value)
- {
- value = DesDecrypt(value);
- JsonData data = JsonMapper.ToObject(value);
- List<Dictionary<string, object>> dataList = ByDateDo(value);
- return Json(new AppResultJson() { Status = "1", Info = "", Data = dataList });
- }
- public List<Dictionary<string, object>> ByDateDo(string value)
- {
- JsonData data = JsonMapper.ToObject(value);
- int UserId = int.Parse(function.CheckInt(data["UserId"].ToString())); //创客
- int ProductType = int.Parse(function.CheckInt(data["ProductType"].ToString())); //产品类型
- string TradeMonth = data["TradeMonth"].ToString();
- int PageSize = int.Parse(function.CheckInt(data["PageSize"].ToString()));
- int PageNum = int.Parse(function.CheckInt(data["PageNum"].ToString()));
- List<Dictionary<string, object>> dataList = new List<Dictionary<string, object>>();
- IQueryable<FluxProfitDetail> query = maindb.FluxProfitDetail.Where(m => m.UserId == UserId && m.TradeMonth == TradeMonth && m.BrandId == ProductType);
- if (PageNum == 1)
- {
- query = query.Take(PageSize);
- }
- else
- {
- int skipNum = PageSize * (PageNum - 1);
- query = query.Skip(skipNum).Take(PageSize);
- }
- foreach (var subdata in query.ToList())
- {
- Dictionary<string, object> curData = new Dictionary<string, object>();
- string TradeDate = subdata.TradeDate;
- curData.Add("TradeDate", TradeDate.Substring(0, 4) + "-" + TradeDate.Substring(4, 2) + "-" + TradeDate.Substring(6, 2)); //交易日
- curData.Add("FluxProfitAmt", subdata.FluxProfitAmt); //流量分润总金额
- PosMerchantInfo merchant = PosMerchantInfoDbconn.Instance.Get(subdata.MerchantId) ?? new PosMerchantInfo();
- string MerchantName = merchant.MerchantName;
- if (ProductType == 2)
- {
- if (MerchantName.Contains("-"))
- {
- MerchantName = MerchantName.Split('-')[1];
- }
- else if (MerchantName.Contains("_"))
- {
- MerchantName = MerchantName.Split('_')[1];
- }
- }
- curData.Add("RealName", MerchantName); //姓名
- curData.Add("Mobile", merchant.MerchantMobile); //手机号
- dataList.Add(curData);
- }
- return dataList;
- }
- #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
- }
- }
|