feat: customer industry distribution
This commit is contained in:
@@ -1,10 +1,16 @@
|
||||
package models
|
||||
|
||||
type DashboardSum struct {
|
||||
Customers int `json:"customers"`
|
||||
Contracts int `json:"contracts"`
|
||||
ContractAmount float64 `json:"contractAmount"`
|
||||
Products int `json:"products"`
|
||||
Date []string `json:"date"`
|
||||
Amount []float64 `json:"amount"`
|
||||
Customers int `json:"customers"`
|
||||
Contracts int `json:"contracts"`
|
||||
ContractAmount float64 `json:"contractAmount"`
|
||||
Products int `json:"products"`
|
||||
Date []string `json:"date"`
|
||||
Amount []float64 `json:"amount"`
|
||||
CustomerIndustry []*CustomerIndustry `json:"customerIndustry"`
|
||||
}
|
||||
|
||||
type CustomerIndustry struct {
|
||||
Name string `json:"name"`
|
||||
Value int `json:"value"`
|
||||
}
|
||||
|
||||
@@ -28,6 +28,8 @@ func (d *DashboardService) Summary(uid int64, days int) models.DashboardSum {
|
||||
ds.Date[i] = time.Unix(day, 0).Format("01-02")
|
||||
d--
|
||||
}
|
||||
s := "industry as name, count(*) as value"
|
||||
global.Db.Model(&models.Customer{}).Select(s).Where("creator = ?", uid).Group("industry").Find(&ds.CustomerIndustry)
|
||||
return ds
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user