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

mysql -h"$ip" -P"$port" -u"qa" -p"qatest" <<EOF
use payment_center;
delete from payment_center.bank_card where user_id=111112222233333;
delete from payment_center.card_bind_info where user_id=111112222233333;
delete from payment_center.bind_card_order where user_id=111112222233333;
delete from payment_center.bank_card where card_no=6227000010912341234;
delete from payment_center.card_bind_info where card_no=6227000010912341234;
delete from payment_center.bank_card_detail where card_no=6227000010912341234;

INSERT INTO payment_center.bank_card (user_id, card_no, card_top, card_last, card_type, card_holder_name, preserve_phone_no, bank_name, bank_code, branch_no, branch_name, city, province, valid_from, valid_thru)
VALUES
    (111112222233333, '6227000010912341234', '622700', '1234', 2, '小测', '18610271234', '建设银行', 'CCB', NULL, NULL, '110102', '110000', NULL, NULL);
INSERT INTO payment_center.bank_card_detail (bank_name, bank_code, card_no, account_property, card_type, is_valid)
VALUES
    ('建设银行', 'CCB', '6227000010912341234', '00', 2, 1);
INSERT INTO payment_center.bind_card_order (user_id, merchant_id, merchant_order_no, pay_approach, ext_data, bind_status, sms_error_code, confirm_error_code, request_id)
VALUES
    (111112222233333, 3, '43779518', 1, '', 5, '', '', 'yeepay1488525851371');
INSERT INTO payment_center.card_bind_info (user_id, pay_approach, bind_id, bank_card_id, is_active, card_no, bind_valid_thru)
VALUES
    (111112222233333, 1, '1488525851371', 1492596, 1, '6227000010912341234', NULL);
 
update payment_center.bank_card t set t.user_id=(select id from payment_center.user where phone_no =$phone_no) where t.user_id=111112222233333;
update payment_center.bind_card_order t set t.user_id=(select id from payment_center.user where phone_no =$phone_no) where t.user_id=111112222233333;
update payment_center.card_bind_info t set t.user_id=(select id from payment_center.user where phone_no =$phone_no),bank_card_id=(select id from payment_center.bank_card where card_no=6227000010912341234 and user_id=(select id from payment_center.user where phone_no =$phone_no)) where t.user_id=111112222233333;

EOF
echo "done!!!"
