Initial commit (code only without large binaries)
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
|
||||
package bills
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/systemconfigs"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/userconfigs"
|
||||
"github.com/TeaOSLab/EdgeUser/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeUser/internal/web/actions/default/finance/financeutils"
|
||||
"github.com/iwind/TeaGo/maps"
|
||||
)
|
||||
|
||||
type MethodOptionsAction struct {
|
||||
actionutils.ParentAction
|
||||
}
|
||||
|
||||
func (this *MethodOptionsAction) RunPost(params struct{}) {
|
||||
// 配置
|
||||
configResp, err := this.RPC().SysSettingRPC().ReadSysSetting(this.UserContext(), &pb.ReadSysSettingRequest{Code: systemconfigs.SettingCodeUserOrderConfig})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
var config = userconfigs.DefaultUserOrderConfig()
|
||||
if len(configResp.ValueJSON) > 0 {
|
||||
err = json.Unmarshal(configResp.ValueJSON, config)
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
this.Data["config"] = config
|
||||
|
||||
// methods
|
||||
methodsResp, err := this.RPC().OrderMethodRPC().FindAllAvailableOrderMethods(this.UserContext(), &pb.FindAllAvailableOrderMethodsRequest{})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
|
||||
var methods = methodsResp.OrderMethods
|
||||
|
||||
// 没有可用的支付方式时也不影响支付
|
||||
var methodMaps = []maps.Map{}
|
||||
for _, method := range methods {
|
||||
methodMaps = append(methodMaps, maps.Map{
|
||||
"id": method.Id,
|
||||
"name": method.Name,
|
||||
"code": method.Code,
|
||||
"description": method.Description,
|
||||
})
|
||||
}
|
||||
|
||||
this.Data["enablePay"] = config.EnablePay
|
||||
this.Data["methods"] = methodMaps
|
||||
|
||||
// 用户余额
|
||||
balance, err := financeutils.FindUserBalance(this.UserContext())
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
this.Data["balance"] = balance
|
||||
|
||||
this.Success()
|
||||
}
|
||||
Reference in New Issue
Block a user