def policy_filter(self): acct_policy = self.product.product_policy or PPMonth bill_type = self.get_account_attr('bill_type') input_max_limit = self.product.input_max_limit output_max_limit = self.product.output_max_limit if acct_policy in ( PPMonth,BOMonth) or (acct_policy == FreeFee and bill_type == FreeFeeDate): # 预付费包月/买断包月/自由时段 if utils.is_expire(self.account.expire_date): self.reply['attrs']['Framed-Pool'] = self.get_param_value("expire_addrpool") elif acct_policy in (PPTimes,PPFlow) : # 预付费时长预付费流量 if self.get_user_balance() <= 0: return self.failure('Lack of balance') elif acct_policy == BOTimes or (acct_policy == FreeFee and bill_type == FreeTimeLen): # 买断时长 / 自由买断时长 if self.get_user_time_length() <= 0: return self.failure('Lack of time_length') elif acct_policy == BOFlows or (acct_policy == FreeFee and bill_type == FreeFeeFlow): # 买断流量 / 自由买断流量 if self.get_user_flow_length() <= 0: return self.failure('Lack of flow_length') if acct_policy == FreeFee: input_max_limit = self.get_account_attr('input_max_limit') output_max_limit = self.get_account_attr('output_max_limit') self.reply['input_limit'] = input_max_limit self.reply['output_limit'] = output_max_limit return True
def policy_filter(self): acct_policy = self.product.product_policy or PPMonth if acct_policy in (PPMonth, BOMonth): if utils.is_expire(self.account.expire_date): self.reply['attrs']['Framed-Pool'] = self.get_param_value( "expire_addrpool") elif acct_policy in (PPTimes, PPFlow): user_balance = self.get_user_balance() if user_balance <= 0: return self.failure('Lack of balance') elif acct_policy == BOTimes: time_length = self.get_user_time_length() if time_length <= 0: return self.failure('Lack of time_length') elif acct_policy == BOFlows: flow_length = self.get_user_flow_length() if flow_length <= 0: return self.failure('Lack of flow_length') self.reply['input_limit'] = self.product.input_max_limit self.reply['output_limit'] = self.product.output_max_limit return True
def policy_filter(self): acct_policy = self.product.product_policy or PPMonth bill_type = self.get_account_attr('bill_type') input_max_limit = self.product.input_max_limit output_max_limit = self.product.output_max_limit if acct_policy in (PPMonth, BOMonth): # 预付费包月/买断包月/自由时段 if utils.is_expire(self.account.expire_date): self.reply['attrs']['Framed-Pool'] = self.get_param_value( "expire_addrpool") elif acct_policy in (PPTimes, PPFlow): # 预付费时长预付费流量 if self.get_user_balance() <= 0: return self.failure('Lack of balance') elif acct_policy == BOTimes: # 买断时长 / 自由买断时长 if self.get_user_time_length() <= 0: return self.failure('Lack of time_length') elif acct_policy == BOFlows: # 买断流量 / 自由买断流量 if self.get_user_flow_length() <= 0: return self.failure('Lack of flow_length') elif acct_policy == FreeFee: bill_type = int(self.get_account_attr('bill_type')) input_max_limit = self.get_account_attr('input_max_limit') output_max_limit = self.get_account_attr('output_max_limit') if bill_type == FreeFeeDate and utils.is_expire( self.account.expire_date): self.reply['attrs']['Framed-Pool'] = self.get_param_value( "expire_addrpool") elif bill_type == FreeTimeLen and self.get_user_time_length() <= 0: return self.failure('Lack of time_length') elif bill_type == FreeFeeFlow and self.get_user_flow_length() <= 0: return self.failure('Lack of flow_length') self.reply['input_rate'] = input_max_limit self.reply['output_rate'] = output_max_limit return True
def policy_filter(self): acct_policy = self.product.product_policy or PPMonth if acct_policy in ( PPMonth,BOMonth): if utils.is_expire(self.account.expire_date): self.reply['attrs']['Framed-Pool'] = self.get_param_value("expire_addrpool") elif acct_policy in (PPTimes,PPFlow): user_balance = self.get_user_balance() if user_balance <= 0: return self.failure('Lack of balance') elif acct_policy == BOTimes: time_length = self.get_user_time_length() if time_length <= 0: return self.failure('Lack of time_length') elif acct_policy == BOFlows: flow_length = self.get_user_flow_length() if flow_length <= 0: return self.failure('Lack of flow_length') self.reply['input_limit'] = self.product.input_max_limit self.reply['output_limit'] = self.product.output_max_limit return True
def get_expire_date(self, expire): if utils.is_expire(expire): return utils.get_currdate() else: return expire