using System; using System.Threading.Tasks; using Dapper; using Datory; using GxPress.Common.Tools; using GxPress.Result.DataCenter; namespace GxPress.Service.Implement.PlatformData { public partial class PlatformDataService { /// /// 商务数据 /// /// public async Task GetCommerceDataResult() { var result = new CommerceDataResult(); result.PlatformCommerceResult = await GetPlatformCommerceResult(); result.ContentSaleRankingResults = await GetContentSaleRankingResults(); result.ContentSaleProportionResults = await GetContentSaleProportionResults(); result.PlatformTodayCommerceResult = await GetPlatformTodayCommerceResult(); return result; } public async Task GetPlatformTodayCommerceResult() { var nowTime = DateTime.Now.ToString("yyyy-MM-dd"); var sql = $@"SELECT (SELECT IFNULL(SUM(Price),0) FROM tede_order where CreatedDate>'{nowTime}') AS Amount, (SELECT COUNT(1) FROM tede_order where CreatedDate>'{nowTime}') AS OrderCount, (SELECT COUNT(1) FROM tede_user where CreatedDate>'{nowTime}') AS VipUserCount, (SELECT IFNULL(SUM(Price),0) FROM tede_order WHERE IsVip = 1 and CreatedDate>'{nowTime}') AS VipAmount, (SELECT COUNT(1) FROM tede_order WHERE IsVip = 1 and CreatedDate>'{nowTime}') AS VipOrderCount"; var connectionString = ConfigHelper.GetValue("Database:ConnectionString"); var database = new Database(DatabaseType.MySql, connectionString); var connection = database.GetConnection(); return await connection.QueryFirstAsync(sql); } } }