|
@@ -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>
|