|
@@ -175,8 +175,22 @@ func getCompanyContractReportData(ctx context.Context, dataType string, params *
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // 过滤掉已删除的销售
|
|
|
|
|
+ normalUserMap := make(map[int]bool)
|
|
|
|
|
+ normalUsers, err := srv.Dao.DB.Model("sys_user").Where("status='10'").FindAll()
|
|
|
|
|
+ if err != nil && err != sql.ErrNoRows {
|
|
|
|
|
+ return nil, err
|
|
|
|
|
+ }
|
|
|
|
|
+ for _, user := range normalUsers {
|
|
|
|
|
+ normalUserMap[user["id"].Int()] = true
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
// 统计目标值和实际值
|
|
// 统计目标值和实际值
|
|
|
for index, target := range targets {
|
|
for index, target := range targets {
|
|
|
|
|
+ // 过滤掉已删除的销售
|
|
|
|
|
+ if !normalUserMap[target["sale_user_id"].Int()] {
|
|
|
|
|
+ continue
|
|
|
|
|
+ }
|
|
|
reportData.XData = append(reportData.XData, target["sale_user_name"].String())
|
|
reportData.XData = append(reportData.XData, target["sale_user_name"].String())
|
|
|
reportData.YDataTarget = append(reportData.YDataTarget, target[targetField].Float64())
|
|
reportData.YDataTarget = append(reportData.YDataTarget, target[targetField].Float64())
|
|
|
if realData, ok := realMap[target["sale_user_id"].Int()]; ok {
|
|
if realData, ok := realMap[target["sale_user_id"].Int()]; ok {
|
|
@@ -226,19 +240,19 @@ func getQuarterGoalReportData(ctx context.Context, dataType string, params *map[
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
got := map[string]float64{}
|
|
got := map[string]float64{}
|
|
|
- ctrdao := srv.Dao.Where("year(created_time) = ?", year)
|
|
|
|
|
|
|
+ ctrdao := srv.Dao.As("a").InnerJoin("sys_user b", "a.incharge_id=b.id").Where("b.status='10'").Where("year(a.created_time) = ?", year)
|
|
|
if quarter != 0 {
|
|
if quarter != 0 {
|
|
|
if quarter == 1 {
|
|
if quarter == 1 {
|
|
|
- ctrdao = ctrdao.Where("month(created_time) in (1,2,3)")
|
|
|
|
|
|
|
+ ctrdao = ctrdao.Where("month(a.created_time) in (1,2,3)")
|
|
|
}
|
|
}
|
|
|
if quarter == 2 {
|
|
if quarter == 2 {
|
|
|
- ctrdao = ctrdao.Where("month(created_time) in (4,5,6)")
|
|
|
|
|
|
|
+ ctrdao = ctrdao.Where("month(a.created_time) in (4,5,6)")
|
|
|
}
|
|
}
|
|
|
if quarter == 3 {
|
|
if quarter == 3 {
|
|
|
- ctrdao = ctrdao.Where("month(created_time) in (7,8,9)")
|
|
|
|
|
|
|
+ ctrdao = ctrdao.Where("month(a.created_time) in (7,8,9)")
|
|
|
}
|
|
}
|
|
|
if quarter == 4 {
|
|
if quarter == 4 {
|
|
|
- ctrdao = ctrdao.Where("month(created_time) in (10,11,12)")
|
|
|
|
|
|
|
+ ctrdao = ctrdao.Where("month(a.created_time) in (10,11,12)")
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
ctrent, err := ctrdao.All()
|
|
ctrent, err := ctrdao.All()
|
|
@@ -305,8 +319,23 @@ func getClockfrequency(ctx context.Context, dataType string, params *map[string]
|
|
|
if err != nil && err != sql.ErrNoRows {
|
|
if err != nil && err != sql.ErrNoRows {
|
|
|
return nil, err
|
|
return nil, err
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ // 过滤掉已删除的销售
|
|
|
|
|
+ normalUserMap := make(map[int]bool)
|
|
|
|
|
+ normalUsers, err := srv.Dao.DB.Model("sys_user").Where("status='10'").FindAll()
|
|
|
|
|
+ if err != nil && err != sql.ErrNoRows {
|
|
|
|
|
+ return nil, err
|
|
|
|
|
+ }
|
|
|
|
|
+ for _, user := range normalUsers {
|
|
|
|
|
+ normalUserMap[user["id"].Int()] = true
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
// 赋值实际值
|
|
// 赋值实际值
|
|
|
for index, target := range platpunchrecords {
|
|
for index, target := range platpunchrecords {
|
|
|
|
|
+ // 过滤掉已删除的销售
|
|
|
|
|
+ if !normalUserMap[target["user_id"].Int()] {
|
|
|
|
|
+ continue
|
|
|
|
|
+ }
|
|
|
reportData.XData = append(reportData.XData, target["user_nick_name"].String())
|
|
reportData.XData = append(reportData.XData, target["user_nick_name"].String())
|
|
|
reportData.YDataTarget = append(reportData.YDataTarget, target["punch_sum"].Float64())
|
|
reportData.YDataTarget = append(reportData.YDataTarget, target["punch_sum"].Float64())
|
|
|
if realData, ok := realMap[target["punch_sum"].Int()]; ok {
|
|
if realData, ok := realMap[target["punch_sum"].Int()]; ok {
|
|
@@ -637,9 +666,9 @@ func (s *HomeService) getNewAndConvertBusiness(productLine []string, params *map
|
|
|
// 报表数据 三大产品线,AB类项目出货金额
|
|
// 报表数据 三大产品线,AB类项目出货金额
|
|
|
func (s *HomeService) getShipmentAmount(productLine, nboType []string) (interface{}, error) {
|
|
func (s *HomeService) getShipmentAmount(productLine, nboType []string) (interface{}, error) {
|
|
|
businessDao := projDao.NewProjBusinessDao(s.Tenant)
|
|
businessDao := projDao.NewProjBusinessDao(s.Tenant)
|
|
|
- data, err := businessDao.Fields("product_line, nbo_type, SUM(est_trans_price) as est_trans_price").
|
|
|
|
|
- WhereIn("product_line", productLine).WhereIn("nbo_type", nboType).
|
|
|
|
|
- Group("product_line, nbo_type").Order("product_line ASC, nbo_type ASC").DataScope(s.Ctx, "sale_id").All()
|
|
|
|
|
|
|
+ data, err := businessDao.As("a").InnerJoin("sys_user b", "a.sale_id=b.id").Fields("a.product_line, a.nbo_type, SUM(a.est_trans_price) as est_trans_price").Where("b.status='10'").
|
|
|
|
|
+ WhereIn("a.product_line", productLine).WhereIn("a.nbo_type", nboType).
|
|
|
|
|
+ Group("a.product_line, a.nbo_type").Order("a.product_line ASC, a.nbo_type ASC").DataScope(s.Ctx, "a.sale_id").All()
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
return nil, err
|
|
return nil, err
|
|
|
}
|
|
}
|
|
@@ -665,28 +694,28 @@ func (s *HomeService) getProductLineSignedAndBackAmount(productLine []string) (i
|
|
|
monthEnd := currentTime.EndOfMonth()
|
|
monthEnd := currentTime.EndOfMonth()
|
|
|
|
|
|
|
|
contractDao := contDao.NewCtrContractDao(s.Tenant)
|
|
contractDao := contDao.NewCtrContractDao(s.Tenant)
|
|
|
- commonDao := contractDao.DataScope(s.Ctx, "incharge_id").WhereIn(contractDao.C.ProductLine, productLine).
|
|
|
|
|
|
|
+ commonDao := contractDao.As("a").InnerJoin("sys_user b", "a.incharge_id=b.id").DataScope(s.Ctx, "incharge_id").WhereIn(contractDao.C.ProductLine, productLine).Where("b.status='10'").
|
|
|
Group(contractDao.C.ProductLine).OrderAsc(contractDao.C.ProductLine)
|
|
Group(contractDao.C.ProductLine).OrderAsc(contractDao.C.ProductLine)
|
|
|
|
|
|
|
|
//累计签约合同金额 contract_amount
|
|
//累计签约合同金额 contract_amount
|
|
|
- allContractAmount, err := commonDao.Fields("product_line, SUM(contract_amount) as contract_amount").All()
|
|
|
|
|
|
|
+ allContractAmount, err := commonDao.Fields("a.product_line, SUM(a.contract_amount) as contract_amount").All()
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
return nil, err
|
|
return nil, err
|
|
|
}
|
|
}
|
|
|
//累计回款金额 collected_amount
|
|
//累计回款金额 collected_amount
|
|
|
- allCollectedAmount, err := commonDao.Fields("product_line, SUM(collected_amount) as collected_amount").All()
|
|
|
|
|
|
|
+ allCollectedAmount, err := commonDao.Fields("a.product_line, SUM(a.collected_amount) as collected_amount").All()
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
return nil, err
|
|
return nil, err
|
|
|
}
|
|
}
|
|
|
//当月签约合同金额(维度:月)
|
|
//当月签约合同金额(维度:月)
|
|
|
monthContractAmount, err := commonDao.WhereGTE(contractDao.C.ContractStartTime, monthStart).WhereLTE(contractDao.C.ContractStartTime, monthEnd).
|
|
monthContractAmount, err := commonDao.WhereGTE(contractDao.C.ContractStartTime, monthStart).WhereLTE(contractDao.C.ContractStartTime, monthEnd).
|
|
|
- Fields("product_line, SUM(contract_amount) as contract_amount").All()
|
|
|
|
|
|
|
+ Fields("a.product_line, SUM(a.contract_amount) as contract_amount").All()
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
return nil, err
|
|
return nil, err
|
|
|
}
|
|
}
|
|
|
//当月回款金额(维度:月)
|
|
//当月回款金额(维度:月)
|
|
|
monthCollectedAmount, err := commonDao.WhereGTE(contractDao.C.ContractStartTime, monthStart).WhereLTE(contractDao.C.ContractStartTime, monthEnd).
|
|
monthCollectedAmount, err := commonDao.WhereGTE(contractDao.C.ContractStartTime, monthStart).WhereLTE(contractDao.C.ContractStartTime, monthEnd).
|
|
|
- Fields("product_line, SUM(collected_amount) as collected_amount").All()
|
|
|
|
|
|
|
+ Fields("a.product_line, SUM(a.collected_amount) as collected_amount").All()
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
return nil, err
|
|
return nil, err
|
|
|
}
|
|
}
|