bugfix: 修改指派扣减逻辑
This commit is contained in:
parent
3638845d6e
commit
9ffca3094b
@ -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, "可用数据分析数不足", "扣减数据分析数量超过当前余额")
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user