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

__author__ = "xiaohesheng"

"""
case_tag:api,mdm-web,a8供货关系申请_客户类型_医院_供销关系申请提交_已存在的供销关系,id2255,id2255-8,sit,on
主数据平台:a8供货关系申请_客户类型_医院_供销关系申请提交_已存在的供销关系 
"""

from common.common_func import commonFuc
from air_case.mdm_login.登录外网系统.登录外网系统 import login_system
from airtest.core.api import using
import sys
module = "a4_mdm3_cm"
def supply_and_marketing_apply():
    module = "a4_mdm3_cm"
    info = FileUtils().r_info("a4_mdm3_cm", "供货关系申请")
    print(info)
    e_corpId = info['e_corpId']
    h_corpId = info['h_corpId']
    e_username = info['e_username']
    h_name = info['h_name']
    token, projectCode, uxid, corpId, info = login_system(e_username,
                                                          commonFuc().get_business_data(module, 'password')).get_token()
    print(token, projectCode, uxid, corpId, info)
    """
     场景:a8供货关系申请_客户类型_医院_供销关系申请提交_已存在的供销关系
     用例名称：a8供货关系申请_客户类型_医院_供销关系申请提交_已存在的供销关系
     输入：h_corpId,contactUser,contactWay
     输出："rtn_msg": ok
    """
    # module = "mdm3_cm"
    #a3供货关系申请_客户类型_医院_供销关系申请提交
    url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "submitSupplyRelation_url")
    # 获取请求头信息
    headers = commonFuc().get_business_data(module, "json_headers2",
                                            commonFuc().get_business_data(module, "json_contentType"), token,
                                            projectCode)
    contactUser=commonFuc().randomString(5)
    contactWay=contactUser
    request_body = commonFuc().get_business_data(module, "payload",h_corpId,contactUser,contactWay)
    # 发送请求
    result = commonFuc().http_post(url, request_body, headers)
    print('result',result)
    # #获取接口返回数据
    check_dict= commonFuc().get_business_data(module, "checkDict1")
    commonFuc().check_result(check_dict,result)
    e_corpId=corpId
    e_username=e_username
    return e_corpId,h_corpId,e_username,h_name
supply_and_marketing_apply()

# FileUtils().w_info1(supply_and_marketing_apply(),module,'供货关系申请')