diff --git a/internal/v2/logic/app/jyy/jyy.go b/internal/v2/logic/app/jyy/jyy.go index 74cc70c..395e984 100644 --- a/internal/v2/logic/app/jyy/jyy.go +++ b/internal/v2/logic/app/jyy/jyy.go @@ -638,7 +638,10 @@ func (o logic) ProfitCount(args ArgsProfitCount) (res Profit, err error) { if args.End != "" { query = query.Where("created_at < ?", args.End) } - query.Select("SUM(actual_total_amount) as total").First(&res) + amount := make([]decimal.Decimal, 0) + q1 := query.Select("IFNULL(SUM(actual_total_amount), 0) as total") + q1.Pluck("total", &amount) + res.Total = amount[0] switch args.Kind { case 1: // 年为单位 @@ -650,7 +653,7 @@ func (o logic) ProfitCount(args ArgsProfitCount) (res Profit, err error) { // 日 query = query.Select("DATE(created_at) as name, count(*) as count, SUM(actual_total_amount) as amount ").Group("DATE(created_at)") } - query.Find(&res.Data) + query.Scan(&res.Data) return }