|
@@ -314,5 +314,129 @@ namespace GxPress.Service.Implement.PlatformData
|
|
|
var connection = database.GetConnection();
|
|
|
return await connection.QueryFirstAsync<PlatformCommerceResult>(sql);
|
|
|
}
|
|
|
+ /// <summary>
|
|
|
+ /// 内容销售排行榜
|
|
|
+ /// </summary>
|
|
|
+ /// <returns></returns>
|
|
|
+ public async Task<List<ContentSaleRankingResult>> GetContentSaleRankingResults()
|
|
|
+ {
|
|
|
+ var result = new List<ContentSaleRankingResult>();
|
|
|
+ foreach (ResourceTypeConst item in Enum.GetValues(typeof(ResourceTypeConst)))
|
|
|
+ {
|
|
|
+ result.Add(new ContentSaleRankingResult { CategoryName = item.GetDescriptionOriginal(), MediaType = item.GetHashCode() });
|
|
|
+ }
|
|
|
+ foreach (AttachTypeConst item in Enum.GetValues(typeof(AttachTypeConst)))
|
|
|
+ {
|
|
|
+ result.Add(new ContentSaleRankingResult { CategoryName = item.GetDescriptionOriginal(), MediaType = item.GetHashCode() });
|
|
|
+ }
|
|
|
+ var connectionString = ConfigHelper.GetValue("Database:ConnectionString");
|
|
|
+ var database = new Database(DatabaseType.MySql, connectionString);
|
|
|
+ var connection = database.GetConnection();
|
|
|
+ var sql = @"SELECT
|
|
|
+ MediaType,
|
|
|
+ SUM(SellAmount) AS Amount,
|
|
|
+ (SUM(SellAmount) / (SELECT
|
|
|
+ SUM(SellAmount)
|
|
|
+ FROM
|
|
|
+ tede_media)) AS Proportion
|
|
|
+ FROM
|
|
|
+ tede_media
|
|
|
+ GROUP BY MediaType";
|
|
|
+ var list = await connection.QueryAsync<ContentSaleRankingResult>(sql);
|
|
|
+ foreach (var item in list)
|
|
|
+ {
|
|
|
+ foreach (var dom in result)
|
|
|
+ {
|
|
|
+ if (dom.MediaType == item.MediaType)
|
|
|
+ {
|
|
|
+ dom.Amount = dom.Amount;
|
|
|
+ dom.Proportion = dom.Proportion;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ sql = @"SELECT
|
|
|
+ AttachType as MediaType,
|
|
|
+ SUM(SellAmount) AS Amount,
|
|
|
+ (SUM(SellAmount) / (SELECT
|
|
|
+ SUM(SellAmount)
|
|
|
+ FROM
|
|
|
+ tede_media)) AS Proportion
|
|
|
+ FROM
|
|
|
+ tede_media where AttachId>0
|
|
|
+ GROUP BY AttachType";
|
|
|
+ list = await connection.QueryAsync<ContentSaleRankingResult>(sql);
|
|
|
+ foreach (var item in list)
|
|
|
+ {
|
|
|
+ foreach (var dom in result)
|
|
|
+ {
|
|
|
+ if (dom.MediaType == item.MediaType)
|
|
|
+ {
|
|
|
+ dom.Amount = dom.Amount;
|
|
|
+ dom.Proportion = dom.Proportion;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ /// <summary>
|
|
|
+ /// 内容分类销售占比
|
|
|
+ /// </summary>
|
|
|
+ /// <returns></returns>
|
|
|
+ public async Task<List<ContentSaleProportionResult>> GetContentSaleProportionResults()
|
|
|
+ {
|
|
|
+ var result = new List<ContentSaleProportionResult>();
|
|
|
+ foreach (ResourceTypeConst item in Enum.GetValues(typeof(ResourceTypeConst)))
|
|
|
+ {
|
|
|
+ result.Add(new ContentSaleProportionResult { Name = item.GetDescriptionOriginal(), MediaType = item.GetHashCode() });
|
|
|
+ }
|
|
|
+ foreach (AttachTypeConst item in Enum.GetValues(typeof(AttachTypeConst)))
|
|
|
+ {
|
|
|
+ result.Add(new ContentSaleProportionResult { Name = item.GetDescriptionOriginal(), MediaType = item.GetHashCode() });
|
|
|
+ }
|
|
|
+ var connectionString = ConfigHelper.GetValue("Database:ConnectionString");
|
|
|
+ var database = new Database(DatabaseType.MySql, connectionString);
|
|
|
+ var connection = database.GetConnection();
|
|
|
+ var sql = @"SELECT
|
|
|
+ MediaType,
|
|
|
+ (SUM(SellAmount) / (SELECT
|
|
|
+ SUM(SellAmount)
|
|
|
+ FROM
|
|
|
+ tede_media)) AS Value
|
|
|
+ FROM
|
|
|
+ tede_media
|
|
|
+ GROUP BY MediaType";
|
|
|
+ var list = await connection.QueryAsync<ContentSaleProportionResult>(sql);
|
|
|
+ foreach (var item in list)
|
|
|
+ {
|
|
|
+ foreach (var dom in result)
|
|
|
+ {
|
|
|
+ if (dom.MediaType == item.MediaType)
|
|
|
+ {
|
|
|
+ dom.Value = dom.Value;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ sql = @"SELECT
|
|
|
+ AttachType as MediaType,
|
|
|
+ (SUM(SellAmount) / (SELECT
|
|
|
+ SUM(SellAmount)
|
|
|
+ FROM
|
|
|
+ tede_media)) AS Proportion
|
|
|
+ FROM
|
|
|
+ tede_media where AttachId>0
|
|
|
+ GROUP BY AttachType";
|
|
|
+ list = await connection.QueryAsync<ContentSaleProportionResult>(sql);
|
|
|
+ foreach (var item in list)
|
|
|
+ {
|
|
|
+ foreach (var dom in result)
|
|
|
+ {
|
|
|
+ if (dom.MediaType == item.MediaType)
|
|
|
+ {
|
|
|
+ dom.Value = dom.Value;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
}
|
|
|
}
|