Exemple #1
0
    def get_phone(cls, user, password="******", type_num=1):
        hr = HandleRequest()
        hm = HandleMysql()
        hr.common_head({'X-Lemonban-Media-Type': 'lemonban.v2'})
        base_url = hy.read_yaml('api', 'load')
        register_url = hy.read_yaml('api', 'register')
        all_url = ''.join((base_url, register_url))
        while True:
            # 获取在数据库中不存在的电话号码
            phone = hm.get_right_phone()
            data = {
                "mobile_phone": phone,
                "pwd": password,
                "type": type_num,
                "reg_name": user
            }
            result = hr.send(url=all_url, data=data)
            if result.json()['code'] == 0 and result.json()["msg"] == "OK":
                break

        my_result = hm.get_mysql_result(hy.read_yaml('mysql', 'user_id'),
                                        args=phone)
        user_id = my_result[0]['id']

        result_data = {
            user: {
                "user_phone": phone,
                "pwd": password,
                "user_id": user_id,
                "reg_name": user
            }
        }
        hm.close()
        hr.close()
        return result_data
Exemple #2
0
 def get_phone(cls, username, password='******', type=1):
     hr = HandleRequest()
     hm = HandleMysql()
     base_url = hy.read_yaml('api', 'load')
     register_url = hy.read_yaml('api', 'register')
     all_url = ''.join((base_url, register_url))
     while True:
         phone = hm.get_non_existent()
         data = {
             "mobile_phone": phone,
             "pwd": password,
             "type": type,
             "reg_name": username
         }
         hr.common_head(hy.read_yaml('api', 'header'))
         result = hr.send(url=all_url, data=data)
         if result.json()['code'] == 0 and result.json()['msg'] == 'OK':
             break
     user_id = hm.get_mysql_result(sql=hy.read_yaml('mysql', 'user_id'),
                                   args=phone)
     result_data = {
         username: {
             "mobilephone": phone,
             "pwd": password,
             "user_id": user_id[0]['id'],
             "reg_name": username
         }
     }
     hr.close()
     hm.close()
     return result_data
Exemple #3
0
 def handle_para(cls, data):
     hl = HandleYaml(PHONE_PATH)
     hm = HandleMysql()
     if re.search(r'{no_exist_phone}', data):
         phone = hm.no_exsit_phone_mysql()
         re_data = re.sub(r'{no_exist_phone}', phone, data)
         HandleMysql().close()
         return re_data
     if re.search(r'{invest_phone}', data):
         re_data = re.sub(r'{invest_phone}',
                          hl.read_yaml('investor', 'mobile_phone'), data)
         return re_data
     if re.search(r'{user_id_re}', data):
         re_data = re.sub(r'{user_id_re}',
                          str(hl.read_yaml('investor', 'id')), data)
         return re_data
     if re.search(r'{member_id_re}', data):
         re_data = re.sub(r'{member_id_re}',
                          str(hl.read_yaml('borrower', 'id')), data)
         return re_data
     if re.search(r'{borrow_phone}', data):
         re_data = re.sub(r'{borrow_phone}',
                          hl.read_yaml('borrower', 'mobile_phone'), data)
         return re_data
     if re.search(r'{no_exist_num}', data):
         re_data = re.sub(
             r'{no_exist_num}',
             str(
                 hm.get_mysql_result(hy.read_yaml('mysql', 'id_sql'))
                 ['maxId'] + 1), data)
         return re_data
     if re.search(r'{admin_phone}', data):
         re_data = re.sub(r'{admin_phone}',
                          hl.read_yaml('admin', 'mobile_phone'), data)
         return re_data
     if re.search(r'{load_id}', data):
         re_data = re.sub(r'{load_id}', str(getattr(cls, 'program_id')),
                          data)
         return re_data
     if re.search(r'{user_id}', data):
         my_data = re.sub(r'{user_id}', str(hl.read_yaml('investor', 'id')),
                          data)
         re_data = re.sub(r'{loan_id_re}', str(getattr(cls, 'program_id')),
                          my_data)
         return re_data
     return data