SELECT ref_id , id 'plan_id', term_no,real_loan_id 'loan_id', service_fee 'qg_service_fee',should_punish 'qg_overdue_interest' FROM new_transaction.user_repayment_plan WHERE real_loan_id IN %s
SELECT ref_id , id 'plan_id', term_no,real_loan_id 'loan_id', service_fee 'qg_service_fee',should_punish 'qg_overdue_interest' FROM new_transaction.user_repayment_plan WHERE real_loan_id IN %s
# SELECT t2.id plan_id FROM red_packet_detail t1 LEFT JOIN user_repayment_plan t2 ON t1.ref_id=t2.ref_id AND t1.term_no=t2.term_no WHERE xyqb_repaid_at>="2017-07-01" AND xyqb_repaid_at<"2017-08-01"
# SELECT t2.id plan_id FROM red_packet_detail t1 LEFT JOIN user_repayment_plan t2 ON t1.ref_id=t2.ref_id AND t1.term_no=t2.term_no WHERE xyqb_repaid_at>="2017-10-01" AND xyqb_repaid_at<"2017-11-10"
# '''
# '''
# sql_plan_id = '''
# sql_plan_id = '''
# SELECT t1.plan_id FROM `xjd_repay_plan_repay_record_ref` t1
# SELECT t1.plan_id FROM `xjd_repay_plan_repay_record_ref` t1
# JOIN `user_repayment_plan` t2 ON t1.plan_id = t2.id
# JOIN `user_repayment_plan` t2 ON t1.plan_id = t2.id
# WHERE t2.fund_code in (290,350,380,420) AND t2.xyqb_repaid_at >= '2017-09-01 00:00:00' AND t2.xyqb_repaid_at < '2017-10-01 00:00:00' AND t1.ref_amount > 0
# WHERE t2.xyqb_repaid_at >= '2017-10-01 00:00:00' AND t2.xyqb_repaid_at < '2017-11-05 00:00:00' AND t1.ref_amount > 0
# '''
# '''
# sql_plan_id = '''
# SELECT t2.id plan_id FROM user_repayment_plan t2 WHERE id IN (6368687,
sql_plan_id='''
# 6368687,
SELECT t2.id plan_id FROM user_repayment_plan t2 WHERE id IN (17818535,14951401,13183085,16775621,16023121,18481649,18478739,18239129,16135315,14459209,15815947,16793909,17317973,16647695,16779713,16960183,16862699,20435587,17356583,16947229,15048301,18538103,16853759,16723967,17990615,17992793,17992907,17995541,17996099,17999693,17917967,18001511,17939003,17939735,19348913)
# 6368689,
'''
# 4787737,
# 4787737,
# 195729,
# 195799,
# 195831
# )
# '''
#
#
# sql_plan_id = '''
# sql_plan_id = '''
...
@@ -232,6 +225,18 @@ def split_money_0(df):
...
@@ -232,6 +225,18 @@ def split_money_0(df):
# 注意退款的情况
# 注意退款的情况
sql_xjd_ref='''select id, plan_id, ref_amount from xjd_repay_plan_repay_record_ref where plan_id in %s and ref_amount > 0 '''
sql_xjd_ref='''select id, plan_id, ref_amount from xjd_repay_plan_repay_record_ref where plan_id in %s and ref_amount > 0 '''
# sql_xjd_ref = '''SELECT
# id,
# plan_id,
# ref_amount
# FROM
# xjd_repay_plan_repay_record_ref t1
# JOIN new_transaction.repay_record_online t2 ON t1.record_id = t2.id
# AND t1.repay_channel = t2.pay_approach
# WHERE
# plan_id IN % s
# AND ref_amount > 0 '''
sql_user_repayment_plan='''
sql_user_repayment_plan='''
select id plan_id, ref_id,term_no,principle, interest, service_fee, should_punish ,repay_status,xyqb_repaid_at from user_repayment_plan where id in %s
select id plan_id, ref_id,term_no,principle, interest, service_fee, should_punish ,repay_status,xyqb_repaid_at from user_repayment_plan where id in %s
# JOIN user_repayment_plan t2 ON t1.plan_id = t2.id
WHERE
# WHERE
t2.fund_code in (290,350,380,420)
#
AND t2.xyqb_repaid_at >= "2017-09-01"
# t2.xyqb_repaid_at >= "2017-10-01"
AND t2.xyqb_repaid_at < "2017-10-10"
# AND t2.xyqb_repaid_at < "2017-11-10"
AND t2.repay_status = 3
# AND t2.repay_status = 3
#
GROUP BY
# GROUP BY
t1.plan_id
# t1.plan_id
"""
# """
#
#
# sql_1 = """
# sql_1 = """
#
#
...
@@ -73,9 +73,9 @@ GROUP BY
...
@@ -73,9 +73,9 @@ GROUP BY
# '''
# '''
# 89647
# 89647
# 9892093
# 9892093
# sql_plan_ref='''
sql_plan_ref='''
# select sum(ref_amount) repay_amount,plan_id from xjd_repay_plan_repay_record_ref where plan_id in (19306061) GROUP BY plan_id
select sum(ref_amount) repay_amount,plan_id from xjd_repay_plan_repay_record_ref where plan_id in (17818535,14951401,13183085,16775621,16023121,18481649,18478739,18239129,16135315,14459209,15815947,16793909,17317973,16647695,16779713,16960183,16862699,20435587,17356583,16947229,15048301,18538103,16853759,16723967,17990615,17992793,17992907,17995541,17996099,17999693,17917967,18001511,17939003,17939735,19348913) GROUP BY plan_id
# '''
'''
sql_user_plan="""select id plan_id,ref_id,term_no, principle, interest, service_fee, should_punish,repay_status from user_repayment_plan where id in %s """
sql_user_plan="""select id plan_id,ref_id,term_no, principle, interest, service_fee, should_punish,repay_status from user_repayment_plan where id in %s """
sql_user_plan="""select id plan_id,ref_id,term_no, principle, interest, service_fee, should_punish,repay_status from audit_temp.user_repayment_plan where id in %s """
sql_red_package='''
select ref_id,term_no,amount red_amount from audit_temp.red_packet_detail where ref_id in %s