Exemple #1
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
Exemple #2
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
Exemple #3
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