create view vi_lc_audit_rent_plan as SELECT LCRP.ID                                        AS ID,
       LCI.DISTRIBUTOR_ID                             AS DISTRIBUTOR_ID,
       LCRP.CONTRACT_ID                               AS CONTRACT_ID,
       LCI.CONTRACT_NUMBER                            AS CONTRACT_NUMBER,
       LUL.CUSTOMER_ID                                AS CUSTOMER_ID,
       LUL.CUSTOMER_NAME                              AS CUSTOMER_NAME,
       LCRP.PLAN_LIST                                 AS PLAN_LIST,
       LCRP.PLAN_DATE                                 AS PLAN_DATE,
       (LCRP.RENT + `nvl`(VIRP.PENALTY_OVER, 0))      AS FACT_RENT,
       LCRP.CORPUS                                    AS FACT_CORPUS,
       LCRP.INTEREST                                  AS FACT_INTEREST,
       (VIRP.RENT_OVER + `nvl`(VIRP.PENALTY_OVER, 0)) AS RENT,
       LCRP.RENT                                      AS PLAN_RENT,
       VIRP.CORPUS_OVER                               AS CORPUS,
       VIRP.INTEREST_OVER                             AS INTEREST,
       `nvl`(VIRP.PENALTY_OVER, 0)                    AS PENALTY,
       CAT.BANK_NAME                                  AS BANK_NAME,
       CAT.ACCOUNT                                    AS ACCOUNT,
       CAT.ACC_NUMBER                                 AS ACC_NUMBER,
       CAT.MOBILE                                     AS MOBILE,
       ifnull(CAT.SIGN_STATUS, 'N')                   AS SIGN_STATUS,
       ifnull(LCRP.AUDIT_STATE, 'N')                  AS AUDIT_STATE,
       ifnull(LCRP.COLLECT_STATUS, '未收款')             AS COLLECT_STATUS,
       ifnull(LCRP.COLLECT_MSG, '')                   AS COLLECT_MSG,
       LCRP.FAILURE_TIME                              AS FAILURE_TIME,
       LCRP.FAILURE_REASON                            AS FAILURE_REASON,
       LCRP.BATCH_STATUS                              AS BATCH_STATUS,
       LCRP.BATCH_NO                                  AS BATCH_NO,
       LCRP.BATCH_SN                                  AS BATCH_SN
FROM (((((APZL.LC_RENT_PLAN LCRP LEFT JOIN (
    SELECT APZL.LC_RENT_INCOME.PAYMENT_NUMBER       AS PAYMENT_NUMBER,
           APZL.LC_RENT_INCOME.PLAN_LIST            AS PLAN_LIST,
           APZL.LC_RENT_INCOME.PLAN_ID              AS PLAN_ID,
           sum(APZL.LC_RENT_INCOME.RENT)            AS RENT,
           sum(APZL.LC_RENT_INCOME.CORPUS)          AS CORPUS,
           sum(APZL.LC_RENT_INCOME.INTEREST)        AS INTEREST,
           sum(APZL.LC_RENT_INCOME.PENALTY)         AS PENALTY,
           sum(APZL.LC_RENT_INCOME.CORPUS_ADJUST)   AS CORPUS_ADJUST,
           sum(APZL.LC_RENT_INCOME.INTEREST_ADJUST) AS INTEREST_ADJUST,
           sum(APZL.LC_RENT_INCOME.PENALTY_ADJUST)  AS PENALTY_ADJUST
    FROM APZL.LC_RENT_INCOME
    WHERE (APZL.LC_RENT_INCOME.ROLL_BACK = '0')
    GROUP BY APZL.LC_RENT_INCOME.PAYMENT_NUMBER, APZL.LC_RENT_INCOME.PLAN_LIST, APZL.LC_RENT_INCOME.PLAN_ID
) LCFI ON (((LCRP.PAYMENT_NUMBER = LCFI.PAYMENT_NUMBER) AND (LCRP.PLAN_LIST = LCFI.PLAN_LIST) AND
            (LCRP.ID = LCFI.PLAN_ID)))) LEFT JOIN APZL.VI_LC_RENT_PLAN VIRP ON ((VIRP.ID = LCRP.ID))) LEFT JOIN APZL.LB_CONTRACT_INFO LCI ON ((LCI.ID = LCRP.CONTRACT_ID))) LEFT JOIN APZL.LB_UNION_LESSEE LUL ON ((LUL.CONTRACT_ID = LCI.ID)))
LEFT JOIN (
    SELECT DISTINCT APZL.CUSTOMER_ACCOUNT.BANK_NAME   AS BANK_NAME,
                    APZL.CUSTOMER_ACCOUNT.ACCOUNT     AS ACCOUNT,
                    APZL.CUSTOMER_ACCOUNT.ACC_NUMBER  AS ACC_NUMBER,
                    APZL.CUSTOMER_ACCOUNT.CUSTOMERID  AS CUSTOMERID,
                    APZL.CUSTOMER_ACCOUNT.ACC_TYPE    AS ACC_TYPE,
                    APZL.CUSTOMER_ACCOUNT.MOBILE      AS MOBILE,
                    APZL.CUSTOMER_ACCOUNT.SIGN_STATUS AS SIGN_STATUS,
                    APZL.CUSTOMER_ACCOUNT.CONTRACT_ID AS CONTRACT_ID
    FROM APZL.CUSTOMER_ACCOUNT
) CAT ON (((CAT.ACC_TYPE = 'Debit') AND (CAT.CONTRACT_ID = LCRP.CONTRACT_ID))))
WHERE ((LCI.CONTRACT_STATUS = '31') AND (LCI.BUSINESSTYPE = '1') AND (VIRP.RENT_OVER > 0));

-- comment on column vi_lc_audit_rent_plan.id not supported: 标识

-- comment on column vi_lc_audit_rent_plan.DISTRIBUTOR_ID not supported: 经销商IDid

-- comment on column vi_lc_audit_rent_plan.contract_id not supported: 合同编号

-- comment on column vi_lc_audit_rent_plan.contract_number not supported: 业务合同号

-- comment on column vi_lc_audit_rent_plan.customer_id not supported: 承租人编号

-- comment on column vi_lc_audit_rent_plan.CUSTOMER_NAME not supported: 承租人名称

-- comment on column vi_lc_audit_rent_plan.plan_list not supported: 期次

-- comment on column vi_lc_audit_rent_plan.plan_date not supported: 计划日期

-- comment on column vi_lc_audit_rent_plan.fact_corpus not supported: 财务本金

-- comment on column vi_lc_audit_rent_plan.fact_interest not supported: 财务租息

-- comment on column vi_lc_audit_rent_plan.plan_rent not supported: 租金

-- comment on column vi_lc_audit_rent_plan.bank_name not supported: 开户银行

-- comment on column vi_lc_audit_rent_plan.account not supported: 帐户名称

-- comment on column vi_lc_audit_rent_plan.acc_number not supported: 银行账号

-- comment on column vi_lc_audit_rent_plan.mobile not supported: 手机号

-- comment on column vi_lc_audit_rent_plan.FAILURE_TIME not supported: 失败时间

-- comment on column vi_lc_audit_rent_plan.FAILURE_REASON not supported: 失败原因

-- comment on column vi_lc_audit_rent_plan.BATCH_STATUS not supported: 批量处理状态

-- comment on column vi_lc_audit_rent_plan.BATCH_NO not supported: 批量交易流水号,若拆分，以,分割

