#!/bin/bash
ip=$1
port=$3
seq=`date "+%Y-%m-%d %H:%M:%S"`
mysqld="-h$ip -P$port -uqa -pqatest"

# 0.未登录：先删除未登录状态下loan_config表数据，再插入新数据
mysql -N $mysqld mall -e "delete from loan_config where loan_state='0' and config_key='buttonConfig'";
mysql -N $mysqld mall -e "set names utf-8; insert into loan_config ( id, loan_state, config_key, config_value, removed, update_at) 
values ( '76', '0', 'buttonConfig', '{\n    \"isShow\":true,\n    \"buttonColor\":\"464B53\",\n   \"buttonTitle\":\"立即申请\",\n \"navUrl\":\"http://$ip:7001/app-landing?registerFrom={registerFrom}&channelId=1&token={token}&appChannel={appChannel}&appName={appName}\",\n    \"typefaceColor\":\"ffffff\"\n}', '0', '$seq')";

# 1.申请借款：先删除未登录状态下loan_config表数据，再插入新数据
mysql -N $mysqld mall -e "delete from loan_config where loan_state='1' and config_key='buttonConfig'";
mysql -N $mysqld mall -e "set names utf-8; insert into loan_config ( id, loan_state, config_key, config_value, removed, update_at) 
values ( '12', '1', 'buttonConfig', '{\n\"isShow\": true,\n\"buttonColor\":\"464B53\",\n\"buttonTitle\":\"立即拿钱\",\n \"navUrl\":\"http://$ip:7001/app-landing?registerFrom={registerFrom}&channelId=1&token={token}&appChannel={appChannel}&appName={appName}\",\n\"typefaceColor\":\"ffffff\"\n}', '0', '$seq')";

# 2.贷款审核中：先删除未登录状态下loan_config表数据，再插入新数据
mysql -N $mysqld mall -e "delete from loan_config where loan_state='2' and config_key='buttonConfig'";
mysql -N $mysqld mall -e "set names utf-8; insert into loan_config ( id, loan_state, config_key, config_value, removed, update_at) 
values ( '19', '2', 'buttonConfig', '{\n\"isShow\":true,\n\"buttonColor\":\"464B53\",\n\"buttonTitle\":\"去提额\",\n \"navUrl\":\"http://$ip:7001/app-landing?registerFrom={registerFrom}&channelId=1&token={token}&appChannel={appChannel}&appName={appName}\",\n\"typefaceColor\":\"ffffff\"\n}', '0', '$seq')";

# 3.审核通过：先删除未登录状态下loan_config表数据，再插入新数据
mysql -N $mysqld mall -e "delete from loan_config where loan_state='3' and config_key='buttonConfig'";
mysql -N $mysqld mall -e "set names utf-8; insert into loan_config ( id, loan_state, config_key, config_value, removed, update_at) 
values ( '27', '3', 'buttonConfig', '{\n\"isShow\":true,\n\"buttonColor\":\"464B53\",\n\"buttonTitle\":\"立即提现\",\n \"navUrl\":\"http://$ip:7001/app-landing?registerFrom={registerFrom}&channelId=1&token={token}&appChannel={appChannel}&appName={appName}\",\n\"typefaceColor\":\"ffffff\"\n}', '0', '$seq')";

# 4.放款中：先删除未登录状态下loan_config表数据，再插入新数据
mysql -N $mysqld mall -e "delete from loan_config where loan_state='4' and config_key='buttonConfig'";
mysql -N $mysqld mall -e "set names utf-8; insert into loan_config ( id, loan_state, config_key, config_value, removed, update_at) 
values ( '36', '4', 'buttonConfig', '{\n\"isShow\":true,\n\"buttonColor\":\"464B53\",\n\"buttonTitle\":\"一键催款\",\n \"navUrl\":\"http://$ip:7001/app-landing?registerFrom={registerFrom}&channelId=1&token={token}&appChannel={appChannel}&appName={appName}\",\n\"typefaceColor\":\"ffffff\"\n}', '0', '$seq')";

# 5.放款失败：先删除未登录状态下loan_config表数据，再插入新数据
mysql -N $mysqld mall -e "delete from loan_config where loan_state='5' and config_key='buttonConfig'";
mysql -N $mysqld mall -e "set names utf-8; insert into loan_config ( id, loan_state, config_key, config_value, removed, update_at) 
values ( '46', '5', 'buttonConfig', '{\n\"isShow\":true,\n\"buttonColor\":\"464B53\",\n\"buttonTitle\":\"立即申请\",\n \"navUrl\":\"http://$ip:7001/app-landing?registerFrom={registerFrom}&channelId=1&token={token}&appChannel={appChannel}&appName={appName}\",\n\"typefaceColor\":\"ffffff\"\n}', '0', '$seq')";

# 6.还款中：先删除未登录状态下loan_config表数据，再插入新数据
mysql -N $mysqld mall -e "delete from loan_config where loan_state='6' and config_key='buttonConfig'";
mysql -N $mysqld mall -e "set names utf-8; insert into loan_config ( id, loan_state, config_key, config_value, removed, update_at) 
values ( '54', '6', 'buttonConfig', '{\n\"isShow\":true,\n\"buttonColor\":\"464B53\",\n\"buttonTitle\":\"去还款\",\n \"navUrl\":\"http://$ip:7001/app-landing?registerFrom={registerFrom}&channelId=1&token={token}&appChannel={appChannel}&appName={appName}\",\n\"typefaceColor\":\"ffffff\"\n}', '0', '$seq')";

# 7.审核拒绝：先删除未登录状态下loan_config表数据，再插入新数据
mysql -N $mysqld mall -e "delete from loan_config where loan_state='7' and config_key='buttonConfig'";
mysql -N $mysqld mall -e "set names utf-8; insert into loan_config ( id, loan_state, config_key, config_value, removed, update_at) 
values ( '65', '7', 'buttonConfig', '{\n\"isShow\":true,\n\"buttonColor\":\"464B53\",\n\"buttonTitle\":\"去借款\",\n \"navUrl\":\"http://$ip:7001/app-landing?registerFrom={registerFrom}&channelId=1&token={token}&appChannel={appChannel}&appName={appName}\",\n\"typefaceColor\":\"ffffff\"\n}', '0', '$seq')";

redis-cli -p 6379 flushall

echo "mall库的loan_config表，按钮配置更新完成"


