From 9ffca3094b909d9b621a72b67165c5a1f8c3aaff Mon Sep 17 00:00:00 2001 From: cjy Date: Wed, 22 Oct 2025 14:07:49 +0800 Subject: [PATCH] =?UTF-8?q?bugfix:=20=E4=BF=AE=E6=94=B9=E6=8C=87=E6=B4=BE?= =?UTF-8?q?=E6=89=A3=E5=87=8F=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/dao/taskDao.go | 66 +++++++++++++++++------------------------ 1 file changed, 27 insertions(+), 39 deletions(-) diff --git a/internal/dao/taskDao.go b/internal/dao/taskDao.go index d8ce3d6..c92e450 100644 --- a/internal/dao/taskDao.go +++ b/internal/dao/taskDao.go @@ -707,11 +707,10 @@ func UpdatePendingCount(req *UpdatePendingCountRequest) error { // 扣减视频:优先 会过期限制(套餐→增值) → 不过期限制(套餐→增值) → 非限制套餐 → 非限制增值 → 手动 need := req.PendingVideoCount if need > 0 { - // 限制会过期 - 套餐 + // 限制会过期 - 套餐(忽略当月限额,只看总余额) if need > 0 { - limitRemain := tb.TaskMonthlyLimitVideoExpireNumber - tb.TaskMonthlyLimitVideoExpireConsumptionNumber totalRemain := tb.TaskBundleLimitVideoExpiredNumber - tb.TaskBundleLimitVideoExpiredConsumptionNumber - alloc := minInt(need, minInt(limitRemain, totalRemain)) + alloc := minInt(need, totalRemain) if alloc > 0 { tb.TaskBundleLimitVideoExpiredConsumptionNumber += alloc tb.TaskMonthlyLimitVideoExpireConsumptionNumber += alloc @@ -719,11 +718,10 @@ func UpdatePendingCount(req *UpdatePendingCountRequest) error { need -= alloc } } - // 限制会过期 - 增值 + // 限制会过期 - 增值(忽略当月限额,只看总余额) if need > 0 { - limitRemain := tb.TaskMonthlyLimitVideoExpireNumber - tb.TaskMonthlyLimitVideoExpireConsumptionNumber totalRemain := tb.TaskIncreaseLimitVideoExpiredNumber - tb.TaskIncreaseLimitVideoExpiredConsumptionNumber - alloc := minInt(need, minInt(limitRemain, totalRemain)) + alloc := minInt(need, totalRemain) if alloc > 0 { tb.TaskIncreaseLimitVideoExpiredConsumptionNumber += alloc tb.TaskMonthlyLimitVideoExpireConsumptionNumber += alloc @@ -731,11 +729,10 @@ func UpdatePendingCount(req *UpdatePendingCountRequest) error { need -= alloc } } - // 限制不过期 - 套餐 + // 限制不过期 - 套餐(忽略当月限额,只看总余额) if need > 0 { - limitRemain := tb.TaskMonthlyLimitVideoNumber - tb.TaskMonthlyLimitVideoConsumptionNumber totalRemain := tb.TaskBundleLimitVideoNumber - tb.TaskBundleLimitVideoConsumptionNumber - alloc := minInt(need, minInt(limitRemain, totalRemain)) + alloc := minInt(need, totalRemain) if alloc > 0 { tb.TaskBundleLimitVideoConsumptionNumber += alloc tb.TaskMonthlyLimitVideoConsumptionNumber += alloc @@ -743,11 +740,10 @@ func UpdatePendingCount(req *UpdatePendingCountRequest) error { need -= alloc } } - // 限制不过期 - 增值 + // 限制不过期 - 增值(忽略当月限额,只看总余额) if need > 0 { - limitRemain := tb.TaskMonthlyLimitVideoNumber - tb.TaskMonthlyLimitVideoConsumptionNumber totalRemain := tb.TaskIncreaseLimitVideoNumber - tb.TaskIncreaseLimitVideoConsumptionNumber - alloc := minInt(need, minInt(limitRemain, totalRemain)) + alloc := minInt(need, totalRemain) if alloc > 0 { tb.TaskIncreaseLimitVideoConsumptionNumber += alloc tb.TaskMonthlyLimitVideoConsumptionNumber += alloc @@ -787,18 +783,17 @@ func UpdatePendingCount(req *UpdatePendingCountRequest) error { } if need > 0 { tx.Rollback() - return commonErr.ReturnError(nil, "可用视频数不足", "扣减视频数量超过当前余额或当月限额") + return commonErr.ReturnError(nil, "可用视频数不足", "扣减视频数量超过当前余额") } } // 扣减图文 need = req.PendingPostCount if need > 0 { - // 限制会过期 - 套餐 + // 限制会过期 - 套餐(忽略当月限额,只看总余额) if need > 0 { - limitRemain := tb.TaskMonthlyLimitImageExpireNumber - tb.TaskMonthlyLimitImageExpireConsumptionNumber totalRemain := tb.TaskBundleLimitImageExpiredNumber - tb.TaskBundleLimitImageExpiredConsumptionNumber - alloc := minInt(need, minInt(limitRemain, totalRemain)) + alloc := minInt(need, totalRemain) if alloc > 0 { tb.TaskBundleLimitImageExpiredConsumptionNumber += alloc tb.TaskMonthlyLimitImageExpireConsumptionNumber += alloc @@ -806,11 +801,10 @@ func UpdatePendingCount(req *UpdatePendingCountRequest) error { need -= alloc } } - // 限制会过期 - 增值 + // 限制会过期 - 增值(忽略当月限额,只看总余额) if need > 0 { - limitRemain := tb.TaskMonthlyLimitImageExpireNumber - tb.TaskMonthlyLimitImageExpireConsumptionNumber totalRemain := tb.TaskIncreaseLimitImageExpiredNumber - tb.TaskIncreaseLimitImageExpiredConsumptionNumber - alloc := minInt(need, minInt(limitRemain, totalRemain)) + alloc := minInt(need, totalRemain) if alloc > 0 { tb.TaskIncreaseLimitImageExpiredConsumptionNumber += alloc tb.TaskMonthlyLimitImageExpireConsumptionNumber += alloc @@ -818,11 +812,10 @@ func UpdatePendingCount(req *UpdatePendingCountRequest) error { need -= alloc } } - // 限制不过期 - 套餐 + // 限制不过期 - 套餐(忽略当月限额,只看总余额) if need > 0 { - limitRemain := tb.TaskMonthlyLimitImageNumber - tb.TaskMonthlyLimitImageConsumptionNumber totalRemain := tb.TaskBundleLimitImageNumber - tb.TaskBundleLimitImageConsumptionNumber - alloc := minInt(need, minInt(limitRemain, totalRemain)) + alloc := minInt(need, totalRemain) if alloc > 0 { tb.TaskBundleLimitImageConsumptionNumber += alloc tb.TaskMonthlyLimitImageConsumptionNumber += alloc @@ -830,11 +823,10 @@ func UpdatePendingCount(req *UpdatePendingCountRequest) error { need -= alloc } } - // 限制不过期 - 增值 + // 限制不过期 - 增值(忽略当月限额,只看总余额) if need > 0 { - limitRemain := tb.TaskMonthlyLimitImageNumber - tb.TaskMonthlyLimitImageConsumptionNumber totalRemain := tb.TaskIncreaseLimitImageNumber - tb.TaskIncreaseLimitImageConsumptionNumber - alloc := minInt(need, minInt(limitRemain, totalRemain)) + alloc := minInt(need, totalRemain) if alloc > 0 { tb.TaskIncreaseLimitImageConsumptionNumber += alloc tb.TaskMonthlyLimitImageConsumptionNumber += alloc @@ -874,18 +866,17 @@ func UpdatePendingCount(req *UpdatePendingCountRequest) error { } if need > 0 { tx.Rollback() - return commonErr.ReturnError(nil, "可用图文数不足", "扣减图文数量超过当前余额或当月限额") + return commonErr.ReturnError(nil, "可用图文数不足", "扣减图文数量超过当前余额") } } // 扣减数据分析 need = req.PendingDataCount if need > 0 { - // 限制会过期 - 套餐 + // 限制会过期 - 套餐(忽略当月限额,只看总余额) if need > 0 { - limitRemain := tb.TaskMonthlyLimitDataAnalysisExpireNumber - tb.TaskMonthlyLimitDataAnalysisExpireConsumptionNumber totalRemain := tb.TaskBundleLimitDataAnalysisExpiredNumber - tb.TaskBundleLimitDataAnalysisExpiredConsumptionNumber - alloc := minInt(need, minInt(limitRemain, totalRemain)) + alloc := minInt(need, totalRemain) if alloc > 0 { tb.TaskBundleLimitDataAnalysisExpiredConsumptionNumber += alloc tb.TaskMonthlyLimitDataAnalysisExpireConsumptionNumber += alloc @@ -893,11 +884,10 @@ func UpdatePendingCount(req *UpdatePendingCountRequest) error { need -= alloc } } - // 限制会过期 - 增值 + // 限制会过期 - 增值(忽略当月限额,只看总余额) if need > 0 { - limitRemain := tb.TaskMonthlyLimitDataAnalysisExpireNumber - tb.TaskMonthlyLimitDataAnalysisExpireConsumptionNumber totalRemain := tb.TaskIncreaseLimitDataAnalysisExpiredNumber - tb.TaskIncreaseLimitDataAnalysisExpiredConsumptionNumber - alloc := minInt(need, minInt(limitRemain, totalRemain)) + alloc := minInt(need, totalRemain) if alloc > 0 { tb.TaskIncreaseLimitDataAnalysisExpiredConsumptionNumber += alloc tb.TaskMonthlyLimitDataAnalysisExpireConsumptionNumber += alloc @@ -905,11 +895,10 @@ func UpdatePendingCount(req *UpdatePendingCountRequest) error { need -= alloc } } - // 限制不过期 - 套餐 + // 限制不过期 - 套餐(忽略当月限额,只看总余额) if need > 0 { - limitRemain := tb.TaskMonthlyLimitDataAnalysisNumber - tb.TaskMonthlyLimitDataAnalysisConsumptionNumber totalRemain := tb.TaskBundleLimitDataAnalysisNumber - tb.TaskBundleLimitDataAnalysisConsumptionNumber - alloc := minInt(need, minInt(limitRemain, totalRemain)) + alloc := minInt(need, totalRemain) if alloc > 0 { tb.TaskBundleLimitDataAnalysisConsumptionNumber += alloc tb.TaskMonthlyLimitDataAnalysisConsumptionNumber += alloc @@ -917,11 +906,10 @@ func UpdatePendingCount(req *UpdatePendingCountRequest) error { need -= alloc } } - // 限制不过期 - 增值 + // 限制不过期 - 增值(忽略当月限额,只看总余额) if need > 0 { - limitRemain := tb.TaskMonthlyLimitDataAnalysisNumber - tb.TaskMonthlyLimitDataAnalysisConsumptionNumber totalRemain := tb.TaskIncreaseLimitDataAnalysisNumber - tb.TaskIncreaseLimitDataAnalysisConsumptionNumber - alloc := minInt(need, minInt(limitRemain, totalRemain)) + alloc := minInt(need, totalRemain) if alloc > 0 { tb.TaskIncreaseLimitDataAnalysisConsumptionNumber += alloc tb.TaskMonthlyLimitDataAnalysisConsumptionNumber += alloc @@ -961,7 +949,7 @@ func UpdatePendingCount(req *UpdatePendingCountRequest) error { } if need > 0 { tx.Rollback() - return commonErr.ReturnError(nil, "可用数据分析数不足", "扣减数据分析数量超过当前余额或当月限额") + return commonErr.ReturnError(nil, "可用数据分析数不足", "扣减数据分析数量超过当前余额") } }