(select total_reback_view.sum from total_reback_view where total_reback_view.contract_unid=tb_contract.contract_unid) as total_reback_amount,
(contract_amount-(select total_reback_view.sum from total_reback_view where total_reback_view.contract_unid=tb_contract.contract_unid)-deduct_amount-stop_amount-exemptions_amount-bad_amount) as contract_remain,
(select total_recv_amount_view.total_recv_amount from total_recv_amount_view where tb_contract.contract_unid=total_recv_amount_view.contract_unid) as total_receive_amount ,
((select total_recv_amount_view.total_recv_amount from total_recv_amount_view where tb_contract.contract_unid=total_recv_amount_view.contract_unid)-(select total_reback_view.sum from total_reback_view where total_reback_view.contract_unid=tb_contract.contract_unid)-deduct_amount-stop_amount-exemptions_amount-bad_amount) as total_amount_remain ,
(select over_days_view.over_days from over_days_view where over_days_view.contract_unid=tb_contract.contract_unid) as over_days
(cast(contract_amount as decimal(18,2))-(select cast(total_reback_view.sum as decimal(18,2)) from total_reback_view where total_reback_view.contract_unid=tb_contract.contract_unid)-cast(deduct_amount as decimal(18,2))-cast(stop_amount as decimal(18,2))-cast(exemptions_amount as decimal(18,2))-cast(bad_amount as decimal(18,2))) as contract_remain,
(select cast(total_reback_view.sum as decimal(18,2)) from total_reback_view where total_reback_view.contract_unid=tb_contract.contract_unid) as total_reback_amount,
(select cast(total_recv_amount_view.total_recv_amount as decimal(18,2)) from total_recv_amount_view where tb_contract.contract_unid=total_recv_amount_view.contract_unid) as total_receive_amount ,
((select cast(total_recv_amount_view.total_recv_amount as decimal(18,2)) from total_recv_amount_view where tb_contract.contract_unid=total_recv_amount_view.contract_unid)-(select cast(total_reback_view.sum as decimal(18,2)) from total_reback_view where total_reback_view.contract_unid=tb_contract.contract_unid)-(cast(deduct_amount as decimal(18,2)))-(cast(stop_amount as decimal(18,2)))-(cast(exemptions_amount as decimal(18,2)))-(cast(bad_amount as decimal(18,2)))) as total_amount_remain ,
(select over_days_view.over_days from over_days_view where over_days_view.contract_unid=tb_contract.contract_unid) as over_days,
(select tb_project.project_name from tb_project where tb_project.project_unid=tb_contract.project_unid) as project_name,
(select tb_customer.customer_name from tb_customer where tb_customer.customer_unid=tb_contract.customer_unid) as customer_name
from tb_contract where 1=1
<iftest="salesperson_name__like !=null and salesperson_name__like !=''">
<iftest="project_name__like !=null and project_name__like !=''">
and
project_unid like #{project_name__like}
tb_contract.project_unid in (select tb_project.project_unid from tb_project where project_name like '%'||#{project_name__like}||'%')
</if>
<iftest="customer_name__like !=null and customer_name__like !=''">
and
customer_unid like #{customer_name__like}
tb_contract.customer_unid in (select tb_customer.customer_unid from tb_customer where customer_name like '%'||#{customer_name__like}||'%')
</if>
<iftest="province !=null and province !=''">
and
...
...
@@ -312,17 +318,17 @@
and
county=#{county}
</if>
<iftest="guarantee_period !=null">
<iftest="guarantee_period !=null and guarantee_period !=0">
and
guarantee_period=#{guarantee_period}
</if>
<iftest="year !=null and year !=''">
and
to_char(sign_date,"yyyy")=#{year}
to_char(sign_date,'yyyy')=#{year}
</if>
<iftest="month !=null and month!=''">
and
to_char(sign_date,"MM")=#{month}
to_char(sign_date,'MM')=#{month}
</if>
<iftest="product_line_type !=null and product_line_type !=''">
and
...
...
@@ -348,7 +354,7 @@
and
confirm_income_amount=#{confirm_income_amount}
</if>
<iftest="amount_state_unid !=null">
<iftest="amount_state_unid !=null and amount_state_unid !=''">
and
amount_state_unid=#{amount_state_unid}
</if>
...
...
@@ -356,18 +362,19 @@
and
#{start_date} <![CDATA[<=]]> sign_date and sign_date <![CDATA[<=]]> #{end_date}
</if>
<iftest="amount_point !=null">
<iftest="amount_point !=null and amount_point !=0.0">
and
contract_amount <![CDATA[>=]]> #{amount_point}
</if>
<iftest="overdays_point !=null">
<iftest="overdays_point !=null and overdays_point !=0">
and
<!--逾期天数-->contract_unid in (select over_days_view.contract_unid from over_days_view where over_days <![CDATA[>=]]> #{overdays_point})
</if>
<iftest="leave_amount_point !=null">
<iftest="leave_amount_point !=null and leave_amount_point !=0.0">
<!--应收款余额-->and
contract_unid in (select receive_amount_view.contract_unid from receive_amount_view where receive_amount_view.leave_amount_point <![CDATA[>=]]> #{leave_amount_point})
</if>
and is_delete=false
<iftest="limit !=null and offset !=null">
limit #{limit} offset #{offset}
</if>
...
...
@@ -378,4 +385,7 @@
<selectid="queryList"resultType="String">
select contract_unid from tb_contract
</select>
<selectid="countNumber"resultType="int">
select count(contract_unid) from tb_contract where is_delete=false
select payment_unid,contract_unid,payment_type,payment_progress,days,cast(payment_propority as decimal(18,2)),payment_requirement from tb_payment_agree where contract_unid = #{contract_unid}