Compare commits
No commits in common. "509ebb61a68e5e4ab2f499f199e99016e1a47419" and "483314d2c420ffe48e78ddce0e6ba1f1604bf76b" have entirely different histories.
509ebb61a6
...
483314d2c4
@ -707,10 +707,11 @@ 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, totalRemain)
|
||||
alloc := minInt(need, minInt(limitRemain, totalRemain))
|
||||
if alloc > 0 {
|
||||
tb.TaskBundleLimitVideoExpiredConsumptionNumber += alloc
|
||||
tb.TaskMonthlyLimitVideoExpireConsumptionNumber += alloc
|
||||
@ -718,10 +719,11 @@ func UpdatePendingCount(req *UpdatePendingCountRequest) error {
|
||||
need -= alloc
|
||||
}
|
||||
}
|
||||
// 限制会过期 - 增值(忽略当月限额,只看总余额)
|
||||
// 限制会过期 - 增值
|
||||
if need > 0 {
|
||||
limitRemain := tb.TaskMonthlyLimitVideoExpireNumber - tb.TaskMonthlyLimitVideoExpireConsumptionNumber
|
||||
totalRemain := tb.TaskIncreaseLimitVideoExpiredNumber - tb.TaskIncreaseLimitVideoExpiredConsumptionNumber
|
||||
alloc := minInt(need, totalRemain)
|
||||
alloc := minInt(need, minInt(limitRemain, totalRemain))
|
||||
if alloc > 0 {
|
||||
tb.TaskIncreaseLimitVideoExpiredConsumptionNumber += alloc
|
||||
tb.TaskMonthlyLimitVideoExpireConsumptionNumber += alloc
|
||||
@ -729,10 +731,11 @@ func UpdatePendingCount(req *UpdatePendingCountRequest) error {
|
||||
need -= alloc
|
||||
}
|
||||
}
|
||||
// 限制不过期 - 套餐(忽略当月限额,只看总余额)
|
||||
// 限制不过期 - 套餐
|
||||
if need > 0 {
|
||||
limitRemain := tb.TaskMonthlyLimitVideoNumber - tb.TaskMonthlyLimitVideoConsumptionNumber
|
||||
totalRemain := tb.TaskBundleLimitVideoNumber - tb.TaskBundleLimitVideoConsumptionNumber
|
||||
alloc := minInt(need, totalRemain)
|
||||
alloc := minInt(need, minInt(limitRemain, totalRemain))
|
||||
if alloc > 0 {
|
||||
tb.TaskBundleLimitVideoConsumptionNumber += alloc
|
||||
tb.TaskMonthlyLimitVideoConsumptionNumber += alloc
|
||||
@ -740,10 +743,11 @@ func UpdatePendingCount(req *UpdatePendingCountRequest) error {
|
||||
need -= alloc
|
||||
}
|
||||
}
|
||||
// 限制不过期 - 增值(忽略当月限额,只看总余额)
|
||||
// 限制不过期 - 增值
|
||||
if need > 0 {
|
||||
limitRemain := tb.TaskMonthlyLimitVideoNumber - tb.TaskMonthlyLimitVideoConsumptionNumber
|
||||
totalRemain := tb.TaskIncreaseLimitVideoNumber - tb.TaskIncreaseLimitVideoConsumptionNumber
|
||||
alloc := minInt(need, totalRemain)
|
||||
alloc := minInt(need, minInt(limitRemain, totalRemain))
|
||||
if alloc > 0 {
|
||||
tb.TaskIncreaseLimitVideoConsumptionNumber += alloc
|
||||
tb.TaskMonthlyLimitVideoConsumptionNumber += alloc
|
||||
@ -783,17 +787,18 @@ 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, totalRemain)
|
||||
alloc := minInt(need, minInt(limitRemain, totalRemain))
|
||||
if alloc > 0 {
|
||||
tb.TaskBundleLimitImageExpiredConsumptionNumber += alloc
|
||||
tb.TaskMonthlyLimitImageExpireConsumptionNumber += alloc
|
||||
@ -801,10 +806,11 @@ func UpdatePendingCount(req *UpdatePendingCountRequest) error {
|
||||
need -= alloc
|
||||
}
|
||||
}
|
||||
// 限制会过期 - 增值(忽略当月限额,只看总余额)
|
||||
// 限制会过期 - 增值
|
||||
if need > 0 {
|
||||
limitRemain := tb.TaskMonthlyLimitImageExpireNumber - tb.TaskMonthlyLimitImageExpireConsumptionNumber
|
||||
totalRemain := tb.TaskIncreaseLimitImageExpiredNumber - tb.TaskIncreaseLimitImageExpiredConsumptionNumber
|
||||
alloc := minInt(need, totalRemain)
|
||||
alloc := minInt(need, minInt(limitRemain, totalRemain))
|
||||
if alloc > 0 {
|
||||
tb.TaskIncreaseLimitImageExpiredConsumptionNumber += alloc
|
||||
tb.TaskMonthlyLimitImageExpireConsumptionNumber += alloc
|
||||
@ -812,10 +818,11 @@ func UpdatePendingCount(req *UpdatePendingCountRequest) error {
|
||||
need -= alloc
|
||||
}
|
||||
}
|
||||
// 限制不过期 - 套餐(忽略当月限额,只看总余额)
|
||||
// 限制不过期 - 套餐
|
||||
if need > 0 {
|
||||
limitRemain := tb.TaskMonthlyLimitImageNumber - tb.TaskMonthlyLimitImageConsumptionNumber
|
||||
totalRemain := tb.TaskBundleLimitImageNumber - tb.TaskBundleLimitImageConsumptionNumber
|
||||
alloc := minInt(need, totalRemain)
|
||||
alloc := minInt(need, minInt(limitRemain, totalRemain))
|
||||
if alloc > 0 {
|
||||
tb.TaskBundleLimitImageConsumptionNumber += alloc
|
||||
tb.TaskMonthlyLimitImageConsumptionNumber += alloc
|
||||
@ -823,10 +830,11 @@ func UpdatePendingCount(req *UpdatePendingCountRequest) error {
|
||||
need -= alloc
|
||||
}
|
||||
}
|
||||
// 限制不过期 - 增值(忽略当月限额,只看总余额)
|
||||
// 限制不过期 - 增值
|
||||
if need > 0 {
|
||||
limitRemain := tb.TaskMonthlyLimitImageNumber - tb.TaskMonthlyLimitImageConsumptionNumber
|
||||
totalRemain := tb.TaskIncreaseLimitImageNumber - tb.TaskIncreaseLimitImageConsumptionNumber
|
||||
alloc := minInt(need, totalRemain)
|
||||
alloc := minInt(need, minInt(limitRemain, totalRemain))
|
||||
if alloc > 0 {
|
||||
tb.TaskIncreaseLimitImageConsumptionNumber += alloc
|
||||
tb.TaskMonthlyLimitImageConsumptionNumber += alloc
|
||||
@ -866,17 +874,18 @@ 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, totalRemain)
|
||||
alloc := minInt(need, minInt(limitRemain, totalRemain))
|
||||
if alloc > 0 {
|
||||
tb.TaskBundleLimitDataAnalysisExpiredConsumptionNumber += alloc
|
||||
tb.TaskMonthlyLimitDataAnalysisExpireConsumptionNumber += alloc
|
||||
@ -884,10 +893,11 @@ func UpdatePendingCount(req *UpdatePendingCountRequest) error {
|
||||
need -= alloc
|
||||
}
|
||||
}
|
||||
// 限制会过期 - 增值(忽略当月限额,只看总余额)
|
||||
// 限制会过期 - 增值
|
||||
if need > 0 {
|
||||
limitRemain := tb.TaskMonthlyLimitDataAnalysisExpireNumber - tb.TaskMonthlyLimitDataAnalysisExpireConsumptionNumber
|
||||
totalRemain := tb.TaskIncreaseLimitDataAnalysisExpiredNumber - tb.TaskIncreaseLimitDataAnalysisExpiredConsumptionNumber
|
||||
alloc := minInt(need, totalRemain)
|
||||
alloc := minInt(need, minInt(limitRemain, totalRemain))
|
||||
if alloc > 0 {
|
||||
tb.TaskIncreaseLimitDataAnalysisExpiredConsumptionNumber += alloc
|
||||
tb.TaskMonthlyLimitDataAnalysisExpireConsumptionNumber += alloc
|
||||
@ -895,10 +905,11 @@ func UpdatePendingCount(req *UpdatePendingCountRequest) error {
|
||||
need -= alloc
|
||||
}
|
||||
}
|
||||
// 限制不过期 - 套餐(忽略当月限额,只看总余额)
|
||||
// 限制不过期 - 套餐
|
||||
if need > 0 {
|
||||
limitRemain := tb.TaskMonthlyLimitDataAnalysisNumber - tb.TaskMonthlyLimitDataAnalysisConsumptionNumber
|
||||
totalRemain := tb.TaskBundleLimitDataAnalysisNumber - tb.TaskBundleLimitDataAnalysisConsumptionNumber
|
||||
alloc := minInt(need, totalRemain)
|
||||
alloc := minInt(need, minInt(limitRemain, totalRemain))
|
||||
if alloc > 0 {
|
||||
tb.TaskBundleLimitDataAnalysisConsumptionNumber += alloc
|
||||
tb.TaskMonthlyLimitDataAnalysisConsumptionNumber += alloc
|
||||
@ -906,10 +917,11 @@ func UpdatePendingCount(req *UpdatePendingCountRequest) error {
|
||||
need -= alloc
|
||||
}
|
||||
}
|
||||
// 限制不过期 - 增值(忽略当月限额,只看总余额)
|
||||
// 限制不过期 - 增值
|
||||
if need > 0 {
|
||||
limitRemain := tb.TaskMonthlyLimitDataAnalysisNumber - tb.TaskMonthlyLimitDataAnalysisConsumptionNumber
|
||||
totalRemain := tb.TaskIncreaseLimitDataAnalysisNumber - tb.TaskIncreaseLimitDataAnalysisConsumptionNumber
|
||||
alloc := minInt(need, totalRemain)
|
||||
alloc := minInt(need, minInt(limitRemain, totalRemain))
|
||||
if alloc > 0 {
|
||||
tb.TaskIncreaseLimitDataAnalysisConsumptionNumber += alloc
|
||||
tb.TaskMonthlyLimitDataAnalysisConsumptionNumber += alloc
|
||||
@ -949,7 +961,7 @@ func UpdatePendingCount(req *UpdatePendingCountRequest) error {
|
||||
}
|
||||
if need > 0 {
|
||||
tx.Rollback()
|
||||
return commonErr.ReturnError(nil, "可用数据分析数不足", "扣减数据分析数量超过当前余额")
|
||||
return commonErr.ReturnError(nil, "可用数据分析数不足", "扣减数据分析数量超过当前余额或当月限额")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user