后台系统配置列表现在只返回当前真实使用的配置项
This commit is contained in:
@@ -20,7 +20,7 @@ import (
|
||||
)
|
||||
|
||||
type Repository struct {
|
||||
db *gorm.DB
|
||||
db *gorm.DB
|
||||
chatRepo *chat.Repository
|
||||
}
|
||||
|
||||
@@ -195,7 +195,7 @@ func (r *Repository) Pay(userID uint64, orderID uint64) error {
|
||||
return ErrOrderCannotPay
|
||||
}
|
||||
timeoutMinutes := pendingPaymentTimeoutMinutes(tx)
|
||||
if order.CreatedAt.Before(time.Now().Add(-time.Duration(timeoutMinutes) * time.Minute)) {
|
||||
if timeoutMinutes > 0 && order.CreatedAt.Before(time.Now().Add(-time.Duration(timeoutMinutes)*time.Minute)) {
|
||||
return ErrOrderCannotPay
|
||||
}
|
||||
|
||||
@@ -1029,7 +1029,7 @@ func pendingPaymentTimeoutMinutes(tx *gorm.DB) int {
|
||||
return defaultPendingPaymentTimeoutMinutes
|
||||
}
|
||||
value, err := strconv.Atoi(row.Value)
|
||||
if err != nil || value <= 0 {
|
||||
if err != nil || value < 0 {
|
||||
return defaultPendingPaymentTimeoutMinutes
|
||||
}
|
||||
return value
|
||||
|
||||
@@ -33,21 +33,30 @@ var defaultConfigs = []defaultConfig{
|
||||
{Key: "handoff.owner_return_confirm_timeout_minutes", Value: "120", Description: "号主待确认结账超时分钟数"},
|
||||
{Key: "order.pending_payment_timeout_minutes", Value: "15", Description: "订单待支付超时取消分钟数"},
|
||||
{Key: "order.return_overdue_grace_minutes", Value: "10", Description: "预计截止后结账宽限分钟数"},
|
||||
{Key: "deposit.min_amount", Value: "50", Description: "发布租号最低押金"},
|
||||
{Key: "listing.review_required", Value: "false", Description: "发布账号是否需要后台人工审核"},
|
||||
{Key: "risk.sms_limit_per_phone_hour", Value: "5", Description: "单手机号每小时短信验证码次数"},
|
||||
{Key: "risk.sms_limit_per_ip_hour", Value: "20", Description: "单 IP 每小时短信验证码次数"},
|
||||
{Key: "realname.required_for_order", Value: "false", Description: "下单是否必须完成实名认证"},
|
||||
{Key: "settlement.platform_fee_rate", Value: "0.00", Description: "平台抽成比例"},
|
||||
{Key: "settlement.owner_cycle_days", Value: "0", Description: "号主结算周期天数"},
|
||||
{Key: "withdraw.min_amount", Value: "100", Description: "提现最低金额预留"},
|
||||
{Key: "chat.default_support_admin_id", Value: "1", Description: "订单群聊回退客服 ID(仅当无可用客服时使用)"},
|
||||
{Key: "chat.auto_welcome_message", Value: "欢迎加入订单群聊!如有任何问题,请随时沟通。", Description: "建群后自动发送的欢迎话术"},
|
||||
{Key: homeAnnouncementsConfigKey, Value: defaultHomeAnnouncementsConfigValue(), Description: "移动端首页公告 JSON 数组"},
|
||||
{Key: homeBannersConfigKey, Value: defaultHomeBannersConfigValue(), Description: "移动端首页轮播图 JSON 数组"},
|
||||
{Key: publishOptionsConfigKey, Value: defaultPublishOptionsConfigValue(), Description: "发布页选项配置 JSON"},
|
||||
{Key: salePriceConfigKey, Value: defaultSalePriceConfigValue(), Description: "内部出售定价规则 JSON"},
|
||||
}
|
||||
|
||||
var adminVisibleConfigKeys = []string{
|
||||
"chat.auto_welcome_message",
|
||||
"chat.default_support_admin_id",
|
||||
"handoff.owner_return_confirm_timeout_minutes",
|
||||
"handoff.owner_submit_timeout_minutes",
|
||||
"handoff.renter_confirm_timeout_minutes",
|
||||
"listing.publish_options",
|
||||
"listing.review_required",
|
||||
"listing.sale_price_config",
|
||||
"mobile.home_announcements",
|
||||
"mobile.home_banners",
|
||||
"order.pending_payment_timeout_minutes",
|
||||
"order.return_overdue_grace_minutes",
|
||||
}
|
||||
|
||||
func NewRepository(db *gorm.DB) *Repository {
|
||||
return &Repository{db: db}
|
||||
}
|
||||
@@ -57,7 +66,7 @@ func (r *Repository) List() ([]ConfigDTO, error) {
|
||||
return nil, err
|
||||
}
|
||||
var rows []model.SystemConfig
|
||||
if err := r.db.Order("`key` ASC").Find(&rows).Error; err != nil {
|
||||
if err := r.db.Where("`key` IN ?", adminVisibleConfigKeys).Order("`key` ASC").Find(&rows).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items := make([]ConfigDTO, 0, len(rows))
|
||||
|
||||
Reference in New Issue
Block a user