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

if [ -z $account ];then
	account=100
fi
date=`date "+%Y-%m-%d %H:%M:%S"`
unique_business_id=CASH_LOAN`date +%s%N`
echo "unique_business_id:"$unique_business_id
mysql -h"$ip" -p"3306" -u"qa" -p"qatest" <<EOF
INSERT INTO redpacket.tb_coupon (unique_business_id, phone, group_id, name, category, category_info, category_type, category_type_info, valid_start_date, valid_end_date, sms_reminder_on_invalid, status, created_at, used_at, updated_at, mark, uid)
VALUES
	('$unique_business_id', '$phone_no', 10000574, N'小测福利~', 8, '{\"loanTerm\":[\"1\",\"2\",\"3\"]}', 3, '{\"rebate\":$account}', '2017-01-01 00:00:13', '2020-06-14 00:00:23', 0, 2, '$date', NULL, '$date', 1, NULL);
EOF
echo "done!!!"
