Skip to content

Commit 2ea3d03

Browse files
csg-pr-botDev AgentRader
committed
fix: 修复组织充值报告中订单用户名显示错误问题 (#967)
Co-authored-by: Dev Agent <dev-agent@example.com> Co-authored-by: rader <ld_leida@hotmail.com>
1 parent d17151f commit 2ea3d03

File tree

4 files changed

+96
-13
lines changed

4 files changed

+96
-13
lines changed

_mocks/opencsg.com/csghub-server/builder/store/database/mock_NamespaceStore.go

Lines changed: 59 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

builder/store/database/namespace.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"time"
66

7+
"github.com/uptrace/bun"
78
"opencsg.com/csghub-server/common/errorx"
89
)
910

@@ -13,6 +14,7 @@ type NamespaceStore interface {
1314
FindByUUID(ctx context.Context, uuid string) (Namespace, error)
1415
Exists(ctx context.Context, path string) (bool, error)
1516
ExistsByUUID(ctx context.Context, uuid string) (bool, error)
17+
FindByUUIDs(ctx context.Context, uuids []string) ([]Namespace, error)
1618
}
1719

1820
type NamespaceStoreImpl struct {
@@ -49,6 +51,7 @@ type Namespace struct {
4951
func (s *NamespaceStoreImpl) FindByPath(ctx context.Context, path string) (namespace Namespace, err error) {
5052
namespace.Path = path
5153
err = s.db.Operator.Core.NewSelect().Model(&namespace).Relation("User").Where("path = ?", path).Scan(ctx)
54+
err = errorx.HandleDBError(err, errorx.Ctx().Set("namespace", path))
5255
return
5356
}
5457

@@ -81,3 +84,20 @@ func (s *NamespaceStoreImpl) FindByUUID(ctx context.Context, uuid string) (names
8184
}
8285
return namespace, nil
8386
}
87+
88+
func (s *NamespaceStoreImpl) FindByUUIDs(ctx context.Context, uuids []string) (namespaces []Namespace, err error) {
89+
if len(uuids) == 0 {
90+
return namespaces, nil
91+
}
92+
93+
err = s.db.Operator.Core.
94+
NewSelect().
95+
Model(&namespaces).
96+
Where("uuid IN (?)", bun.In(uuids)).
97+
Scan(ctx)
98+
if err != nil {
99+
return namespaces, errorx.HandleDBError(err, errorx.Ctx().Set("uuids", uuids))
100+
}
101+
102+
return namespaces, nil
103+
}

common/types/accounting.go

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,8 @@ type RechargeResp struct {
449449
UpdatedAt time.Time `json:"updated_at"`
450450
Description string `json:"description"`
451451
UserName string `json:"user_name"`
452+
EntityType string `json:"entity_type"`
453+
OrgName string `json:"org_name"`
452454
}
453455

454456
const RechargeExtraType = "recharge"
@@ -531,18 +533,18 @@ type RechargesIndexResp struct {
531533
}
532534

533535
type PresentIndexResp struct {
534-
ID int64 `json:"id"`
535-
EventUUID string `json:"event_uuid"`
536-
UserUUID string `json:"user_uuid"`
537-
UserName string `json:"user_name"`
538-
ActivityID int64 `json:"activity_id"`
539-
Value float64 `json:"value"`
540-
OpUID string `json:"op_uid"`
541-
OpDesc string `json:"op_desc"`
542-
ParticipantUUID string `json:"participant_uuid"`
543-
ExpireAt time.Time `json:"expire_at"`
544-
Status AccountPresentStatus `json:"status"`
545-
CreatedAt time.Time `json:"created_at"`
536+
ID int64 `json:"id"`
537+
EventUUID string `json:"event_uuid"`
538+
UserUUID string `json:"user_uuid"`
539+
UserName string `json:"user_name"`
540+
ActivityID int64 `json:"activity_id"`
541+
Value float64 `json:"value"`
542+
OpUID string `json:"op_uid"`
543+
OpDesc string `json:"op_desc"`
544+
ParticipantUUID string `json:"participant_uuid"`
545+
ExpireAt time.Time `json:"expire_at"`
546+
Status AccountPresentStatus `json:"status"`
547+
CreatedAt time.Time `json:"created_at"`
546548
}
547549

548550
type PresentsIndexResp struct {

component/accounting.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ type accountingComponentImpl struct {
1717
accountingClient accounting.AccountingClient
1818
userStore database.UserStore
1919
orgStore database.OrgStore
20+
namespaceStore database.NamespaceStore
2021
memberStore database.MemberStore
2122
deployTaskStore database.DeployTaskStore
2223
userSvcClient rpc.UserSvcClient
@@ -65,7 +66,8 @@ func NewAccountingComponent(config *config.Config) (AccountingComponent, error)
6566
userSvcClient: userRpcClient,
6667
notificationSvcClient: rpc.NewNotificationSvcHttpClient(fmt.Sprintf("%s:%d", config.Notification.Host, config.Notification.Port),
6768
rpc.AuthWithApiKey(config.APIToken)),
68-
config: config,
69+
config: config,
70+
namespaceStore: database.NewNamespaceStore(),
6971
}, nil
7072
}
7173

0 commit comments

Comments
 (0)