def register_insert(company_id, channel_id, gmt_create, mobile_platform): """ @:param mobile_platform : 所属客户端0:ios, 1:android 2 api 直接插库进行模拟用户注册 """ # 创建user # 查询渠道 channel = convert.query(models.Channel, id=channel_id).one() user_cid = cid_generate() user_mobile = fakerInstance.phone_number() user_id = my_snow().get_next_id() user_name = create_name_by_cid(user_cid) user_password = hashlib.md5( str(user_mobile).encode('utf-8')).hexdigest()[3:19] user_detail_address = fakerInstance.address() user_channel_name = channel.name print("register_insert user_cid", user_cid) print("register_insert user_mobile", user_mobile) print("register_insert user_id", user_id) user = User() user.gmt_create = gmt_create user.gmt_modified = gmt_create user.is_deleted = 0 user.id = user_id user.company_id = company_id user.cid = user_cid user.mobile = user_mobile user.name = user_name user.password = user_password user.register_channel = user_channel_name user.register_channel_id = channel_id user.mobile_md5 = hashlib.md5( str(user_mobile).encode('utf-8')).hexdigest()[3:19] convert.add_one(user) # 创建user_detail user_detail = UserDetail() user_detail.id = my_snow().get_next_id() user_detail.gmt_create = gmt_create user_detail.gmt_modified = gmt_create user_detail.is_deleted = 0 user_detail.cert_item = None user_detail.user_id = user_id user_detail.company_id = company_id user_detail.cid = user_cid user_detail.mobile = user_mobile user_detail.name = user_name user_detail.password = user_password user_detail.channel_id = channel_id user_detail.channel_name = user_channel_name user_detail.province = split_address(user_detail_address).get("province") user_detail.city = split_address(user_detail_address).get("city") user_detail.address = user_detail_address user_detail.gender = check_sex(user_cid) user_detail.nationality = "汉" user_detail.birthday = create_birthday user_detail.marital_status = None user_detail.income_level = None user_detail.education_level = None user_detail.bank_account_id = None user_detail.category = None user_detail.mobile_platform = mobile_platform user_detail.operator_id = None user_detail.first_apply_time = gmt_create user_detail.first_deduct_time = None user_detail.loan_amount = None user_detail.raise_amount = None user_detail.emrg_contact_name_a = None user_detail.emrg_contact_name_b = None user_detail.emrg_contact_mobile_a = None user_detail.emrg_contact_mobile_b = None user_detail.idcard_front_img = None user_detail.idcard_back_img = None user_detail.thirdparty_data = None user_detail.raise_comment = None user_detail.update_count = None user_detail.name_mirror = None user_detail.raise_amount_sign = None convert.add_one(user_detail) # 模拟event_id now = time.time() _event_id = str(company_id) + "_" + str(channel_id) + "_" + str( int(now * 1000)) print("register_insert _event_id", _event_id) # 模拟token 取手机号的md5加密截取部分 _token = user_password print("register_insert _event_id", _token) return dict(mobile=user_mobile, event_id=_event_id, token=_token)