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

#把资金方放款时间更新为昨天，便于测试
date=`date -d yesterday  "+%Y-%m-%d %H:%M:%S"`

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

update xyqb.loan_application_manifest_history
set loan_paid_at='$date',transaction_status=2
where loan_application_history_id=(select id from xyqb.loan_application_history where business_type=0 and user_id=(select id from xyqb_user.user where phone_no =$phone_no) and is_active=1);

update xyqb.page_state_info
set state='ViewRepayState'
where loan_id=(select id from xyqb.loan_application_history where business_type=0 and user_id=(select id from xyqb_user.user where phone_no =$phone_no) and is_active=1);

EOF
date=`date "+%Y-%m-%d %H:%M:%S"`
echo "done!!! $date"
