u
This commit is contained in:
1 parent
3af982d669
commit
6a24be0864
28 files changed
+572
-458
No files matched your search
@@ -12,12 +12,14 @@ import (
|
||||
"cn/oneao/base-go/utils/response"
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/jackc/pgx/v5/pgtype"
|
||||
"github.com/shopspring/decimal"
|
||||
"sort"
|
||||
"time"
|
||||
|
||||
"github.com/jackc/pgx/v5/pgtype"
|
||||
"github.com/shopspring/decimal"
|
||||
|
||||
money "cn/oneao/base-go/biz/model/money"
|
||||
|
||||
"github.com/cloudwego/hertz/pkg/app"
|
||||
"github.com/cloudwego/hertz/pkg/protocol/consts"
|
||||
)
|
||||
@@ -51,7 +53,8 @@ func QueryMoneyRecord(ctx context.Context, c *app.RequestContext) {
|
||||
// 最终返回统一类型
|
||||
var records []*money.MoneyRecordItem
|
||||
|
||||
if ok { // 有空间ID,查询空间内所有用户
|
||||
// 有空间ID,查询空间内所有用户
|
||||
if ok {
|
||||
params := repo.FindMoneyRecordsBySpaceParams{
|
||||
SpaceID: spaceID,
|
||||
RecordTime: pgtype.Timestamp{Time: startTime, Valid: true},
|
||||
@@ -79,8 +82,8 @@ func QueryMoneyRecord(ctx context.Context, c *app.RequestContext) {
|
||||
UpdateTime: pgtypex.TimestampToDateTimeString(r.UpdateTime),
|
||||
})
|
||||
}
|
||||
|
||||
} else { // 没有空间ID,只查询单用户
|
||||
} else {
|
||||
// 没有空间ID,只查询单用户
|
||||
params := repo.FindUserMoneyRecordsParams{
|
||||
UserID: userID,
|
||||
RecordTime: pgtype.Timestamp{Time: startTime, Valid: true},
|
||||
@@ -100,7 +103,7 @@ func QueryMoneyRecord(ctx context.Context, c *app.RequestContext) {
|
||||
CategoryIcon: r.CategoryIcon.String,
|
||||
CategoryName: r.CategoryName.String,
|
||||
UserId: r.UserID,
|
||||
Username: "", // 单用户查询没有 username
|
||||
Username: "",
|
||||
Amount: pgtypex.NumericToString(r.Amount),
|
||||
Remark: r.Remark.String,
|
||||
RecordTime: pgtypex.TimestampToDateString(r.RecordTime),
|
||||
@@ -162,6 +165,7 @@ func QueryMoneyRecord(ctx context.Context, c *app.RequestContext) {
|
||||
Records: resultGroups,
|
||||
TotalIncome: totalIncome.Round(2).StringFixed(2),
|
||||
TotalExpense: totalExpense.Round(2).StringFixed(2),
|
||||
TotalBalance: totalIncome.Sub(totalExpense).Round(2).StringFixed(2),
|
||||
}
|
||||
|
||||
response.Success(c).Data(result).Send()
|
||||
|
||||
Reference in new issue
Block a user