|
@@ -38,6 +38,7 @@ namespace OASystem.API.Controllers
|
|
|
private readonly DelegationInfoRepository _groupRep;
|
|
|
private readonly SetDataRepository _setDataRep;
|
|
|
private readonly TeamRateRepository _teamRateRep;
|
|
|
+ private readonly VisitingClientsRepository _visitingClientsRep;
|
|
|
|
|
|
/// <summary>
|
|
|
/// Init
|
|
@@ -46,13 +47,14 @@ namespace OASystem.API.Controllers
|
|
|
/// <param name="sqlSugar"></param>
|
|
|
/// <param name="groupRep"></param>
|
|
|
/// <param name="setDataRep"></param>
|
|
|
- public StatisticsController(IMapper mapper, SqlSugarClient sqlSugar, DelegationInfoRepository groupRep, SetDataRepository setDataRep, TeamRateRepository teamRate)
|
|
|
+ public StatisticsController(IMapper mapper, SqlSugarClient sqlSugar, DelegationInfoRepository groupRep, SetDataRepository setDataRep, TeamRateRepository teamRate, VisitingClientsRepository visitingClientsRep)
|
|
|
{
|
|
|
_mapper = mapper;
|
|
|
_groupRep = groupRep;
|
|
|
_setDataRep = setDataRep;
|
|
|
_sqlSugar = sqlSugar;
|
|
|
_teamRateRep = teamRate;
|
|
|
+ _visitingClientsRep = visitingClientsRep;
|
|
|
}
|
|
|
|
|
|
|
|
@@ -2108,7 +2110,8 @@ namespace OASystem.API.Controllers
|
|
|
MonthlyTimeSegment timeSegment = new MonthlyTimeSegment(y, m);
|
|
|
monthDatas.Add(new { name = $"{ConvertToChinese(m)}", beginDt = timeSegment.Start.ToString("yyyy-MM-dd"), endDt = timeSegment.End.ToString("yyyy-MM-dd") });
|
|
|
}
|
|
|
- quarterData = new { name = "第一季度", beginDt = $"{y}-01-01", endDt = $" {y}-03-31", monthData = monthDatas };
|
|
|
+ //quarterData = new { name = "第一季度", beginDt = $"{y}-01-01", endDt = $" {y}-03-31", monthData = monthDatas };
|
|
|
+ quarterData = new { name = "第一季度", monthData = monthDatas };
|
|
|
}
|
|
|
else if (q == 1)
|
|
|
{
|
|
@@ -2120,7 +2123,8 @@ namespace OASystem.API.Controllers
|
|
|
monthDatas.Add(new { name = $"{ConvertToChinese(m)}", beginDt = timeSegment.Start.ToString("yyyy-MM-dd"), endDt = timeSegment.End.ToString("yyyy-MM-dd") });
|
|
|
}
|
|
|
|
|
|
- quarterData = new { name = "第二季度", beginDt = $"{y}-04-01", endDt = $"{y}-06-30", monthData = monthDatas };
|
|
|
+ //quarterData = new { name = "第二季度", beginDt = $"{y}-04-01", endDt = $"{y}-06-30", monthData = monthDatas };
|
|
|
+ quarterData = new { name = "第二季度", monthData = monthDatas };
|
|
|
}
|
|
|
else if (q == 2)
|
|
|
{
|
|
@@ -2131,7 +2135,8 @@ namespace OASystem.API.Controllers
|
|
|
MonthlyTimeSegment timeSegment = new MonthlyTimeSegment(y, m);
|
|
|
monthDatas.Add(new { name = $"{ConvertToChinese(m)}", beginDt = timeSegment.Start.ToString("yyyy-MM-dd"), endDt = timeSegment.End.ToString("yyyy-MM-dd") });
|
|
|
}
|
|
|
- quarterData = new { name = "第三季度", beginDt = $"{y}-07-01", endDt = $"{y}-09-30", monthData = monthDatas };
|
|
|
+ //quarterData = new { name = "第三季度", beginDt = $"{y}-07-01", endDt = $"{y}-09-30", monthData = monthDatas };
|
|
|
+ quarterData = new { name = "第三季度", monthData = monthDatas };
|
|
|
}
|
|
|
else if (q == 3)
|
|
|
{
|
|
@@ -2142,7 +2147,8 @@ namespace OASystem.API.Controllers
|
|
|
MonthlyTimeSegment timeSegment = new MonthlyTimeSegment(y, m);
|
|
|
monthDatas.Add(new { name = $"{ConvertToChinese(m)}", beginDt = timeSegment.Start.ToString("yyyy-MM-dd"), endDt = timeSegment.End.ToString("yyyy-MM-dd") });
|
|
|
}
|
|
|
- quarterData = new { name = "第四季度", beginDt = $"{y}-10-01", endDt = $"{y}-12-31", monthData = monthDatas };
|
|
|
+ //quarterData = new { name = "第四季度", beginDt = $"{y}-10-01", endDt = $"{y}-12-31", monthData = monthDatas };
|
|
|
+ quarterData = new { name = "第四季度", monthData = monthDatas };
|
|
|
}
|
|
|
quarterDatas.Add(quarterData);
|
|
|
}
|
|
@@ -2150,7 +2156,7 @@ namespace OASystem.API.Controllers
|
|
|
dtData.Add(new
|
|
|
{
|
|
|
year = y,
|
|
|
- yearData = new { beginDt = $"{y}-01-01", endDt = $"{y}-12-31" },
|
|
|
+ //yearData = new { beginDt = $"{y}-01-01", endDt = $"{y}-12-31" },
|
|
|
quarterData = quarterDatas,
|
|
|
});
|
|
|
}
|
|
@@ -2205,12 +2211,12 @@ namespace OASystem.API.Controllers
|
|
|
|
|
|
//今年销售额
|
|
|
string beginDt = $"{_dto.BeginDt} 00:00:00",endDt = $"{_dto.EndDt} 23:59:59";
|
|
|
- decimal thisYearSales = GroupSales(_dto.CompanyId, _dto.GroupPickupUserId, beginDt, endDt);
|
|
|
+ decimal thisYearSales = await GroupSales(_dto.CompanyId, _dto.GroupPickupUserId, beginDt, endDt);
|
|
|
|
|
|
//去年销售额
|
|
|
string lastYearBeginDt = $"{DateTime.Parse(_dto.BeginDt).AddYears(-1).ToString("yyyy-MM-dd")} 00:00:00";
|
|
|
string lastYearEndDt = $"{DateTime.Parse(_dto.EndDt).AddYears(-1).ToString("yyyy-MM-dd")} 23:59:59";
|
|
|
- decimal lastYearSales = GroupSales(_dto.CompanyId, _dto.GroupPickupUserId, lastYearBeginDt, lastYearEndDt);
|
|
|
+ decimal lastYearSales = await GroupSales(_dto.CompanyId, _dto.GroupPickupUserId, lastYearBeginDt, lastYearEndDt);
|
|
|
|
|
|
//同比
|
|
|
decimal yoy = 0.00M;
|
|
@@ -2232,7 +2238,7 @@ namespace OASystem.API.Controllers
|
|
|
/// <param name="beginDt"></param>
|
|
|
/// <param name="endDt"></param>
|
|
|
/// <returns></returns>
|
|
|
- private decimal GroupSales(int companyId,int groupPickupUserId,string beginDt,string endDt)
|
|
|
+ private async Task<decimal> GroupSales(int companyId,int groupPickupUserId,string beginDt,string endDt)
|
|
|
{
|
|
|
decimal sales = 0.00M;
|
|
|
|
|
@@ -2242,12 +2248,12 @@ namespace OASystem.API.Controllers
|
|
|
if (companyId > 0) userSqlWhere += string.Format($" And CompanyId={companyId}");
|
|
|
if (groupPickupUserId > 0) userSqlWhere += string.Format($" And Id={groupPickupUserId}");
|
|
|
string userSql = string.Format($" Select * From Sys_Users Where Isdel = 0 {userSqlWhere}");
|
|
|
- userId = _sqlSugar.SqlQueryable<Sys_Users>(userSql).Select(it => it.Id).ToList();
|
|
|
+ userId = await _sqlSugar.SqlQueryable<Sys_Users>(userSql).Select(it => it.Id).ToListAsync();
|
|
|
|
|
|
//团组信息
|
|
|
string groupSql = string.Format($"Select * From Grp_DelegationInfo Where Isdel = 0 And VisitDate Between '{beginDt}' And '{endDt}'");
|
|
|
if (userId.Count > 0) groupSql = $"{groupSql} And JietuanOperator In ({string.Join(",", userId)})";
|
|
|
- var groupIds = _sqlSugar.SqlQueryable<Grp_DelegationInfo>(groupSql).Select(it => it.Id).ToList();
|
|
|
+ var groupIds = await _sqlSugar.SqlQueryable<Grp_DelegationInfo>(groupSql).Select(it => it.Id).ToListAsync();
|
|
|
|
|
|
|
|
|
//销售额 = 收款账单.账单模块 + 收款账单.成本预算模块 + 收款账单.分摊费用 Fin_ForeignReceivables
|
|
@@ -2256,7 +2262,7 @@ namespace OASystem.API.Controllers
|
|
|
1 ,// - 成本预算模块
|
|
|
2 ,// - 分摊费用
|
|
|
};
|
|
|
- var foreignReceivables = _sqlSugar.Queryable<Fin_ForeignReceivables>().Where(it => it.IsDel == 0 && feeTypes.Contains(it.AddingWay) && groupIds.Contains(it.Diid)).ToList();
|
|
|
+ var foreignReceivables = await _sqlSugar.Queryable<Fin_ForeignReceivables>().Where(it => it.IsDel == 0 && feeTypes.Contains(it.AddingWay) && groupIds.Contains(it.Diid)).ToListAsync();
|
|
|
sales = foreignReceivables.Sum(it => it.ItemSumPrice * it.Rate);
|
|
|
|
|
|
return sales;
|
|
@@ -2438,6 +2444,82 @@ Order By Count Desc");
|
|
|
return Ok(JsonView(true, "操作成功!", rankingData, total));
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// 市场部销售额
|
|
|
+ /// 客户拜访列表
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="_dto">市场部销售额请求dto</param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [HttpPost("PostMarketingSalesVCList")]
|
|
|
+ [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
|
|
|
+ public async Task<IActionResult> PostMarketingSalesVCList(MarketingSalesVCListDto _dto)
|
|
|
+ {
|
|
|
+ #region 参数验证
|
|
|
+ MarketingSalesUserPageFuncDtoBaseFoalidator validationRules = new MarketingSalesUserPageFuncDtoBaseFoalidator();
|
|
|
+ var validResult = await validationRules.ValidateAsync(_dto);
|
|
|
+ if (!validResult.IsValid)
|
|
|
+ {
|
|
|
+ var errors = new StringBuilder();
|
|
|
+ foreach (var error in validResult.Errors) errors.AppendLine(error.ErrorMessage);
|
|
|
+ return Ok(JsonView(false, errors.ToString()));
|
|
|
+ }
|
|
|
+
|
|
|
+ PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
|
|
|
+
|
|
|
+ #region 页面操作权限验证
|
|
|
+ pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
|
|
|
+
|
|
|
+ if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, MsgTips.CheckAuth));
|
|
|
+ #endregion
|
|
|
+ #endregion
|
|
|
+ return Ok(await _visitingClientsRep._List(_dto.PortType,_dto.PageIndex,_dto.PageIndex,_dto.DiId,_dto.Search));
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 市场部销售额
|
|
|
+ /// 客户拜访 操作(添加 Or 编辑)
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="_dto">市场部销售额请求dto</param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [HttpPost("PostMarketingSalesVCOperate")]
|
|
|
+ [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
|
|
|
+ public async Task<IActionResult> PostMarketingSalesVCOperate(MarketingSalesVCOperrateDto _dto)
|
|
|
+ {
|
|
|
+ #region 参数验证
|
|
|
+ MarketingSalesUserPageFuncDtoBaseFoalidator validationRules = new MarketingSalesUserPageFuncDtoBaseFoalidator();
|
|
|
+ var validResult = await validationRules.ValidateAsync(_dto);
|
|
|
+ if (!validResult.IsValid)
|
|
|
+ {
|
|
|
+ var errors = new StringBuilder();
|
|
|
+ foreach (var error in validResult.Errors) errors.AppendLine(error.ErrorMessage);
|
|
|
+ return Ok(JsonView(false, errors.ToString()));
|
|
|
+ }
|
|
|
+
|
|
|
+ PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
|
|
|
+
|
|
|
+ #region 页面操作权限验证
|
|
|
+ pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
|
|
|
+
|
|
|
+ if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, MsgTips.CheckAuth));
|
|
|
+ #endregion
|
|
|
+ #endregion
|
|
|
+ return Ok(await _visitingClientsRep._AddOrEdit(_dto));
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 市场部销售额
|
|
|
+ /// 客户拜访 Del
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="_dto">市场部销售额请求dto</param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [HttpPost("PostMarketingSalesVCDel")]
|
|
|
+ [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
|
|
|
+ public async Task<IActionResult> PostMarketingSalesVCDel(MarketingSalesVCDelDto _dto)
|
|
|
+ {
|
|
|
+
|
|
|
+ return Ok(await _visitingClientsRep._Del(_dto.Id,_dto.UserId));
|
|
|
+ }
|
|
|
+
|
|
|
#endregion
|
|
|
}
|
|
|
}
|