#!/bin/bash
ip=$1
phone_no=$2
len=`echo $phone_no|awk '{print length($0)}'`
if [ $len -ne 11 ];then
	echo "请输入11位手机号!"
	exit -1
fi
seq=XYBT`date +%s%N`

mysql -h"$ip" -p"3306" -u"qa" -p"qatest" <<EOF 
use xyqb;
update xyqb.loan_application_history 
set progress=39
where business_type=1 and is_active=1 and user_id=(
select id from xyqb_user.user where phone_no='$phone_no'
);

update xyqb.baitiao_account 
set status=1,credit_amount=10000
where user_id=(
select id from xyqb_user.user where phone_no='$phone_no'
); 


insert into  xyqb.baitiao_consume_history
(user_id,order_id,remaining_amount,consume_type,consume_seq)
values 
((select id from xyqb_user.user where phone_no='$phone_no'),-1,
(select credit_amount from baitiao_account 
where  user_id=(select id from xyqb_user.user where phone_no='$phone_no')),0,'$seq');

update xyqb.baitiao_account
set pay_pwd='dfd3514d3c2dadbeb3b0774a08f591cb', pay_pwd_salt='QUYzRkUyMDFBRkU1NzUzNjEzRURBMkM5'
where user_id=(
select id from xyqb_user.user where phone_no='$phone_no');

EOF
echo "done!!! `date`"
