Esempio n. 1
0
 def test_gift_14(self):
     '''业务-礼物配置-霸屏特效,横幅'''
     self.exp_res = {
         'status': True,
         'code': 200,
         'data': {
             'gift': {
                 'screen_effect': {
                     'effect': '',
                     'frame': {
                         'time': gift['bp']['tx_frame']['time'],
                         'height': gift['bp']['tx_frame']['height'],
                         'num': gift['bp']['tx_frame']['num'],
                         'img': ''
                     }
                 },
                 'screen_hf': {
                     'time': gift['bp']['hf_time']
                 }
             }
         }
     }
     self.user = self.create_user()
     self.data['t_count'] = gift['bp']['count']
     MoneyClass.set_money(self.user, 10, 1000)
Esempio n. 2
0
 def test_gift_15(self):
     '''业务-粉丝值'''
     self.exp_res = {'status': True, 'code': 200, 'data': {}}
     self.user = self.create_user()
     MoneyClass.set_money(self.user, 1)
     get_loveliness = User.loveliness('get', self.user, cid)
     self.ver = lambda: User.loveliness(
         'get', self.user, cid) == get_loveliness + gift['fan_exp']
Esempio n. 3
0
 def test_gift_17(self):
     '''业务-余额足够'''
     self.exp_res = {'status': True, 'code': 200}
     self.user = self.create_user()
     MoneyClass.set_money(self.user, 1)
     get_money = MoneyClass.get_money(self.user)['coin']
     self.ver = lambda: MoneyClass.get_money(self.user)[
         'coin'] == get_money - gift['mb']
Esempio n. 4
0
 def test_gift_18(self):
     '''业务-送礼记录'''
     self.exp_res = {'status': True, 'code': 200, 'data': {}}
     self.user = self.create_user()
     MoneyClass.set_money(self.user, 1)
     send_gift_count = MoneyClass.get_money_pay(self.user, cid)
     self.ver = lambda: MoneyClass.get_money_pay(self.user, cid
                                                 ) == send_gift_count + 1
Esempio n. 5
0
 def test_gift_05(self):
     '''业务-角色-房管'''
     self.user = self.create_user()
     MoneyClass.set_money(self.user, 1)
     User.set_fg(cid, self.user)
     self.exp_res = dict(code=200,
                         status=True,
                         data=dict(extend=dict(is_fg='1')))
Esempio n. 6
0
    def test_gift_19(self):
        '''业务-收礼记录,礼物中无宝箱'''
        self.exp_res = {'status': True, 'code': 200, 'data': {}}
        self.user = self.create_user()
        MoneyClass.set_money(self.user, 1)

        # 收礼记录
        get_gift_count = MoneyClass.money_income('count', anchor, self.user)
        self.ver = lambda: MoneyClass.money_income('count', anchor, self.user
                                                   ) == get_gift_count + 1
Esempio n. 7
0
 def test_gift_09(self):
     '''业务-赠送爱心-用户赠送爱心增加经验主播增加仙能'''
     self.user = self.create_user()
     self.data['gift'] = 0
     self.exp_res = {'status': True, 'code': 200}
     MoneyClass.set_xd(self.user, 1000)
     # 获取用户平台经验,主播仙能
     user_experience = User.get_experience(self.user)[0]
     anchor_experience = User.get_experience(anchor)[1]
     self.ver = lambda: User.get_experience(self.user)[0] == user_experience + 1000 and \
                        User.get_experience(anchor)[1] == anchor_experience + 1000
Esempio n. 8
0
    def test_gift_20(self):
        '''业务-收礼记录,礼物中有宝箱'''
        self.exp_res = {'status': True, 'code': 200, 'data': {}}
        self.user = self.create_user()
        self.data['gift'] = '52'
        MoneyClass.set_money(self.user, 4)

        # 收礼记录,及收礼金额
        get_gift_count = MoneyClass.money_income('count', anchor, self.user)
        self.ver = lambda: MoneyClass.money_income('count', anchor, self.user) == get_gift_count + 1 and \
                           MoneyClass.money_income('get', anchor, self.user) == 2
Esempio n. 9
0
 def test_gift_07(self):
     '''业务-显示图标-徽章'''
     self.exp_res = {
         'code': 200,
         'data': {
             'badge': [{
                 'bid': '1',
             }]
         }
     }
     self.user = self.create_user()
     User.set_badge(self.user)
     MoneyClass.set_money(self.user, 1)
Esempio n. 10
0
 def test_gift_06(self):
     '''业务-角色-粉丝'''
     self.user = self.create_user()
     MoneyClass.set_money(self.user, 1)
     User.set_fs_level(self.user, cid)
     self.exp_res = {
         'code': 200,
         'data': {
             'fans': {
                 'cid': cid,
                 'level': '25',
                 'name': '粉丝'
             }
         }
     }
Esempio n. 11
0
 def test(self, *args):
     name = self._testMethodName
     for res in [1, 2, -1, -2]:
         logging.info(f"用例:{name}结算选项{res}开始{'*' * 80}")
         # 开盘
         period = create(guess_type='match', play_type='gamble')
         # 下注
         money_data = []
         for data in args:
             # 获取用户的货币信息,预期货币信息
             uid = data['uid']
             xd = MoneyClass.get_xd(uid)  # 获取仙豆
             md = MoneyClass.get_money(uid)['bean']  # 获取猫豆
             if res == 1:
                 exp = data['ret'][0]
             elif res == 2:
                 exp = data['ret'][1]
             else:
                 exp = data['ret'][2]
             money_data.append((uid, xd, md, exp))
             # 计算用户下注
             choses = {}
             for chose, amount in data.items():
                 if chose != 'ret' and chose != 'uid':
                     i = 0
                     choses[i] = {'chose': chose, 'amount': amount}
                     i = i + 1
                     bet(uid,
                         period=period,
                         coin_type='free_bean',
                         chose=choses)
                     # self.assertEqual(Common.get_xd(uid), xd - amount, '仙豆未扣除')
                     bet(uid,
                         period=period,
                         coin_type='cat_bean',
                         chose=choses)
                     # self.assertEqual(Common.get_money(uid)['bean'], md - amount, '猫豆未扣除')
         # 结算
         settlement(period=period, win_option=res)
         # 验证结果
         for uid, xd, md, exp in money_data:
             self.assertEqual(MoneyClass.get_xd(uid), xd + exp,
                              uid + '仙豆结算错误')
             self.assertEqual(
                 MoneyClass.get_money(uid)['bean'], md + exp,
                 uid + '猫豆结算错误')
     logging.info('用例:' + name + '结束')
Esempio n. 12
0
 def test_gift_13(self):
     '''业务-礼物配置-连击'''
     self.exp_res = {
         'status': True,
         'code': 200,
         'data': {
             'gift': {
                 'current_count': '1',
                 'before_count': '0',
                 'repeat': {
                     'img': ''
                 },
             }
         }
     }
     self.user = self.create_user()
     MoneyClass.set_money(self.user, 1)
Esempio n. 13
0
 def test_gift_12(self):
     '''业务-礼物配置-道具名称,id,赠送语'''
     self.exp_res = {
         'status': True,
         'code': 200,
         'data': {
             'gift': {
                 'word': gift['word'],
                 'send_count': '1',
                 'gift_id': gift['gift_id'],
                 'name': gift['name'],
                 'resource_path': 'http://img.new.huomaotv.com.cn/'
             }
         }
     }
     self.user = self.create_user()
     MoneyClass.set_money(self.user, 1)
Esempio n. 14
0
 def test_14(self):
     '''弹幕卡不足,余额足时,发言彩色弹幕'''
     self.exp_res = {
         'code': 200,
         'data': {
             'barrage': {
                 'type': '300',
                 'color': '#e24040',
                 'num': '0',
                 'msg': '测试弹幕'
             }
         }
     }
     self.user = self.create_user()
     self.data['color_barrage'] = 1
     MoneyClass.set_money(self.user, 1)
     # 二次验证函数
     self.ver = lambda: MoneyClass.get_money(self.user)['coin'] == 0
Esempio n. 15
0
    def test_13(self):
        '''业务-彩色弹幕'''
        self.exp_res = {
            'code': 200,
            'data': {
                'barrage': {
                    'type': '300',
                    'color': '#e24040',
                    'num': '0',
                    'msg': '测试弹幕'
                }
            }
        }
        self.user = self.create_user()
        # 添加用户弹幕卡和货币
        Bag.add_bag(self.user)
        MoneyClass.set_money(self.user, 10)
        self.data['color_barrage'] = 1

        # 二次验证函数
        self.ver = lambda: Bag.get_dmk(
            self.user) == 0 and MoneyClass.get_money(self.user)['coin'] == 10
Esempio n. 16
0
 def test_gift_11(self):
     '''业务-礼物配置-礼物未启用'''
     self.exp_res = {'status': False, 'message': '礼物未激活', 'code': '211'}
     self.user = self.create_user()
     self.data['gift'] = 1
     MoneyClass.set_money(self.user, 1)
Esempio n. 17
0
        def _ver():
            noble_profit = get_noble_exp = get_noble_money = pay_money = False
            if to_uid:
                # A 赠送模式
                # 1  判断增送者猫币
                buyer_coin_new = MoneyClass.get_money(buyer_uid)['coin']
                if _type == 'create' or _type == 'upgrade' or (_type == 'protect_create' and level != old_level):
                    # 开通/升级 首月原价,其他优惠价
                    pay_money = (noble_data[level][0] * 1 + noble_data[level][1] * (month - 1)) * discount
                elif _type == 'renew' or (_type == 'protect_create' and level == old_level):
                    # 续费/续费保护期购买 只花费折扣价格
                    pay_money = noble_data[level][1] * month * discount
                if buyer_coin != buyer_coin_new + pay_money:
                    logger_test_api.error(f'赠送者-猫币错误{buyer_coin}:{buyer_coin_new}')
                    return False
                # 2 判断赠送者贵族猫币
                buyer_noble_coin_new = MoneyClass.get_noble_coin(buyer_uid)
                if buyer_noble_coin != buyer_noble_coin_new:
                    logger_test_api.error(f'赠送者贵族猫币错误{buyer_noble_coin}:{buyer_noble_coin_new}')
                    return False
                # 3 判断赠送者平台经验
                buyer_exp_new = User.get_experience(buyer_uid)[0]
                if buyer_exp != buyer_exp_new:
                    logger_test_api.error(f'赠送者平台经验错误{buyer_exp}:{buyer_exp_new}')
                    return False
                # 判断赠送者喇叭
                buyer_lb_new = Bag.get_dmk(buyer_uid, 90011)
                if buyer_lb != buyer_lb_new:
                    logger_test_api.error(f'赠送者喇叭错误{buyer_lb}:{buyer_lb_new}')
                    return False
                # 4 判断被增送者猫币
                to_uid_coin_new = MoneyClass.get_money(to_uid)['coin']
                if to_uid_coin != to_uid_coin_new:
                    logger_test_api.error(f'被赠送者猫币错误{to_uid_coin}:{to_uid_coin_new}')
                    return False
                # 5 判断被增送贵族猫币,平台经验,喇叭
                to_uid_noble_coin_new = MoneyClass.get_noble_coin(to_uid)
                to_uid_exp_new = User.get_experience(to_uid)[0]
                to_uid_lb_new = Bag.get_dmk(to_uid, 90011)

                get_noble_money = noble_data[level][2] * discount * month
                get_noble_exp = noble_data[level][4] * discount * month
                get_noble_lb = noble_data[level][5] * month
                # if _type == 'create' or _type == 'protect_create':
                #     # 开通/续费保护期 获得一个月
                #     get_noble_money = noble_data[level][2] * discount
                #     get_noble_exp = noble_data[level][4] * discount
                # elif _type == 'renew':
                #     # 续费 不获得
                #     get_noble_money = 0
                #     get_noble_exp = 0
                # elif _type == 'upgrade':
                #     # 返还第一个月和之前月份未给的
                #     get_noble_money = noble_data[level][2] * discount + noble_data[old_level][2] * (old_month - 1)
                #     get_noble_exp = noble_data[level][4] * discount + noble_data[old_level][4] * (old_month - 1)
                if to_uid_noble_coin != to_uid_noble_coin_new - get_noble_money:
                    logger_test_api.error(f'被赠送者贵族猫币错误{to_uid_noble_coin}:{to_uid_noble_coin_new}')
                    return False
                if to_uid_exp != to_uid_exp_new - get_noble_exp:
                    logger_test_api.error(f'普通-平台经验错误{to_uid_exp}:{to_uid_exp_new}:{get_noble_exp}')
                    return False
                if to_uid_lb != to_uid_lb_new - get_noble_lb:
                    logger_test_api.error(f'普通-喇叭错误{to_uid_lb}!={to_uid_lb_new}-{get_noble_lb}')
                    return False

                # 判断主播提成
                profit = User.find_noble_anchor_profit(to_uid, pay_money)
                if _type == 'create' or _type == 'upgrade' or (_type == 'protect_create' and level != old_level):
                    # 开通/升级 获得一个月
                    noble_profit = noble_data[level][3] * 10 / 10 * discount
                elif _type == 'renew' or (_type == 'protect_create' and level == old_level):
                    # 续费/续费保护期  不获得主播提成
                    noble_profit = 0
                if profit != noble_profit:
                    logger_test_api.error(f'普通-主播提成错误{profit}')
                    return False
            else:
                # B 普通模式
                # 1 判断花费猫币
                buyer_coin_new = MoneyClass.get_money(buyer_uid)['coin']
                if _type == 'create' or _type == 'upgrade' or (_type == 'protect_create' and level != old_level):
                    # 开通/升级/续费保护不同等级 首月原价,其他优惠价
                    pay_money = (noble_data[level][0] * 1 + noble_data[level][1] * (month - 1)) * discount
                elif _type == 'renew' or (_type == 'protect_create' and level == old_level):
                    # 续费/续费保护相同等级购买 只花费折扣价格
                    pay_money = noble_data[level][1] * month * discount
                if buyer_coin != buyer_coin_new + pay_money:
                    logger_test_api.error(f'普通-猫币错误{buyer_coin}:{buyer_coin_new}:{pay_money}')
                    return False
                # 2 判断贵族猫币,平台经验,喇叭数量
                buyer_lb_new = Bag.get_dmk(buyer_uid, 90011)
                buyer_noble_coin_new = MoneyClass.get_noble_coin(buyer_uid)
                buyer_exp_new = User.get_experience(buyer_uid)[0]

                # 新逻辑 开通/续费/升级/续费保护期购买 获得所有
                get_noble_money = noble_data[level][2] * discount * month
                get_noble_exp = noble_data[level][4] * discount * month
                get_noble_lb = noble_data[level][5] * month  # 喇叭不打折

                #   if _type == 'create' or _type == 'protect_create' :
                #     # 开通/续费保护期购买 获得一个月
                #     get_noble_money = noble_data[level][2] * discount
                #     get_noble_exp = noble_data[level][4] * discount
                # elif _type == 'renew':
                #     # 续费 不获得
                #     get_noble_money = 0
                #     get_noble_exp = 0
                # elif _type == 'upgrade':
                #     # 返还第一个月和之前月份未给的
                #     get_noble_money = noble_data[level][2] * discount + noble_data[old_level][2] * (old_month - 1)
                #     get_noble_exp = noble_data[level][4] * discount + noble_data[old_level][4] * (old_month - 1)
                #
                if buyer_noble_coin != buyer_noble_coin_new - get_noble_money:
                    logger_test_api.error(f'普通-贵族猫币错误{buyer_noble_coin}:{buyer_noble_coin_new}')
                    return False

                if buyer_exp != buyer_exp_new - get_noble_exp:
                    logger_test_api.error(f'普通-平台经验错误{buyer_exp}:{buyer_exp_new}:{get_noble_exp}')
                    return False

                if buyer_lb != buyer_lb_new - get_noble_lb:
                    logger_test_api.error(f'普通-喇叭错误{buyer_lb}!={buyer_lb_new}-{get_noble_lb}')
                    return False

                # 3 判断主播提成
                profit = User.find_noble_anchor_profit(buyer_uid, pay_money)
                if _type == 'create' or _type == 'upgrade' or (_type == 'protect_create' and level != old_level):
                    # 开通/升级 获得一个月
                    noble_profit = round(noble_data[level][3] * 10 / 10 * discount, 2)
                elif _type == 'renew' or (_type == 'protect_create' and level == old_level):
                    # 续费/续费保护期  不获得主播提成
                    noble_profit = 0
                if profit != noble_profit:
                    logger_test_api.error(f'普通-主播提成错误{noble_profit}:{profit}')
                    return False

            return True
Esempio n. 18
0
 def test(self, *args):
     name = self._testMethodName
     for res in [1, 2, -1, -2]:  # , 1,2, -1, -2
         logging.info(f"用例:{name}结算选项{res}开始{'*' * 80}")
         # 开盘
         period = create(guess_type='match', play_type='banker')
         # 下注
         money_data = []
         for data in args:
             # 获取用户的货币信息,预期货币信息
             uid = data['uid']
             xd = MoneyClass.get_xd(uid)  # 获取仙豆
             md = MoneyClass.get_money(uid)['bean']  # 获取猫豆
             if res == 1:
                 exp = data['ret'][0]
             elif res == 2:
                 exp = data['ret'][1]
             else:
                 exp = data['ret'][2]
             money_data.append((uid, xd, md, exp))
             # 首先坐庄
             banker_data_list = data.get('banker')
             if banker_data_list and isinstance(banker_data_list, list):
                 for banker_data in banker_data_list:
                     for chose, amount in banker_data.items():
                         banker(data['uid'],
                                period=period,
                                coin_type='free_bean',
                                chose=chose,
                                amount=amount[0],
                                banker_odds=amount[1])
                         banker(data['uid'],
                                period=period,
                                coin_type='cat_bean',
                                chose=chose,
                                amount=amount[0],
                                banker_odds=amount[1])
             elif banker_data_list:
                 for chose, amount in banker_data_list.items():
                     banker(data['uid'],
                            period=period,
                            coin_type='free_bean',
                            chose=chose,
                            amount=amount[0],
                            banker_odds=amount[1])
                     banker(data['uid'],
                            period=period,
                            coin_type='cat_bean',
                            chose=chose,
                            amount=amount[0],
                            banker_odds=amount[1])
             # 下注
             buyer_data = data.get('buyer')
             if buyer_data:
                 choses = {}
                 for chose, amounts in buyer_data.items():
                     amount = amounts[0]
                     now_odds = amounts[1]
                     r_amount = amounts[2] if len(amounts) == 3 else amount
                     i = 0
                     choses[i] = {
                         'chose': chose,
                         'amount': amount,
                         'now_odds': now_odds
                     }
                     i = i + 1
                     bet(data['uid'],
                         period=period,
                         coin_type='free_bean',
                         punter='buyer',
                         chose=choses)
                     self.assertEqual(MoneyClass.get_xd(uid), xd - r_amount,
                                      uid + '仙豆未扣除')
                     bet(data['uid'],
                         period=period,
                         coin_type='cat_bean',
                         punter='buyer',
                         chose=choses)
                     self.assertEqual(
                         MoneyClass.get_money(uid)['bean'], md - r_amount,
                         uid + '猫豆未扣除')
         # 结算
         settlement(period=period, win_option=res)
         # 验证结果
         for uid, xd, md, exp in money_data:
             self.assertEqual(MoneyClass.get_xd(uid), xd + exp,
                              uid + '仙豆结算错误')
             self.assertEqual(
                 MoneyClass.get_money(uid)['bean'], md + exp,
                 uid + '猫豆结算错误')
         logging.info(f"用例:{name}结算选项{res}结束{'*' * 80}")
Esempio n. 19
0
    def validate(self, _type='create'):
        # discount = self.discount and Decimal(str(self.discount)) or 1
        discount = isinstance(self.discount, dict) and self.discount['discount'] * 10 / 100 or self.discount * 10 / 100
        # 贵族等级:开通价格0,续费价格1,返还猫币2,主播提成3,增加经验4,喇叭5
        noble_data = {
            1: [66, 30, 30, 13.2, 0, 0],
            2: [500, 300, 300, 100, 50000, 0],
            3: [1500, 1000, 1000, 300, 125000, 0],
            4: [5000, 3000, 3000, 1000, 500000, 5],
            5: [15000, 10000, 10000, 3000, 1250000, 8],
            6: [40000, 30000, 30000, 6000, 2500000, 15],
            7: [120000, 100000, 100000, 12000, 5000000, 30]
        }
        level = isinstance(self.discount, dict) and self.discount['level'] or self.data['level']
        month = isinstance(self.discount, dict) and self.discount['month'] or self.data['month']
        old_level = hasattr(self, 'old_level') and self.old_level
        old_month = hasattr(self, 'old_month') and self.old_month
        # 获取赠送者用户的猫币,贵族猫币,平台经验
        buyer_uid = self.user
        buyer_coin = MoneyClass.get_money(buyer_uid)['coin']
        buyer_noble_coin = MoneyClass.get_noble_coin(buyer_uid)
        buyer_exp = User.get_experience(buyer_uid)[0]
        buyer_lb = Bag.get_dmk(buyer_uid, 90011)

        # 获取被赠送者的猫币,贵族猫币,平台经验
        to_uid = self.data.get('to_uid')
        if to_uid:
            to_uid_coin = MoneyClass.get_money(to_uid)['coin']
            to_uid_noble_coin = MoneyClass.get_noble_coin(to_uid)
            to_uid_exp = User.get_experience(to_uid)[0]
            to_uid_lb = Bag.get_dmk(to_uid, 90011)

        def _ver():
            noble_profit = get_noble_exp = get_noble_money = pay_money = False
            if to_uid:
                # A 赠送模式
                # 1  判断增送者猫币
                buyer_coin_new = MoneyClass.get_money(buyer_uid)['coin']
                if _type == 'create' or _type == 'upgrade' or (_type == 'protect_create' and level != old_level):
                    # 开通/升级 首月原价,其他优惠价
                    pay_money = (noble_data[level][0] * 1 + noble_data[level][1] * (month - 1)) * discount
                elif _type == 'renew' or (_type == 'protect_create' and level == old_level):
                    # 续费/续费保护期购买 只花费折扣价格
                    pay_money = noble_data[level][1] * month * discount
                if buyer_coin != buyer_coin_new + pay_money:
                    logger_test_api.error(f'赠送者-猫币错误{buyer_coin}:{buyer_coin_new}')
                    return False
                # 2 判断赠送者贵族猫币
                buyer_noble_coin_new = MoneyClass.get_noble_coin(buyer_uid)
                if buyer_noble_coin != buyer_noble_coin_new:
                    logger_test_api.error(f'赠送者贵族猫币错误{buyer_noble_coin}:{buyer_noble_coin_new}')
                    return False
                # 3 判断赠送者平台经验
                buyer_exp_new = User.get_experience(buyer_uid)[0]
                if buyer_exp != buyer_exp_new:
                    logger_test_api.error(f'赠送者平台经验错误{buyer_exp}:{buyer_exp_new}')
                    return False
                # 判断赠送者喇叭
                buyer_lb_new = Bag.get_dmk(buyer_uid, 90011)
                if buyer_lb != buyer_lb_new:
                    logger_test_api.error(f'赠送者喇叭错误{buyer_lb}:{buyer_lb_new}')
                    return False
                # 4 判断被增送者猫币
                to_uid_coin_new = MoneyClass.get_money(to_uid)['coin']
                if to_uid_coin != to_uid_coin_new:
                    logger_test_api.error(f'被赠送者猫币错误{to_uid_coin}:{to_uid_coin_new}')
                    return False
                # 5 判断被增送贵族猫币,平台经验,喇叭
                to_uid_noble_coin_new = MoneyClass.get_noble_coin(to_uid)
                to_uid_exp_new = User.get_experience(to_uid)[0]
                to_uid_lb_new = Bag.get_dmk(to_uid, 90011)

                get_noble_money = noble_data[level][2] * discount * month
                get_noble_exp = noble_data[level][4] * discount * month
                get_noble_lb = noble_data[level][5] * month
                # if _type == 'create' or _type == 'protect_create':
                #     # 开通/续费保护期 获得一个月
                #     get_noble_money = noble_data[level][2] * discount
                #     get_noble_exp = noble_data[level][4] * discount
                # elif _type == 'renew':
                #     # 续费 不获得
                #     get_noble_money = 0
                #     get_noble_exp = 0
                # elif _type == 'upgrade':
                #     # 返还第一个月和之前月份未给的
                #     get_noble_money = noble_data[level][2] * discount + noble_data[old_level][2] * (old_month - 1)
                #     get_noble_exp = noble_data[level][4] * discount + noble_data[old_level][4] * (old_month - 1)
                if to_uid_noble_coin != to_uid_noble_coin_new - get_noble_money:
                    logger_test_api.error(f'被赠送者贵族猫币错误{to_uid_noble_coin}:{to_uid_noble_coin_new}')
                    return False
                if to_uid_exp != to_uid_exp_new - get_noble_exp:
                    logger_test_api.error(f'普通-平台经验错误{to_uid_exp}:{to_uid_exp_new}:{get_noble_exp}')
                    return False
                if to_uid_lb != to_uid_lb_new - get_noble_lb:
                    logger_test_api.error(f'普通-喇叭错误{to_uid_lb}!={to_uid_lb_new}-{get_noble_lb}')
                    return False

                # 判断主播提成
                profit = User.find_noble_anchor_profit(to_uid, pay_money)
                if _type == 'create' or _type == 'upgrade' or (_type == 'protect_create' and level != old_level):
                    # 开通/升级 获得一个月
                    noble_profit = noble_data[level][3] * 10 / 10 * discount
                elif _type == 'renew' or (_type == 'protect_create' and level == old_level):
                    # 续费/续费保护期  不获得主播提成
                    noble_profit = 0
                if profit != noble_profit:
                    logger_test_api.error(f'普通-主播提成错误{profit}')
                    return False
            else:
                # B 普通模式
                # 1 判断花费猫币
                buyer_coin_new = MoneyClass.get_money(buyer_uid)['coin']
                if _type == 'create' or _type == 'upgrade' or (_type == 'protect_create' and level != old_level):
                    # 开通/升级/续费保护不同等级 首月原价,其他优惠价
                    pay_money = (noble_data[level][0] * 1 + noble_data[level][1] * (month - 1)) * discount
                elif _type == 'renew' or (_type == 'protect_create' and level == old_level):
                    # 续费/续费保护相同等级购买 只花费折扣价格
                    pay_money = noble_data[level][1] * month * discount
                if buyer_coin != buyer_coin_new + pay_money:
                    logger_test_api.error(f'普通-猫币错误{buyer_coin}:{buyer_coin_new}:{pay_money}')
                    return False
                # 2 判断贵族猫币,平台经验,喇叭数量
                buyer_lb_new = Bag.get_dmk(buyer_uid, 90011)
                buyer_noble_coin_new = MoneyClass.get_noble_coin(buyer_uid)
                buyer_exp_new = User.get_experience(buyer_uid)[0]

                # 新逻辑 开通/续费/升级/续费保护期购买 获得所有
                get_noble_money = noble_data[level][2] * discount * month
                get_noble_exp = noble_data[level][4] * discount * month
                get_noble_lb = noble_data[level][5] * month  # 喇叭不打折

                #   if _type == 'create' or _type == 'protect_create' :
                #     # 开通/续费保护期购买 获得一个月
                #     get_noble_money = noble_data[level][2] * discount
                #     get_noble_exp = noble_data[level][4] * discount
                # elif _type == 'renew':
                #     # 续费 不获得
                #     get_noble_money = 0
                #     get_noble_exp = 0
                # elif _type == 'upgrade':
                #     # 返还第一个月和之前月份未给的
                #     get_noble_money = noble_data[level][2] * discount + noble_data[old_level][2] * (old_month - 1)
                #     get_noble_exp = noble_data[level][4] * discount + noble_data[old_level][4] * (old_month - 1)
                #
                if buyer_noble_coin != buyer_noble_coin_new - get_noble_money:
                    logger_test_api.error(f'普通-贵族猫币错误{buyer_noble_coin}:{buyer_noble_coin_new}')
                    return False

                if buyer_exp != buyer_exp_new - get_noble_exp:
                    logger_test_api.error(f'普通-平台经验错误{buyer_exp}:{buyer_exp_new}:{get_noble_exp}')
                    return False

                if buyer_lb != buyer_lb_new - get_noble_lb:
                    logger_test_api.error(f'普通-喇叭错误{buyer_lb}!={buyer_lb_new}-{get_noble_lb}')
                    return False

                # 3 判断主播提成
                profit = User.find_noble_anchor_profit(buyer_uid, pay_money)
                if _type == 'create' or _type == 'upgrade' or (_type == 'protect_create' and level != old_level):
                    # 开通/升级 获得一个月
                    noble_profit = round(noble_data[level][3] * 10 / 10 * discount, 2)
                elif _type == 'renew' or (_type == 'protect_create' and level == old_level):
                    # 续费/续费保护期  不获得主播提成
                    noble_profit = 0
                if profit != noble_profit:
                    logger_test_api.error(f'普通-主播提成错误{noble_profit}:{profit}')
                    return False

            return True

        return _ver
Esempio n. 20
0
from django.shortcuts import render
from django.http import StreamingHttpResponse, HttpResponse, JsonResponse, HttpResponseRedirect
from huomao.common import Common
from huomao.user import User
from huomao.channel import Channel
from huomao.money import MoneyClass
from huomao.test import test
import logging
import json

user = User()
channel = Channel()
money = MoneyClass()


def api_test(request):
    return render(request, 'api_test.html')


def chatroom(request):
    return render(request, 'chatroom.html')


def new_web(request, method=''):
    if request.META.get('HTTP_X_FORWARDED_FOR'):
        ip = request.META['HTTP_X_FORWARDED_FOR']
    else:
        ip = request.META['REMOTE_ADDR']
    print(ip)
    if method == '':
        return render(request, 'index.html')
Esempio n. 21
0
# -*- coding: utf-8 -*-
# Date   : 2018/7/24 13:54
# Author : lixingyun
# Description :
from huomao.user import User
from huomao.bag import Bag
from decimal import *
import requests
from huomao.common import Common, REDIS_INST
from huomao.money import MoneyClass
import time
# Bag.add_bag(1522,90001)

# User.add_noble_card(34052, 3, 2, 1)

#
# t = Bag.get_dmk(1522,90011)

item = 1000
uid = 35482

MoneyClass.set_money(uid, item / 1000, 0)

REDIS_INST.delete('hm_new_guess_active_recharge_joins_tag')
# url = 'http://lxy.new.huomaotv.com.cn/badgeexchange/exchangePay?room_number=0&refer=web'
url = 'http://lxy.new.huomaotv.com.cn/Smallgame/exchangePay?room_number=0&refer=web'
ret = requests.post(url,
                    data=dict(item=item),
                    cookies=Common.generate_cookies(uid))
print(ret.text)
Esempio n. 22
0
    'zhuxiao',
    'lisiyuan',
    'machao',
    'xiawenhao',
    'gaolingyun',
    'huangrui',
    'zhaoxu',
    'yubinbin',
    'yangjichao',
    'liyu',
    'liuyilin',
    'yuhan',
]
#
# for i in users:
#     try:
#         name = 'hm_' + str(i) +'1'
#         uid = User.find_uid(name)['msg']
#         print(uid)
#         REDIS_INST.delete(f'hm_{uid}')
#     except  Exception as e:
#         print(e)

# [26342,26449]
for i in range(100):
    u = User()
    uid = u.reg('testling')
    u.bd_sj(uid)
    MoneyClass.set_money(uid, 1000000)
    print(uid)
Esempio n. 23
0
 def create_user(self):
     uid = User.reg('noble')
     logger_test_api.info(f'注册用户UID:{uid}')
     User.bd_sj(uid)
     MoneyClass.set_money(uid, 9000000)
     return uid