|
@@ -2179,12 +2179,6 @@ ORDER BY
|
|
|
.Select(it => it.JietuanOperator)
|
|
|
.ToList();
|
|
|
|
|
|
- //var jobData = _sqlSugar.Queryable<Sys_JobPost>().Where(it => it.IsDel == 0 && companyIds.Contains(it.CompanyId) && (it.JobName.Contains("经理") || it.JobName.Contains("主管")))
|
|
|
- // .Select(it => new { it.Id, it.CompanyId, it.DepId, it.JobName })
|
|
|
- // .ToList();
|
|
|
- //List<int> jobIds = jobData.Select(it => it.Id).ToList();
|
|
|
- //(depIds.Contains(it.DepId) || jobIds.Contains(it.JobPostId)
|
|
|
- //userId = 21
|
|
|
var userData = _sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && (pickGroupUserIds.Contains(it.Id) || it.Id == 21))
|
|
|
.Select(it => new { id = it.Id, companyId = it.CompanyId, name = it.CnName })
|
|
|
.ToList();
|
|
@@ -2376,6 +2370,39 @@ ORDER BY
|
|
|
|
|
|
string lastBeginDt = Convert.ToDateTime(beginDt).AddYears(-1).ToString("yyyy-MM-dd HH:mm:ss"),
|
|
|
lastEndDt = Convert.ToDateTime(endDt).AddYears(-1).ToString("yyyy-MM-dd HH:mm:ss");
|
|
|
+ // string salesSql = string.Format(@"
|
|
|
+ //SELECT
|
|
|
+ // 'ThisSales' As [Name],
|
|
|
+ // CAST(SUM(Sales) AS decimal(12,2)) As Sales
|
|
|
+ //FROM
|
|
|
+ // (
|
|
|
+ // SELECT di.VisitDate,
|
|
|
+ // (SELECT CAST(SUM(ItemSumPrice * Rate) AS decimal(12,2)) FROM Fin_ForeignReceivables
|
|
|
+ // WHERE IsDel = 0 AND AddingWay IN (0, 1, 2)AND di.Id = Diid
|
|
|
+ // ) AS Sales
|
|
|
+ // FROM
|
|
|
+ // Grp_DelegationInfo di
|
|
|
+ // WHERE di.IsDel = 0 AND di.IsSure = 1
|
|
|
+ // AND di.JietuanOperator IN (SELECT Id FROM Sys_Users WITH (NoLock) WHERE IsDel = 0 {0})
|
|
|
+ // AND di.VisitDate BETWEEN '{1}' AND '{2}'
|
|
|
+ // ) temp
|
|
|
+ //Union ALL
|
|
|
+ //SELECT
|
|
|
+ // 'LastSales' As [Name],
|
|
|
+ // CAST(SUM(Sales) AS decimal(12,2)) As Sales
|
|
|
+ //FROM
|
|
|
+ // (
|
|
|
+ // SELECT di.VisitDate,
|
|
|
+ // (SELECT CAST(SUM(ItemSumPrice * Rate) AS decimal(12,2)) FROM Fin_ForeignReceivables
|
|
|
+ // WHERE IsDel = 0 AND AddingWay IN (0, 1, 2)AND di.Id = Diid
|
|
|
+ // ) AS Sales
|
|
|
+ // FROM
|
|
|
+ // Grp_DelegationInfo di
|
|
|
+ // WHERE di.IsDel = 0 AND di.IsSure = 1
|
|
|
+ // AND di.JietuanOperator IN (SELECT Id FROM Sys_Users WITH (NoLock) WHERE IsDel = 0 {3})
|
|
|
+ // AND di.VisitDate BETWEEN '{4}' AND '{5}'
|
|
|
+ // ) temp", userSqlWhere, beginDt, endDt, userSqlWhere, lastBeginDt, lastEndDt);
|
|
|
+
|
|
|
string salesSql = string.Format(@"
|
|
|
SELECT
|
|
|
'ThisSales' As [Name],
|
|
@@ -2388,7 +2415,7 @@ FROM
|
|
|
) AS Sales
|
|
|
FROM
|
|
|
Grp_DelegationInfo di
|
|
|
- WHERE di.IsDel = 0 AND di.IsSure = 1
|
|
|
+ WHERE di.IsDel = 0
|
|
|
AND di.JietuanOperator IN (SELECT Id FROM Sys_Users WITH (NoLock) WHERE IsDel = 0 {0})
|
|
|
AND di.VisitDate BETWEEN '{1}' AND '{2}'
|
|
|
) temp
|
|
@@ -2404,11 +2431,10 @@ FROM
|
|
|
) AS Sales
|
|
|
FROM
|
|
|
Grp_DelegationInfo di
|
|
|
- WHERE di.IsDel = 0 AND di.IsSure = 1
|
|
|
+ WHERE di.IsDel = 0
|
|
|
AND di.JietuanOperator IN (SELECT Id FROM Sys_Users WITH (NoLock) WHERE IsDel = 0 {3})
|
|
|
AND di.VisitDate BETWEEN '{4}' AND '{5}'
|
|
|
) temp", userSqlWhere, beginDt, endDt, userSqlWhere, lastBeginDt, lastEndDt);
|
|
|
-
|
|
|
var salesData = await _sqlSugar.SqlQueryable<SalesView>(salesSql).ToListAsync();
|
|
|
|
|
|
thisSales = salesData.Where(x => x.Name.Equals("ThisSales")).First()?.Sales ?? 0;
|
|
@@ -2441,7 +2467,6 @@ FROM
|
|
|
/// <summary>
|
|
|
/// 市场部销售额
|
|
|
/// 团组列表
|
|
|
- /// (增加团组查询条件 IsSure=1)
|
|
|
/// </summary>
|
|
|
/// <param name="_dto">市场部销售额请求dto</param>
|
|
|
/// <returns></returns>
|
|
@@ -2489,6 +2514,48 @@ FROM
|
|
|
|
|
|
string beginDt = $"{_dto.BeginDt} 00:00:00", endDt = $"{_dto.EndDt} 23:59:59";
|
|
|
|
|
|
+ // string sql = string.Format(@$"SELECT
|
|
|
+ // ROW_NUMBER() OVER (
|
|
|
+ // ORDER BY
|
|
|
+ // CollectionDays
|
|
|
+ // ) AS RowNumber,
|
|
|
+ // *
|
|
|
+ //FROM
|
|
|
+ // (
|
|
|
+ // SELECT
|
|
|
+ // di.Id,
|
|
|
+ // di.TeamName,
|
|
|
+ // di.ClientUnit,
|
|
|
+ // di.ClientName,
|
|
|
+ // di.VisitDate,
|
|
|
+ // di.VisitPNumber,
|
|
|
+ // di.JietuanOperator,
|
|
|
+ // di.VisitEndDate,
|
|
|
+ // (
|
|
|
+ // SELECT
|
|
|
+ // CAST(
|
|
|
+ // COALESCE(SUM(ItemSumPrice * Rate), 0) AS DECIMAL(12, 2)
|
|
|
+ // ) AS GroupSales
|
|
|
+ // FROM
|
|
|
+ // Fin_ForeignReceivables
|
|
|
+ // WHERE
|
|
|
+ // IsDel = 0
|
|
|
+ // AND di.Id = Diid
|
|
|
+ // AND AddingWay IN (0, 1, 2)
|
|
|
+ // ) AS GroupSales,
|
|
|
+ // u.CnName AS GroupPickupUser,
|
|
|
+ // DATEADD(DAY, 7, di.VisitEndDate) AS CollectionDays
|
|
|
+ // FROM
|
|
|
+ // Grp_DelegationInfo di
|
|
|
+ // WITH
|
|
|
+ // (NoLock)
|
|
|
+ // LEFT JOIN Sys_Users u ON di.JietuanOperator = u.Id
|
|
|
+ // WHERE
|
|
|
+ // di.Isdel = 0
|
|
|
+ // AND di.IsSure = 1 {userSql}
|
|
|
+ // AND VisitDate Between '{beginDt}' And '{endDt}'
|
|
|
+ // ) Temp ");
|
|
|
+
|
|
|
string sql = string.Format(@$"SELECT
|
|
|
ROW_NUMBER() OVER (
|
|
|
ORDER BY
|
|
@@ -2527,7 +2594,7 @@ FROM
|
|
|
LEFT JOIN Sys_Users u ON di.JietuanOperator = u.Id
|
|
|
WHERE
|
|
|
di.Isdel = 0
|
|
|
- AND di.IsSure = 1 {userSql}
|
|
|
+ {userSql}
|
|
|
AND VisitDate Between '{beginDt}' And '{endDt}'
|
|
|
) Temp ");
|
|
|
|
|
@@ -2602,7 +2669,7 @@ FROM
|
|
|
From Grp_DelegationInfo di
|
|
|
Left Join Sys_SetData sd On di.TeamDid = sd.Id
|
|
|
Where di.Isdel = 0
|
|
|
-And IsSure = 1 {userSql}
|
|
|
+ {userSql}
|
|
|
And VisitDate Between '{beginDt}' And '{endDt}'
|
|
|
Group By [Name]
|
|
|
Order By Count Desc");
|
|
@@ -2615,7 +2682,7 @@ Order By Count Desc");
|
|
|
From Grp_DelegationInfo di
|
|
|
Left Join Sys_SetData sd On di.TeamLevSId = sd.Id
|
|
|
Where di.Isdel = 0
|
|
|
-And IsSure = 1 {userSql}
|
|
|
+ {userSql}
|
|
|
And VisitDate Between '{beginDt}' And '{endDt}'
|
|
|
Group By [Name]
|
|
|
Order By Count Desc");
|
|
@@ -2630,7 +2697,7 @@ Order By Count Desc");
|
|
|
From Grp_DelegationInfo di
|
|
|
Left Join Sys_SetData sd On di.TeamDid = sd.Id
|
|
|
Where di.Isdel = 0
|
|
|
-And IsSure = 1 {userSql}
|
|
|
+ {userSql}
|
|
|
And VisitDate Between '{beginDt}' And '{endDt}'
|
|
|
Group By [Name]
|
|
|
Order By Count Desc");
|
|
@@ -2643,7 +2710,7 @@ Order By Count Desc");
|
|
|
From Grp_DelegationInfo di
|
|
|
Left Join Sys_SetData sd On di.TeamLevSId = sd.Id
|
|
|
Where di.Isdel = 0
|
|
|
-And IsSure = 1 {userSql}
|
|
|
+ {userSql}
|
|
|
And VisitDate Between '{beginDt}' And '{endDt}'
|
|
|
Group By [Name]
|
|
|
Order By Count Desc");
|
|
@@ -2712,7 +2779,7 @@ Order By Count Desc");
|
|
|
From Grp_DelegationInfo di
|
|
|
Left Join Sys_Users u On di.JietuanOperator = u.Id
|
|
|
Where di.Isdel = 0
|
|
|
- AND IsSure = 1 {userSql}
|
|
|
+ {userSql}
|
|
|
And VisitDate Between '{beginDt}' And '{endDt}'
|
|
|
Group By CnName");
|
|
|
|
|
@@ -2726,7 +2793,6 @@ Order By Count Desc");
|
|
|
/// <summary>
|
|
|
/// 市场部销售额
|
|
|
/// 团组列表、客户类型、客户等级、接单排名
|
|
|
- /// (增加团组查询条件 IsSure=1)
|
|
|
/// </summary>
|
|
|
/// <param name="_dto">市场部销售额请求dto</param>
|
|
|
/// <returns></returns>
|
|
@@ -2814,7 +2880,7 @@ FROM
|
|
|
LEFT JOIN Sys_Users u ON di.JietuanOperator = u.Id
|
|
|
WHERE
|
|
|
di.Isdel = 0
|
|
|
- AND di.IsSure = 1 {userSql}
|
|
|
+ {userSql}
|
|
|
AND VisitDate Between '{beginDt}' And '{endDt}'
|
|
|
) Temp ");
|
|
|
RefAsync<int> total = 0;
|
|
@@ -2829,7 +2895,7 @@ FROM
|
|
|
From Grp_DelegationInfo di
|
|
|
Left Join Sys_SetData sd On di.TeamDid = sd.Id
|
|
|
Where di.Isdel = 0
|
|
|
-And IsSure = 1 {userSql}
|
|
|
+ {userSql}
|
|
|
And VisitDate Between '{beginDt}' And '{endDt}'
|
|
|
Group By [Name]
|
|
|
Order By Count Desc");
|
|
@@ -2842,7 +2908,7 @@ Order By Count Desc");
|
|
|
From Grp_DelegationInfo di
|
|
|
Left Join Sys_SetData sd On di.TeamLevSId = sd.Id
|
|
|
Where di.Isdel = 0
|
|
|
-And IsSure = 1 {userSql}
|
|
|
+ {userSql}
|
|
|
And VisitDate Between '{beginDt}' And '{endDt}'
|
|
|
Group By [Name]
|
|
|
Order By Count Desc");
|
|
@@ -2858,7 +2924,7 @@ Order By Count Desc");
|
|
|
From Grp_DelegationInfo di
|
|
|
Left Join Sys_Users u On di.JietuanOperator = u.Id
|
|
|
Where di.Isdel = 0
|
|
|
- AND IsSure = 1 {userSql}
|
|
|
+ {userSql}
|
|
|
And VisitDate Between '{beginDt}' And '{endDt}'
|
|
|
Group By CnName");
|
|
|
|
|
@@ -2879,8 +2945,6 @@ Order By Count Desc");
|
|
|
return Ok(JsonView(true, "操作成功!", viewData, total));
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
/// <summary>
|
|
|
/// 市场部销售额
|
|
|
/// 客户拜访列表
|