#!/bin/bash
ip=$1
phone_no=$2
coupon_type=$3 # 1-友宝满减券;2-商城购物满减券;3-商城购物折扣券;4-商城购物实物折扣券;5-商城购物实物满减券;6-商城购物充值折扣券;7-现金贷还款折扣券;8-现金贷还款抵扣券;9-现金贷还款免息券;10-白条购物满减券;11-外部白条满减券（深圳通）

HOSTNAME="$ip"   #数据库信息
PORT="3306"
USERNAME="qa"
PASSWORD="qatest"

DBNAME="redpacket"    #数据库名称
TABLENAME="tb-coupon"




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


case "$coupon_type" in
1)
coupon_1="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 (concat('MALL20170626111210457af1ec45g',NOW()), '$phone_no', '10000572', '友宝优惠券', '9', '{\"firstChannel\":\"2\"}', '1', '{\"full\":200,\"cut\":5}', NOW(),'2028-09-24 23:59:00', '0', '2', NOW(), NULL, NOW(), '2', '26364792')"
mysql -h${HOSTNAME} -p${PORT} -u${USERNAME} -p${PASSWORD}  ${DBNAME} -e"set names utf8; ${coupon_1}"

echo "友宝满减券新增成功！！！"
;;

2)
coupon_2="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 ( concat('MALL20171109161159417a4d41cg1',NOW()), '$phone_no', '10000669', '商城购物满减券', '6', '{\"firstChannel\":1,\"channelId\":[]}', '1', '{\"full\":\"100\",\"cut\":\"5\"}', NOW(), '2028-09-24 23:59:00','0', '2', NOW(), NULL, NOW(), NULL, '1000033')"
mysql -h${HOSTNAME} -p${PORT} -u${USERNAME} -p${PASSWORD}  ${DBNAME} -e"set names utf8; ${coupon_2}" 
echo "商城购物满减券增加成功"
;;

 3)
coupon_3="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 ( concat('MALL20171109161216046a1f635gd',NOW()), '$phone_no', '10000670', '商城购物折扣券', '6', '{\"firstChannel\":1,\"channelId\":[]}', '2', '{\"discount\":\"5\"}', NOW(),'2028-09-24 23:59:00', '0', '2', NOW(), NULL, NOW(), NULL, '1000033')"
mysql -h${HOSTNAME} -p${PORT} -u${USERNAME} -p${PASSWORD}  ${DBNAME} -e"set names utf8; ${coupon_3}" 
echo "商城购物折扣券增加成功"
;;

4)
coupon_4="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 ( concat('MALL20171109161216046a1f635gd',NOW()), '$phone_no', '10000679', '商城购物实物折扣券', '6', '{\"firstChannel\":3,\"channelId\":[]}', '2', '{\"discount\":8}', NOW(), '2028-09-24 23:59:00', '0', '2', NOW(), NULL, NOW(), NULL, '1000033')"
mysql -h${HOSTNAME} -p${PORT} -u${USERNAME} -p${PASSWORD}  ${DBNAME} -e"set names utf8; ${coupon_4}" 
echo "商城购物实物折扣券增加成功"
;;

5)
coupon_5="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 ( concat('MALL2017110917061815515d71558',NOW()), '$phone_no', '10000678', '商城购物实物满减券', '6', '{\"firstChannel\":3,\"channelId\":[]}', '1', '{\"full\":100,\"cut\":5}',NOW(),'2028-09-24 23:59:00', '0', '2', NOW(), NULL, NOW(), NULL, '1000033');"
mysql -h${HOSTNAME} -p${PORT} -u${USERNAME} -p${PASSWORD}  ${DBNAME} -e"set names utf8; ${coupon_5}" 
echo "商城购物实物满减券增加成功"
;;

6)
coupon_6="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 ( concat('MALL201711091706293642335f562',NOW()), '$phone_no', '10000677', '商城购物充值折扣券', '6', '{\"firstChannel\":2,\"channelId\":[]}', '2', '{\"discount\":8}', NOW(),'2028-09-24 23:59:00', '0', '2', NOW(), NULL, NOW(), NULL, '1000033')"
mysql -h${HOSTNAME} -p${PORT} -u${USERNAME} -p${PASSWORD}  ${DBNAME} -e"set names utf8; ${coupon_6}" 
echo "商城购物充值折扣券增加成功"
;;

7)
coupon_7="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 ( concat('CASH_LOAN2017102419394902108ea8623',NOW()), '$phone_no', '10000649', '现金贷还款折扣券', '8', '{\"loanTerm\":[1,2,3]}', '2', '{\"discount\":8.8}', NOW(),'2028-09-24 23:59:00','0', '2', NOW(), NULL, NOW(), NULL, '5')"
mysql -h${HOSTNAME} -p${PORT} -u${USERNAME} -p${PASSWORD}  ${DBNAME} -e"set names utf8; ${coupon_7}" 
echo "现金贷还款折扣券增加成功"
;;

8)
coupon_8="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 ( concat('CASH_LOAN20171109161259004ad216ge3',NOW()), '$phone_no', '10000672', '现金贷抵扣券', '8', '{\"loanTerm\":[1,2]}', '3', '{\"rebate\":\"100\"}', NOW(),'2028-09-24 23:59:00', '0', '2', NOW(), NULL, NOW(), NULL, '1000033')"
mysql -h${HOSTNAME} -p${PORT} -u${USERNAME} -p${PASSWORD}  ${DBNAME} -e"set names utf8; ${coupon_8}" 
echo "现金贷抵扣券增加成功"
;;

9)
coupon_9="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 (concat('CASH_LOAN2017110916134482203d783ga',NOW()), '$phone_no', '10000673', '现金贷还款免息券', '8', '{\"loanTerm\":[1,2]}', '4', '{}', NOW(), '2028-09-24 23:59:00', '0', '2', NOW(), NULL, NOW(), NULL, '1000033')"
mysql -h${HOSTNAME} -p${PORT} -u${USERNAME} -p${PASSWORD}  ${DBNAME} -e"set names utf8; ${coupon_9}" 
echo "现金贷还款免息券增加成功"
;;

10)
coupon_10="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 (concat('OUT_BAITIAO201711091613599425d5e345g',NOW()), '$phone_no', '10000674', '白条购物券满减券', '9', '{\"firstChannel\":1}', '1', '{\"full\":\"100\",\"cut\":\"50\"}', NOW(),'2028-09-24 23:59:00', '0', '2', NOW(), NULL, NOW(), NULL, '1000033')"
mysql -h${HOSTNAME} -p${PORT} -u${USERNAME} -p${PASSWORD}  ${DBNAME} -e"set names utf8; ${coupon_10}" 
echo "白条购物券满减券增加成功"
;;

11)
coupon_11="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 ( concat('OUT_BAITIAO201711091614166796e01b39g',NOW()), '$phone_no', '10000675', '深圳通白条购物券满减券', '9', '{\"firstChannel\":2}', '1', '{\"full\":\"100\",\"cut\":\"5\"}',NOW(), '2028-09-24 23:59:00', '0', '2', NOW(), NULL, NOW(), NULL, '1000033')"
mysql -h${HOSTNAME} -p${PORT} -u${USERNAME} -p${PASSWORD}  ${DBNAME} -e"set names utf8; ${coupon_11}" 
echo "深圳通白条购物券满减券增加成功"
;;

esac
