import curlify

from feature import *

def devResult(uuid,codes,codetype='pre'):
    headers = {
        'Content-Type': 'application/x-www-form-urlencoded',
        'rc_auth_key': 'rc_offline',
        'rc_auth_secret': '9d9}bc24!e1z1x3`(x~4r29d$+45n3)\'zb696b$85e>_]p2&4f{,a3~8b3e_ldt^'
    }
    temp={'uuid':uuid}
    temp_codes=','.join(codes)
    body={
        "codes":temp_codes
    }
    if codetype=='pre':
        body["user_uuid"]=uuid
        url=pre_loan_url
    else:
        url=mid_loan_url
        body['tradeNo']=0
        body['userUuid']=uuid
    t=requests.post(url,data=body,headers=headers)
    #print('开发结果===',t.text,uuid)
    #print(curlify.to_curl(t.request))
    for code in codes:
        #print(code)
        temp[code+'_dev']=jsonpath.jsonpath(t.json(),'$..{}.value'.format(code))[0]
    return temp


def getuuids():
    sql="""
    select distinct a.uuid from xyqb_user.user a 
join xyqb_user.user_detail b on a.id=b.user_id
    """
    df=execmysl('feature_aliyun',sql)
    filename=os.path.join(feature_report,'uuids.xlsx')
    df['uuid'].to_excel(filename,index=0,encoding = 'utf-8',float_format = str)

if __name__ == '__main__':
    getuuids()