修复比例默认选择和二维码预警崩溃

This commit is contained in:
yml
2026-06-17 21:58:29 +08:00
parent 0a42392d5e
commit 342edad78b
4 changed files with 9 additions and 7 deletions
@@ -316,7 +316,7 @@ func checkQrCodeStockAndAlert(tx *gorm.DB, conversation *model.ChatConversation)
alertContent := fmt.Sprintf("企业微信群二维码库存不足(剩余 %d 张),请及时补充", count)
// 发送站内信给所有客服
var entries []interface{}
entries := make([]map[string]interface{}, 0, len(csAdmins))
now := time.Now()
for _, admin := range csAdmins {
entries = append(entries, map[string]interface{}{
@@ -89,8 +89,9 @@ function normalizeDraftForm(value: unknown): PublishForm {
next.common_regions = Array.isArray(value.common_regions)
? value.common_regions.filter((region): region is string => typeof region === 'string')
: []
// 默认使用参考比例:如果草稿中的 accelerated_sale_ratio 是 0未设置,重置为空字符串
if (!next.accelerated_sale_ratio || next.accelerated_sale_ratio === 0) {
// 默认使用参考比例:如果草稿中的 accelerated_sale_ratio 是 0未设置或非法值,重置为空字符串
const acceleratedRatio = Number(next.accelerated_sale_ratio)
if (!Number.isFinite(acceleratedRatio) || acceleratedRatio <= 0) {
next.accelerated_sale_ratio = ''
}
if (next.haf_coin_amount === 0) next.haf_coin_amount = ''
@@ -566,7 +566,7 @@ function selectDailyLoss(value: string | number) {
class="ratio-mode-btn"
:class="{
active:
form.accelerated_sale_ratio === maxAcceleratedSaleRatio &&
Number(form.accelerated_sale_ratio) === maxAcceleratedSaleRatio &&
maxAcceleratedSaleRatio > 0,
}"
:disabled="maxAcceleratedSaleRatio <= 0"
@@ -584,7 +584,7 @@ function selectDailyLoss(value: string | number) {
:class="{
active:
hasAcceleratedSaleRatioInput() &&
form.accelerated_sale_ratio !== maxAcceleratedSaleRatio,
Number(form.accelerated_sale_ratio) !== maxAcceleratedSaleRatio,
}"
>
<strong>自定比例</strong>
+3 -2
View File
@@ -170,8 +170,9 @@ export function readFinalSaleRatio(
return roundRatio(Math.min(Math.max(ratio, defaultRatio), maxAcceleratedSaleRatio))
}
export function hasAcceleratedSaleRatioInput(value: number | '') {
return value !== '' && value !== null
export function hasAcceleratedSaleRatioInput(value: number | '' | null | undefined) {
const ratio = Number(value)
return value !== '' && value !== null && value !== undefined && Number.isFinite(ratio) && ratio > 0
}
export function calculatePlatformPricing(options: {