znpt-backend/core/src/main/resources/mapper/ContractMapper.xml

81 lines
3.8 KiB
XML

<?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">
<mapper namespace="com.dite.znpt.mapper.ContractMapper">
<sql id="Base_Column_List">
a.contract_id, a.customer, a.code, a.project_id,
a.salesperson_id, a.department_id, a.sign_date, a.duration,
a.type, a.product_service, a.payment_date, a.payment_address,
a.amount, a.account_number, a.notes, a.contract_status,
a.create_time, a.create_by, a.update_time, a.update_by
</sql>
<select id="queryBySelective" resultType="com.dite.znpt.domain.vo.ContractResp">
select
<include refid="Base_Column_List"/>,
u.name as salespersonName, d.dept_name as salespersonDeptName,
p.project_name, (select sum(cs.amount) from contract_settlement cs where a.contract_id=cs.contract_id) as settlementAmount
from contract a
left join user u on a.salesperson_id = u.user_id
left join dept d on a.department_id=d.dept_id
left join project p on a.project_id=p.project_id
<where>
<if test="contractId != null and contractId != ''">
and a.contract_id like concat ('%', #{contractId}, '%')
</if>
<if test="customer != null and customer != ''">
and a.customer like concat ('%', #{customer}, '%')
</if>
<if test="code != null and code != ''">
and a.code like concat ('%', #{code}, '%')
</if>
<if test="projectId != null and projectId != ''">
and a.project_id like concat ('%', #{projectId}, '%')
</if>
<if test="salespersonId != null and salespersonId != ''">
and a.salesperson_id like concat ('%', #{salespersonId}, '%')
</if>
<if test="departmentId != null and departmentId != ''">
and a.department_id like concat ('%', #{departmentId}, '%')
</if>
<if test="signDate != null">
and a.sign_date = #{signDate}
</if>
<if test="duration != null and duration != ''">
and a.duration like concat ('%', #{duration}, '%')
</if>
<if test="type != null and type != ''">
and a.type like concat ('%', #{type}, '%')
</if>
<if test="productService != null and productService != ''">
and a.product_service like concat ('%', #{productService}, '%')
</if>
<if test="paymentDate != null">
and a.payment_date = #{paymentDate}
</if>
<if test="performanceDeadline != null">
and a.performance_deadline = #{performanceDeadline}
</if>
<if test="paymentAddress != null and paymentAddress != ''">
and a.payment_address like concat ('%', #{paymentAddress}, '%')
</if>
<if test="amount != null">
and a.amount = #{amount}
</if>
<if test="accountNumber != null and accountNumber != ''">
and a.account_number like concat ('%', #{accountNumber}, '%')
</if>
<if test="notes != null">
and a.notes = #{notes}
</if>
<if test="contractStatus != null and contractStatus != ''">
and a.contract_status like concat ('%', #{contractStatus}, '%')
</if>
<if test="contractText != null">
and a.contract_text like concat ('%', #{contractText}, '%')
</if>
</where>
</select>
</mapper>