#!/bin/bash
ip=$1
phone_no=$2
namespace=$4
HOSTNAME="${ip}"
PORT=$3
USERNAME='qa'
PASSWORD='qatest'

date=$(date "+ %Y-%m-%d %H:%M:%S")

mysql="-h${HOSTNAME} -P${PORT} -u${USERNAME} -p${PASSWORD}"

function basicData()
{
	#查询用户ID
	uuid="SELECT uuid  from user where phone_no=${phone_no}"
	id="SELECT id  from user where phone_no=${phone_no}"
        uid=`mysql -N $mysql  xyqb_user -e "set names utf8;${uuid}"`
        userid=`mysql -N $mysql  xyqb_user -e "set names utf8;${id}"`
	#spider_center.user_auth_info插入基础资料、拍照、运营商认证
	spider="INSERT INTO spider_center.user_auth_info (auth_type, last_auth_time, auth_account_name, user_id, auth_status) VALUES (14, '${date}', ${phone_no}, '${uid}', 1),(7, '${date}', ${phone_no}, '${uid}', 1),(0,'${date}',${phone_no}, '${uid}', 1)"
     	#xyqb_user.address插入地址
	address="INSERT INTO xyqb_user.address (user_id, province_code, province, city_code, city, district_code, district, address, created_at, updated_at) VALUES(${userid}, 450000, '广西壮族自治区', 450500, '北海市', 450503, '银海区', '海淀区中关村102号', '${date}', '${date}')"
        #xyqb_user.contact插入联系人信息
	contact="INSERT INTO xyqb_user.contact (user_id, name, phone_no, relation, created_at, updated_at)VALUES(${userid}, '张三', '13888888889', 3, '${date}', '${date}'),( ${userid}, '李四', '13888888888', 3, '${date}', '${date}')"
	#xyqb_user.user_detail添加联系人邮箱
        userDetail="update xyqb_user.user_detail set email='19925632562@163.com' where user_id=${userid}"
	#xyqb_user.user_ext_info插入用户职业、学历
        userExtInfo="INSERT INTO xyqb_user.user_ext_info (user_id, means_of_income_payment, monthly_income_range, occupation, education, has_car, has_social_security, has_house, has_credit_card, marry_status, created_at, updated_at) VALUES(${userid}, 0, 3, 3, 3, 0, 0, 0, 0, 0, '${date}', '${date}')"
	
	#执行sql
	mysql ${mysql} -e"set names utf8;${spider};${address};${contact};${userDetail};${userExtInfo}"

	echo "done!!!!${date} "
}
basicData $ip $phone_no $namespace $PORT
