Пример #1
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Date   : 2018/5/31 19:25
# Author : lixingyun
# Description :
from huomao.common import Common
from time import time
import requests
from huomao.user import User


User.add_noble_card(1522, 2, 2, 2)

# STREAM_REFRESH_API_EXPIRE = 10

# a = Common.hash_table(30183)
# print(a)
# exit(1)
# url = 'http://test1.api.huomao.com/channels/channelDetail'
# # url = 'http://lxyapi.new.huomaotv.com.cn/channels/channelDetail'
# data = dict(
#     refer='android',
#     cid=9418,
#     expires_time=1527757747,
#     post_data=1,
#     time=1528181184,
#     uid=27064,
#     now_time=int(time()),
#     an=67,
#     ver='dev2.4',
# )
Пример #2
0
    def test(self, *args):
        logger_test_api.info(args)
        # 开通参数
        self.data['month'] = args[-1]
        self.data['level'] = args[-2]
        self.old_level = args[1]
        self.old_month = args[2]
        # 创建购买用户
        self.user = self.create_user()
        # 是否赠送,创建用户贵族
        if args[3]:
            self.data['to_uid'] = self.create_user()
            self.data['type'] = 2
            if args[0] != 'first':
                # 是首次开通,不用预先开通用户贵族
                User.create_noble(self.data['to_uid'], level=self.old_level, month=self.old_month)
            if args[0] == 'expired_protect':
                User.set_noble_expire(self.data['to_uid'])
            elif args[0] == 'expired':
                User.set_noble_expire(self.data['to_uid'], 50)
        else:
            if args[0] != 'first':
                User.create_noble(self.user, level=self.old_level, month=self.old_month)
            if args[0] == 'expired_protect':
                User.set_noble_expire(self.user)
            elif args[0] == 'expired':
                User.set_noble_expire(self.user, 50)

        # 通用8折皇帝,国王不打折,指定打折卡,添加打折卡
        self.discount = args[-3]
        if isinstance(self.discount, dict):
            # 添加打折卡
            use_level = self.discount['level']
            discount = self.discount['discount']
            open_month = self.discount['month']
            if discount < 10:
                self.data['card'] = User.add_noble_card(self.user, use_level, discount, open_month)
            else:
                Bag.add_bag(self.user, self.discount['card'])
                self.data['card'] = self.discount['card']
        elif self.discount > 0 and self.data['level'] <= 5:
            Bag.add_bag(self.user, bag=90001)
        else:
            self.discount = 10
        # 验证
        if isinstance(args[4], dict) and args[4].get('card'):
            if self.old_level == self.data['level'] and args[0] == 'unexpired':
                self.exp_res = {'code': 201, 'data': ''}
            else:
                self.ver = self.validate('renew')
        elif args[0] == 'expired_protect':
            self.ver = self.validate('protect_create')
        elif args[0] == 'expired':
            self.ver = self.validate('create')
        elif args[0] == 'unexpired':
            # 验证
            if self.old_level == self.data['level']:
                self.ver = self.validate('renew')
            elif self.old_level < self.data['level']:
                self.ver = self.validate('upgrade')
            else:
                self.exp_res = {'code': 201, 'data': ''}
        else:
            self.ver = self.validate()