# -*- encoding=utf8 -*-
import sys

from air_case.mdm_login.登录外网系统.登录外网系统 import login_system
from common.timeUtils import timeUtils

from common.common_func import commonFuc
from common.fileUtls import *
__author__ = "xiaohesheng"

"""
case_tag:api,mdm-web旧接口,产品规格新增,id2253,id2253-1,sit,on
主数据平台:web产品规格新增
"""

module = "mdm3_psm"
# 登录
info = FileUtils().r_info("mdm3_pim",'产品新增')
username=info['username']
goodsname=info['goodsname']
password = commonFuc().get_business_data("mdm3_pim", "password")
# print(username, password)
# 获取token和projectCode
token, projectCode, uxid, corpId,info = login_system(username, password).get_token()
# 查询已添加产品数据
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "listVoPage_url")
#
# # 获取请求头信息
headers = commonFuc().get_business_data(module, "json_headers2",
                                        commonFuc().get_business_data(module, "json_contentType"), token,
                                        projectCode)
request_body = commonFuc().get_business_data(module, "payload10", corpId,goodsname)
# 发送请求
result = commonFuc().http_post(url, request_body, headers)
# print('查询已添加产品信息',result)
MGID=commonFuc().analysis_json('id',commonFuc().analysis_json('data',result))
#产品规格申报===============================================
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "submitGoodsSpecsRegist_url")
#
# # 获取请求头信息
headers = commonFuc().get_business_data(module, "json_headers2",
                                        commonFuc().get_business_data(module, "json_contentType"), token,
                                        projectCode)
request_body = commonFuc().get_business_data(module, "payload1", MGID,goodsname)
# print('request_body',request_body)
# 发送请求
result = commonFuc().http_post(url, request_body, headers)
print('产品规格申报',result)
code=commonFuc().analysis_json('code',result)
goodsname1=commonFuc().analysis_json('goodsName',commonFuc().analysis_json('goodsRegistVO',commonFuc().analysis_json('data',result)))
# print("goodsname1",goodsname1)
commonFuc().check_text_exist(code,result)
commonFuc().check_text_exist(goodsname1,result)



