id,
deleted,
modified,
created,
production_fund_id, title, type, tax_no, plan_amount, real_amount, plan_make_date, real_make_date, state, reason, apply_id, checker_id, maker_id, bank_name, bank_account, bank_address, bank_tel, make_item, item_quantity, item_unit, tax_rate, tax_amount, remark
SELECT
fi.*,
fi.created AS createTime,
(case orf.business_type when 'ASSET_BUSINESS' THEN '资产业务' WHEN 'MAJOR_BUSINESS' THEN '大中型业务' WHEN 'ITEM_BUSINESS' THEN '土规业务' else '个贷业务' end) as businessType,
orf.order_id,
orf.order_name,
(orf.should_amount=orf.real_amount) as isPayAll,
u.name AS applyName,
pf.production_no
FROM
finance_invoice fi
LEFT JOIN order_fund orf ON fi.order_fund_id = orf.id
LEFT JOIN user u ON u.id = fi.apply_id
left join production_fund pf on pf.id = fi.production_fund_id
where fi.deleted = 0 and orf.deleted = 0
and (fi.state = '申请作废' or fi.state = '审核中')
and fi.state = #{vo.state}
and (
fi.title like concat ('%',#{keyword},'%')
or orf.order_name like concat('%',#{keyword},'%')
or orf.order_id like concat('%',#{keyword},'%')
or orf.business_type like concat('%',#{keyword},'%')
or u.name like concat('%',#{keyword},'%')
or fi.type like concat('%',#{keyword},'%')
or fi.tax_no like concat('%',#{keyword},'%')
or fi.plan_amount like concat('%',#{keyword},'%')
or fi.state like concat('%',#{keyword},'%')
or fi.remark like concat('%',#{keyword},'%')
or pf.production_no like concat('%',#{keyword},'%')
)
and fi.plan_make_date >= #{vo.pStartDate}
and fi.plan_make_date <= #{vo.pEndDate}
and fi.real_make_date >= #{vo.rStartDate}
and fi.real_make_date <= #{vo.rEndDate}
and fi.modified >= #{vo.dStartDate}
and fi.modified <= #{vo.dEndDate}
and fi.created >= #{vo.aStartDate}
and fi.created <= #{vo.aEndDate}
order by fi.modified DESC
order by fi.created DESC