Commit 9840b961 by 王军业

12211

1 parent 86f89863
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.vion.financial.mapper.ContractMapper"> <mapper namespace="com.vion.financial.mapper.ContractMapper">
<insert id="addOne" parameterType="com.vion.financial.vo.ContractVo" keyColumn="contract_unid" keyProperty="contract_unid" useGeneratedKeys="true"> <insert id="addOne" parameterType="com.vion.financial.vo.ContractVo" keyColumn="contract_unid" keyProperty="contract_unid" useGeneratedKeys="true">
INSERT INTO tb_contract( INSERT INTO tb_contract(
contract_unid contract_unid
<if test="salesperson_unid != null and salesperson_unid != ''"> <if test="salesperson_unid != null and salesperson_unid != ''">
,salesperson_unid ,salesperson_unid
</if> </if>
<if test="province != null and province != ''"> <if test="province != null and province != ''">
,province,province_name ,province,province_name
</if> </if>
<if test="city !=null and city != ''"> <if test="city !=null and city != ''">
,city,city_name ,city,city_name
</if> </if>
<if test="county != null and county != ''"> <if test="county != null and county != ''">
,county,county_name ,county,county_name
</if> </if>
<if test="guarantee_period != null"> <if test="guarantee_period != null">
,guarantee_period ,guarantee_period
</if> </if>
<if test="sign_date != null"> <if test="sign_date != null">
,sign_date ,sign_date
</if> </if>
<if test="product_line_type != null and product_line_type != ''"> <if test="product_line_type != null and product_line_type != ''">
,product_line_type ,product_line_type
</if> </if>
<if test="contract_state != null and contract_state != ''"> <if test="contract_state != null and contract_state != ''">
,contract_state ,contract_state
</if> </if>
<if test="contract_type != null and contract_type != ''"> <if test="contract_type != null and contract_type != ''">
,contract_type ,contract_type
</if> </if>
<if test="contract_amount != null "> <if test="contract_amount != null ">
,contract_amount ,contract_amount
</if> </if>
<if test="deduct_amount != null "> <if test="deduct_amount != null ">
,deduct_amount ,deduct_amount
</if> </if>
<if test="contract_amount_note != null and contract_amount_note != ''"> <if test="contract_amount_note != null and contract_amount_note != ''">
,contract_amount_note ,contract_amount_note
</if> </if>
<if test="stop_amount != null "> <if test="stop_amount != null ">
,stop_amount ,stop_amount
</if> </if>
<if test="reback_note != null and reback_note != ''"> <if test="reback_note != null and reback_note != ''">
,reback_note ,reback_note
</if> </if>
<if test="exemptions_amount != null "> <if test="exemptions_amount != null ">
,exemptions_amount ,exemptions_amount
</if> </if>
<if test="contract_remain_note != null and contract_remain_note != ''"> <if test="contract_remain_note != null and contract_remain_note != ''">
,contract_remain_note ,contract_remain_note
</if> </if>
<if test="is_archive != null and is_archive != ''"> <if test="is_archive != null and is_archive != ''">
,is_archive ,is_archive
</if> </if>
<if test="bad_amount != null "> <if test="bad_amount != null ">
,bad_amount ,bad_amount
</if> </if>
<if test="bad_amount_note != null and bad_amount_note != ''"> <if test="bad_amount_note != null and bad_amount_note != ''">
,bad_amount_note ,bad_amount_note
</if> </if>
<if test="confirm_income_amount != null "> <if test="confirm_income_amount != null ">
,confirm_income_amount ,confirm_income_amount
</if> </if>
<if test="amount_state_unid != null and amount_state_unid != ''"> <if test="amount_state_unid != null and amount_state_unid != ''">
,amount_state_unid ,amount_state_unid
</if> </if>
<if test="start_guarantee_date != null "> <if test="start_guarantee_date != null ">
,start_guarantee_date ,start_guarantee_date
</if> </if>
<if test="end_guarantee_date != null "> <if test="end_guarantee_date != null ">
,end_guarantee_date ,end_guarantee_date
</if> </if>
<if test="mainten_start_point != null and mainten_start_point != ''"> <if test="mainten_start_point != null and mainten_start_point != ''">
,mainten_start_point ,mainten_start_point
</if> </if>
<if test="contract_note != null and contract_note != ''"> <if test="contract_note != null and contract_note != ''">
,contract_note ,contract_note
</if> </if>
,is_delete ,is_delete
<if test="project_unid != null and project_unid != ''"> <if test="project_unid != null and project_unid != ''">
,project_unid ,project_unid
</if> </if>
<if test="customer_unid != null and customer_unid != ''"> <if test="customer_unid != null and customer_unid != ''">
,customer_unid ,customer_unid
</if> </if>
<if test="province_name !=null and province_name !=''"> <if test="province_name !=null and province_name !=''">
,province_name ,province_name
</if> </if>
<if test="city_name !=null and city_name !=''"> <if test="city_name !=null and city_name !=''">
,city_name ,city_name
</if> </if>
<if test="county_name !=null and county_name !=''"> <if test="county_name !=null and county_name !=''">
,county_name ,county_name
</if> </if>
) VALUES( ) VALUES(
#{contract_unid} #{contract_unid}
<if test="salesperson_unid != null and salesperson_unid != ''"> <if test="salesperson_unid != null and salesperson_unid != ''">
,#{salesperson_unid} ,#{salesperson_unid}
</if> </if>
<if test="province != null and province != ''"> <if test="province != null and province != ''">
,#{province},#{province_name} ,#{province},#{province_name}
</if> </if>
<if test="city !=null and city != ''"> <if test="city !=null and city != ''">
, #{city},#{city_name} , #{city},#{city_name}
</if> </if>
<if test="county != null and county != ''"> <if test="county != null and county != ''">
,#{county},#{county_name} ,#{county},#{county_name}
</if> </if>
<if test="guarantee_period != null "> <if test="guarantee_period != null ">
,#{guarantee_period} ,#{guarantee_period}
</if> </if>
<if test="sign_date != null "> <if test="sign_date != null ">
,#{sign_date,typeHandler=com.vion.financial.handler.MilliDateTypeHandler} ,#{sign_date,typeHandler=com.vion.financial.handler.MilliDateTypeHandler}
</if> </if>
<if test="product_line_type != null and product_line_type != ''"> <if test="product_line_type != null and product_line_type != ''">
,#{product_line_type} ,#{product_line_type}
</if> </if>
<if test="contract_state != null and contract_state != ''"> <if test="contract_state != null and contract_state != ''">
,#{contract_state} ,#{contract_state}
</if> </if>
<if test="contract_type != null and contract_type != ''"> <if test="contract_type != null and contract_type != ''">
,#{contract_type} ,#{contract_type}
</if> </if>
<if test="contract_amount != null "> <if test="contract_amount != null ">
,#{contract_amount} ,#{contract_amount}
</if> </if>
<if test="deduct_amount != null "> <if test="deduct_amount != null ">
,#{deduct_amount} ,#{deduct_amount}
</if> </if>
<if test="contract_amount_note != null and contract_amount_note != ''"> <if test="contract_amount_note != null and contract_amount_note != ''">
,#{contract_amount_note} ,#{contract_amount_note}
</if> </if>
<if test="stop_amount != null "> <if test="stop_amount != null ">
,#{stop_amount} ,#{stop_amount}
</if> </if>
<if test="reback_note != null and reback_note != ''"> <if test="reback_note != null and reback_note != ''">
,#{reback_note} ,#{reback_note}
</if> </if>
<if test="exemptions_amount != null "> <if test="exemptions_amount != null ">
,#{exemptions_amount} ,#{exemptions_amount}
</if> </if>
<if test="contract_remain_note != null and contract_remain_note != ''"> <if test="contract_remain_note != null and contract_remain_note != ''">
,#{contract_remain_note} ,#{contract_remain_note}
</if> </if>
<if test="is_archive != null and is_archive != ''"> <if test="is_archive != null and is_archive != ''">
,#{is_archive} ,#{is_archive}
</if> </if>
<if test="bad_amount != null "> <if test="bad_amount != null ">
,#{bad_amount} ,#{bad_amount}
</if> </if>
<if test="bad_amount_note != null and bad_amount_note != ''"> <if test="bad_amount_note != null and bad_amount_note != ''">
,#{bad_amount_note} ,#{bad_amount_note}
</if> </if>
<if test="confirm_income_amount != null "> <if test="confirm_income_amount != null ">
,#{confirm_income_amount} ,#{confirm_income_amount}
</if> </if>
<if test="amount_state_unid != null and amount_state_unid != ''"> <if test="amount_state_unid != null and amount_state_unid != ''">
,#{amount_state_unid} ,#{amount_state_unid}
</if> </if>
<if test="start_guarantee_date != null "> <if test="start_guarantee_date != null ">
,#{start_guarantee_date,typeHandler=com.vion.financial.handler.MilliDateTypeHandler} ,#{start_guarantee_date,typeHandler=com.vion.financial.handler.MilliDateTypeHandler}
</if> </if>
<if test="end_guarantee_date != null "> <if test="end_guarantee_date != null ">
,#{end_guarantee_date,typeHandler=com.vion.financial.handler.MilliDateTypeHandler} ,#{end_guarantee_date,typeHandler=com.vion.financial.handler.MilliDateTypeHandler}
</if> </if>
<if test="mainten_start_point != null and mainten_start_point != ''"> <if test="mainten_start_point != null and mainten_start_point != ''">
,#{mainten_start_point} ,#{mainten_start_point}
</if> </if>
<if test="contract_note != null and contract_note != ''"> <if test="contract_note != null and contract_note != ''">
,#{contract_note} ,#{contract_note}
</if> </if>
,false ,false
<if test="project_unid != null and project_unid != ''"> <if test="project_unid != null and project_unid != ''">
,#{project_unid} ,#{project_unid}
</if> </if>
<if test="customer_unid != null and customer_unid != ''"> <if test="customer_unid != null and customer_unid != ''">
,#{customer_unid} ,#{customer_unid}
</if> </if>
<if test="province_name !=null and province_name !=''"> <if test="province_name !=null and province_name !=''">
,#{province_name} ,#{province_name}
</if> </if>
<if test="city_name !=null and city_name !=''"> <if test="city_name !=null and city_name !=''">
,#{city_name} ,#{city_name}
</if> </if>
<if test="county_name !=null and county_name !=''"> <if test="county_name !=null and county_name !=''">
,#{county_name} ,#{county_name}
</if> </if>
) )
</insert> </insert>
<select id="queryOne" resultType="com.vion.financial.vo.ContractVo" parameterType="java.lang.String"> <select id="queryOne" resultType="com.vion.financial.vo.ContractVo" parameterType="java.lang.String">
select select
contract_unid, salesperson_unid, province, city, county, province_name,city_name,county_name, contract_unid, salesperson_unid, province, city, county, province_name,city_name,county_name,
guarantee_period, sign_date, product_line_type, contract_state, guarantee_period, sign_date, product_line_type, contract_state,
contract_type, cast(contract_amount as decimal(18,2)), cast(deduct_amount as decimal(18,2)), contract_amount_note, contract_type, cast(contract_amount as decimal(18,2)), cast(deduct_amount as decimal(18,2)), contract_amount_note,
cast(stop_amount as decimal(18,2)), reback_note, cast(exemptions_amount as decimal(18,2)), contract_remain_note, cast(stop_amount as decimal(18,2)), reback_note, cast(exemptions_amount as decimal(18,2)), contract_remain_note,
is_archive, cast(bad_amount as decimal(18,2)), bad_amount_note, cast(confirm_income_amount as decimal(18,2)), is_archive, cast(bad_amount as decimal(18,2)), bad_amount_note, cast(confirm_income_amount as decimal(18,2)),
amount_state_unid, start_guarantee_date, end_guarantee_date, amount_state_unid, start_guarantee_date, end_guarantee_date,
mainten_start_point, contract_note, is_delete, project_unid, mainten_start_point, contract_note, is_delete, project_unid,
customer_unid, customer_unid,
(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, (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_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) 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 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 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_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, (select tb_customer.customer_name from tb_customer where tb_customer.customer_unid=tb_contract.customer_unid) as customer_name,
(select cast(e17_view.e17 as decimal(18,2)) from e17_view where e17_view.contract_unid=tb_contract.contract_unid) as advance_pay, (select cast(e17_view.e17 as decimal(18,2)) from e17_view where e17_view.contract_unid=tb_contract.contract_unid) as advance_pay,
(select cast(e18_view.e18 as decimal(18,2)) from e18_view where e18_view.contract_unid=tb_contract.contract_unid) as arrive_pay, (select cast(e18_view.e18 as decimal(18,2)) from e18_view where e18_view.contract_unid=tb_contract.contract_unid) as arrive_pay,
(select cast(e19_view.e19 as decimal(18,2)) from e19_view where e19_view.contract_unid=tb_contract.contract_unid) as acceptanc_pay, (select cast(e19_view.e19 as decimal(18,2)) from e19_view where e19_view.contract_unid=tb_contract.contract_unid) as acceptanc_pay,
(select cast(e21_view.e21 as decimal(18,2)) from e21_view where e21_view.contract_unid=tb_contract.contract_unid) as mainten_pay, (select cast(e21_view.e21 as decimal(18,2)) from e21_view where e21_view.contract_unid=tb_contract.contract_unid) as mainten_pay,
(select d18_view.d18 from d18_view where d18_view.contract_unid=tb_contract.contract_unid) as advance_pay_date, (select d18_view.d18 from d18_view where d18_view.contract_unid=tb_contract.contract_unid) as advance_pay_date,
(select d19_view.d19 from d19_view where d19_view.contract_unid=tb_contract.contract_unid) as arrive_pay_date, (select d19_view.d19 from d19_view where d19_view.contract_unid=tb_contract.contract_unid) as arrive_pay_date,
(select d20_view.d20 from d20_view where d20_view.contract_unid=tb_contract.contract_unid) as acceptanc_pay_date, (select d20_view.d20 from d20_view where d20_view.contract_unid=tb_contract.contract_unid) as acceptanc_pay_date,
(select d22_view.d21 from d22_view where d22_view.contract_unid=tb_contract.contract_unid) as mainten_pay_date, (select d22_view.d21 from d22_view where d22_view.contract_unid=tb_contract.contract_unid) as mainten_pay_date,
(select max(tb_deliver_goods.deliver_goods_date) from tb_deliver_goods where tb_deliver_goods.contract_unid=tb_contract.contract_unid ) as deliver_date, (select max(tb_deliver_goods.deliver_goods_date) from tb_deliver_goods where tb_deliver_goods.contract_unid=tb_contract.contract_unid ) as deliver_date,
(select max(tb_project_acceptanc.acceptanc_date) from tb_project_acceptanc where tb_project_acceptanc.contract_unid=tb_contract.contract_unid ) as acceptanc_date (select max(tb_project_acceptanc.acceptanc_date) from tb_project_acceptanc where tb_project_acceptanc.contract_unid=tb_contract.contract_unid ) as acceptanc_date
from tb_contract where contract_unid = #{contract_unid} from tb_contract where contract_unid = #{contract_unid}
</select> </select>
<update id="updateOne" parameterType="com.vion.financial.vo.ContractVo" keyColumn="contract_unid" keyProperty="contract_unid" useGeneratedKeys="true"> <update id="updateOne" parameterType="com.vion.financial.vo.ContractVo" keyColumn="contract_unid" keyProperty="contract_unid" useGeneratedKeys="true">
update tb_contract update tb_contract
<set> <set>
<if test="salesperson_unid != null and salesperson_unid != ''"> <if test="salesperson_unid != null and salesperson_unid != ''">
salesperson_unid=#{salesperson_unid}, salesperson_unid=#{salesperson_unid},
</if> </if>
<if test="province != null and province != ''"> <if test="province != null and province != ''">
province=#{province}, province=#{province},
province_name=#{province_name}, province_name=#{province_name},
</if> </if>
<if test="city !=null and city != ''"> <if test="city !=null and city != ''">
city=#{city}, city=#{city},
city_name=#{city_name}, city_name=#{city_name},
</if> </if>
<if test="county != null and county != ''"> <if test="county != null and county != ''">
county=#{county}, county=#{county},
county_name=#{county_name}, county_name=#{county_name},
</if> </if>
<if test="guarantee_period != null "> <if test="guarantee_period != null ">
guarantee_period=#{guarantee_period}, guarantee_period=#{guarantee_period},
</if> </if>
<if test="sign_date != null "> <if test="sign_date != null ">
sign_date=#{sign_date,typeHandler=com.vion.financial.handler.MilliDateTypeHandler}, sign_date=#{sign_date,typeHandler=com.vion.financial.handler.MilliDateTypeHandler},
</if> </if>
<if test="product_line_type != null and product_line_type != ''"> <if test="product_line_type != null and product_line_type != ''">
product_line_type=#{product_line_type}, product_line_type=#{product_line_type},
</if> </if>
<if test="contract_state != null and contract_state != ''"> <if test="contract_state != null and contract_state != ''">
contract_state=#{contract_state}, contract_state=#{contract_state},
</if> </if>
<if test="contract_type != null and contract_type != ''"> <if test="contract_type != null and contract_type != ''">
contract_type=#{contract_type}, contract_type=#{contract_type},
</if> </if>
contract_amount=#{contract_amount}, contract_amount=#{contract_amount},
deduct_amount=#{deduct_amount}, deduct_amount=#{deduct_amount},
<if test="contract_amount_note != null and contract_amount_note != ''"> <if test="contract_amount_note != null and contract_amount_note != ''">
contract_amount_note=#{contract_amount_note}, contract_amount_note=#{contract_amount_note},
</if> </if>
stop_amount=#{stop_amount}, stop_amount=#{stop_amount},
<if test="reback_note != null and reback_note != ''"> <if test="reback_note != null and reback_note != ''">
reback_note=#{reback_note}, reback_note=#{reback_note},
</if> </if>
exemptions_amount=#{exemptions_amount}, exemptions_amount=#{exemptions_amount},
<if test="contract_remain_note != null and contract_remain_note != ''"> <if test="contract_remain_note != null and contract_remain_note != ''">
contract_remain_note=#{contract_remain_note}, contract_remain_note=#{contract_remain_note},
</if> </if>
<if test="is_archive != null and is_archive != ''"> <if test="is_archive != null and is_archive != ''">
is_archive=#{is_archive}, is_archive=#{is_archive},
</if> </if>
bad_amount=#{bad_amount}, bad_amount=#{bad_amount},
<if test="bad_amount_note != null and bad_amount_note != ''"> <if test="bad_amount_note != null and bad_amount_note != ''">
bad_amount_note=#{bad_amount_note}, bad_amount_note=#{bad_amount_note},
</if> </if>
confirm_income_amount=#{confirm_income_amount}, confirm_income_amount=#{confirm_income_amount},
<if test="amount_state_unid != null and amount_state_unid != ''"> <if test="amount_state_unid != null and amount_state_unid != ''">
amount_state_unid=#{amount_state_unid}, amount_state_unid=#{amount_state_unid},
</if> </if>
<if test="start_guarantee_date != null "> <if test="start_guarantee_date != null ">
start_guarantee_date=#{start_guarantee_date,typeHandler=com.vion.financial.handler.MilliDateTypeHandler}, start_guarantee_date=#{start_guarantee_date,typeHandler=com.vion.financial.handler.MilliDateTypeHandler},
</if> </if>
<if test="end_guarantee_date != null "> <if test="end_guarantee_date != null ">
end_guarantee_date=#{end_guarantee_date,typeHandler=com.vion.financial.handler.MilliDateTypeHandler}, end_guarantee_date=#{end_guarantee_date,typeHandler=com.vion.financial.handler.MilliDateTypeHandler},
</if> </if>
<if test="mainten_start_point != null and mainten_start_point != ''"> <if test="mainten_start_point != null and mainten_start_point != ''">
mainten_start_point=#{mainten_start_point}, mainten_start_point=#{mainten_start_point},
</if> </if>
<if test="contract_note != null and contract_note != ''"> <if test="contract_note != null and contract_note != ''">
contract_note=#{contract_note}, contract_note=#{contract_note},
</if> </if>
<if test="is_delete != null and is_delete != ''"> <if test="is_delete != null and is_delete != ''">
is_delete=#{is_delete}, is_delete=#{is_delete},
</if> </if>
<if test="project_unid != null and project_unid != ''"> <if test="project_unid != null and project_unid != ''">
project_unid=#{project_unid}, project_unid=#{project_unid},
</if> </if>
<if test="customer_unid != null and customer_unid != ''"> <if test="customer_unid != null and customer_unid != ''">
customer_unid=#{customer_unid} customer_unid=#{customer_unid}
</if> </if>
</set> </set>
where contract_unid=#{contract_unid} where contract_unid=#{contract_unid}
</update> </update>
<delete id="deleteOne" parameterType="java.lang.String"> <delete id="deleteOne" parameterType="java.lang.String">
update tb_contract set is_delete = true where contract_unid = #{contract_unid} <!-- update tb_contract set is_delete = true where contract_unid = #{contract_unid} -->
<!-- delete from tb_contract where contract_unid = #{contract_unid} --> delete from tb_contract where contract_unid = #{contract_unid}
</delete> </delete>
<select id="count" parameterType="com.vion.financial.vo.SelectVo" resultType="int"> <select id="count" parameterType="com.vion.financial.vo.SelectVo" resultType="int">
select count(1) as count from tb_contract where 1=1 select count(1) as count from tb_contract where 1=1
<if test="contract_unid !=null and contract_unid !=''"> <if test="contract_unid !=null and contract_unid !=''">
and and
contract_unid=#{contract_unid} contract_unid=#{contract_unid}
</if> </if>
<if test="salesperson_unids !=null"> <if test="salesperson_unids !=null">
and and
salesperson_unid in salesperson_unid in
<foreach collection="salesperson_unids" index="index" item="salesperson_unid" open="(" close=")" separator=","> <foreach collection="salesperson_unids" index="index" item="salesperson_unid" open="(" close=")" separator=",">
#{salesperson_unid} #{salesperson_unid}
</foreach> </foreach>
</if> </if>
<if test="project_name__like !=null and project_name__like !=''"> <if test="project_name__like !=null and project_name__like !=''">
and and
tb_contract.project_unid in (select tb_project.project_unid from tb_project where project_name 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> </if>
<if test="customer_name__like !=null and customer_name__like !=''"> <if test="customer_name__like !=null and customer_name__like !=''">
and and
tb_contract.customer_unid in (select tb_customer.customer_unid from tb_customer where customer_name 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> </if>
<if test="province !=null and province !=''"> <if test="province !=null and province !=''">
and and
province=#{province} province=#{province}
</if> </if>
<if test="city !=null and city !=''"> <if test="city !=null and city !=''">
and and
city=#{city} city=#{city}
</if> </if>
<if test="county !=null and county !=''"> <if test="county !=null and county !=''">
and and
county=#{county} county=#{county}
</if> </if>
<if test="guarantee_period !=null "> <if test="guarantee_period !=null ">
and and
guarantee_period=#{guarantee_period} guarantee_period=#{guarantee_period}
</if> </if>
<if test="year !=null and year !=''"> <if test="year !=null and year !=''">
and and
to_char(sign_date,'yyyy')=#{year} to_char(sign_date,'yyyy')=#{year}
</if> </if>
<if test="month !=null and month!=''"> <if test="month !=null and month!=''">
and and
to_char(sign_date,'MM')=#{month} to_char(sign_date,'MM')=#{month}
</if> </if>
<if test="product_line_type !=null and product_line_type !=''"> <if test="product_line_type !=null and product_line_type !=''">
and and
product_line_type=#{product_line_type} product_line_type=#{product_line_type}
</if> </if>
<if test="contract_state !=null and contract_state!=''"> <if test="contract_state !=null and contract_state!=''">
and and
contract_state=#{contract_state} contract_state=#{contract_state}
</if> </if>
<if test="contract_type !=null and contract_type !=''"> <if test="contract_type !=null and contract_type !=''">
and and
contract_type=#{contract_type} contract_type=#{contract_type}
</if> </if>
<if test="is_archive !=null"> <if test="is_archive !=null">
and and
is_archive=#{is_archive} is_archive=#{is_archive}
</if> </if>
<if test="acceptanc_type !=null and acceptanc_type !=''"> <if test="acceptanc_type !=null and acceptanc_type !=''">
and and
contract_unid in (select tb_project_acceptanc.contract_unid from tb_project_acceptanc where tb_project_acceptanc.acceptanc_type=#{acceptanc_type}) contract_unid in (select tb_project_acceptanc.contract_unid from tb_project_acceptanc where tb_project_acceptanc.acceptanc_type=#{acceptanc_type})
</if> </if>
<if test="confirm_income_amount !=null"> <if test="confirm_income_amount !=null">
and and
confirm_income_amount=#{confirm_income_amount} confirm_income_amount=#{confirm_income_amount}
</if> </if>
<if test="amount_state_unid !=null and amount_state_unid !=''"> <if test="amount_state_unid !=null and amount_state_unid !=''">
and and
amount_state_unid=#{amount_state_unid} amount_state_unid=#{amount_state_unid}
</if> </if>
<if test="start_date != null and end_date !=null"> <if test="start_date != null and end_date !=null">
and and
#{start_date,typeHandler=com.vion.financial.handler.MilliDateTypeHandler} <![CDATA[<=]]> sign_date and sign_date <![CDATA[<=]]> #{end_date,typeHandler=com.vion.financial.handler.MilliDateTypeHandler} #{start_date,typeHandler=com.vion.financial.handler.MilliDateTypeHandler} <![CDATA[<=]]> sign_date and sign_date <![CDATA[<=]]> #{end_date,typeHandler=com.vion.financial.handler.MilliDateTypeHandler}
</if> </if>
<if test="amount_start_point !=null "> <if test="amount_start_point !=null ">
and and
contract_amount <![CDATA[>=]]> #{amount_start_point} contract_amount <![CDATA[>=]]> #{amount_start_point}
</if> </if>
<if test="amount_end_point !=null "> <if test="amount_end_point !=null ">
and and
contract_amount <![CDATA[<=]]> #{amount_end_point} contract_amount <![CDATA[<=]]> #{amount_end_point}
</if> </if>
<if test="overdays_start_point !=null and overdays_end_point == null"> <if test="overdays_start_point !=null and overdays_end_point == null">
and and
<!--逾期天数-->contract_unid in (select over_days_view.contract_unid from over_days_view where over_days <![CDATA[>=]]> #{overdays_start_point}) <!--逾期天数-->contract_unid in (select over_days_view.contract_unid from over_days_view where over_days <![CDATA[>=]]> #{overdays_start_point})
</if> </if>
<if test="overdays_start_point !=null and overdays_end_point !=null "> <if test="overdays_start_point !=null and overdays_end_point !=null ">
and and
<!--逾期天数-->contract_unid in (select over_days_view.contract_unid from over_days_view where over_days <![CDATA[>=]]> #{overdays_start_point} and over_days <![CDATA[<=]]> #{overdays_end_point}) <!--逾期天数-->contract_unid in (select over_days_view.contract_unid from over_days_view where over_days <![CDATA[>=]]> #{overdays_start_point} and over_days <![CDATA[<=]]> #{overdays_end_point})
</if> </if>
<if test="overdays_start_point ==null and overdays_end_point !=null"> <if test="overdays_start_point ==null and overdays_end_point !=null">
contract_unid in (select over_days_view.contract_unid from over_days_view where over_days <![CDATA[<=]]> #{overdays_end_point}) contract_unid in (select over_days_view.contract_unid from over_days_view where over_days <![CDATA[<=]]> #{overdays_end_point})
</if> </if>
<if test="leave_amount_start_point !=null "> <if test="leave_amount_start_point !=null ">
<!--应收款余额-->and <!--应收款余额-->and
contract_unid in (select receive_amount_view.contract_unid from receive_amount_view where receive_amount_view.leave_amount_point <![CDATA[>=]]> #{leave_amount_start_point}) contract_unid in (select receive_amount_view.contract_unid from receive_amount_view where receive_amount_view.leave_amount_point <![CDATA[>=]]> #{leave_amount_start_point})
</if> </if>
<if test="leave_amount_end_point !=null "> <if test="leave_amount_end_point !=null ">
and and
contract_unid in (select receive_amount_view.contract_unid from receive_amount_view where receive_amount_view.leave_amount_point <![CDATA[<=]]> #{leave_amount_end_point}) contract_unid in (select receive_amount_view.contract_unid from receive_amount_view where receive_amount_view.leave_amount_point <![CDATA[<=]]> #{leave_amount_end_point})
</if> </if>
and is_delete=false and is_delete=false
and project_unid is not null and project_unid is not null
and customer_unid is not null and customer_unid is not null
</select> </select>
<select id="selectByCondition" parameterType="com.vion.financial.vo.SelectVo" resultType="com.vion.financial.vo.ContractVo"> <select id="selectByCondition" parameterType="com.vion.financial.vo.SelectVo" resultType="com.vion.financial.vo.ContractVo">
select select
contract_unid, salesperson_unid, province, city, county, province_name,city_name,county_name, contract_unid, salesperson_unid, province, city, county, province_name,city_name,county_name,
guarantee_period, sign_date, product_line_type, contract_state, guarantee_period, sign_date, product_line_type, contract_state,
contract_type, cast(contract_amount as decimal(18,2)), cast(deduct_amount as decimal(18,2)), contract_amount_note, contract_type, cast(contract_amount as decimal(18,2)), cast(deduct_amount as decimal(18,2)), contract_amount_note,
cast(stop_amount as decimal(18,2)), reback_note, cast(exemptions_amount as decimal(18,2)), contract_remain_note, cast(stop_amount as decimal(18,2)), reback_note, cast(exemptions_amount as decimal(18,2)), contract_remain_note,
is_archive, cast(bad_amount as decimal(18,2)), bad_amount_note, cast(confirm_income_amount as decimal(18,2)), is_archive, cast(bad_amount as decimal(18,2)), bad_amount_note, cast(confirm_income_amount as decimal(18,2)),
amount_state_unid, start_guarantee_date, end_guarantee_date, amount_state_unid, start_guarantee_date, end_guarantee_date,
mainten_start_point, contract_note, is_delete, project_unid, mainten_start_point, contract_note, is_delete, project_unid,
customer_unid, customer_unid,
(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, (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_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) 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 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 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_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, (select tb_customer.customer_name from tb_customer where tb_customer.customer_unid=tb_contract.customer_unid) as customer_name,
(select cast(e17_view.e17 as decimal(18,2)) from e17_view where e17_view.contract_unid=tb_contract.contract_unid) as advance_pay, (select cast(e17_view.e17 as decimal(18,2)) from e17_view where e17_view.contract_unid=tb_contract.contract_unid) as advance_pay,
(select cast(e18_view.e18 as decimal(18,2)) from e18_view where e18_view.contract_unid=tb_contract.contract_unid) as arrive_pay, (select cast(e18_view.e18 as decimal(18,2)) from e18_view where e18_view.contract_unid=tb_contract.contract_unid) as arrive_pay,
(select cast(e19_view.e19 as decimal(18,2)) from e19_view where e19_view.contract_unid=tb_contract.contract_unid) as acceptanc_pay, (select cast(e19_view.e19 as decimal(18,2)) from e19_view where e19_view.contract_unid=tb_contract.contract_unid) as acceptanc_pay,
(select cast(e21_view.e21 as decimal(18,2)) from e21_view where e21_view.contract_unid=tb_contract.contract_unid) as mainten_pay, (select cast(e21_view.e21 as decimal(18,2)) from e21_view where e21_view.contract_unid=tb_contract.contract_unid) as mainten_pay,
(select d18_view.d18 from d18_view where d18_view.contract_unid=tb_contract.contract_unid) as advance_pay_date, (select d18_view.d18 from d18_view where d18_view.contract_unid=tb_contract.contract_unid) as advance_pay_date,
(select d19_view.d19 from d19_view where d19_view.contract_unid=tb_contract.contract_unid) as arrive_pay_date, (select d19_view.d19 from d19_view where d19_view.contract_unid=tb_contract.contract_unid) as arrive_pay_date,
(select d20_view.d20 from d20_view where d20_view.contract_unid=tb_contract.contract_unid) as acceptanc_pay_date, (select d20_view.d20 from d20_view where d20_view.contract_unid=tb_contract.contract_unid) as acceptanc_pay_date,
(select d22_view.d21 from d22_view where d22_view.contract_unid=tb_contract.contract_unid) as mainten_pay_date, (select d22_view.d21 from d22_view where d22_view.contract_unid=tb_contract.contract_unid) as mainten_pay_date,
(select max(tb_deliver_goods.deliver_goods_date) from tb_deliver_goods where tb_deliver_goods.contract_unid=tb_contract.contract_unid ) as deliver_date, (select max(tb_deliver_goods.deliver_goods_date) from tb_deliver_goods where tb_deliver_goods.contract_unid=tb_contract.contract_unid ) as deliver_date,
(select max(tb_project_acceptanc.acceptanc_date) from tb_project_acceptanc where tb_project_acceptanc.contract_unid=tb_contract.contract_unid ) as acceptanc_date (select max(tb_project_acceptanc.acceptanc_date) from tb_project_acceptanc where tb_project_acceptanc.contract_unid=tb_contract.contract_unid ) as acceptanc_date
from tb_contract where 1=1 from tb_contract where 1=1
<if test="contract_unid !=null and contract_unid !=''"> <if test="contract_unid !=null and contract_unid !=''">
and and
contract_unid=#{contract_unid} contract_unid=#{contract_unid}
</if> </if>
<if test="salesperson_unids !=null"> <if test="salesperson_unids !=null">
and and
salesperson_unid in salesperson_unid in
<foreach collection="salesperson_unids" index="index" item="salesperson_unid" open="(" close=")" separator=","> <foreach collection="salesperson_unids" index="index" item="salesperson_unid" open="(" close=")" separator=",">
#{salesperson_unid} #{salesperson_unid}
</foreach> </foreach>
</if> </if>
<if test="project_name__like !=null and project_name__like !=''"> <if test="project_name__like !=null and project_name__like !=''">
and and
tb_contract.project_unid in (select tb_project.project_unid from tb_project where project_name 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> </if>
<if test="customer_name__like !=null and customer_name__like !=''"> <if test="customer_name__like !=null and customer_name__like !=''">
and and
tb_contract.customer_unid in (select tb_customer.customer_unid from tb_customer where customer_name 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> </if>
<if test="province !=null and province !=''"> <if test="province !=null and province !=''">
and and
province=#{province} province=#{province}
</if> </if>
<if test="city !=null and city !=''"> <if test="city !=null and city !=''">
and and
city=#{city} city=#{city}
</if> </if>
<if test="county !=null and county !=''"> <if test="county !=null and county !=''">
and and
county=#{county} county=#{county}
</if> </if>
<if test="guarantee_period !=null "> <if test="guarantee_period !=null ">
and and
guarantee_period=#{guarantee_period} guarantee_period=#{guarantee_period}
</if> </if>
<if test="year !=null and year !=''"> <if test="year !=null and year !=''">
and and
to_char(sign_date,'yyyy')=#{year} to_char(sign_date,'yyyy')=#{year}
</if> </if>
<if test="month !=null and month!=''"> <if test="month !=null and month!=''">
and and
to_char(sign_date,'MM')=#{month} to_char(sign_date,'MM')=#{month}
</if> </if>
<if test="product_line_type !=null and product_line_type !=''"> <if test="product_line_type !=null and product_line_type !=''">
and and
product_line_type=#{product_line_type} product_line_type=#{product_line_type}
</if> </if>
<if test="contract_state !=null and contract_state!=''"> <if test="contract_state !=null and contract_state!=''">
and and
contract_state=#{contract_state} contract_state=#{contract_state}
</if> </if>
<if test="contract_type !=null and contract_type !=''"> <if test="contract_type !=null and contract_type !=''">
and and
contract_type=#{contract_type} contract_type=#{contract_type}
</if> </if>
<if test="is_archive !=null"> <if test="is_archive !=null">
and and
is_archive=#{is_archive} is_archive=#{is_archive}
</if> </if>
<if test="acceptanc_type !=null and acceptanc_type !=''"> <if test="acceptanc_type !=null and acceptanc_type !=''">
and and
contract_unid in (select tb_project_acceptanc.contract_unid from tb_project_acceptanc where tb_project_acceptanc.acceptanc_type=#{acceptanc_type}) contract_unid in (select tb_project_acceptanc.contract_unid from tb_project_acceptanc where tb_project_acceptanc.acceptanc_type=#{acceptanc_type})
</if> </if>
<if test="confirm_income_amount !=null"> <if test="confirm_income_amount !=null">
and and
confirm_income_amount=#{confirm_income_amount} confirm_income_amount=#{confirm_income_amount}
</if> </if>
<if test="amount_state_unid !=null and amount_state_unid !=''"> <if test="amount_state_unid !=null and amount_state_unid !=''">
and and
amount_state_unid=#{amount_state_unid} amount_state_unid=#{amount_state_unid}
</if> </if>
<if test="start_date != null "> <if test="start_date != null ">
and and
#{start_date,typeHandler=com.vion.financial.handler.MilliDateTypeHandler} <![CDATA[<=]]> sign_date #{start_date,typeHandler=com.vion.financial.handler.MilliDateTypeHandler} <![CDATA[<=]]> sign_date
</if> </if>
<if test="end_date !=null"> <if test="end_date !=null">
and sign_date <![CDATA[<=]]> #{end_date,typeHandler=com.vion.financial.handler.MilliDateTypeHandler} and sign_date <![CDATA[<=]]> #{end_date,typeHandler=com.vion.financial.handler.MilliDateTypeHandler}
</if> </if>
<if test="amount_start_point !=null "> <if test="amount_start_point !=null ">
and and
contract_amount <![CDATA[>=]]> #{amount_start_point} contract_amount <![CDATA[>=]]> #{amount_start_point}
</if> </if>
<if test="amount_end_point !=null "> <if test="amount_end_point !=null ">
and and
contract_amount <![CDATA[<=]]> #{amount_end_point} contract_amount <![CDATA[<=]]> #{amount_end_point}
</if> </if>
<if test="overdays_start_point !=null and overdays_end_point == null"> <if test="overdays_start_point !=null and overdays_end_point == null">
and and
<!--逾期天数-->contract_unid in (select over_days_view.contract_unid from over_days_view where over_days <![CDATA[>=]]> #{overdays_start_point}) <!--逾期天数-->contract_unid in (select over_days_view.contract_unid from over_days_view where over_days <![CDATA[>=]]> #{overdays_start_point})
</if> </if>
<if test="overdays_start_point !=null and overdays_end_point !=null "> <if test="overdays_start_point !=null and overdays_end_point !=null ">
and and
<!--逾期天数-->contract_unid in (select over_days_view.contract_unid from over_days_view where over_days <![CDATA[>=]]> #{overdays_start_point} and over_days <![CDATA[<=]]> #{overdays_end_point}) <!--逾期天数-->contract_unid in (select over_days_view.contract_unid from over_days_view where over_days <![CDATA[>=]]> #{overdays_start_point} and over_days <![CDATA[<=]]> #{overdays_end_point})
</if> </if>
<if test="overdays_start_point ==null and overdays_end_point !=null"> <if test="overdays_start_point ==null and overdays_end_point !=null">
contract_unid in (select over_days_view.contract_unid from over_days_view where over_days <![CDATA[<=]]> #{overdays_end_point}) contract_unid in (select over_days_view.contract_unid from over_days_view where over_days <![CDATA[<=]]> #{overdays_end_point})
</if> </if>
<if test="leave_amount_start_point !=null "> <if test="leave_amount_start_point !=null ">
<!--应收款余额-->and <!--应收款余额-->and
contract_unid in (select receive_amount_view.contract_unid from receive_amount_view where receive_amount_view.leave_amount_point <![CDATA[>=]]> #{leave_amount_start_point}) contract_unid in (select receive_amount_view.contract_unid from receive_amount_view where receive_amount_view.leave_amount_point <![CDATA[>=]]> #{leave_amount_start_point})
</if> </if>
<if test="leave_amount_end_point !=null "> <if test="leave_amount_end_point !=null ">
and and
contract_unid in (select receive_amount_view.contract_unid from receive_amount_view where receive_amount_view.leave_amount_point <![CDATA[<=]]> #{leave_amount_end_point}) contract_unid in (select receive_amount_view.contract_unid from receive_amount_view where receive_amount_view.leave_amount_point <![CDATA[<=]]> #{leave_amount_end_point})
</if> </if>
<if test="salesperson_unid !=null and salesperson_unid !=''"> <if test="salesperson_unid !=null and salesperson_unid !=''">
and and
salesperson_unid = #{salesperson_unid} salesperson_unid = #{salesperson_unid}
</if> </if>
and is_delete=false and is_delete=false
and project_unid is not null and project_unid is not null
and customer_unid is not null and customer_unid is not null
<if test="limit !=null "> <if test="limit !=null ">
limit #{limit} limit #{limit}
</if> </if>
<if test="offset !=null"> <if test="offset !=null">
offset #{offset} offset #{offset}
</if> </if>
</select> </select>
<select id="exportContracts" parameterType="com.vion.financial.vo.SelectVo" resultType="com.vion.financial.excel.ExportModel"> <select id="exportContracts" parameterType="com.vion.financial.vo.SelectVo" resultType="com.vion.financial.excel.ExportModel">
select select
contract_unid, salesperson_unid, province, city, county, province_name,city_name,county_name, <if test="columns == null">
guarantee_period, sign_date, product_line_type, contract_state, *
contract_type, cast(contract_amount as decimal(18,2)), cast(deduct_amount as decimal(18,2)), contract_amount_note, </if>
cast(stop_amount as decimal(18,2)), reback_note, cast(exemptions_amount as decimal(18,2)), contract_remain_note, <if test="columns !=null">
is_archive, cast(bad_amount as decimal(18,2)), bad_amount_note, cast(confirm_income_amount as decimal(18,2)), contract_unid,
amount_state_unid, start_guarantee_date, end_guarantee_date, <foreach collection="columns" index="index" item="column" separator=",">
mainten_start_point, contract_note, is_delete, project_unid, ${column}
customer_unid, </foreach>
to_char(sign_date,'yyyy') as year, to_char(sign_date,'MM') as month, </if>
(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, from (select
(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, contract_unid, salesperson_unid, province, city, county, province_name,city_name,county_name,
(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 , guarantee_period, sign_date, product_line_type, contract_state,
((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 , contract_type, cast(contract_amount as decimal(18,2)), cast(deduct_amount as decimal(18,2)), contract_amount_note,
(select over_days_view.over_days from over_days_view where over_days_view.contract_unid=tb_contract.contract_unid) as over_days, cast(stop_amount as decimal(18,2)), reback_note, cast(exemptions_amount as decimal(18,2)), contract_remain_note,
(select tb_project.project_name from tb_project where tb_project.project_unid=tb_contract.project_unid) as project_name, is_archive, cast(bad_amount as decimal(18,2)), bad_amount_note, cast(confirm_income_amount as decimal(18,2)),
(select tb_customer.customer_name from tb_customer where tb_customer.customer_unid=tb_contract.customer_unid) as customer_name, amount_state_unid, start_guarantee_date, end_guarantee_date,
(select cast(e17_view.e17 as decimal(18,2)) from e17_view where e17_view.contract_unid=tb_contract.contract_unid) as advance_pay, mainten_start_point, contract_note, is_delete, project_unid,
(select cast(e18_view.e18 as decimal(18,2)) from e18_view where e18_view.contract_unid=tb_contract.contract_unid) as arrive_pay, customer_unid,
(select cast(e19_view.e19 as decimal(18,2)) from e19_view where e19_view.contract_unid=tb_contract.contract_unid) as acceptanc_pay, to_char(sign_date,'yyyy') as year, to_char(sign_date,'MM') as month,
(select cast(e21_view.e21 as decimal(18,2)) from e21_view where e21_view.contract_unid=tb_contract.contract_unid) as mainten_pay, (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 d18_view.d18 from d18_view where d18_view.contract_unid=tb_contract.contract_unid) as advance_pay_date, (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 d19_view.d19 from d19_view where d19_view.contract_unid=tb_contract.contract_unid) as arrive_pay_date, (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 d20_view.d20 from d20_view where d20_view.contract_unid=tb_contract.contract_unid) as acceptanc_pay_date, ((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 d22_view.d21 from d22_view where d22_view.contract_unid=tb_contract.contract_unid) as mainten_pay_date, (select over_days_view.over_days from over_days_view where over_days_view.contract_unid=tb_contract.contract_unid) as over_days,
<!-- (select d21_view.d21 from d21_view where d21_view.contract_unid=tb_contract.contract_unid) as mainten_pay_deliver_date, (select tb_project.project_name from tb_project where tb_project.project_unid=tb_contract.project_unid) as project_name,
(select d22_view.d21 from d22_view where d22_view.contract_unid=tb_contract.contract_unid) as mainten_pay_acceptanc_date, --> (select tb_customer.customer_name from tb_customer where tb_customer.customer_unid=tb_contract.customer_unid) as customer_name,
(select max(tb_deliver_goods.deliver_goods_date) from tb_deliver_goods where tb_deliver_goods.contract_unid=tb_contract.contract_unid ) as deliver_date, (select cast(e17_view.e17 as decimal(18,2)) from e17_view where e17_view.contract_unid=tb_contract.contract_unid) as advance_pay,
(select max(tb_project_acceptanc.acceptanc_date) from tb_project_acceptanc where tb_project_acceptanc.contract_unid=tb_contract.contract_unid ) as acceptanc_date (select cast(e18_view.e18 as decimal(18,2)) from e18_view where e18_view.contract_unid=tb_contract.contract_unid) as arrive_pay,
from tb_contract where 1=1 (select cast(e19_view.e19 as decimal(18,2)) from e19_view where e19_view.contract_unid=tb_contract.contract_unid) as acceptanc_pay,
<if test="contract_unid !=null and contract_unid !=''"> (select cast(e21_view.e21 as decimal(18,2)) from e21_view where e21_view.contract_unid=tb_contract.contract_unid) as mainten_pay,
and (select d18_view.d18 from d18_view where d18_view.contract_unid=tb_contract.contract_unid) as advance_pay_date,
contract_unid=#{contract_unid} (select d19_view.d19 from d19_view where d19_view.contract_unid=tb_contract.contract_unid) as arrive_pay_date,
</if> (select d20_view.d20 from d20_view where d20_view.contract_unid=tb_contract.contract_unid) as acceptanc_pay_date,
<if test="salesperson_unids !=null"> (select d22_view.d21 from d22_view where d22_view.contract_unid=tb_contract.contract_unid) as mainten_pay_date,
and <!-- (select d21_view.d21 from d21_view where d21_view.contract_unid=tb_contract.contract_unid) as mainten_pay_deliver_date,
salesperson_unid in (select d22_view.d21 from d22_view where d22_view.contract_unid=tb_contract.contract_unid) as mainten_pay_acceptanc_date, -->
<foreach collection="salesperson_unids" index="index" item="salesperson_unid" open="(" close=")" separator=","> (select max(tb_deliver_goods.deliver_goods_date) from tb_deliver_goods where tb_deliver_goods.contract_unid=tb_contract.contract_unid ) as deliver_date,
#{salesperson_unid} (select max(tb_project_acceptanc.acceptanc_date) from tb_project_acceptanc where tb_project_acceptanc.contract_unid=tb_contract.contract_unid ) as acceptanc_date
</foreach> from tb_contract where 1=1
</if> <if test="contract_unid !=null and contract_unid !=''">
<if test="project_name__like !=null and project_name__like !=''"> and
and contract_unid=#{contract_unid}
tb_contract.project_unid in (select tb_project.project_unid from tb_project where project_name like '%'||#{project_name__like}||'%') </if>
</if> <if test="salesperson_unids !=null">
<if test="customer_name__like !=null and customer_name__like !=''"> and
and salesperson_unid in
tb_contract.customer_unid in (select tb_customer.customer_unid from tb_customer where customer_name like '%'||#{customer_name__like}||'%') <foreach collection="salesperson_unids" index="index" item="salesperson_unid" open="(" close=")" separator=",">
</if> #{salesperson_unid}
<if test="province !=null and province !=''"> </foreach>
and </if>
province=#{province} <if test="project_name__like !=null and project_name__like !=''">
</if> and
<if test="city !=null and city !=''"> tb_contract.project_unid in (select tb_project.project_unid from tb_project where project_name like '%'||#{project_name__like}||'%')
and </if>
city=#{city} <if test="customer_name__like !=null and customer_name__like !=''">
</if> and
<if test="county !=null and county !=''"> tb_contract.customer_unid in (select tb_customer.customer_unid from tb_customer where customer_name like '%'||#{customer_name__like}||'%')
and </if>
county=#{county} <if test="province !=null and province !=''">
</if> and
<if test="guarantee_period !=null "> province=#{province}
and </if>
guarantee_period=#{guarantee_period} <if test="city !=null and city !=''">
</if> and
<if test="year !=null and year !=''"> city=#{city}
and </if>
to_char(sign_date,'yyyy')=#{year} <if test="county !=null and county !=''">
</if> and
<if test="month !=null and month!=''"> county=#{county}
and </if>
to_char(sign_date,'MM')=#{month} <if test="guarantee_period !=null ">
</if> and
<if test="product_line_type !=null and product_line_type !=''"> guarantee_period=#{guarantee_period}
and </if>
product_line_type=#{product_line_type} <if test="year !=null and year !=''">
</if> and
<if test="contract_state !=null and contract_state!=''"> to_char(sign_date,'yyyy')=#{year}
and </if>
contract_state=#{contract_state} <if test="month !=null and month!=''">
</if> and
<if test="contract_type !=null and contract_type !=''"> to_char(sign_date,'MM')=#{month}
and </if>
contract_type=#{contract_type} <if test="product_line_type !=null and product_line_type !=''">
</if> and
<if test="is_archive !=null"> product_line_type=#{product_line_type}
and </if>
is_archive=#{is_archive} <if test="contract_state !=null and contract_state!=''">
</if> and
<if test="acceptanc_type !=null and acceptanc_type !=''"> contract_state=#{contract_state}
and </if>
contract_unid in (select tb_project_acceptanc.contract_unid from tb_project_acceptanc where tb_project_acceptanc.acceptanc_type=#{acceptanc_type}) <if test="contract_type !=null and contract_type !=''">
</if> and
<if test="confirm_income_amount !=null"> contract_type=#{contract_type}
and </if>
confirm_income_amount=#{confirm_income_amount} <if test="is_archive !=null">
</if> and
<if test="amount_state_unid !=null and amount_state_unid !=''"> is_archive=#{is_archive}
and </if>
amount_state_unid=#{amount_state_unid} <if test="acceptanc_type !=null and acceptanc_type !=''">
</if> and
<if test="start_date != null "> contract_unid in (select tb_project_acceptanc.contract_unid from tb_project_acceptanc where tb_project_acceptanc.acceptanc_type=#{acceptanc_type})
and </if>
#{start_date,typeHandler=com.vion.financial.handler.MilliDateTypeHandler} <![CDATA[<=]]> sign_date <if test="confirm_income_amount !=null">
</if> and
<if test="end_date!=null"> confirm_income_amount=#{confirm_income_amount}
and sign_date <![CDATA[<=]]> #{end_date,typeHandler=com.vion.financial.handler.MilliDateTypeHandler} </if>
</if> <if test="amount_state_unid !=null and amount_state_unid !=''">
<if test="amount_start_point !=null "> and
and amount_state_unid=#{amount_state_unid}
contract_amount <![CDATA[>=]]> #{amount_start_point} </if>
</if> <if test="start_date != null ">
<if test="amount_end_point !=null "> and
and #{start_date,typeHandler=com.vion.financial.handler.MilliDateTypeHandler} <![CDATA[<=]]> sign_date
contract_amount <![CDATA[<=]]> #{amount_end_point} </if>
</if> <if test="end_date!=null">
<!-- <if test="overdays_start_point !=null "> and sign_date <![CDATA[<=]]> #{end_date,typeHandler=com.vion.financial.handler.MilliDateTypeHandler}
and </if>
逾期天数contract_unid in (select over_days_view.contract_unid from over_days_view where over_days <![CDATA[>=]]> #{overdays_start_point}) <if test="amount_start_point !=null ">
</if> and
<if test="overdays_end_point !=null "> contract_amount <![CDATA[>=]]> #{amount_start_point}
and </if>
逾期天数contract_unid in (select over_days_view.contract_unid from over_days_view where over_days <![CDATA[<=]]> #{overdays_end_point}) <if test="amount_end_point !=null ">
</if> --> and
<if test="overdays_start_point !=null and overdays_end_point == null"> contract_amount <![CDATA[<=]]> #{amount_end_point}
and </if>
<!--逾期天数-->contract_unid in (select over_days_view.contract_unid from over_days_view where over_days <![CDATA[>=]]> #{overdays_start_point}) <!-- <if test="overdays_start_point !=null ">
</if> and
<if test="overdays_start_point !=null and overdays_end_point !=null "> 逾期天数contract_unid in (select over_days_view.contract_unid from over_days_view where over_days <![CDATA[>=]]> #{overdays_start_point})
and </if>
<!--逾期天数-->contract_unid in (select over_days_view.contract_unid from over_days_view where over_days <![CDATA[>=]]> #{overdays_start_point} and over_days <![CDATA[<=]]> #{overdays_end_point}) <if test="overdays_end_point !=null ">
</if> and
<if test="overdays_start_point ==null and overdays_end_point !=null"> 逾期天数contract_unid in (select over_days_view.contract_unid from over_days_view where over_days <![CDATA[<=]]> #{overdays_end_point})
contract_unid in (select over_days_view.contract_unid from over_days_view where over_days <![CDATA[<=]]> #{overdays_end_point}) </if> -->
</if> <if test="overdays_start_point !=null and overdays_end_point == null">
<if test="leave_amount_start_point !=null "> and
<!--应收款余额-->and <!--逾期天数-->contract_unid in (select over_days_view.contract_unid from over_days_view where over_days <![CDATA[>=]]> #{overdays_start_point})
contract_unid in (select receive_amount_view.contract_unid from receive_amount_view where receive_amount_view.leave_amount_point <![CDATA[>=]]> #{leave_amount_start_point}) </if>
</if> <if test="overdays_start_point !=null and overdays_end_point !=null ">
<if test="leave_amount_end_point !=null "> and
contract_unid in (select receive_amount_view.contract_unid from receive_amount_view where receive_amount_view.leave_amount_point <![CDATA[<=]]> #{leave_amount_end_point}) <!--逾期天数-->contract_unid in (select over_days_view.contract_unid from over_days_view where over_days <![CDATA[>=]]> #{overdays_start_point} and over_days <![CDATA[<=]]> #{overdays_end_point})
</if> </if>
and is_delete=false <if test="overdays_start_point ==null and overdays_end_point !=null">
and project_unid is not null contract_unid in (select over_days_view.contract_unid from over_days_view where over_days <![CDATA[<=]]> #{overdays_end_point})
and customer_unid is not null </if>
</select> <if test="leave_amount_start_point !=null ">
<!--应收款余额-->and
contract_unid in (select receive_amount_view.contract_unid from receive_amount_view where receive_amount_view.leave_amount_point <![CDATA[>=]]> #{leave_amount_start_point})
<select id="isDelete" parameterType="String" resultType="Boolean"> </if>
select is_delete from tb_contract where contract_unid = #{contract_unid} <if test="leave_amount_end_point !=null ">
</select> contract_unid in (select receive_amount_view.contract_unid from receive_amount_view where receive_amount_view.leave_amount_point <![CDATA[<=]]> #{leave_amount_end_point})
<select id="queryList" resultType="String"> </if>
select contract_unid from tb_contract where and is_delete=false
is_delete=false and project_unid is not null
<!-- and project_unid is null and customer_unid is not null
and customer_unid is null --> ) contract
</select> </select>
<select id="countNumber" resultType="int">
select count(contract_unid) from tb_contract where is_delete=false
</select> <select id="isDelete" parameterType="String" resultType="Boolean">
<delete id="actualDeleteOne" parameterType="String"> select is_delete from tb_contract where contract_unid = #{contract_unid}
delete from tb_contract where contract_unid = #{contract_unid} </select>
</delete> <select id="queryList" resultType="String">
</mapper> select contract_unid from tb_contract where
is_delete=false
<!-- and project_unid is null
and customer_unid is null -->
</select>
<select id="countNumber" resultType="int">
select count(contract_unid) from tb_contract where is_delete=false
</select>
<delete id="actualDeleteOne" parameterType="String">
delete from tb_contract where contract_unid = #{contract_unid}
</delete>
</mapper>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!