#!/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}');"
        mysql ${mysql} -e"set names utf8;${spider};${address};${contact}"

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