Beispiel #1
0
def getUserRelation(host, phone, password):
    url = "{}{}".format(rc.read_json()['url'][str(host)], rc.read_json()['path']['getUserRelation'])
    headers = ah.get_headers(host, phone, password)
    try:
        res = requests.post(url=url, headers=headers)
        return res.text
    except Exception as e:
        return "error_info: {}".format(str(e))
def get_auth_code(host,phone):
    url = "{}{}".format(readConfig.read_json()['url'][str(host)],readConfig.read_json()['path']['authcode'])
    data = {'phone':phone}
    res = requests.post(url=url,data=data)
    if '{"interval":120}' in res.text:
        print("获取验证码成功!")
    else:
        print(res.text)
def get_customer_work_info(host, phone, password):
    url = "{}{}".format(rc.read_json()['url'][str(host)],
                        rc.read_json()['houseLoanPath']['getCustomerWorkInfo'])
    headers = ah.get_headers(host, phone, password)
    try:
        res = requests.post(url=url, headers=headers)
        return res.text
    except Exception as e:
        return "error_info: {}".format(str(e))
def get_house_base_info(host, phone, password):
    url = "{}{}".format(rc.read_json()['url'][str(host)],
                        rc.read_json()['houseLoanPath']['getBaseHouseInfo'])
    headers = ah.get_headers(host, phone, password)
    try:
        res = requests.post(url=url, headers=headers)
        if "success" in res.text:
            return res.text
    except Exception as e:
        return "error_info:{}".format(str(e))
Beispiel #5
0
def perfectOccupation(host, phone, password):
    url = "{}{}".format(rc.read_json()['url'][str(host)], rc.read_json()['path']['occupation'])
    headers = ah.get_headers(host, phone, password)
    data = rc.read_json()['data']['occupationData']
    try:
        res = requests.post(url=url, data=data, headers=headers)
        if "添加成功" in res.text:
            print("用户职业信息添加成功,职业信息内容如下:" + getOccupationInfo(host, phone, password))
        # print("错误信息为:" + res.text)
    except Exception as e:
        print("error_info: {}".format(str(e)))
def get_customer_manageMent_info(host, phone, password):
    url = "{}{}".format(
        rc.read_json()['url'][str(host)],
        rc.read_json()['houseLoanPath']['getCustomerManageMentInfo'])
    headers = ah.get_headers(host, phone, password)
    try:
        res = requests.post(url=url, headers=headers)
        if res.status_code == 200:
            return res.text
    except Exception as e:
        return "error_info:{}".format(e)
Beispiel #7
0
def userBase(host, phone, password):
    url = "{}{}".format(rc.read_json()['url'][str(host)], rc.read_json()['path']['userBase'])
    headers = headers = ah.get_headers(host,phone,password)
    data = rc.read_json()['data']['userBaseData']
    try:
        res = requests.post(url=url, data=data, headers=headers)
        if "添加成功" in res.text:
            print("添加个人基本信息成功,个人基本信息内容如下:" + getUserBase(host, phone, password))
        else:
            print("错误信息为:" + res.text)
    except Exception as e:
        print("error_info: %s" %e)
Beispiel #8
0
def login(host, phone, password):
    url = "{}{}".format(rc.read_json()['url'][str(host)],
                        rc.read_json()['path']['login'])
    data = {'phone': str(phone), 'password': str(password)}
    res = requests.post(url=url, data=data)
    if 'access_token' and 'token_type' in res.text:
        auth_token = "{} {}".format(res.json()['token_type'].capitalize(),
                                    res.json()['access_token'])
        if auth_token:
            return auth_token
        else:
            return res.text
def save_property_holder_info(host, phone, password):
    url = "{}{}".format(rc.read_json()['url'][str(host)],
                        rc.read_json()['houseLoanPath']['propertyHolderInfo'])
    headers = ah.get_headers(host, phone, password)
    data = rc.read_json()['data']['propertyHodlerInfo']
    try:
        res = requests.post(url=url, data=data, headers=headers)
        if "success" in res.text:
            print("添加共有产权人信息成功,共有产权人信息内容如下:" +
                  get_property_hodler_info(host, phone, password))
    except Exception as e:
        print("error_info:{}".format(str(e)))
def register(host,phone,password):
    url = "{}{}".format(readConfig.read_json()['url'][str(host)],readConfig.read_json()['path']['register'])
    data ={
        'phone':str(phone),
        'password':str(password),
        'captcha':'888888',
        'login_termianl':'2'
    }
    res = requests.post(url =url,data=data)
    if 'access_token' and 'token_type' in res.text:
        auth = "{} {}".format(res.json()['token_type'].capitalize(),res.json()['access_token'])
        print("账户注册成功,返回Token为:%s" %(auth))
    else:
        print(res.text)
def save_custome_work_info(host, phone, password):
    url = "{}{}".format(rc.read_json()['url'][str(host)],
                        rc.read_json()['houseLoanPath']['customerWorkInfo'])
    headers = ah.get_headers(host, phone, password)
    data = rc.read_json()['data']['customerWorkInfo']
    try:
        res = requests.post(url=url, data=data, headers=headers)
        if "success" in res.text:
            print("添加工作信息成功,工作信息内容如下:" +
                  get_customer_work_info(host, phone, password))
        else:
            print("接口异常信息为:" + res.text)
    except Exception as e:
        print("error_info:{}".format(str(e)))
Beispiel #12
0
def get_credit_mobile_authUrl(host, phone, password):
    url = "{}{}".format(rc.read_json()['url'][str(host)],
                        rc.read_json()['path']['creditAuthMobileUrl'])
    headers = ah.get_headers(host, phone, password)
    data = {'type': '1'}
    try:
        res = requests.post(url=url, data=data, headers=headers)
        if res.status_code == 200:
            result = json.loads(res.text)
            print("获取信贷运营商认证ULR地址成功,地址如下:{}".format(result['url']))
        else:
            print("接口异常信息为:" + res.text)
    except Exception as e:
        print("error_info:{}".format(str(e)))
def save_house_base_info(host, phone, password):
    url = "{}{}".format(rc.read_json()['url'][str(host)],
                        rc.read_json()['houseLoanPath']['houseBaseInfo'])
    headers = ah.get_headers(host, phone, password)
    data = rc.read_json()['data']['houseloanBaseInfo']
    data['id'] = get_house_base_info_id(host, phone, password)
    try:
        res = requests.post(url=url, data=data, headers=headers)
        if "success" in res.text:
            print("添加房产基本信息成功,房产基本信息内容如下:" +
                  get_house_base_info(host, phone, password))
        else:
            print("接口异常信息为:" + res.text)
    except Exception as e:
        print("error_info:{}".format(str(e)))
def get_house_auth_mobile_url(host, phone, password):
    url = "{}{}".format(
        rc.read_json()['url'][str(host)],
        rc.read_json()['houseLoanPath']['houseLoanAuthMobileUrl'])
    headers = ah.get_headers(host, phone, password)
    data = {'type': '1'}
    try:
        res = requests.post(url=url, data=data, headers=headers)
        if "success" in res.text:
            url_info = json.loads(res.text)
            print("获取房贷运营商认证地址成功,地址内容如下:" + url_info['url'])
        else:
            print("接口异常信息为:" + res.text)
    except Exception as e:
        print("error_info:{}".format(str(e)))
Beispiel #15
0
def getMobileCertification(host, phone, password):
    url = "{}{}".format(rc.read_json()['url'][str(host)], rc.read_json()['path']['onLineAuthMobileUrl'])
    headers = ah.get_headers(host, phone, password)
    data = {
        'type': '1'
    }
    try:
        res = requests.post(url=url, data=data, headers=headers)
        result = json.loads(res.text)
        if res.status_code == 200:
            print("获取网销运营商认证地址成功,地址内容如下:{}".format(result['url']))
        else:
            print("错误信息为:" + res.text)
    except Exception as e:
        print("Error_info:{}".format(str(e)))
def manager(host,phone,password,customer_code):
    path1 = '{}'.format(readConfig.read_json()['url'][str(host)])
    path2 = '/v1/staff/{}?nothing=' .format(customer_code)
    url1 = path1 + path2
    path3 = '{}'.format(readConfig.read_json()['path']['staff'])
    url2 = path1 + path3
    headers = readConfig.read_json()['headers']
    headers['Authorization'] = login.login(host,phone,password)
    res1 = requests.get(url=url1,headers=headers)
    data = {
        'staffNo':customer_code
    }
    res2 = requests.post(url=url2,data=data,headers=headers)
    mess = '{}\n{}'.format(res1.json(),res2.json())
    if 'hasStaffServer' in mess:
        print(mess)
def get_headers(host, phone, password):
    headers = rc.read_json()['headers']
    headers['Authorization'] = l.login(host, phone, password)
    headers['Host'] = "api-sandbox.hxgp.com"
    return headers


# print(get_headers('161','13511012200','123123123'))
def confirmation(host,idCard,idCardName,phone,password):
    url = "{}{}".format(readConfig.read_json()['url'][str(host)],readConfig.read_json()['path']['confirmation'])
    headers = gh.get_headers(host,phone,password)
    data = {
        'confirmation':1,
        'idCardCode':idCard,
        'idCardName':idCardName
    }
    try:
        res = requests.post(url=url,data=data,headers=headers)
        result = json.loads(res.text)
        if res.status_code == 200:
            print("实名认证通过,接口返回内容为:{}".format(result))
        else:
            print("实名认证失败,接口错误信息为:{}".format(res.text))
    except Exception as e:
        print("error_info:{}".format(str(e)))
def db_base(host,sql):
    db_conn = pymysql.connect(
        host=str(readConfig.read_json()['database'][host]['host']),
        port=int(readConfig.read_json()['database'][host]['port']),
        user=readConfig.read_json()['database'][host]['user'],
        passwd=readConfig.read_json()['database'][host]['password'],
        db=readConfig.read_json()['database'][host]['db'],
        cursorclass = pymysql.cursors.DictCursor
    )
    cursor = db_conn.cursor()
    try:
        cursor.execute(sql)
        db_conn.commit()
        data = cursor.fetchall()
        return data
    except:
        db_conn.rollback()
    db_conn.close()
def face_ocr(host,phone,password):
    url = "{}{}".format(readConfig.read_json()['url'][str(host)],readConfig.read_json()['path']['ocr'])
    headers = {"Connection": "keep-alive", "Host": "api-sandbox.hxgp.com"}
    headers['Authorization'] = login.login(host,phone,password)
    ocr_img_path = os.path.abspath(os.path.dirname(__file__))
    with open('{}\\1.jpg'.format(ocr_img_path),'rb') as frontImage:
        with open('{}\\2.jpg'.format(ocr_img_path),'rb') as backImage:
            files = {
                'frontImage':frontImage,
                'backImage':backImage
            }
            try:
                res = requests.post(url=url,headers=headers,files=files)
                result = json.loads(res.text)
                if 'idCardCode' and 'idCardName' in result:
                    print("OCR识别成功,识别结果为 :{}".format(res.text))
                else:
                    print("OCR识别成功,接口错误信息为:{}".format(res.text))
            except Exception as e:
                print("error_info:{}".format(str(e)))
Beispiel #21
0
def userRelation(host, phone, password):
    url = "{}{}".format(rc.read_json()['url'][str(host)], rc.read_json()['path']['userRelation'])
    headers = ah.get_headers(host, phone, password)
    spouse = rc.read_json()['data']['userRelationData']['a']
    family = rc.read_json()['data']['userRelationData']['b']
    colleague = rc.read_json()['data']['userRelationData']['c']
    friend = rc.read_json()['data']['userRelationData']['d']
    contacts = "[{},{},{},{}]".format(spouse, family, colleague, friend)
    contacts = contacts.replace('\'', '\"').replace(' ', '')
    data = {"contacts": contacts,
            "emergencyContactKnow": rc.read_json()['data']['userRelationData']['emergencyContactKnow'],
            "familyKnow": rc.read_json()['data']['userRelationData']['familyKnow']
            }

    try:
        res = requests.post(url=url, data=data, headers=headers)
        if "添加成功" in res.text:
            print("添加联系人信息成功,联系人信息如下:" + getUserRelation(host, phone, password))
        else:
            print("错误信息为:" + res.text)
    except Exception as e:
        print("Error_info:{}".format(str(e)))
def save_CustomerForHouseLoan(host, phone, password):
    url = "{}{}".format(
        rc.read_json()['url'][str(host)],
        rc.read_json()['houseLoanPath']['CustomerForHouseLoan'])
    headers = ah.get_headers(host, phone, password)
    link1 = rc.read_json()['data']['linkMen']["a"]
    link2 = rc.read_json()['data']['linkMen']["b"]
    link3 = rc.read_json()['data']['linkMen']["c"]
    link4 = rc.read_json()['data']['linkMen']["d"]
    linkMen = "[{},{},{},{}]".format(link1, link2, link3, link4)
    linkMen = linkMen.replace('\'', '\"').replace(' ', '')
    data = rc.read_json()['data']['houseloan_couserInfo']
    data['linkMen'] = linkMen
    try:
        res = requests.post(url=url, data=data, headers=headers)
        if "success" in res.text:
            print("添加基本信息成功,基本信息内容如下:" +
                  get_customer_info(host, phone, password))
        else:
            print("接口异常信息为:" + res.text)
    except Exception as e:
        print("error_info:{}".format(str(e)))