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

__author__ = "xiaohesheng"

"""
case_tag:api,mdm-web,a9供货关系申请_客户类型_医院_供销关系编辑,id2255,id2255-9,sit,on
主数据平台:a9供货关系申请_客户类型_医院_供销关系编辑 
"""

from common.common_func import commonFuc
from air_case.mdm_login.登录外网系统.登录外网系统 import login_system
from airtest.core.api import using
import sys
module = "mdm3_cm"
def supply_and_marketing_edit():
    module = "mdm3_cm"
    info = FileUtils().r_info("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)
    """
     场景:a9供货关系申请_客户类型_医院_供销关系编辑
     用例名称：a9供货关系申请_客户类型_医院_供销关系编辑
     输入：h_corpId,contactUser,contactWay
     输出："rtn_msg": ok
    """
    # module = "mdm3_cm"
    #a3供货关系申请_客户类型_医院_供销关系申请提交
    url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "editSupplyRelation_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, "payload5",h_corpId,contactUser,contactWay)
    # 发送请求
    result = commonFuc().http_post(url, request_body, headers)
    print('result',result)
    # #获取接口返回数据
    check_dict= commonFuc().get_business_data(module, "checkDict2")
    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_edit()

