更改统计
This commit is contained in:
parent
824199c87c
commit
2a60d34711
@ -188,3 +188,68 @@ func int64SliceToInt(in []int64) []int {
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func countPoolInventory(mi interface{}, soldOnly bool) (int64, error) {
|
||||
qs := models.Orm.QueryTable(mi).Filter("delete_time__isnull", true)
|
||||
if soldOnly {
|
||||
qs = qs.Filter("is_extracted__in", 1, 2)
|
||||
}
|
||||
n, err := qs.Count()
|
||||
return n, err
|
||||
}
|
||||
|
||||
// AccountPoolInventoryTotals GET /platform/home/accountPoolInventoryTotals
|
||||
// 各号池:账号总数(未删)、已售卖(is_extracted 为 1 或 2)
|
||||
func (c *PlatformHomeController) AccountPoolInventoryTotals() {
|
||||
if _, err := requirePlatformAuth(&c.Controller); err != nil {
|
||||
poolJSONErr(&c.Controller, 401, 401, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
type invModule struct {
|
||||
Key string `json:"key"`
|
||||
Label string `json:"label"`
|
||||
Total int64 `json:"total"`
|
||||
Sold int64 `json:"sold"`
|
||||
}
|
||||
|
||||
modules := []invModule{
|
||||
{Key: "cursor", Label: "Cursor"},
|
||||
{Key: "krio", Label: "Kiro"},
|
||||
{Key: "windsurf", Label: "Windsurf"},
|
||||
}
|
||||
modelsList := []interface{}{
|
||||
new(models.PlatformAccountPoolCursor),
|
||||
new(models.PlatformAccountPoolKiro),
|
||||
new(models.PlatformAccountPoolWindsurf),
|
||||
}
|
||||
|
||||
var grandTotal, grandSold int64
|
||||
for i := range modules {
|
||||
tot, err := countPoolInventory(modelsList[i], false)
|
||||
if err != nil {
|
||||
poolJSONErr(&c.Controller, 500, 500, "统计失败: "+err.Error())
|
||||
return
|
||||
}
|
||||
sd, err := countPoolInventory(modelsList[i], true)
|
||||
if err != nil {
|
||||
poolJSONErr(&c.Controller, 500, 500, "统计失败: "+err.Error())
|
||||
return
|
||||
}
|
||||
modules[i].Total = tot
|
||||
modules[i].Sold = sd
|
||||
grandTotal += tot
|
||||
grandSold += sd
|
||||
}
|
||||
|
||||
c.Data["json"] = map[string]interface{}{
|
||||
"code": 200,
|
||||
"msg": "success",
|
||||
"data": map[string]interface{}{
|
||||
"modules": modules,
|
||||
"grandTotal": grandTotal,
|
||||
"grandSold": grandSold,
|
||||
},
|
||||
}
|
||||
_ = c.ServeJSON()
|
||||
}
|
||||
|
||||
@ -160,6 +160,7 @@ func Register() {
|
||||
|
||||
// 首页统计
|
||||
beego.Router("/platform/home/accountPoolDailyExtract", &controllers.PlatformHomeController{}, "get:AccountPoolDailyExtract")
|
||||
beego.Router("/platform/home/accountPoolInventoryTotals", &controllers.PlatformHomeController{}, "get:AccountPoolInventoryTotals")
|
||||
|
||||
// 账号池管理(cursor/windsurf/krio)
|
||||
beego.Router("/platform/accountPool/cursor/list", &controllers.PlatformAccountPoolCursorController{}, "get:List")
|
||||
|
||||
BIN
server.exe
BIN
server.exe
Binary file not shown.
Loading…
Reference in New Issue
Block a user