xcommon

package
v0.0.0-...-c0ca47f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 23, 2026 License: AGPL-3.0 Imports: 16 Imported by: 2

Documentation

Index

Constants

View Source
const Precision = 4 // 小数位数

Variables

View Source
var (
	ErrCustomerAddClosed           = errors.New(`已关闭`)
	ErrCustomerRoleDisabled        = errors.New(`当前角色未开启此功能`)
	ErrCustomerAddMaxPerDay        = errors.New(`已达到今日最大数量`)
	ErrCustomerAddMaxPending       = errors.New(`待审核数量已达上限`)
	ErrCustomerAddMaxPendingPerDay = errors.New(`待审核数量已达今日上限`)
)
View Source
var (
	BackendURL = common.BackendURL
)
View Source
var CurrencySymbols = map[string]string{
	`CNY`: `¥`,
	`USD`: `$`,
	`JPY`: `¥`,
	`EUR`: `€`,
	`GBP`: `£`,
	`FRF`: `₣`,
	`KRW`: `₩`,
	`RUB`: `₽`,
	`HKD`: `HK$`,
	`AUD`: `A$`,
	`CAD`: `C$`,
	`INR`: `₹`,
}

CurrencySymbols 货币符号

Functions

func BackendAssetsURL

func BackendAssetsURL(ctx echo.Context) string

func CalcPrice

func CalcPrice(price float64, exchangeRate float64, precision ...int32) float64

func CalcPriceByInternal

func CalcPriceByInternal(ctx echo.Context, price float64, precision ...int32) float64

func CheckGlobalCustomerAdd

func CheckGlobalCustomerAdd(ctx echo.Context, customerID interface{}, typ string, counter CustomerAddedCounter) error

func CheckRoleCustomerAdd

func CheckRoleCustomerAdd(ctx echo.Context, permission *xrole.RolePermission, behaviorName string, customerID interface{}, counter CustomerAddedCounter) error

func CurrencyByInternal

func CurrencyByInternal(ctx echo.Context) string

func CurrencyWithCurrencyAndPrecision

func CurrencyWithCurrencyAndPrecision(ctx echo.Context, amount float64, currency string, precision int32, withFlags ...bool) string

CurrencyWithPrecision HTML模板函数:币种 amount: 金额 currency: 币种 precision: 小数位数 withFlags[0]: 是否带货币符号 withFlags[1]: 是否清楚小数末尾的0

func CurrencyWithPrecision

func CurrencyWithPrecision(ctx echo.Context, amount float64, precision int32, withFlags ...bool) string

CurrencyWithPrecision HTML模板函数:币种 amount: 金额 precision: 小数位数 withFlags[0]: 是否带货币符号 withFlags[1]: 是否清楚小数末尾的0

func DefaultCurrency

func DefaultCurrency() string

DefaultCurrency 默认币种

func DefaultCurrencySymbol

func DefaultCurrencySymbol() string

DefaultCurrencySymbol 默认币种符号

func FrontendAssetsURL

func FrontendAssetsURL(ctx echo.Context) string

func FrontendURL

func FrontendURL(ctx echo.Context) string

func GetCurrencyPrecision

func GetCurrencyPrecision(ctx echo.Context) int32

func GetCurrencySymbol

func GetCurrencySymbol(ctx echo.Context, inputCurrency ...string) string

func HTMLCurrency

func HTMLCurrency(ctx echo.Context, amount float64, withFlags ...bool) template.HTML

HTMLCurrency HTML模板函数:币种 amount: 金额 withFlags[0]: 是否带货币符号 withFlags[1]: 是否清楚小数末尾的0

func HTMLCurrencySymbol

func HTMLCurrencySymbol(ctx echo.Context, inputCurrency ...string) template.HTML

HTMLCurrencySymbol HTML模板函数:币种符号

func HTMLCurrencyWithPrecision

func HTMLCurrencyWithPrecision(ctx echo.Context, amount float64, precision int32, withFlags ...bool) template.HTML

HTMLCurrencyWithPrecision HTML模板函数:币种 amount: 金额 precision: 小数位数 withFlags[0]: 是否带货币符号 withFlags[1]: 是否清楚小数末尾的0

func HTMLPriceFormat

func HTMLPriceFormat(ctx echo.Context, price float64, currency string, exchangeRate float64, precision ...int32) template.HTML

func ParseIconFromCSS

func ParseIconFromCSS(content string, prefixes ...string) ([]string, error)

func PriceFormatByInternal

func PriceFormatByInternal(ctx echo.Context, price float64, precision ...int32) template.HTML

func SetCurrencyPrecision

func SetCurrencyPrecision(ctx echo.Context, precision int32)

func SetCurrencySymbol

func SetCurrencySymbol(currency string, symbol string)

SetCurrencySymbol 登记货币符号

func SiteName

func SiteName() string

func SiteSlogan

func SiteSlogan() string

func SiteURL

func SiteURL(ctx echo.Context) string

Types

type ConfigCustomerAdd

type ConfigCustomerAdd struct {
	MaxPerDay        int64 `json:"maxPerDay"`
	MaxPending       int64 `json:"maxPending"`
	MaxPendingPerDay int64 `json:"maxPendingPerDay"`
}

func (*ConfigCustomerAdd) Combine

func (c *ConfigCustomerAdd) Combine(source interface{}) interface{}

func (*ConfigCustomerAdd) GetMaxPending

func (c *ConfigCustomerAdd) GetMaxPending() int64

func (*ConfigCustomerAdd) GetMaxPendingPerDay

func (c *ConfigCustomerAdd) GetMaxPendingPerDay() int64

func (*ConfigCustomerAdd) GetMaxPerDay

func (c *ConfigCustomerAdd) GetMaxPerDay() int64

type CurrencyGetter

type CurrencyGetter interface {
	Currency() string
}

type CustomChecker

type CustomChecker interface {
	CustomCheck(ctx echo.Context, permission *xrole.RolePermission, customerID interface{}, counter CustomerAddedCounter) error
}

type CustomerAddedCounter

type CustomerAddedCounter interface {
	CustomerTodayCount(uid interface{}) (int64, error)
	CustomerPendingCount(uid interface{}) (int64, error)
	CustomerPendingTodayCount(uid interface{}) (int64, error)
}

type CustomerAddedMaxGetter

type CustomerAddedMaxGetter interface {
	GetMaxPerDay() int64
	GetMaxPending() int64
	GetMaxPendingPerDay() int64
}

type FloatConverter

type FloatConverter interface {
	Convert(price float64, precision ...int32) float64
}

type PriceFormatter

type PriceFormatter interface {
	PriceFormat(ctx echo.Context, price float64, precision ...int32) string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL