| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Data;
- 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 ActivityRecommendKingController : BaseController
- {
- public ActivityRecommendKingController(IHttpContextAccessor accessor, ILogger<BaseController> logger, IOptions<Setting> setting) : base(accessor, logger, setting)
- {
- OtherMySqlConn.connstr = Library.ConfigurationManager.AppSettings["SqlConnStr"].ToString();
- }
- #region 创客-开机王
- // [Authorize]
- public JsonResult List(string value)
- {
- value = DesDecrypt(value);
- JsonData data = JsonMapper.ToObject(value);
- Dictionary<string, object> Other = new Dictionary<string, object>();
- List<Dictionary<string, object>> Obj = ListDo(value, out Other);
- return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj, Other = Other });
- }
- public List<Dictionary<string, object>> ListDo(string value, out Dictionary<string, object> Other)
- {
- JsonData data = JsonMapper.ToObject(value);
- List<Dictionary<string, object>> Obj = new List<Dictionary<string, object>>();
- int PageSize = int.Parse(function.CheckInt(data["PageSize"].ToString()));
- int PageNum = int.Parse(function.CheckInt(data["PageNum"].ToString()));
- int SkipNum = PageSize * (PageNum - 1);
- var days = (int)DateTime.Now.DayOfWeek - 1;
- DateTime start = DateTime.Parse(DateTime.Now.AddDays(-days).ToString("yyyy-MM-dd") + " 00:00:00");
- DateTime end = start.AddDays(6);
- string startDate = start.ToString("yyyyMMdd");
- string endDate = end.ToString("yyyyMMdd");
- string StartId = function.ReadInstance("/ActivityRecommendKing/StartId" + startDate + ".txt");
- if(string.IsNullOrEmpty(StartId))
- {
- DataTable getid = OtherMySqlConn.dtable("SELECT min(Id) FROM UserTradeMonthSummary where SeoKeyword >= '" + startDate + "' and SeoKeyword <= '" + endDate + "'");
- if(getid.Rows.Count > 0)
- {
- StartId = getid.Rows[0][0].ToString();
- function.WritePage("/ActivityRecommendKing/", "StartId" + startDate + ".txt", StartId);
- }
- }
- DataTable dt = OtherMySqlConn.dtable("SELECT UserId,sum(ActiveBuddyMerStatus) Sum FROM UserTradeMonthSummary where Id>=" + StartId + " and SeoKeyword >= '" + startDate + "' and SeoKeyword <= '" + endDate + "'and SeoTitle='self' GROUP BY UserId ORDER BY Sum DESC LIMIT " + SkipNum + "," + PageSize + "");
- foreach (DataRow item in dt.Rows)
- {
- Dictionary<string, object> obj = new Dictionary<string, object>();
- var query = maindb.Users.FirstOrDefault(m => m.Id == (int)item["UserId"]);
- obj.Add("HeadPhoto", DefaultPic(query.HeadPhoto));
- obj.Add("RealName", PublicFunction.SetSensitiveName(query.RealName));
- obj.Add("MakerCode", query.MakerCode);
- obj.Add("OpenCount", int.Parse(item["Sum"].ToString()));
- Obj.Add(obj);
- }
- Other = new Dictionary<string, object>();
- Other.Add("StratTime", start.ToString("yyyy-MM-dd"));
- Other.Add("EndTime", end.ToString("yyyy-MM-dd"));
- return Obj;
- }
- #endregion
- }
- }
|