Bläddra i källkod

国交部统计-->商邀相关 api代码编写

LEIYI 4 månader sedan
förälder
incheckning
912f0287dc

+ 27 - 18
OASystem/OASystem.Api/Controllers/StatisticsController.cs

@@ -4216,45 +4216,54 @@ ORDER BY
         [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
         public async Task<IActionResult> StatisticsInvitation(YOYDto _dto)
         {
-
             if (_dto.Year < 1) return Ok(JsonView(false, "操作失败"));
 
-
             string beginDt = $"{_dto.Year}-01-01 00:00:00",
                    endDt = $"{_dto.Year}-12-31 23:59:59";
 
             string sql = string.Format(@"
 SELECT
-  ioa.DiId,
-  ioa.InviterArea AS Country
+  oa.DiId,
+  di.TeamName AS GroupName,
+  oa.Country,
+  oa.Area AS City,
+  oa.Client,
+  oa.Date
 FROM
-  Grp_InvitationOfficialActivities ioa
-  INNER JOIN Grp_CreditCardPayment ccp ON ioa.Id = ccp.CId
-  AND ccp.IsDel = 0
-  AND ccp.CTable = 81
-  INNER JOIN Grp_DelegationInfo di ON ioa.DiId = di.Id
+  Res_OfficialActivities oa
+  LEFT JOIN Grp_DelegationInfo di ON oa.DiId = di.Id
 WHERE
-  ioa.IsDel = 0
-  AND di.TeamDid IN (38,39,40,1048)
-  AND ccp.IsPay = 1
-  AND ioa.CreateTime BETWEEN '{0}' AND '{1}'
-", beginDt, endDt);
+  oa.IsDel = 0
+  AND oa.Date BETWEEN '{0}' AND '{1}'
+  ", beginDt, endDt);
 
-            var data = await _sqlSugar.SqlQueryable<StatisticsInvitation>(sql).ToListAsync();
+            var data = await _sqlSugar.SqlQueryable<StatisticsInvitation_HW>(sql).ToListAsync();
 
-            var groupByData = data.GroupBy(x => x.Country)
+            var groupByCountry = data.GroupBy(x => x.Country)
                                   .Select(g => new
                                   {
                                       Country = g.Key,
                                       TimeNum = g.Count(),
-                                      LinkGroupIds = g.Select(x => x.DIId).ToList()
+                                      LinkGroupIds = g.Select(x => x.GroupName).Distinct().ToList()
+
+                                  })
+                                  .OrderByDescending(x => x.TimeNum)
+                                  .Take(10)
+                                  .ToList();
+            var groupByClient = data.GroupBy(x => x.Client)
+                                  .Select(g => new
+                                  {
+                                      Country = g.Key,
+                                      TimeNum = g.Count(),
+                                      LinkGroupIds = g.Select(x => x.GroupName).Distinct().ToList()
 
                                   })
                                   .OrderByDescending(x => x.TimeNum)
                                   .Take(10)
                                   .ToList();
+            
 
-            return Ok(JsonView(true, "操作成功!", groupByData));
+            return Ok(JsonView(true, "操作成功!", new { groupByCountry= groupByCountry, groupByClient = groupByClient }));
         }
 
         /// <summary>

+ 10 - 0
OASystem/OASystem.Domain/ViewModels/Financial/Fin_DailyFeePaymentView.cs

@@ -925,6 +925,16 @@ namespace OASystem.Domain.ViewModels.Financial
     #endregion
 
     #region 商邀邀请
+
+    public class StatisticsInvitation_HW
+    {
+        public int DIId { get; set; }
+        public string GroupName { get; set; }
+        public string Country { get; set; }
+        public string City { get; set; }
+        public string Client { get; set; }
+    }
+
     public class StatisticsInvitation
     {
         public int DIId { get; set; }

+ 3 - 0
OASystem/OASystem.Infrastructure/GlobalUsings.cs

@@ -11,3 +11,6 @@ global using Microsoft.AspNetCore.Http;
 global using System.Text.RegularExpressions;
 global using OASystem.Domain.Entities.System;
 global using OASystem.Domain.ViewModels.System;
+
+
+