Merge branch 'feat-cjy-taskBench' into dev
This commit is contained in:
commit
509ebb61a6
@ -707,11 +707,10 @@ func UpdatePendingCount(req *UpdatePendingCountRequest) error {
|
|||||||
// 扣减视频:优先 会过期限制(套餐→增值) → 不过期限制(套餐→增值) → 非限制套餐 → 非限制增值 → 手动
|
// 扣减视频:优先 会过期限制(套餐→增值) → 不过期限制(套餐→增值) → 非限制套餐 → 非限制增值 → 手动
|
||||||
need := req.PendingVideoCount
|
need := req.PendingVideoCount
|
||||||
if need > 0 {
|
if need > 0 {
|
||||||
// 限制会过期 - 套餐
|
// 限制会过期 - 套餐(忽略当月限额,只看总余额)
|
||||||
if need > 0 {
|
if need > 0 {
|
||||||
limitRemain := tb.TaskMonthlyLimitVideoExpireNumber - tb.TaskMonthlyLimitVideoExpireConsumptionNumber
|
|
||||||
totalRemain := tb.TaskBundleLimitVideoExpiredNumber - tb.TaskBundleLimitVideoExpiredConsumptionNumber
|
totalRemain := tb.TaskBundleLimitVideoExpiredNumber - tb.TaskBundleLimitVideoExpiredConsumptionNumber
|
||||||
alloc := minInt(need, minInt(limitRemain, totalRemain))
|
alloc := minInt(need, totalRemain)
|
||||||
if alloc > 0 {
|
if alloc > 0 {
|
||||||
tb.TaskBundleLimitVideoExpiredConsumptionNumber += alloc
|
tb.TaskBundleLimitVideoExpiredConsumptionNumber += alloc
|
||||||
tb.TaskMonthlyLimitVideoExpireConsumptionNumber += alloc
|
tb.TaskMonthlyLimitVideoExpireConsumptionNumber += alloc
|
||||||
@ -719,11 +718,10 @@ func UpdatePendingCount(req *UpdatePendingCountRequest) error {
|
|||||||
need -= alloc
|
need -= alloc
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 限制会过期 - 增值
|
// 限制会过期 - 增值(忽略当月限额,只看总余额)
|
||||||
if need > 0 {
|
if need > 0 {
|
||||||
limitRemain := tb.TaskMonthlyLimitVideoExpireNumber - tb.TaskMonthlyLimitVideoExpireConsumptionNumber
|
|
||||||
totalRemain := tb.TaskIncreaseLimitVideoExpiredNumber - tb.TaskIncreaseLimitVideoExpiredConsumptionNumber
|
totalRemain := tb.TaskIncreaseLimitVideoExpiredNumber - tb.TaskIncreaseLimitVideoExpiredConsumptionNumber
|
||||||
alloc := minInt(need, minInt(limitRemain, totalRemain))
|
alloc := minInt(need, totalRemain)
|
||||||
if alloc > 0 {
|
if alloc > 0 {
|
||||||
tb.TaskIncreaseLimitVideoExpiredConsumptionNumber += alloc
|
tb.TaskIncreaseLimitVideoExpiredConsumptionNumber += alloc
|
||||||
tb.TaskMonthlyLimitVideoExpireConsumptionNumber += alloc
|
tb.TaskMonthlyLimitVideoExpireConsumptionNumber += alloc
|
||||||
@ -731,11 +729,10 @@ func UpdatePendingCount(req *UpdatePendingCountRequest) error {
|
|||||||
need -= alloc
|
need -= alloc
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 限制不过期 - 套餐
|
// 限制不过期 - 套餐(忽略当月限额,只看总余额)
|
||||||
if need > 0 {
|
if need > 0 {
|
||||||
limitRemain := tb.TaskMonthlyLimitVideoNumber - tb.TaskMonthlyLimitVideoConsumptionNumber
|
|
||||||
totalRemain := tb.TaskBundleLimitVideoNumber - tb.TaskBundleLimitVideoConsumptionNumber
|
totalRemain := tb.TaskBundleLimitVideoNumber - tb.TaskBundleLimitVideoConsumptionNumber
|
||||||
alloc := minInt(need, minInt(limitRemain, totalRemain))
|
alloc := minInt(need, totalRemain)
|
||||||
if alloc > 0 {
|
if alloc > 0 {
|
||||||
tb.TaskBundleLimitVideoConsumptionNumber += alloc
|
tb.TaskBundleLimitVideoConsumptionNumber += alloc
|
||||||
tb.TaskMonthlyLimitVideoConsumptionNumber += alloc
|
tb.TaskMonthlyLimitVideoConsumptionNumber += alloc
|
||||||
@ -743,11 +740,10 @@ func UpdatePendingCount(req *UpdatePendingCountRequest) error {
|
|||||||
need -= alloc
|
need -= alloc
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 限制不过期 - 增值
|
// 限制不过期 - 增值(忽略当月限额,只看总余额)
|
||||||
if need > 0 {
|
if need > 0 {
|
||||||
limitRemain := tb.TaskMonthlyLimitVideoNumber - tb.TaskMonthlyLimitVideoConsumptionNumber
|
|
||||||
totalRemain := tb.TaskIncreaseLimitVideoNumber - tb.TaskIncreaseLimitVideoConsumptionNumber
|
totalRemain := tb.TaskIncreaseLimitVideoNumber - tb.TaskIncreaseLimitVideoConsumptionNumber
|
||||||
alloc := minInt(need, minInt(limitRemain, totalRemain))
|
alloc := minInt(need, totalRemain)
|
||||||
if alloc > 0 {
|
if alloc > 0 {
|
||||||
tb.TaskIncreaseLimitVideoConsumptionNumber += alloc
|
tb.TaskIncreaseLimitVideoConsumptionNumber += alloc
|
||||||
tb.TaskMonthlyLimitVideoConsumptionNumber += alloc
|
tb.TaskMonthlyLimitVideoConsumptionNumber += alloc
|
||||||
@ -787,18 +783,17 @@ func UpdatePendingCount(req *UpdatePendingCountRequest) error {
|
|||||||
}
|
}
|
||||||
if need > 0 {
|
if need > 0 {
|
||||||
tx.Rollback()
|
tx.Rollback()
|
||||||
return commonErr.ReturnError(nil, "可用视频数不足", "扣减视频数量超过当前余额或当月限额")
|
return commonErr.ReturnError(nil, "可用视频数不足", "扣减视频数量超过当前余额")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 扣减图文
|
// 扣减图文
|
||||||
need = req.PendingPostCount
|
need = req.PendingPostCount
|
||||||
if need > 0 {
|
if need > 0 {
|
||||||
// 限制会过期 - 套餐
|
// 限制会过期 - 套餐(忽略当月限额,只看总余额)
|
||||||
if need > 0 {
|
if need > 0 {
|
||||||
limitRemain := tb.TaskMonthlyLimitImageExpireNumber - tb.TaskMonthlyLimitImageExpireConsumptionNumber
|
|
||||||
totalRemain := tb.TaskBundleLimitImageExpiredNumber - tb.TaskBundleLimitImageExpiredConsumptionNumber
|
totalRemain := tb.TaskBundleLimitImageExpiredNumber - tb.TaskBundleLimitImageExpiredConsumptionNumber
|
||||||
alloc := minInt(need, minInt(limitRemain, totalRemain))
|
alloc := minInt(need, totalRemain)
|
||||||
if alloc > 0 {
|
if alloc > 0 {
|
||||||
tb.TaskBundleLimitImageExpiredConsumptionNumber += alloc
|
tb.TaskBundleLimitImageExpiredConsumptionNumber += alloc
|
||||||
tb.TaskMonthlyLimitImageExpireConsumptionNumber += alloc
|
tb.TaskMonthlyLimitImageExpireConsumptionNumber += alloc
|
||||||
@ -806,11 +801,10 @@ func UpdatePendingCount(req *UpdatePendingCountRequest) error {
|
|||||||
need -= alloc
|
need -= alloc
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 限制会过期 - 增值
|
// 限制会过期 - 增值(忽略当月限额,只看总余额)
|
||||||
if need > 0 {
|
if need > 0 {
|
||||||
limitRemain := tb.TaskMonthlyLimitImageExpireNumber - tb.TaskMonthlyLimitImageExpireConsumptionNumber
|
|
||||||
totalRemain := tb.TaskIncreaseLimitImageExpiredNumber - tb.TaskIncreaseLimitImageExpiredConsumptionNumber
|
totalRemain := tb.TaskIncreaseLimitImageExpiredNumber - tb.TaskIncreaseLimitImageExpiredConsumptionNumber
|
||||||
alloc := minInt(need, minInt(limitRemain, totalRemain))
|
alloc := minInt(need, totalRemain)
|
||||||
if alloc > 0 {
|
if alloc > 0 {
|
||||||
tb.TaskIncreaseLimitImageExpiredConsumptionNumber += alloc
|
tb.TaskIncreaseLimitImageExpiredConsumptionNumber += alloc
|
||||||
tb.TaskMonthlyLimitImageExpireConsumptionNumber += alloc
|
tb.TaskMonthlyLimitImageExpireConsumptionNumber += alloc
|
||||||
@ -818,11 +812,10 @@ func UpdatePendingCount(req *UpdatePendingCountRequest) error {
|
|||||||
need -= alloc
|
need -= alloc
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 限制不过期 - 套餐
|
// 限制不过期 - 套餐(忽略当月限额,只看总余额)
|
||||||
if need > 0 {
|
if need > 0 {
|
||||||
limitRemain := tb.TaskMonthlyLimitImageNumber - tb.TaskMonthlyLimitImageConsumptionNumber
|
|
||||||
totalRemain := tb.TaskBundleLimitImageNumber - tb.TaskBundleLimitImageConsumptionNumber
|
totalRemain := tb.TaskBundleLimitImageNumber - tb.TaskBundleLimitImageConsumptionNumber
|
||||||
alloc := minInt(need, minInt(limitRemain, totalRemain))
|
alloc := minInt(need, totalRemain)
|
||||||
if alloc > 0 {
|
if alloc > 0 {
|
||||||
tb.TaskBundleLimitImageConsumptionNumber += alloc
|
tb.TaskBundleLimitImageConsumptionNumber += alloc
|
||||||
tb.TaskMonthlyLimitImageConsumptionNumber += alloc
|
tb.TaskMonthlyLimitImageConsumptionNumber += alloc
|
||||||
@ -830,11 +823,10 @@ func UpdatePendingCount(req *UpdatePendingCountRequest) error {
|
|||||||
need -= alloc
|
need -= alloc
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 限制不过期 - 增值
|
// 限制不过期 - 增值(忽略当月限额,只看总余额)
|
||||||
if need > 0 {
|
if need > 0 {
|
||||||
limitRemain := tb.TaskMonthlyLimitImageNumber - tb.TaskMonthlyLimitImageConsumptionNumber
|
|
||||||
totalRemain := tb.TaskIncreaseLimitImageNumber - tb.TaskIncreaseLimitImageConsumptionNumber
|
totalRemain := tb.TaskIncreaseLimitImageNumber - tb.TaskIncreaseLimitImageConsumptionNumber
|
||||||
alloc := minInt(need, minInt(limitRemain, totalRemain))
|
alloc := minInt(need, totalRemain)
|
||||||
if alloc > 0 {
|
if alloc > 0 {
|
||||||
tb.TaskIncreaseLimitImageConsumptionNumber += alloc
|
tb.TaskIncreaseLimitImageConsumptionNumber += alloc
|
||||||
tb.TaskMonthlyLimitImageConsumptionNumber += alloc
|
tb.TaskMonthlyLimitImageConsumptionNumber += alloc
|
||||||
@ -874,18 +866,17 @@ func UpdatePendingCount(req *UpdatePendingCountRequest) error {
|
|||||||
}
|
}
|
||||||
if need > 0 {
|
if need > 0 {
|
||||||
tx.Rollback()
|
tx.Rollback()
|
||||||
return commonErr.ReturnError(nil, "可用图文数不足", "扣减图文数量超过当前余额或当月限额")
|
return commonErr.ReturnError(nil, "可用图文数不足", "扣减图文数量超过当前余额")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 扣减数据分析
|
// 扣减数据分析
|
||||||
need = req.PendingDataCount
|
need = req.PendingDataCount
|
||||||
if need > 0 {
|
if need > 0 {
|
||||||
// 限制会过期 - 套餐
|
// 限制会过期 - 套餐(忽略当月限额,只看总余额)
|
||||||
if need > 0 {
|
if need > 0 {
|
||||||
limitRemain := tb.TaskMonthlyLimitDataAnalysisExpireNumber - tb.TaskMonthlyLimitDataAnalysisExpireConsumptionNumber
|
|
||||||
totalRemain := tb.TaskBundleLimitDataAnalysisExpiredNumber - tb.TaskBundleLimitDataAnalysisExpiredConsumptionNumber
|
totalRemain := tb.TaskBundleLimitDataAnalysisExpiredNumber - tb.TaskBundleLimitDataAnalysisExpiredConsumptionNumber
|
||||||
alloc := minInt(need, minInt(limitRemain, totalRemain))
|
alloc := minInt(need, totalRemain)
|
||||||
if alloc > 0 {
|
if alloc > 0 {
|
||||||
tb.TaskBundleLimitDataAnalysisExpiredConsumptionNumber += alloc
|
tb.TaskBundleLimitDataAnalysisExpiredConsumptionNumber += alloc
|
||||||
tb.TaskMonthlyLimitDataAnalysisExpireConsumptionNumber += alloc
|
tb.TaskMonthlyLimitDataAnalysisExpireConsumptionNumber += alloc
|
||||||
@ -893,11 +884,10 @@ func UpdatePendingCount(req *UpdatePendingCountRequest) error {
|
|||||||
need -= alloc
|
need -= alloc
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 限制会过期 - 增值
|
// 限制会过期 - 增值(忽略当月限额,只看总余额)
|
||||||
if need > 0 {
|
if need > 0 {
|
||||||
limitRemain := tb.TaskMonthlyLimitDataAnalysisExpireNumber - tb.TaskMonthlyLimitDataAnalysisExpireConsumptionNumber
|
|
||||||
totalRemain := tb.TaskIncreaseLimitDataAnalysisExpiredNumber - tb.TaskIncreaseLimitDataAnalysisExpiredConsumptionNumber
|
totalRemain := tb.TaskIncreaseLimitDataAnalysisExpiredNumber - tb.TaskIncreaseLimitDataAnalysisExpiredConsumptionNumber
|
||||||
alloc := minInt(need, minInt(limitRemain, totalRemain))
|
alloc := minInt(need, totalRemain)
|
||||||
if alloc > 0 {
|
if alloc > 0 {
|
||||||
tb.TaskIncreaseLimitDataAnalysisExpiredConsumptionNumber += alloc
|
tb.TaskIncreaseLimitDataAnalysisExpiredConsumptionNumber += alloc
|
||||||
tb.TaskMonthlyLimitDataAnalysisExpireConsumptionNumber += alloc
|
tb.TaskMonthlyLimitDataAnalysisExpireConsumptionNumber += alloc
|
||||||
@ -905,11 +895,10 @@ func UpdatePendingCount(req *UpdatePendingCountRequest) error {
|
|||||||
need -= alloc
|
need -= alloc
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 限制不过期 - 套餐
|
// 限制不过期 - 套餐(忽略当月限额,只看总余额)
|
||||||
if need > 0 {
|
if need > 0 {
|
||||||
limitRemain := tb.TaskMonthlyLimitDataAnalysisNumber - tb.TaskMonthlyLimitDataAnalysisConsumptionNumber
|
|
||||||
totalRemain := tb.TaskBundleLimitDataAnalysisNumber - tb.TaskBundleLimitDataAnalysisConsumptionNumber
|
totalRemain := tb.TaskBundleLimitDataAnalysisNumber - tb.TaskBundleLimitDataAnalysisConsumptionNumber
|
||||||
alloc := minInt(need, minInt(limitRemain, totalRemain))
|
alloc := minInt(need, totalRemain)
|
||||||
if alloc > 0 {
|
if alloc > 0 {
|
||||||
tb.TaskBundleLimitDataAnalysisConsumptionNumber += alloc
|
tb.TaskBundleLimitDataAnalysisConsumptionNumber += alloc
|
||||||
tb.TaskMonthlyLimitDataAnalysisConsumptionNumber += alloc
|
tb.TaskMonthlyLimitDataAnalysisConsumptionNumber += alloc
|
||||||
@ -917,11 +906,10 @@ func UpdatePendingCount(req *UpdatePendingCountRequest) error {
|
|||||||
need -= alloc
|
need -= alloc
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 限制不过期 - 增值
|
// 限制不过期 - 增值(忽略当月限额,只看总余额)
|
||||||
if need > 0 {
|
if need > 0 {
|
||||||
limitRemain := tb.TaskMonthlyLimitDataAnalysisNumber - tb.TaskMonthlyLimitDataAnalysisConsumptionNumber
|
|
||||||
totalRemain := tb.TaskIncreaseLimitDataAnalysisNumber - tb.TaskIncreaseLimitDataAnalysisConsumptionNumber
|
totalRemain := tb.TaskIncreaseLimitDataAnalysisNumber - tb.TaskIncreaseLimitDataAnalysisConsumptionNumber
|
||||||
alloc := minInt(need, minInt(limitRemain, totalRemain))
|
alloc := minInt(need, totalRemain)
|
||||||
if alloc > 0 {
|
if alloc > 0 {
|
||||||
tb.TaskIncreaseLimitDataAnalysisConsumptionNumber += alloc
|
tb.TaskIncreaseLimitDataAnalysisConsumptionNumber += alloc
|
||||||
tb.TaskMonthlyLimitDataAnalysisConsumptionNumber += alloc
|
tb.TaskMonthlyLimitDataAnalysisConsumptionNumber += alloc
|
||||||
@ -961,7 +949,7 @@ func UpdatePendingCount(req *UpdatePendingCountRequest) error {
|
|||||||
}
|
}
|
||||||
if need > 0 {
|
if need > 0 {
|
||||||
tx.Rollback()
|
tx.Rollback()
|
||||||
return commonErr.ReturnError(nil, "可用数据分析数不足", "扣减数据分析数量超过当前余额或当月限额")
|
return commonErr.ReturnError(nil, "可用数据分析数不足", "扣减数据分析数量超过当前余额")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user