Initial commit (code only without large binaries)
This commit is contained in:
64
EdgeUser/internal/web/actions/default/finance/index.go
Normal file
64
EdgeUser/internal/web/actions/default/finance/index.go
Normal file
@@ -0,0 +1,64 @@
|
||||
package bills
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/userconfigs"
|
||||
"github.com/TeaOSLab/EdgeUser/internal/web/actions/actionutils"
|
||||
"github.com/iwind/TeaGo/maps"
|
||||
timeutil "github.com/iwind/TeaGo/utils/time"
|
||||
)
|
||||
|
||||
type IndexAction struct {
|
||||
actionutils.ParentAction
|
||||
}
|
||||
|
||||
func (this *IndexAction) Init() {
|
||||
this.Nav("", "", "")
|
||||
}
|
||||
|
||||
func (this *IndexAction) RunGet(params struct {
|
||||
Keyword string
|
||||
}) {
|
||||
this.Data["keyword"] = params.Keyword
|
||||
|
||||
accountResp, err := this.RPC().UserAccountRPC().FindEnabledUserAccountWithUserId(this.UserContext(), &pb.FindEnabledUserAccountWithUserIdRequest{
|
||||
UserId: this.UserId(),
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
var account = accountResp.UserAccount
|
||||
|
||||
var accountMap = maps.Map{}
|
||||
accountMap["total"] = account.Total
|
||||
accountMap["totalFrozen"] = account.TotalFrozen
|
||||
this.Data["account"] = accountMap
|
||||
|
||||
// 最近操作记录
|
||||
logsResp, err := this.RPC().UserAccountLogRPC().ListUserAccountLogs(this.UserContext(), &pb.ListUserAccountLogsRequest{
|
||||
UserAccountId: account.Id,
|
||||
Offset: 0,
|
||||
Size: 10,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
var logMaps = []maps.Map{}
|
||||
for _, log := range logsResp.UserAccountLogs {
|
||||
logMaps = append(logMaps, maps.Map{
|
||||
"id": log.Id,
|
||||
"description": log.Description,
|
||||
"createdTime": timeutil.FormatTime("Y-m-d H:i:s", log.CreatedAt),
|
||||
"delta": log.Delta,
|
||||
"deltaFrozen": log.DeltaFrozen,
|
||||
"total": log.Total,
|
||||
"totalFrozen": log.TotalFrozen,
|
||||
"event": userconfigs.FindAccountEvent(log.EventType),
|
||||
})
|
||||
}
|
||||
this.Data["logs"] = logMaps
|
||||
|
||||
this.Show()
|
||||
}
|
||||
Reference in New Issue
Block a user