# -*- encoding=utf8 -*-
from common.fileUtls import FileUtils

__author__ = "xiaohesheng"

"""
case_tag:api,mdm-web,a7_4代配送下单列表数据查询_已完成,id2291,id2291-37,sit,on
主数据平台:a7_4代配送下单列表数据查询_已完成 
"""

from common.common_func import commonFuc
from airtest.core.api import using
import sys
module = "a6_mdm3_dp"
def select1():
    pro_path = commonFuc().get_pro_path()
    sys.path.append(pro_path + r'\\air_case\\a6_mdm3_dp\\a1企业登录.air')
    using(pro_path + r'\\air_case\\a6_mdm3_dp\\a1企业登录.air')
    from a1企业登录 import e_login
    token, projectCode, uxid, corpId, e_name = e_login()
    # # 获取医院corpId
    # sys.path.append(pro_path + r'\\air_case\\a4_mdm3_cm\\a1供货关系申请_客户类型_医院_登录_医院登录获取医院id2.air')
    # using(pro_path + r'\\air_case\\a4_mdm3_cm\\a1供货关系申请_客户类型_医院_登录_医院登录获取医院id2.air')
    # from a1供货关系申请_客户类型_医院_登录_医院登录获取医院id import h_login
    # h_token, h_projectCode, h_uxid, h_corpId, h_name = h_login()
    """
     场景:a7_4代配送下单列表数据查询_已完成
     用例名称：a7_4代配送下单列表数据查询_已完成
     输入：无
     输出："rtn_msg": 0
    """
    module = "a6_mdm3_dp"
    #a6_4代配送下单列表数据查询_待确认查询3
    url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "purchase_page_url")
    # 获取请求头信息
    headers = commonFuc().get_business_data(module, "json_headers2",
                                            commonFuc().get_business_data(module, "json_contentType"), token,
                                            projectCode)
    goodsname = commonFuc().randomString(5)
    request_body = commonFuc().get_business_data(module, "payload9_4")
    # request_body = commonFuc().get_business_data(module, "payload10_1")

    # print('request_body',request_body)
    # 发送请求
    result = commonFuc().http_post(url, request_body, headers)
    print('result', result)
    #断言
    code=commonFuc().analysis_json('code',result)
    data=commonFuc().analysis_json('data',result)
    total=commonFuc().analysis_json('total',data)
    data1=commonFuc().analysis_json('data',data)
    if code==0 and total>=1:
        id1 = commonFuc().analysis_json('id', data1[0])
        print(id1)
        id2 = commonFuc().analysis_json('id', data1[1])
        print(id2)
        commonFuc().check_text_exist(code, result)
        return id1, id2
    else:
        commonFuc().check_text_exist('error', result)
select1()

