update_repayment_plan="UPDATE baitiao_bill_repayment_plan as a set a.bill_id=(SELECT id from baitiao_bill where baitiao_bill.user_phone='${phone_no}' and baitiao_bill.month=${paymonth}) where a.id=${id}"
update_repayment_plan="UPDATE baitiao_bill_repayment_plan as a set a.bill_id=(SELECT id from baitiao_bill where baitiao_bill.user_phone='${phone_no}' and baitiao_bill.month=${paymonth}) where a.id=${id}"
select_update_repayment_plan="UPDATE baitiao_bill_repayment_plan as aa set aa.deadline='${line1}' WHERE aa.id=${id}"
select_update_repayment_plan="UPDATE baitiao_bill_repayment_plan as aa set aa.deadline='${line1}' WHERE aa.id=${id}"
#echo ${select_update_repayment_plan}
echo${select_update_repayment_plan}
mysql -N$mysqld xyqb -e"${select_update_repayment_plan}"
mysql -N$mysqld xyqb -e"${select_update_repayment_plan}"
#更新笑脸还款计划金额baitiao_fund_repayment_plan
#更新笑脸还款计划金额baitiao_fund_repayment_plan
select_fund_repayment_plan1="update baitiao_fund_repayment_plan as a,baitiao_bill_repayment_plan as b set a.principal=b.principal,a.interest=b.interest WHERE a.plan_id=b.id and b.id=${id} and a.fund_order_id=${fund_order_id1}"
select_fund_repayment_plan1="update baitiao_fund_repayment_plan as a,baitiao_bill_repayment_plan as b set a.principal=b.principal,a.interest=b.interest WHERE a.plan_id=b.id and b.id=${id} and a.fund_order_id=${fund_order_id1}"
# echo ${select_fund_repayment_plan1}
echo${select_fund_repayment_plan1}
mysql -N$mysqld xyqb -e"${select_update_repayment_plan}"
mysql -N$mysqld xyqb -e"${select_update_repayment_plan}"
mysql -N$mysqld${DBNAME2}-e"set names utf8; ${con2}"
#广源库loan_application_manifest_history表增加数据
user_id=`mysql -N$mysqld${DBNAME2}-e"select id from ${TABLENAME4} where phone_no=${phone_no}"`
protocol_number=`mysql -N$mysqld${DBNAME1}-e"select ssq_contract_no from ${TABLENAME5} where loan_application_history_id=${loan_application_history_id}"`
echo$protocol_number
con3="INSERT INTO gyxd.loan_application_manifest_history(loan_id,loan_user_id,channel_id,credit_assignment,bank_card_id,loan_progress,reported_progress,amount,term, purpose,protocol_number,service_fee_per_term,total_repayment_amount,monthly_repayment,annual_interest_rate,principal_and_interest_per_term,total_principal_and_interest,loan_received_at,loan_paid_at,transaction_status,remark,payment_notification_url,created_at,updated_at,notify_at,sign_status,loan_status,recall_status, repay_status,debt_status,distribute_fund_id,credit_assigned_at)
mysql -N$mysqld${DBNAME2}-e"set names utf8; ${con3}"
#gyxd增加还款计划
loan_application_manifest_history_id=`mysql -N$mysqld${DBNAME2}-e"select id from ${TABLENAME2} where loan_id =${loan_application_history_id}"`
con4="INSERT INTO gyxd.repayment_plan(loan_user_id,loan_application_manifest_history_id,loan_id,channel_id,term_no,deadline,current_repayment,required_repayment,repayment_status,repaid_at,qg_repay_at,credit_assigned_at,overdue_interest,activity_relief,repayment_received_at,remark,collection_relief,principal_amount, interest,service_fee,reported_progress,credit_assignment,debt_fund_id,debt_status,pay_approach,pay_approach_desc,compensation_status,compensation_at,overdue_service_fee,pay_order_no,actual_service_fee)