예제 #1
0
    def bing_relationship_data(self,ip,payment_method,data,buyer_id):
        # 查询买家是否绑定销售/业务焕商/TCO
        if payment_method in ["易贝", "易贝券"]:
            # 获取买家绑定的销售/业务焕商/TCO dict
            bind_buyer_relationship = SQL(ip).bind_user_relationship(buyer_id)
            if bind_buyer_relationship != None:
                bind_buyer_relationship_data = bind_user_relationship_id(ip, bind_buyer_relationship)
            else:
                bind_buyer_relationship_data = None

            return bind_buyer_relationship_data

        elif payment_method in ["抵工资", "家人购", "现金"]:
            if payment_method == "现金":
                payer_id = data['卖家']
            else:
                payer_id = data['出钱方']

            # 获取买家绑定的销售/业务焕商/TCO dict
            bind_buyer_relationship = SQL(ip).bind_user_relationship(buyer_id)
            if bind_buyer_relationship != None:
                bind_buyer_relationship_data = bind_user_relationship_id(ip, bind_buyer_relationship)
            else:
                bind_buyer_relationship_data = None

            # 获取出钱人绑定的销售/业务焕商/TCO dict
            bind_payer_relationship = SQL(ip).bind_user_relationship(payer_id)
            if bind_payer_relationship != None:
                bind_payer_relationship_data = bind_user_relationship_id(ip, bind_payer_relationship)
            else:
                bind_payer_relationship_data = None

            return bind_buyer_relationship_data,bind_payer_relationship_data
예제 #2
0
def second_payagent_ratio_data(ip, province_id, city_id, area_id, platform_id):
    '''

    Parameters
    ----------
    ip:数据库IP
    province_id:省代理商id
    city_id:市代理商id
    area_id:区代理商id
    platform_id:平台id

    Returns:返回所用的二级分佣比例
    -------

    '''

    # 买家注册地没有代理商
    if province_id == None and city_id == None and area_id == None:
        # 用平台比例
        second_payagent_ratio = SQL(ip).platform_second_payagent_ratio(
            platform_id)
    # 买家注册地有代理商
    else:
        second_payagent_ratio = SQL(ip).second_payagent_ratio(
            province_id, city_id, area_id)

    return second_payagent_ratio
예제 #3
0
    def superior_template(self,
                          ip,
                          payment_method,
                          data,
                          sheet_name,
                          case_id,
                          phone_1,
                          phone_2=None):
        '''

        :param payment_method: 支付方式
        :param data: data
        :param sheet_name: 表单
        :param case_id: 用例id
        :param phone_1: 手机号 易贝 易贝券
        :param phone_2: 手机号 其余支付方式 需要考虑卖家/家人/企业
        :return: 写回Excel的上级城市焕商/代理商id模板
        '''

        if payment_method in ["易贝", "易贝券"]:
            buyer_phone = eval(data)['buyer_phone']
            buyer_regional_agent = SQL(ip).regional_agent(
                buyer_phone)  # 查询买家上级
            buyer_superior = Superior().superior(ip, buyer_regional_agent,
                                                 phone_1)
            b = buyer_superior
            DoExcel.superior(test_case_path, sheet_name, case_id, str(b))
            return b

        elif payment_method in ["抵工资", "家人购"]:
            buyer_phone = eval(data)['buyer_phone']
            disanfang_phone = eval(data)['disanfang_phone']
            buyer_regional_agent = SQL(ip).regional_agent(
                buyer_phone)  # 查询买家上级
            disanfang_regional_agent = SQL(ip).regional_agent(
                disanfang_phone)  # 查询企业/家人上级
            buyer_superior = Superior().superior(ip, buyer_regional_agent,
                                                 phone_1)
            disanfang_superior = Superior().superior(ip,
                                                     disanfang_regional_agent,
                                                     phone_2)
            b = {"储备池分佣": buyer_superior, "支付服务费分佣": disanfang_superior}
            DoExcel.superior(test_case_path, sheet_name, case_id, str(b))
            return b

        else:  # 现金
            buyer_phone = eval(data)['buyer_phone']
            seller_phone = eval(data)['seller_phone']
            buyer_regional_agent = SQL(ip).regional_agent(
                buyer_phone)  # 查询买家上级
            seller_regional_agent = SQL(ip).regional_agent(
                seller_phone)  # 查询卖家上级
            buyer_superior = Superior().superior(ip, buyer_regional_agent,
                                                 phone_1)
            seller_superior = Superior().superior(ip, seller_regional_agent,
                                                  phone_2)
            b = {"储备池分佣": buyer_superior, "支付服务费分佣": seller_superior}
            DoExcel.superior(test_case_path, sheet_name, case_id, str(b))
            return b
예제 #4
0
def bind_user_relationship_id(ip, data):
    '''

    Parameters
    ----------
    ip:数据库ip
    data:用户绑定的销售/业务焕商/TCO

    Returns:文字转换后的用户绑定的销售/业务焕商/TCO
    -------

    '''

    b = {}

    for i in range(len(data)):
        if data[i]['bind_type'] == "FREE_SALES":
            b["自由销售"] = data[i]['business_user_id']

        elif data[i]['bind_type'] == "SALES":
            b["销售"] = data[i]['business_user_id']

        else:
            b["TCO"] = data[i]['business_user_id']

    
    if "自由销售" in b.keys():
        Q = SQL(ip).bind_user_relationship2(b["自由销售"])

    elif "销售" in b.keys():
        Q = SQL(ip).bind_user_relationship2(b["销售"])

    if "自由销售" not in b.keys():
        b["自由销售"] = None

    if "销售" not in b.keys():
        b["销售"] = None

    if "TCO" not in b.keys():
        b["TCO"] = None

    if Q != None:
        b["买家上级的上级id"] = Q[0]['business_user_id']
        b["买家上级的上级身份"] = Q[0]['bind_type']
        if b["买家上级的上级身份"] =='SALES':
            b["买家上级的上级身份"] ="销售"
        elif b["买家上级的上级身份"] =='FREE_SALES':
            b["买家上级的上级身份"] ="业务焕商"
        elif b["买家上级的上级身份"] =='TCO':
            b["买家上级的上级身份"] ="TCO"
    else:
        b["买家上级的上级id"] = None
        b["买家上级的上级身份"] = None



    return b
예제 #5
0
    def fenyong(self, ip, province_id, city_id, area_id, personal_id):

        data = SQL(ip).ratio(province_id, city_id, area_id, personal_id)

        fenyong = {}

        if data != None:
            # print(data)
            for i in data:

                if data[0]['type'] != 5:
                    u1 = i['ratio']
                    if i['type'] == 1:
                        fenyong["省分佣比例"] = u1

                    elif i['type'] == 2:
                        fenyong["市分佣比例"] = u1

                    elif i['type'] == 3:
                        fenyong["区分佣比例"] = u1

                    elif i['type'] == 4:
                        fenyong["个人分佣比例"] = u1
                else:
                    if len(data) == 2:
                        u2 = [data[0]['ratio'], data[1]['ratio']]
                        if data[0]['ratio'] >= data[1]['ratio']:
                            fenyong["市分佣比例"] = u2[0]
                            fenyong["区分佣比例"] = u2[1]
                        else:
                            fenyong["市分佣比例"] = u2[1]
                            fenyong["区分佣比例"] = u2[0]
                    else:
                        u3 = data[0]['ratio']
                        sss = SQL(ip).chengshihuanshang(data[0]['user_id'])
                        fenyong[sss] = u3

        if province_id == None:
            fenyong["省分佣比例"] = None
        if city_id == None:
            fenyong["市分佣比例"] = None
        if area_id == None:
            fenyong["区分佣比例"] = None
        if personal_id == None:
            fenyong["个人分佣比例"] = None

        # print("最终",fenyong)

        return fenyong
예제 #6
0
def chulidata(data, ip, order):
    '''

    Parameters
    ----------
    data:待处理流水文本 list
    ip:数据库ip
    order:订单号

    Returns:把钱包变化之前的值、变化之后的值替换回去
    -------

    '''

    b = SQL(ip).current(order)

    b = list(b)

    for i in range(len(data)):

        data[i] = list(data[i])
        data[i][5] = b[i][0]
        data[i][4] = data[i][5] + data[i][3]
        data[i] = tuple(data[i])

    a = tuple(data)
    return a
예제 #7
0
    def fanhui(self,ip, superior):  # 以后写回Excel对比用
        '''

        :param superior: 上级代理商/城市焕商
        :return: user_id, biz_type, changes, category
        '''
        sql_data = SQL(ip).wallet_detail(self.order)  # 支付数据
        global a, b
        user_id = []
        biz_type = []
        changes = []
        category = []
        shuju = Title(self.buyer_identity, self.seller_identity, self.payment_method).title(superior)
        # print("shuju", shuju)
        # print(len(shuju))
        for i in range(0, len(shuju)):
            mmm = (sql_data[i])[0]
            lll = (sql_data[i])[2]
            kkk = (sql_data[i])[3]
            nnn = (sql_data[i])[7]
            user_id.append(mmm)
            biz_type.append(lll)
            changes.append(kkk)
            category.append(nnn)
            # print('次数i:{0}'.format(i))

        return user_id, biz_type, changes, category
예제 #8
0
    def expected(self, ip, calculation, data, superior, reserve_fund=None):
        '''

        :param charge_amount:未消耗充值金额
        :param reserve_fund:储备池金额
        :param data: 手机号、id
        :param superior:上级代理商/城市焕商
        :param buyer_province_proportion:买家上级省代理商
        :param buyer_city_proportion:买家上级市代理商
        :param buyer_area_proportion:买家上级区代理商
        :param buyer_personal_proportion:买家上级个人焕商
        :param disanfang_province_proportion:企业/家人上级省代理商
        :param disanfang_city_proportion:企业/家人上级市代理商
        :param disanfang_area_proportion:企业/家人上级区代理商
        :param disanfang_personal_proportion:企业/家人上级个人焕商
        :return:预期流水模板
        '''

        sql_data = SQL(ip).wallet_detail(self.order)  # 支付数据

        user_id = GeShiHua(self.buyer_identity, self.seller_identity,
                           self.member_level, self.payment_method,
                           self.order).userid(data, superior)
        # print("userid", user_id)

        expected_changes = GeShiHua(self.buyer_identity, self.seller_identity,
                                    self.member_level, self.payment_method,
                                    self.order).expected_changes(
                                        ip, calculation,
                                        reserve_fund)  # 格式化之后的changes
        # print("expected_changes", expected_changes)
        biz_type = (GeShiHua(self.buyer_identity, self.seller_identity,
                             self.member_level, self.payment_method,
                             self.order).fanhui(ip, superior))[1]

        category = (GeShiHua(self.buyer_identity, self.seller_identity,
                             self.member_level, self.payment_method,
                             self.order).fanhui(ip, superior))[3]

        # 控制流水条数
        shuju = Title(self.buyer_identity, self.seller_identity,
                      self.payment_method).title(superior)
        # print(shuju)
        # print(len(shuju))

        bbb = []
        for i in range(0, len(shuju)):
            a1 = user_id[i]
            a3 = biz_type[i]
            a4 = expected_changes[i]
            a6 = (sql_data[i])[5]
            a5 = a6 + a4
            a8 = category[i]
            aaa = (a1, 2, a3, a4, a5, a6, shuju[i], a8)
            bbb.append(aaa)
            # print("i", i)
        # print("bbb", bbb)
        bbb = tuple(bbb)
        return bbb
예제 #9
0
    def transaction(self, ip, member_level, payment_method, order, charge_amount, reserve_fund):
        global service_fee_data, pay_commission
        print("---------------------分割线-------------------------")

        # 根据订单号查流水
        sql_data = SQL(ip).wallet_detail(order)

        # 商品价格
        price = ((sql_data[0])[3]) * -1

        print("选择的会员等级是:{0}".format(member_level))
        print("选择的支付方式是:{0}".format(payment_method))

        # 通过调用方法返回的需要支付的易贝/现金服务费
        service_fee_data = PaymentMethod().payment_method(member_level, payment_method,
                                                          price)

        print("----------------计算支付服务费分佣----------------")

        # pay_service_fee方法计算服务费分佣  支付方式 要分佣的服务费 服务费分佣比例
        if payment_method in ["易贝"]:

            pay_commission = Dividend(self.buyer_identity, self.seller_identity, self.buyer_province_proportion,
                                      self.buyer_city_proportion, self.buyer_area_proportion,
                                      self.buyer_personal_proportion).pay_service_fee(payment_method,
                                                                                      service_fee_data[1],
                                                                                      yb[member_level])
        # 这些支付方式需要考虑 买家上级 和 企业/家人/卖家上级
        elif payment_method in ["抵工资", "家人购", "现金", "微信", "支付宝"]:
            pay_commission = Dividend(self.buyer_identity, self.seller_identity,
                                          self.buyer_province_proportion, self.buyer_city_proportion,
                                          self.buyer_area_proportion, self.buyer_personal_proportion,
                                          self.disanfang_province_proportion,
                                          self.disanfang_city_proportion, self.disanfang_area_proportion,
                                          self.disanfang_personal_proportion).pay_service_fee(payment_method,
                                                                                              service_fee_data[1],
                                                                                              yb[member_level])

        # 公海用户购买个人焕商商品 需要考虑储备池分佣
        if (self.buyer_identity == "公海用户" and self.seller_identity == "个人焕商") or (
                self.buyer_identity == "公海用户" and self.seller_identity == "非焕商且已绑定个人焕商"):  # 公海用户需要考虑储备池分佣
            print("----------------计算现金服务费(储备池)分佣----------------")
            cash_commission = Dividend(self.buyer_identity, self.seller_identity, self.buyer_province_proportion,
                                       self.buyer_city_proportion, self.buyer_area_proportion,
                                       self.buyer_personal_proportion).cash_service_fee(charge_amount, reserve_fund)
            # 公海用户购买个人焕商商品  易贝券不会有支付服务费分佣 其他的需要
            if payment_method != '易贝券':
                return service_fee_data, cash_commission, pay_commission
            else:
                return service_fee_data, cash_commission
        # 其他情况都不用考虑储备池分佣
        else:
            if payment_method == '易贝券':
                return service_fee_data
            else:
                return service_fee_data, pay_commission
예제 #10
0
    def superior(self, ip, regional_agent, phone):
        '''
        :param regional_agent:上级代理商/城市焕商
        :param phone:手机号
        :return:上级代理商/城市焕商模板
        '''

        # t=[{'signed_user_id': 15239, 'area_name': ''}]
        a = SQL(ip).personal(phone)
        c = [a]

        b = {}
        # print(len(regional_agent))
        for i in range(0, len(regional_agent)):

            if (regional_agent)[i].__contains__('type'):
                print("上级是代理商")
                u1 = regional_agent[i]['type']
                u2 = regional_agent[i]['id']

                if u1 == 1:
                    b["省代理商"] = u2
                elif u1 == 2:
                    b["市代理商"] = u2
                else:
                    b["区代理商"] = u2

            else:
                print("上级是城市焕商")
                u2 = regional_agent[i]['signed_user_id']
                if (regional_agent)[i]['area_name'] != "":
                    b["区代理商"] = u2
                else:
                    b["市代理商"] = u2

        if "省代理商" not in b:
            b["省代理商"] = None
        if "市代理商" not in b:
            b["市代理商"] = None
        if "区代理商" not in b:
            b["区代理商"] = None

        c.append(b)
        return c
예제 #11
0
    def get_order(cls, ip, file_name, sheet_name, case_id, buyerid):
        '''

        :param file_name: 文件名
        :param sheet_name: 表单名
        :param case_id: 用例id
        :param buyerid: 买家id
        :return: 订单id写回Excel
        '''

        wb = load_workbook(file_name)
        sheet = wb[sheet_name]
        # 查库获取最新的1条订单,一般是前端操作完,然后查库,获取订单
        order_data = SQL(ip).order(buyerid)
        # 返回是这种 ((39717, 'EC-2020070216034000008747'),)
        order = (order_data[0])[1]
        sheet.cell(case_id + 1, 12).value = order
        wb.save(file_name)
        return order
예제 #12
0
    def get_order(cls, ip, file_name, sheet_name, case_id, buyerid):
        '''

        :param file_name: 文件名
        :param sheet_name: 表单名
        :param case_id: 用例id
        :param buyerid: 买家id
        :return: 订单id写回Excel
        '''

        wb = load_workbook(file_name)
        sheet = wb[sheet_name]
        # 查库获取最新的1条订单,一般是前端操作完,然后查库,获取订单
        order_data = SQL(ip).order(buyerid)
        # print(order_data)
        order = (order_data[0])[0]  # 返回是这种 ('EC-2020050611310900010204',)
        sheet.cell(case_id + 1, 11).value = order
        wb.save(file_name)
        return order
예제 #13
0
    def fan_hui(self, ip, order, expected_moban):  # 以后写回Excel对比用
        '''

        :param superior: 上级代理商/城市焕商
        :return: user_id, biz_type, changes, category
        '''
        sql_data = SQL(ip).wallet_detail(order)  # 支付数据
        user_id = []
        biz_type = []
        changes = []
        category = []

        for i in range(0, len(expected_moban)):
            mmm = (sql_data[i])[0]
            lll = (sql_data[i])[2]
            kkk = (sql_data[i])[3]
            nnn = (sql_data[i])[7]
            user_id.append(mmm)
            biz_type.append(lll)
            changes.append(kkk)
            category.append(nnn)
            # print('次数i:{0}'.format(i))

        return user_id, biz_type, changes, category
예제 #14
0
    def test_1_buy_goods(self, item):

        my_logger.info("----------开始执行用例{0},环境是{1}----------".format(
            item['case_id'], item['surroundings']))

        ip = IP[item['surroundings']]

        H5_Login_url = url(item['surroundings'])[0]
        H5_home_url = url(item['surroundings'])[1]

        buyer_phone = eval(item['data'])['buyer_phone']
        seller_phone = eval(item['data'])['seller_phone']

        # 获取绑定关系
        superior = SuperiorTemplate().superior_template_main(
            ip, item['payment_method'], item['data'], buyer_phone)

        Boss_login_url = url(item['surroundings'])[2]

        operational_setting = eval(item['operational_setting'])

        print("----------开始BOSS后台设置运营分佣比例操作----------")

        self.driver.get(Boss_login_url)
        #Boss后台设置运营分佣比例
        BossSetting(self.driver).main(ip, item['payment_method'], superior,
                                      operational_setting)

        print("----------BOSS后台运营分佣比例设置完毕----------")

        self.driver.quit()

        mobile_emulation = {'deviceName': 'iPhone X'}
        chrome_options = webdriver.ChromeOptions()
        chrome_options.add_experimental_option("mobileEmulation",
                                               mobile_emulation)
        driver = webdriver.Chrome(options=chrome_options)

        driver.get(H5_Login_url)
        self.lg = H5_LoginPage(driver)

        self.lg.login(buyer_phone)

        #定位
        time.sleep(5)
        Location().location(driver)

        buyer_identity = item['buyer_identity']
        seller_identity = item['seller_identity']

        if buyer_identity == "公海用户":
            if seller_identity == "个人焕商" or seller_identity == "非焕商且已绑定个人焕商":
                driver.find_element(*MyIndex.myIndex).click()
                time.sleep(6)

                # # 充值
                Recharge().recharge(driver)
                time.sleep(2)
                # 支付按键
                BuyGoods(driver).pay()
                time.sleep(2)

                # 写回储备池和充值金额
                user_id = eval(item['data'])["买家"]
                reserve_fund_data = SQL(ip).reserve_fund_data(user_id)
                DoExcel.reserve_fund(test_case_path, item['sheet_name'],
                                     item['case_id'], str(reserve_fund_data))
                # time.sleep(5)

                driver.get(H5_home_url)
                time.sleep(2)

        # 选择商品
        Seach_Goods().seach_goods(driver, item['goodsname'])

        # 购买流程
        BuyGoods(driver).BuyGood(item['payment_method'])
        time.sleep(3)

        # 卖家操作
        driver.get(H5_Login_url)
        lg = H5_LoginPage(driver)
        lg.login(seller_phone)
        time.sleep(2)
        driver.get(H5_home_url)
        time.sleep(2)
        driver.find_element(*MyIndex.myIndex).click()
        time.sleep(2)
        # 滚动至元素【销售订单】可见,点击
        ActionChains(driver).move_to_element(
            driver.find_element(*MyIndex.saleOrderList)).perform()
        driver.execute_script('window.scrollBy(0,500)')
        time.sleep(2)
        driver.find_element(*MyIndex.saleOrderList).click()
        time.sleep(5)
        # 确认订单
        WebDriverWait(driver, 10).until(
            EC.visibility_of_element_located((MyIndex.confirm_Order))).click()
        time.sleep(6)

        # 根据商品名判断流程
        if "实物商品" in item['goodsname']:
            ReceiptDelivery(driver).real_goods(H5_Login_url, buyer_phone)

        elif "本地服务" in item['goodsname']:
            ReceiptDelivery(driver).local_life(H5_Login_url, H5_home_url,
                                               buyer_phone, seller_phone)

        elif "商企服务" in item['goodsname']:
            ReceiptDelivery(driver).local_life(H5_Login_url, H5_home_url,
                                               buyer_phone, seller_phone)

        # 写回订单号
        buyerid = eval(item['data'])['买家']
        order = DoExcel.get_order(ip, test_case_path, item['sheet_name'],
                                  item['case_id'], buyerid)

        # 获取绑定关系,写回Excel
        superior = SuperiorTemplate().superior_template_main(
            ip, item['payment_method'], item['data'], buyer_phone)
        DoExcel.superior(test_case_path, item['sheet_name'], item['case_id'],
                         str(superior))

        # 获取上级分佣比例,写回Excel
        proportion = SuperiorTemplate().fenyong_template_main(
            ip, item['payment_method'], superior)
        DoExcel.fenyong_bili(test_case_path, item['sheet_name'],
                             item['case_id'], str(proportion))

        if buyer_identity == "公海用户":
            if seller_identity == "个人焕商" or seller_identity == "非焕商且已绑定个人焕商":
                # 跳回卖家,解除伙伴绑定
                driver.get(H5_Login_url)
                lg = H5_LoginPage(driver)
                if seller_identity == "个人焕商":
                    lg.login(seller_phone)
                elif seller_identity == "非焕商且已绑定个人焕商":
                    bangding_phone = eval(item['data'])['bangding_phone']
                    lg.login(bangding_phone)
                time.sleep(2)
                driver.get(H5_home_url)
                time.sleep(2)
                driver.find_element(*MyIndex.myIndex).click()
                time.sleep(2)
                driver.find_element(*MyIndex.myPartner).click()
                time.sleep(3)
                # 解绑
                UntiePartner().untie_partner(driver, item['surroundings'])

        my_logger.info("----------前端操作执行完毕----------")

        ip = IP[item['surroundings']]
        data = eval(item['data'])

        buyer_id = data['买家']

        # 查询买家是否绑定销售/业务焕商/TCO
        if item['payment_method'] in ["易贝", "易贝券"]:
            # 获取买家绑定的销售/业务焕商/TCO dict
            bind_buyer_relationship_data = BingRelationshipData(
            ).bing_relationship_data(ip, item['payment_method'], data,
                                     buyer_id)

            # 把买家上级销售/业务焕商的上级写回Excel
            DoExcel().bing_sale_id(test_case_path, item['sheet_name'],
                                   item['case_id'],
                                   str(bind_buyer_relationship_data))

        elif item['payment_method'] in ["抵工资", "家人购", "现金"]:
            bind_relationship_data = BingRelationshipData(
            ).bing_relationship_data(ip, item['payment_method'], data,
                                     buyer_id)
            bind_buyer_relationship_data = bind_relationship_data[0]
            bind_payer_relationship_data = bind_relationship_data[1]
            # 买家上级销售/业务焕商的上级,写回模板
            bind_buyer_relationship_id = {
                "储备金二级分佣对象": bind_buyer_relationship_data,
                "支付服务费二级分佣对象": bind_payer_relationship_data
            }
            DoExcel().bing_sale_id(test_case_path, item['sheet_name'],
                                   item['case_id'],
                                   str(bind_buyer_relationship_id))

        # 获取这笔订单应该【使用】的二级分佣比例
        transaction_second_payagent_ratio = TransactionSecondPayagentRatio(
        ).transaction_second_payagent_ratio(ip, item['payment_method'],
                                            superior, data)
        # 把这笔订单所使用的二级分佣比例写回Excel
        DoExcel().second_payagent_ratio(test_case_path, item['sheet_name'],
                                        item['case_id'],
                                        str(transaction_second_payagent_ratio))

        driver.quit()
        my_logger.info("----------开始进行对比----------")

        try:
            ip = IP[item['surroundings']]
            if buyer_identity == "公海用户":
                if seller_identity == "个人焕商" or seller_identity == "非焕商且已绑定个人焕商":
                    charge_amount = reserve_fund_data['charge_amount']
                    reserve_fund = reserve_fund_data['reserve_fund']
                else:
                    charge_amount = None
                    reserve_fund = None
            else:
                charge_amount = None
                reserve_fund = None

            calculation_data = CalculationData().calculation_data(
                ip, item['payment_method'], item['member_level'],
                buyer_identity, seller_identity, proportion, charge_amount,
                reserve_fund, order)

            if item['payment_method'] in ["易贝", "易贝券"]:
                expected_moban = MoBan(buyer_identity, seller_identity,
                                       item['member_level'],
                                       item['payment_method'],
                                       order).expected_moban(
                                           ip, data, superior, reserve_fund,
                                           calculation_data,
                                           transaction_second_payagent_ratio,
                                           bind_buyer_relationship_data)
            elif item['payment_method'] in ["抵工资", "家人购", "现金"]:
                expected_moban = MoBan(buyer_identity, seller_identity,
                                       item['member_level'],
                                       item['payment_method'],
                                       order).expected_moban(
                                           ip, data, superior, reserve_fund,
                                           calculation_data,
                                           transaction_second_payagent_ratio,
                                           bind_buyer_relationship_data,
                                           bind_payer_relationship_data)

            # 写回Excel用
            fanhui = FanHui().fan_hui(ip, order, expected_moban)

            sql_data = SQL(ip).wallet_detail(order)

            for i in range(0, len(expected_moban)):
                self.assertEqual(expected_moban[i], sql_data[i])

            self.assertEqual(expected_moban, sql_data)
            my_logger.info("用例{0}正确!{1}".format(item['case_id'],
                                                item['title']))
            TestResult = 'Pass'
            Error = None

        except AssertionError as e:
            my_logger.info("用例错误!错误原因是第{0}行,{1}:".format(i + 1, e))
            TestResult = 'Failed'
            Error = "用例错误!错误原因是:第{0}行,{1}:".format(i + 1, e)
            raise e  # 异常处理完后记得抛出

        finally:  # 不管怎样都得写入Excel
            DoExcel().write_back(test_case_path, item['sheet_name'],
                                 item['case_id'] + 1, str(fanhui[0]),
                                 str(fanhui[2]), str(expected_moban),
                                 str(sql_data), TestResult, str(Error))

        # time.sleep(2)
        my_logger.info("----------对比结束----------")
        my_logger.info("----------用例{0}执行完毕----------".format(item['case_id']))
예제 #15
0
    def test_2_duibi(self, item):

        global i, expected_userid, fanhui, expected_changes, expected, sql_data, TestResult, Error

        try:

            ip = IP[item['surroundings']]

            if item['payment_method'] in ["易贝", "易贝券"]:
                buyer_province_proportion = eval(item['proportion'])['省分佣比例']
                buyer_city_proportion = eval(item['proportion'])['市分佣比例']
                buyer_area_proportion = eval(item['proportion'])['区分佣比例']
                buyer_personal_proportion = eval(item['proportion'])['个人分佣比例']
                disanfang_province_proportion = None
                disanfang_city_proportion = None
                disanfang_area_proportion = None
                disanfang_personal_proportion = None
            else:
                buyer_province_proportion = (eval(
                    item['proportion']))['储备池分佣']['省分佣比例']
                buyer_city_proportion = (eval(
                    item['proportion']))['储备池分佣']['市分佣比例']
                buyer_area_proportion = (eval(
                    item['proportion']))['储备池分佣']['区分佣比例']
                buyer_personal_proportion = (eval(
                    item['proportion']))['储备池分佣']['个人分佣比例']
                disanfang_province_proportion = (eval(
                    item['proportion']))['支付服务费分佣']['省分佣比例']
                disanfang_city_proportion = (eval(
                    item['proportion']))['支付服务费分佣']['市分佣比例']
                disanfang_area_proportion = (eval(
                    item['proportion']))['支付服务费分佣']['区分佣比例']
                disanfang_personal_proportion = (eval(
                    item['proportion']))['支付服务费分佣']['个人分佣比例']

            if item['buyer_identity'] == "公海用户":
                if item['seller_identity'] == "个人焕商" or item[
                        'seller_identity'] == "非焕商且已绑定个人焕商":
                    charge_amount = eval(item['reserve_fund'])['charge_amount']
                    reserve_fund = eval(item['reserve_fund'])['reserve_fund']
                else:
                    charge_amount = None
                    reserve_fund = None
            else:
                charge_amount = None
                reserve_fund = None

            # 预期分佣的用户id流水
            expected_userid = GeShiHua(
                item['buyer_identity'], item['seller_identity'],
                item['member_level'], item['payment_method'],
                item['order']).userid(eval(item['data']),
                                      eval(item['superior']))
            # print("expected_userid", expected_userid)

            # 计算出来的(商品价格,需要支付的易贝服务费,需要支付的现金服务费)(储备池分佣)(服务费分佣)
            calculation = A(
                item['buyer_identity'],
                item['seller_identity'],
                buyer_province_proportion=buyer_province_proportion,
                buyer_city_proportion=buyer_city_proportion,
                buyer_area_proportion=buyer_area_proportion,
                buyer_personal_proportion=buyer_personal_proportion,
                disanfang_province_proportion=disanfang_province_proportion,
                disanfang_city_proportion=disanfang_city_proportion,
                disanfang_area_proportion=disanfang_area_proportion,
                disanfang_personal_proportion=disanfang_personal_proportion,
            ).transaction(ip, item['member_level'], item['payment_method'],
                          item['order'], charge_amount, reserve_fund)

            # print("calculation", calculation)

            # 预期的变化金额值流水
            expected_changes = GeShiHua(
                item['buyer_identity'], item['seller_identity'],
                item['member_level'], item['payment_method'],
                item['order']).expected_changes(ip,
                                                calculation,
                                                reserve_fund=reserve_fund)
            # print('expected_changes', expected_changes)

            # 预期的流水
            expected = GeShiHua(
                item['buyer_identity'], item['seller_identity'],
                item['member_level'], item['payment_method'],
                item['order']).expected(ip,
                                        calculation,
                                        eval(item['data']),
                                        eval(item['superior']),
                                        reserve_fund=reserve_fund)
            # print("expected", expected)

            # 写回Excel用
            fanhui = GeShiHua(item['buyer_identity'], item['seller_identity'],
                              item['member_level'], item['payment_method'],
                              item['order']).fanhui(ip, eval(item['superior']))

            sql_data = SQL(ip).wallet_detail(item['order'])

            shuju = Title(item['buyer_identity'], item['seller_identity'],
                          item['payment_method']).title(eval(item['superior']))

            for i in range(0, len(shuju)):
                self.assertEqual(expected[i], sql_data[i])

            self.assertEqual(expected, sql_data)

            my_logger.info("用例{0}正确!{1}".format(item['case_id'],
                                                item['title']))
            TestResult = 'Pass'
            Error = None

        except AssertionError as e:
            my_logger.info("用例错误!错误原因是第{0}行,{1}:".format(i + 1, e))
            TestResult = 'Failed'
            Error = "用例错误!错误原因是:第{0}行,{1}:".format(i + 1, e)
            raise e  # 异常处理完后记得抛出

        finally:  # 不管怎样都得写入Excel
            DoExcel().write_back(test_case_path,
                                 item['sheet_name'], item['case_id'] + 1,
                                 str(expected_userid), str(fanhui[0]),
                                 str(expected_changes), str(fanhui[2]),
                                 str(expected), str(sql_data), TestResult,
                                 str(Error))
예제 #16
0
    def test_1_buy_goods(self, item):

        global disanfang_province_id, disanfang_city_id, disanfang_area_id, disanfang_personal_id, i, TestResult, Error, reserve_fund, expected_userid, fanhui, expected_changes, expected, sql_data

        my_logger.info("----------开始执行用例{0},环境是{1}----------".format(
            item['case_id'], item['surroundings']))

        ip = IP[item['surroundings']]
        H5_Login_url = url(item['surroundings'])[0]
        H5_home_url = url(item['surroundings'])[1]

        self.driver.get(H5_Login_url)
        self.lg = LoginPage(self.driver)

        buyer_phone = eval(item['data'])['buyer_phone']
        seller_phone = eval(item['data'])['seller_phone']
        self.lg.login(buyer_phone)
        time.sleep(3)

        buyer_identity = item['buyer_identity']
        seller_identity = item['seller_identity']

        if buyer_identity == "公海用户":
            if seller_identity == "个人焕商" or seller_identity == "非焕商且已绑定个人焕商":
                self.driver.find_element(*MyIndex.myIndex).click()
                time.sleep(5)

                # 充值
                WebDriverWait(self.driver, 10).until(
                    EC.visibility_of_element_located(
                        (MyIndex.serviceRecharge))).click()
                time.sleep(3)
                self.driver.find_element(*MyIndex.recharge_amount).click()
                time.sleep(2)
                self.driver.find_element(*MyIndex.input_amount).send_keys(100)
                time.sleep(2)
                self.driver.find_element(*MyIndex.queren).click()
                time.sleep(4)
                WebDriverWait(self.driver, 10).until(
                    EC.visibility_of_element_located(
                        (MyIndex.rechare_now))).click()
                time.sleep(3)
                WebDriverWait(self.driver, 10).until(
                    EC.visibility_of_element_located(
                        (MyIndex.querenzhifu))).click()
                time.sleep(2)

                # 支付按键
                BuyGoods(self.driver).pay()
                time.sleep(2)

                # 写回储备池和充值金额
                user_id = eval(item['data'])["买家"]
                reserve_fund = SQL(ip).reserve_fund(user_id)
                DoExcel.reserve_fund(test_case_path, item['sheet_name'],
                                     item['case_id'], str(reserve_fund))
                # time.sleep(5)

                self.driver.get(H5_home_url)
                time.sleep(2)

        # 选择商品
        self.driver.find_element(*Home.search).click()
        time.sleep(3)
        WebDriverWait(self.driver,
                      10).until(EC.visibility_of_element_located(
                          (Home.input))).send_keys(item['goodsname'])
        time.sleep(2)
        self.driver.find_element(*Home.input).send_keys(Keys.ENTER)
        time.sleep(3)
        # 点击【商品】
        self.driver.find_element(*Home.real_goods).click()
        time.sleep(3)

        # 购买流程
        BuyGoods(self.driver).BuyGood(item['payment_method'])
        time.sleep(3)
        BuyGoods(self.driver).pay()
        time.sleep(2)

        # 卖家操作
        self.driver.get(H5_Login_url)
        lg = LoginPage(self.driver)
        lg.login(seller_phone)
        time.sleep(2)
        self.driver.get(H5_home_url)
        time.sleep(2)
        self.driver.find_element(*MyIndex.myIndex).click()
        time.sleep(2)
        # 滚动至元素【销售订单】可见,点击
        ActionChains(self.driver).move_to_element(
            self.driver.find_element(*MyIndex.saleOrderList)).perform()
        self.driver.execute_script('window.scrollBy(0,500)')
        time.sleep(2)
        self.driver.find_element(*MyIndex.saleOrderList).click()
        time.sleep(5)
        # 确认订单
        WebDriverWait(self.driver, 10).until(
            EC.visibility_of_element_located((MyIndex.confirm_Order))).click()
        time.sleep(6)

        # 根据商品名判断流程
        if item['goodsname'].find('实物商品') != -1:  # 商品名字包含实物商品
            # 发货
            self.driver.find_element(*MyIndex.ship).click()
            time.sleep(2)
            self.driver.find_element(*MyIndex.logistics_company).click()
            time.sleep(3)
            WebDriverWait(self.driver, 10).until(
                EC.visibility_of_element_located((MyIndex.debang))).click()
            time.sleep(2)
            self.driver.find_element(
                *MyIndex.dingdanhao).send_keys("lalalalala")
            time.sleep(2)
            self.driver.find_element(*MyIndex.ship_now).click()
            time.sleep(2)

            # 买家
            self.driver.get(H5_Login_url)
            lg = LoginPage(self.driver)
            lg.login(buyer_phone)
            time.sleep(2)
            # 点击【采购订单】
            self.driver.find_element(*MyIndex.purchase).click()
            time.sleep(4)
            # 收货
            WebDriverWait(self.driver, 10).until(
                EC.visibility_of_element_located((MyIndex.receipt))).click()
            time.sleep(3)

            # 支付按键
            BuyGoods(self.driver).pay()
            time.sleep(2)

        elif item['goodsname'].find('本地生活') != -1:
            # 本地生活
            self.driver.get(H5_Login_url)
            lg = LoginPage(self.driver)
            lg.login(buyer_phone)
            time.sleep(2)
            self.driver.get(H5_home_url)
            time.sleep(2)
            self.driver.find_element(*MyIndex.myIndex).click()
            time.sleep(2)
            # 点击【采购订单】
            self.driver.find_element(*MyIndex.purchase).click()
            time.sleep(4)
            # 点击第一个订单
            self.driver.find_element(*BG.frist_order).click()
            time.sleep(2)
            xuliehao = ReturnTxt(self.driver).xuliehao_txt()
            # print(xuliehao)

            time.sleep(2)

            # 卖家
            self.driver.get(H5_Login_url)
            lg = LoginPage(self.driver)
            lg.login(seller_phone)
            time.sleep(2)
            self.driver.get(H5_home_url)
            time.sleep(2)
            self.driver.find_element(*MyIndex.myIndex).click()
            time.sleep(2)
            # 滚动至元素【销售订单】可见,点击
            ActionChains(self.driver).move_to_element(
                self.driver.find_element(*MyIndex.saleOrderList)).perform()
            self.driver.execute_script('window.scrollBy(0,500)')
            time.sleep(2)
            self.driver.find_element(*MyIndex.saleOrderList).click()
            time.sleep(5)
            # 点击第一个订单
            self.driver.find_element(*BG.frist_order).click()
            time.sleep(2)
            # 输入序列号
            self.driver.find_element(*BG.click_xuliehao).send_keys(xuliehao)
            # 点击确定
            self.driver.find_element(*BG.click_queding).click()
            time.sleep(1)
            self.driver.find_element(*BG.click_queding2).click()
            time.sleep(2)

        elif item['goodsname'].find('商企服务') != -1:
            # 买家
            self.driver.get(H5_Login_url)
            lg = LoginPage(self.driver)
            lg.login(buyer_phone)
            time.sleep(2)
            # 点击【采购订单】
            self.driver.find_element(*MyIndex.purchase).click()
            time.sleep(4)

            # 确认签约
            self.driver.find_element(*BG.qianyue).click()

            # 支付按键
            BuyGoods(self.driver).pay()
            time.sleep(2)

        # 写回订单号
        buyerid = eval(item['data'])['买家']
        order = DoExcel.get_order(ip, test_case_path, item['sheet_name'],
                                  item['case_id'], int(buyerid))
        # time.sleep(5)

        # 获取绑定关系,写回Excel
        if item['payment_method'] in ["易贝", "易贝券"]:
            superior = SuperiorTemplate().superior_template(
                ip, item['payment_method'], item['data'], item['sheet_name'],
                item['case_id'], buyer_phone)

        elif item['payment_method'] in ["抵工资", "家人购"]:
            disanfang_phone = eval(item['data'])['disanfang_phone']
            superior = SuperiorTemplate().superior_template(
                ip, item['payment_method'], item['data'], item['sheet_name'],
                item['case_id'], buyer_phone, disanfang_phone)

        else:
            seller_phone = eval(item['data'])['seller_phone']
            superior = SuperiorTemplate().superior_template(
                ip, item['payment_method'], item['data'], item['sheet_name'],
                item['case_id'], buyer_phone, seller_phone)

        # time.sleep(5)
        # print('shangji',shangji)

        if item['payment_method'] in ["易贝", "易贝券"]:
            buyer_province_id = superior[1]['省代理商']
            buyer_city_id = superior[1]['市代理商']
            buyer_area_id = superior[1]['区代理商']
            buyer_personal_id = superior[0]['个人焕商']
        else:
            buyer_province_id = superior['储备池分佣'][1]['省代理商']
            buyer_city_id = superior['储备池分佣'][1]['市代理商']
            buyer_area_id = superior['储备池分佣'][1]['区代理商']
            buyer_personal_id = superior['储备池分佣'][0]['个人焕商']

            disanfang_province_id = superior['支付服务费分佣'][1]['省代理商']
            disanfang_city_id = superior['支付服务费分佣'][1]['市代理商']
            disanfang_area_id = superior['支付服务费分佣'][1]['区代理商']
            disanfang_personal_id = superior['支付服务费分佣'][0]['个人焕商']

        # print(buyer_province_id,buyer_city_id,buyer_area_id,buyer_personal_id)
        # 获取上级分佣比例,写回Excel
        if item['payment_method'] in ["易贝", "易贝券"]:
            proportion = SuperiorTemplate().fenyong_template(
                ip, item['payment_method'], item['sheet_name'],
                item['case_id'], buyer_province_id, buyer_city_id,
                buyer_area_id, buyer_personal_id)

        elif item['payment_method'] in ["抵工资", "家人购"]:
            proportion = SuperiorTemplate().fenyong_template(
                ip, item['payment_method'], item['sheet_name'],
                item['case_id'], buyer_province_id, buyer_city_id,
                buyer_area_id, buyer_personal_id, disanfang_province_id,
                disanfang_city_id, disanfang_area_id, disanfang_personal_id)

        else:
            proportion = SuperiorTemplate().fenyong_template(
                ip, item['payment_method'], item['sheet_name'],
                item['case_id'], buyer_province_id, buyer_city_id,
                buyer_area_id, buyer_personal_id, disanfang_province_id,
                disanfang_city_id, disanfang_area_id, disanfang_personal_id)

        # time.sleep(5)

        if buyer_identity == "公海用户":
            if seller_identity == "个人焕商" or seller_identity == "非焕商且已绑定个人焕商":
                # 跳回卖家,解除伙伴绑定
                self.driver.get(H5_Login_url)
                lg = LoginPage(self.driver)
                if seller_identity == "个人焕商":
                    lg.login(seller_phone)
                elif seller_identity == "非焕商且已绑定个人焕商":
                    bangding_phone = eval(item['data'])['bangding_phone']
                    lg.login(bangding_phone)
                time.sleep(2)
                self.driver.get(H5_home_url)
                time.sleep(2)
                self.driver.find_element(*MyIndex.myIndex).click()
                time.sleep(2)
                self.driver.find_element(*MyIndex.myPartner).click()
                time.sleep(3)
                if item['surroundings'] == "test":
                    self.driver.find_element(*MyIndex.delete1).click()
                elif item['surroundings'] == "mtest":
                    self.driver.find_element(*MyIndex.delete2).click()
                elif item['surroundings'] == "dev1":
                    self.driver.find_element(*MyIndex.delete3).click()
                time.sleep(2)
                self.driver.find_element(*MyIndex.queren).click()
                time.sleep(5)

        my_logger.info("----------用例{0}执行完毕----------".format(item['case_id']))
        my_logger.info("----------开始进行对比----------")

        try:
            ip = IP[item['surroundings']]

            if item['payment_method'] in ["易贝", "易贝券"]:
                buyer_province_proportion = proportion['省分佣比例']
                buyer_city_proportion = proportion['市分佣比例']
                buyer_area_proportion = proportion['区分佣比例']
                buyer_personal_proportion = proportion['个人分佣比例']
                disanfang_province_proportion = None
                disanfang_city_proportion = None
                disanfang_area_proportion = None
                disanfang_personal_proportion = None
            else:
                buyer_province_proportion = proportion['储备池分佣']['省分佣比例']
                buyer_city_proportion = proportion['储备池分佣']['市分佣比例']
                buyer_area_proportion = proportion['储备池分佣']['区分佣比例']
                buyer_personal_proportion = proportion['储备池分佣']['个人分佣比例']

                disanfang_province_proportion = proportion['支付服务费分佣']['省分佣比例']
                disanfang_city_proportion = proportion['支付服务费分佣']['市分佣比例']
                disanfang_area_proportion = proportion['支付服务费分佣']['区分佣比例']
                disanfang_personal_proportion = proportion['支付服务费分佣']['个人分佣比例']

            if item['buyer_identity'] == "公海用户":
                if item['seller_identity'] == "个人焕商" or item[
                        'seller_identity'] == "非焕商且已绑定个人焕商":
                    charge_amount = reserve_fund['charge_amount']
                    reserve_fund = reserve_fund['reserve_fund']
                else:
                    charge_amount = None
                    reserve_fund = None
            else:
                charge_amount = None
                reserve_fund = None

            # 预期分佣的用户id流水
            expected_userid = GeShiHua(item['buyer_identity'],
                                       item['seller_identity'],
                                       item['member_level'],
                                       item['payment_method'],
                                       order).userid(eval(item['data']),
                                                     superior)
            # print("expected_userid", expected_userid)

            # 计算出来的(商品价格,需要支付的易贝服务费,需要支付的现金服务费)(储备池分佣)(服务费分佣)
            calculation = A(
                item['buyer_identity'],
                item['seller_identity'],
                buyer_province_proportion=buyer_province_proportion,
                buyer_city_proportion=buyer_city_proportion,
                buyer_area_proportion=buyer_area_proportion,
                buyer_personal_proportion=buyer_personal_proportion,
                disanfang_province_proportion=disanfang_province_proportion,
                disanfang_city_proportion=disanfang_city_proportion,
                disanfang_area_proportion=disanfang_area_proportion,
                disanfang_personal_proportion=disanfang_personal_proportion,
            ).transaction(ip, item['member_level'], item['payment_method'],
                          order, charge_amount, reserve_fund)

            # print("calculation", calculation)

            # 预期的变化金额值流水
            expected_changes = GeShiHua(
                item['buyer_identity'], item['seller_identity'],
                item['member_level'], item['payment_method'],
                order).expected_changes(ip,
                                        calculation,
                                        reserve_fund=reserve_fund)
            # print('expected_changes', expected_changes)

            # 预期的流水
            expected = GeShiHua(item['buyer_identity'],
                                item['seller_identity'], item['member_level'],
                                item['payment_method'],
                                order).expected(ip,
                                                calculation,
                                                eval(item['data']),
                                                superior,
                                                reserve_fund=reserve_fund)
            # print("expected", expected)

            # 写回Excel用
            fanhui = GeShiHua(item['buyer_identity'], item['seller_identity'],
                              item['member_level'], item['payment_method'],
                              order).fanhui(ip, superior)

            sql_data = SQL(ip).wallet_detail(order)

            shuju = Title(item['buyer_identity'], item['seller_identity'],
                          item['payment_method']).title(superior)

            for i in range(0, len(shuju)):
                self.assertEqual(expected[i], sql_data[i])

            self.assertEqual(expected, sql_data)
            my_logger.info("用例{0}正确!{1}".format(item['case_id'],
                                                item['title']))
            TestResult = 'Pass'
            Error = None

        except AssertionError as e:
            my_logger.info("用例错误!错误原因是第{0}行,{1}:".format(i + 1, e))
            TestResult = 'Failed'
            Error = "用例错误!错误原因是:第{0}行,{1}:".format(i + 1, e)
            raise e  # 异常处理完后记得抛出

        finally:  # 不管怎样都得写入Excel
            DoExcel().write_back(test_case_path,
                                 item['sheet_name'], item['case_id'] + 1,
                                 str(expected_userid), str(fanhui[0]),
                                 str(expected_changes), str(fanhui[2]),
                                 str(expected), str(sql_data), TestResult,
                                 str(Error))

        # time.sleep(2)
        my_logger.info("----------对比结束----------")
예제 #17
0
    def main(self, ip, payment_method, superior, operational_setting):

        if payment_method in ["易贝", "易贝券"]:

            operational_setting_province_id = superior[1]["省代理商"]
            operational_setting_province_data = operational_setting["省代理商"]

            operational_setting_city_id = superior[1]["市代理商"]
            operational_setting_city_data = operational_setting["市代理商"]

            operational_setting_area_id = superior[1]["区代理商"]
            operational_setting_area_data = operational_setting["区代理商"]

            if operational_setting_province_id != None:
                phone = SQL(ip).user_phone(operational_setting_province_id)
                Boss_LoginPage(self.driver).login(phone, "qaz123")
                self.boss_operational_setting(
                    operational_setting_province_data)

            if operational_setting_city_id != None:
                phone = SQL(ip).user_phone(operational_setting_city_id)
                Boss_LoginPage(self.driver).login(phone, "qaz123")
                self.boss_operational_setting(operational_setting_city_data)

            if operational_setting_area_id != None:
                phone = SQL(ip).user_phone(operational_setting_area_id)
                Boss_LoginPage(self.driver).login(phone, "qaz123")
                self.boss_operational_setting(operational_setting_area_data)
        else:

            reserve_fund_superior_province_id = superior["储备池分佣"][1]["省代理商"]
            reserve_fund_operational_setting_province_data = operational_setting[
                "储备池分佣"]["省代理商"]

            reserve_fund_superior_city_id = superior["储备池分佣"][1]["市代理商"]
            reserve_fund_operational_setting_city_data = operational_setting[
                "储备池分佣"]["市代理商"]

            reserve_fund_superior_area_id = superior["储备池分佣"][1]["区代理商"]
            reserve_fund_operational_setting_area_data = operational_setting[
                "储备池分佣"]["区代理商"]

            if reserve_fund_superior_province_id != None:
                phone = SQL(ip).user_phone(reserve_fund_superior_province_id)
                Boss_LoginPage(self.driver).login(phone, "qaz123")
                self.boss_operational_setting(
                    reserve_fund_operational_setting_province_data)

            if reserve_fund_superior_city_id != None:
                phone = SQL(ip).user_phone(reserve_fund_superior_city_id)
                Boss_LoginPage(self.driver).login(phone, "qaz123")
                self.boss_operational_setting(
                    reserve_fund_operational_setting_city_data)

            if reserve_fund_superior_area_id != None:
                phone = SQL(ip).user_phone(reserve_fund_superior_area_id)
                Boss_LoginPage(self.driver).login(phone, "qaz123")
                self.boss_operational_setting(
                    reserve_fund_operational_setting_area_data)

            service_fee_superior_province_id = superior["支付服务费分佣"][1]["省代理商"]
            service_fee_operational_setting_province_data = operational_setting[
                "支付服务费分佣"]["省代理商"]

            service_fee_superior_city_id = superior["支付服务费分佣"][1]["省代理商"]
            service_fee_operational_setting_city_data = operational_setting[
                "支付服务费分佣"]["省代理商"]

            service_fee_superior_area_id = superior["支付服务费分佣"][1]["省代理商"]
            service_fee_operational_setting_area_data = operational_setting[
                "支付服务费分佣"]["省代理商"]

            if service_fee_superior_province_id != None:
                phone = SQL(ip).user_phone(service_fee_superior_province_id)
                Boss_LoginPage(self.driver).login(phone, "qaz123")
                self.boss_operational_setting(
                    service_fee_operational_setting_province_data)

            if service_fee_superior_city_id != None:
                phone = SQL(ip).user_phone(service_fee_superior_city_id)
                Boss_LoginPage(self.driver).login(phone, "qaz123")
                self.boss_operational_setting(
                    service_fee_operational_setting_city_data)

            if service_fee_superior_area_id != None:
                phone = SQL(ip).user_phone(service_fee_superior_area_id)
                Boss_LoginPage(self.driver).login(phone, "qaz123")
                self.boss_operational_setting(
                    service_fee_operational_setting_area_data)
예제 #18
0
            if service_fee_superior_area_id != None:
                phone = SQL(ip).user_phone(service_fee_superior_area_id)
                Boss_LoginPage(self.driver).login(phone, "qaz123")
                self.boss_operational_setting(
                    service_fee_operational_setting_area_data)


if __name__ == '__main__':
    driver = webdriver.Chrome()
    ip = "192.168.0.101"
    operational_setting = {
        '省代理商': {
            '销售': 0.3,
            '业务焕商': 0,
            'TCO': 0.3
        },
        '市代理商': '未设置',
        '区代理商': '未设置'
    }
    superior = [{
        '个人焕商': 1000650
    }, {
        '省代理商': 1000646,
        '市代理商': 1000647,
        '区代理商': 1000648
    }]
    # 窗口最大化
    driver.maximize_window()
    phone = SQL(ip).user_phone(superior[1]["市代理商"])
    BossSetting(driver).boss_operational_setting(operational_setting["市代理商"])
예제 #19
0
    def test_2_duibi(self, item):

        try:
            ip = IP[item['surroundings']]
            superior = eval(item['superior'])
            data = eval(item['data'])

            if item['payment_method'] in ["易贝", "易贝券"]:
                buyer_province_proportion = eval(item['proportion'])['省分佣比例']
                buyer_city_proportion = eval(item['proportion'])['市分佣比例']
                buyer_area_proportion = eval(item['proportion'])['区分佣比例']
                buyer_personal_proportion = eval(item['proportion'])['个人分佣比例']
                disanfang_province_proportion = None
                disanfang_city_proportion = None
                disanfang_area_proportion = None
                disanfang_personal_proportion = None
            else:
                buyer_province_proportion = (eval(
                    item['proportion']))['储备池分佣']['省分佣比例']
                buyer_city_proportion = (eval(
                    item['proportion']))['储备池分佣']['市分佣比例']
                buyer_area_proportion = (eval(
                    item['proportion']))['储备池分佣']['区分佣比例']
                buyer_personal_proportion = (eval(
                    item['proportion']))['储备池分佣']['个人分佣比例']
                disanfang_province_proportion = (eval(
                    item['proportion']))['支付服务费分佣']['省分佣比例']
                disanfang_city_proportion = (eval(
                    item['proportion']))['支付服务费分佣']['市分佣比例']
                disanfang_area_proportion = (eval(
                    item['proportion']))['支付服务费分佣']['区分佣比例']
                disanfang_personal_proportion = (eval(
                    item['proportion']))['支付服务费分佣']['个人分佣比例']

            if item['buyer_identity'] == "公海用户":
                if item['seller_identity'] == "个人焕商" or item[
                        'seller_identity'] == "非焕商且已绑定个人焕商":
                    charge_amount = eval(item['reserve_fund'])['charge_amount']
                    reserve_fund = eval(item['reserve_fund'])['reserve_fund']
                else:
                    charge_amount = None
                    reserve_fund = None
            else:
                charge_amount = None
                reserve_fund = None

            # 计算出来的(商品价格,需要支付的易贝服务费,需要支付的现金服务费)(储备池分佣)(服务费分佣)
            calculation = A(
                item['buyer_identity'],
                item['seller_identity'],
                buyer_province_proportion=buyer_province_proportion,
                buyer_city_proportion=buyer_city_proportion,
                buyer_area_proportion=buyer_area_proportion,
                buyer_personal_proportion=buyer_personal_proportion,
                disanfang_province_proportion=disanfang_province_proportion,
                disanfang_city_proportion=disanfang_city_proportion,
                disanfang_area_proportion=disanfang_area_proportion,
                disanfang_personal_proportion=disanfang_personal_proportion,
            ).transaction(ip, item['member_level'], item['payment_method'],
                          item['order'], charge_amount, reserve_fund)

            transaction_second_payagent_ratio = eval(
                item['second_payagent_ratio'])

            if item['payment_method'] in ["抵工资", "家人购", "现金", "微信", "支付宝"]:
                bind_buyer_relationship_data = eval(
                    item['bind_relationship_data'])["储备金二级分佣对象"]

                bind_payer_relationship_data = eval(
                    item['bind_relationship_data'])["支付服务费二级分佣对象"]
            else:
                bind_buyer_relationship_data = eval(
                    item['bind_relationship_data'])
                bind_payer_relationship_data = eval(
                    item['bind_relationship_data'])

            # 预期的流水

            if item['payment_method'] in ["易贝", "易贝券"]:
                expected_moban = MoBan(
                    item['buyer_identity'], item['seller_identity'],
                    item['member_level'], item['payment_method'],
                    item['order']).moban(eval(item['data']),
                                         superior,
                                         ip,
                                         calculation,
                                         item['order'],
                                         transaction_second_payagent_ratio,
                                         bind_buyer_relationship_data,
                                         reserve_fund=reserve_fund)
            else:
                expected_moban = MoBan(
                    item['buyer_identity'], item['seller_identity'],
                    item['member_level'], item['payment_method'],
                    item['order']).moban(eval(item['data']),
                                         superior,
                                         ip,
                                         calculation,
                                         item['order'],
                                         transaction_second_payagent_ratio,
                                         bind_buyer_relationship_data,
                                         bind_payer_relationship_data,
                                         reserve_fund=reserve_fund)
            # print("expected", expected)

            # 写回Excel用
            fanhui = GeShiHua(item['buyer_identity'], item['seller_identity'],
                              item['member_level'], item['payment_method'],
                              item['order']).fanhui(ip, eval(item['superior']))

            sql_data = SQL(ip).wallet_detail(item['order'])

            shuju = Title(item['buyer_identity'], item['seller_identity'],
                          item['payment_method']).title(eval(item['superior']))

            for i in range(0, len(shuju)):
                self.assertEqual(expected_moban[i], sql_data[i])

            self.assertEqual(expected_moban, sql_data)

            my_logger.info("用例{0}正确!{1}".format(item['case_id'],
                                                item['title']))
            TestResult = 'Pass'
            Error = None

        except AssertionError as e:
            my_logger.info("用例错误!错误原因是第{0}行,{1}:".format(i + 1, e))
            TestResult = 'Failed'
            Error = "用例错误!错误原因是:第{0}行,{1}:".format(i + 1, e)
            raise e  # 异常处理完后记得抛出

        finally:  # 不管怎样都得写入Excel
            DoExcel().write_back(test_case_path, item['sheet_name'],
                                 item['case_id'] + 1, str(fanhui[0]),
                                 str(fanhui[2]), str(expected_moban),
                                 str(sql_data), TestResult, str(Error))
예제 #20
0
    def expected_changes(self,ip, calculation, reserve_fund=None):  # 预期变化值
        '''

        :param charge_amount:未消耗充值金额
        :param reserve_fund:储备池金额
        :return:变化的金额
        '''

        global iii
        sql_data = SQL(ip).wallet_detail(self.order)  # 支付数据

        if self.payment_method in ['易贝', '抵工资', '家人购']:
            a = (sql_data[0])[3]  # 读取的商品价格
            b = (calculation[0])[1]  # 买家应出易贝服务费
            c = (calculation[0])[2]  # 买家应出现金服务费

            if self.payment_method == "易贝":

                d = (calculation[1])[0]  # 储备池买家上级个人焕商分佣
                e = (calculation[1])[1]  # 储备池买家上级区代理商分佣
                f = (calculation[1])[2]  # 储备池买家上级市代理商分佣
                g = (calculation[1])[3]  # 储备池买家上级省代理商分佣
                h = (calculation[1])[4]  # 储备池平台分佣

                if (self.buyer_identity == "公海用户" and self.seller_identity == "个人焕商") or (
                        self.buyer_identity == "公海用户" and self.seller_identity == "非焕商且已绑定个人焕商"):
                    i = (calculation[2])[0]  # 易贝服务费买家上级个人焕商分佣
                    j = (calculation[2])[1]  # 易贝服务费买家上级区代理商分佣
                    k = (calculation[2])[2]  # 易贝服务费买家上级市代理商分佣
                    l = (calculation[2])[3]  # 易贝服务费买家上级省代理商分佣
                    m = (calculation[2])[4]  # 易贝服务费平台分佣
                    iii = [a, b * -1, c * -1, a * -1,
                           b,
                           c, a, a * -1, reserve_fund * -1,
                           d,
                           e, f, g, h,
                           b * -1,
                           i, j, k, l, m]

                elif self.buyer_identity == "公海用户":
                    # i = (calculation[1])[0]  # 易贝服务费买家上级个人焕商分佣
                    j = (calculation[1])[1]  # 易贝服务费买家上级区代理商分佣
                    k = (calculation[1])[2]  # 易贝服务费买家上级市代理商分佣
                    l = (calculation[1])[3]  # 易贝服务费买家上级省代理商分佣
                    m = (calculation[1])[4]  # 易贝服务费平台分佣
                    iii = [a, b * -1, c * -1, a * -1,
                           b,
                           c, a, a * -1,
                           b * -1,
                           j, k, l, m]
                else:
                    i = (calculation[1])[0]  # 易贝服务费买家上级个人焕商分佣
                    j = (calculation[1])[1]  # 易贝服务费买家上级区代理商分佣
                    k = (calculation[1])[2]  # 易贝服务费买家上级市代理商分佣
                    l = (calculation[1])[3]  # 易贝服务费买家上级省代理商分佣
                    m = (calculation[1])[4]  # 易贝服务费平台分佣
                    iii = [a, b * -1, c * -1, a * -1,
                           b,
                           c, a, a * -1,
                           b * -1,
                           i, j, k, l, m]

            else:  # 抵工资、家人购
                d = (calculation[1])[0]  # 储备池买家上级个人焕商分佣
                e = (calculation[1])[1]  # 储备池买家上级区代理商分佣
                f = (calculation[1])[2]  # 储备池买家上级市代理商分佣
                g = (calculation[1])[3]  # 储备池买家上级省代理商分佣
                h = (calculation[1])[4]  # 储备池平台分佣

                if (self.buyer_identity == "公海用户" and self.seller_identity == "个人焕商") or (
                        self.buyer_identity == "公海用户" and self.seller_identity == "非焕商且已绑定个人焕商"):
                    i = (calculation[2])[0]  # 易贝服务费买家上级个人焕商分佣
                    j = (calculation[2])[1]  # 易贝服务费买家上级区代理商分佣
                    k = (calculation[2])[2]  # 易贝服务费买家上级市代理商分佣
                    l = (calculation[2])[3]  # 易贝服务费买家上级省代理商分佣
                    m = (calculation[2])[4]  # 易贝服务费平台分佣

                    iii = [a, b * -1, c * -1, a * -1,
                           b, c,
                           a, a * -1,
                           reserve_fund * -1,
                           d, e, f, g, h,
                           b * -1,
                           i, j, k, l, m]
                    # print("iii",iii)

                else:
                    i = (calculation[1])[0]  # 易贝服务费买家上级个人焕商分佣
                    j = (calculation[1])[1]  # 易贝服务费买家上级区代理商分佣
                    k = (calculation[1])[2]  # 易贝服务费买家上级市代理商分佣
                    l = (calculation[1])[3]  # 易贝服务费买家上级省代理商分佣
                    m = (calculation[1])[4]  # 易贝服务费平台分佣
                    iii = [a, b * -1, c * -1, a * -1,
                           b, c,
                           a, a * -1,
                           b * -1,
                           i, j, k, l, m]

        elif self.payment_method == '易贝券':
            a = (sql_data[0])[3]  # 读取的商品价格
            if (self.buyer_identity == "公海用户" and self.seller_identity == "个人焕商") or (
                    self.buyer_identity == "公海用户" and self.seller_identity == "非焕商且已绑定个人焕商"):
                b = calculation[0]  # 计算用的商品价格
                d = (calculation[1])[0]  # 储备池买家上级个人焕商分佣
                e = (calculation[1])[1]  # 储备池买家上级区代理商分佣
                f = (calculation[1])[2]  # 储备池买家上级市代理商分佣
                g = (calculation[1])[3]  # 储备池买家上级省代理商分佣
                h = (calculation[1])[4]  # 储备池平台分佣
                iii = [a, b, b * -1, b,
                       reserve_fund * -1,
                       d,
                       e, f, g, h]
                # print("易贝券")
            else:
                b = calculation  # 计算用的商品价格
                iii = [a, b, b * -1, b]

        else:  # 现金
            a = (sql_data[0])[3]  # 读取的商品价格
            b = (calculation[0])[0]  # 计算得到的商品价格
            c = (calculation[0])[1]  # 卖家需要支付的现金服务费
            o = b - c  # 卖家实际应收到的金额

            if (self.buyer_identity == "公海用户" and self.seller_identity == "个人焕商") or (
                    self.buyer_identity == "公海用户" and self.seller_identity == "非焕商且已绑定个人焕商"):

                d = (calculation[1])[0]  # 储备池买家上级个人焕商分佣
                e = (calculation[1])[1]  # 储备池买家上级区代理商分佣
                f = (calculation[1])[2]  # 储备池买家上级市代理商分佣
                g = (calculation[1])[3]  # 储备池买家上级省代理商分佣
                h = (calculation[1])[4]  # 储备池平台分佣

                i = (calculation[2])[0]  # 现金服务费卖家上级个人焕商分佣
                j = (calculation[2])[1]  # 现金服务费卖家上级区代理商分佣
                k = (calculation[2])[2]  # 现金服务费卖家上级市代理商分佣
                l = (calculation[2])[3]  # 现金服务费卖家上级省代理商分佣
                m = (calculation[2])[4]  # 现金服务费平台分佣
                iii = [a, o, c, o * -1,
                       b,
                       c * -1, reserve_fund * -1,
                       d, e, f, g, h,
                       c * -1,
                       i, j, k, l, m]
            else:
                i = (calculation[1])[0]  # 现金服务费卖家上级个人焕商分佣
                j = (calculation[1])[1]  # 现金服务费卖家上级区代理商分佣
                k = (calculation[1])[2]  # 现金服务费卖家上级市代理商分佣
                l = (calculation[1])[3]  # 现金服务费卖家上级省代理商分佣
                m = (calculation[1])[4]  # 现金服务费平台分佣

                iii = [a, o, c, o * -1, b,
                       c * -1,
                       c * -1,
                       i, j, k, l, m]

        # 精华 我把分佣等于0的值去掉 就意味不分佣给这些人
        iii = quchong(iii, 0)
        return iii
예제 #21
0
    def test_2_duibi(self, item):

        try:
            sheet_name = item['sheet_name']
            case_id = item['case_id']
            title = item['title']
            ip = IP[item['surroundings']]
            payment_method = item['payment_method']
            member_level = item['member_level']
            buyer_identity = item['buyer_identity']
            seller_identity = item['seller_identity']
            test_data = eval(item['data'])
            proportion = eval(item['proportion'])
            reserve_fund = eval(item['reserve_fund'])
            superior = eval(item['superior'])
            order = item['order']

            if buyer_identity == "公海用户":
                if seller_identity == "个人焕商" or seller_identity == "非焕商且已绑定个人焕商":
                    charge_amount = reserve_fund['charge_amount']
                    reserve_fund = reserve_fund['reserve_fund']
                else:
                    charge_amount = None
                    reserve_fund = None
            else:
                charge_amount = None
                reserve_fund = None

            calculation_data = CalculationData().calculation_data(
                ip, payment_method, member_level, buyer_identity,
                seller_identity, proportion, charge_amount, reserve_fund,
                order)

            transaction_second_payagent_ratio = eval(
                item['second_payagent_ratio'])

            if payment_method in ["易贝", "易贝券"]:
                bind_buyer_relationship_data = eval(
                    item['bind_relationship_data'])

                expected_moban = MoBan(buyer_identity, seller_identity,
                                       member_level, payment_method,
                                       order).expected_moban(
                                           ip, test_data, superior,
                                           reserve_fund, calculation_data,
                                           transaction_second_payagent_ratio,
                                           bind_buyer_relationship_data)

            elif payment_method in ["抵工资", "家人购", "现金"]:
                bind_buyer_relationship_data = eval(
                    item['bind_relationship_data']["储备金二级分佣对象"])
                bind_payer_relationship_data = eval(
                    item['bind_relationship_data']["支付服务费二级分佣对象"])

                expected_moban = MoBan(buyer_identity, seller_identity,
                                       member_level, payment_method,
                                       order).expected_moban(
                                           ip, test_data, superior,
                                           reserve_fund, calculation_data,
                                           transaction_second_payagent_ratio,
                                           bind_buyer_relationship_data,
                                           bind_payer_relationship_data)

            # 写回Excel用
            fanhui = FanHui().fan_hui(ip, order, expected_moban)

            sql_data = SQL(ip).wallet_detail(order)

            for i in range(0, len(expected_moban)):
                self.assertEqual(expected_moban[i], sql_data[i])

            self.assertEqual(expected_moban, sql_data)

            my_logger.info("用例{0}正确!{1}".format(case_id, title))
            TestResult = 'Pass'
            Error = None

        except AssertionError as e:
            my_logger.info("用例错误!错误原因是第{0}行,{1}:".format(i + 1, e))
            TestResult = 'Failed'
            Error = "用例错误!错误原因是:第{0}行,{1}:".format(i + 1, e)
            raise e  # 异常处理完后记得抛出

        finally:  # 不管怎样都得写入Excel
            DoExcel().write_back(test_case_path, sheet_name, case_id + 1,
                                 str(fanhui[0]), str(fanhui[2]),
                                 str(expected_moban), str(sql_data),
                                 TestResult, str(Error))