李昊 4 anos atrás
pai
commit
61d8a9f40a

+ 3 - 3
gx_api/GxPress/Api/GxPress.Api/AdminControllers/AdminPlatformDataController.cs

@@ -40,9 +40,9 @@ namespace GxPress.Api.AdminControllers
             result.ContentIncreaseResult = await platformDataService.GetContentIncreaseResult();
             result.PlatformAccumulativeVisitResult = await platformDataService.GetPlatformAccumulativeVisitResult();
             result.VisitPortResult = new List<VisitPortResult>();
-            result.PlatformCommerceResult =await platformDataService.GetPlatformCommerceResult();
-            result.ContentSaleRankingResults = new List<ContentSaleRankingResult>();
-            result.ContentSaleProportionResults = new List<ContentSaleProportionResult>();
+            result.PlatformCommerceResult = await platformDataService.GetPlatformCommerceResult();
+            result.ContentSaleRankingResults = await platformDataService.GetContentSaleRankingResults();
+            result.ContentSaleProportionResults = await platformDataService.GetContentSaleProportionResults();
             return result;
         }
     }

+ 10 - 0
gx_api/GxPress/Model/GxPress.Result/DataCenter/PlatformDataResult.cs

@@ -342,6 +342,11 @@ namespace GxPress.Result.DataCenter
         /// <value></value>
         public string CategoryName { get; set; }
         /// <summary>
+        ///类型
+        /// </summary>
+        /// <value></value>
+        public int MediaType { get; set; }
+        /// <summary>
         /// 销售总额
         /// </summary>
         /// <value></value>
@@ -367,5 +372,10 @@ namespace GxPress.Result.DataCenter
         /// </summary>
         /// <value></value>
         public int Value { get; set; }
+        /// <summary>
+        ///类型
+        /// </summary>
+        /// <value></value>
+        public int MediaType { get; set; }
     }
 }

BIN
gx_api/GxPress/Service/.DS_Store


+ 124 - 0
gx_api/GxPress/Service/GxPress.Service.Implement/PlatformData/PlatformDataService.cs

@@ -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;
+        }
     }
 }

+ 11 - 1
gx_api/GxPress/Service/GxPress.Service.Interface/PlatformData/IPlatformDataService.cs

@@ -46,7 +46,7 @@ namespace GxPress.Service.Interface.PlatformData
         /// </summary>
         /// <returns></returns>
         Task<PayContentstatisticsResult> GetPayContentstatisticsResult();
-          /// <summary>
+        /// <summary>
         /// 内容增长情况图
         /// </summary>
         /// <returns></returns>
@@ -61,5 +61,15 @@ namespace GxPress.Service.Interface.PlatformData
         /// </summary>
         /// <returns></returns>
         Task<PlatformCommerceResult> GetPlatformCommerceResult();
+        /// <summary>
+        /// 内容销售排行榜
+        /// </summary>
+        /// <returns></returns>
+        Task<List<ContentSaleRankingResult>> GetContentSaleRankingResults();
+        /// <summary>
+        /// 内容分类销售占比
+        /// </summary>
+        /// <returns></returns>
+        Task<List<ContentSaleProportionResult>> GetContentSaleProportionResults();
     }
 }