|
@@ -88,16 +88,25 @@ extension PurchaseManager {
|
|
|
}
|
|
|
|
|
|
//判断视频是否超出限制,return true 是拦截的意思
|
|
|
- func judgeVideoV2ExceedLimit(vipFreeNumType:VipFreeNumType) -> Bool{
|
|
|
+ func judgeInterceptVideoV2ExceedLimit(vipFreeNumType:VipFreeNumType) -> Bool{
|
|
|
+ var intercept:Bool = false
|
|
|
if vipFreeNumType.isVideo {
|
|
|
- return videoAvailableNum <= 0 //次数不够的,返回 true
|
|
|
+ intercept = videoAvailableNum <= 0 //次数不够的,返回 true
|
|
|
}
|
|
|
- return false
|
|
|
+
|
|
|
+ //如果次数不够用,且不是 vip,就看用户有没有免费次数
|
|
|
+ if intercept,isVip == false {
|
|
|
+ if freeNum(type: vipFreeNumType) > 0 {//如果有免费次数,则不拦截
|
|
|
+ intercept = false
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return intercept
|
|
|
}
|
|
|
|
|
|
- func judgeUsedNumType(vipFreeNumType:VipFreeNumType,completion: @escaping (Any?, Error?) -> Void) -> Bool{
|
|
|
+ func judgeInterceptUsedNumType(vipFreeNumType:VipFreeNumType,completion: @escaping (Any?, Error?) -> Void) -> Bool{
|
|
|
///需要校验,是否超出了 vip 生成的次数,且需要判断是否超过最大次数
|
|
|
- if judgeVideoV2ExceedLimit(vipFreeNumType: vipFreeNumType) {
|
|
|
+ if judgeInterceptVideoV2ExceedLimit(vipFreeNumType: vipFreeNumType) {
|
|
|
completion(nil,NSError(domain: "", code: TSNetWorkCode.generateToMax.rawValue))
|
|
|
return true
|
|
|
}
|
|
@@ -111,10 +120,10 @@ extension PurchaseManager {
|
|
|
return false
|
|
|
}
|
|
|
|
|
|
- func judgeUsedNumUrlType(urlType:TSNeURLType,completion:@escaping (Result<Any, Error>) -> Void) -> Bool{
|
|
|
+ func judgeInterceptUsedNumUrlType(urlType:TSNeURLType,completion:@escaping (Result<Any, Error>) -> Void) -> Bool{
|
|
|
let vipFreeNumType:VipFreeNumType = urlType.isVideo ? VipFreeNumType.videoType : .aiGenerate
|
|
|
///需要校验,是否超出了 vip 生成的次数,且需要判断是否超过最大次数
|
|
|
- if urlType.needValidate,judgeVideoV2ExceedLimit(vipFreeNumType: vipFreeNumType) {
|
|
|
+ if urlType.needValidate,judgeInterceptVideoV2ExceedLimit(vipFreeNumType: vipFreeNumType) {
|
|
|
completion(.failure(NSError(domain: "", code: TSNetWorkCode.generateToMax.rawValue)))
|
|
|
return true
|
|
|
}
|
|
@@ -130,14 +139,14 @@ extension PurchaseManager {
|
|
|
|
|
|
//判断试用的视频次数,是否超出了最大数量,如果超出,提示用户购买加油宝
|
|
|
//isCanFree 是否可以免费试用
|
|
|
- func judgePurchaseVideoPackage(vipFreeNumType:VipFreeNumType,isCanFree:Bool = true,target:UIViewController) -> Bool{
|
|
|
+ func judgeInterceptPurchaseVideoPackage(vipFreeNumType:VipFreeNumType,isCanFree:Bool = true,target:UIViewController) -> Bool{
|
|
|
|
|
|
//先判断非会员是否有免费的试用次数
|
|
|
if isCanFree,isVip == false,freeNum(type: vipFreeNumType) > 0 {
|
|
|
return false
|
|
|
}
|
|
|
///需要校验,是否超出了 vip 生成的次数,且需要判断是否超过最大次数
|
|
|
- if judgeVideoV2ExceedLimit(vipFreeNumType: vipFreeNumType) {
|
|
|
+ if judgeInterceptVideoV2ExceedLimit(vipFreeNumType: vipFreeNumType) {
|
|
|
kPresentModalVC(target: target, modelVC: TSPurchaseVideoTimesVC(isShowAlertModel: true),transitionStyle:.crossDissolve)
|
|
|
return true
|
|
|
}
|