1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- <?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.ruoyi.web.work.mapper.StatementMapper">
- <sql id="selectStatementVo">
- SELECT
- s.id,
- s.company_id,
- s.num,
- s.channel,
- s.invoice,
- s.state,
- s.audit,
- s.give,
- s.batch_name,
- s.file_name,
- s.msg,
- s.service_company,
- s.create_time,
- s.generate_time,
- s.submit_time,
- s.audit_time,
- s.give_time,
- ( SELECT COUNT( d.id ) FROM tb_statement_detail d WHERE d.statement_id = s.id ) AS peoples,
- ( SELECT SUM( d.money ) FROM tb_statement_detail d WHERE d.statement_id = s.id ) AS money,
- ( SELECT SUM( d.real_money ) FROM tb_statement_detail d WHERE d.statement_id = s.id ) AS real_money,
- ( SELECT SUM( d.service_money ) FROM tb_statement_detail d WHERE d.statement_id = s.id ) AS service_money,
- p.project_name,
- c.company_name
- FROM
- tb_statement s
- LEFT JOIN tb_project p ON p.id = s.project_id
- LEFT JOIN tb_company c ON c.id = s.company_id
- </sql>
- <select id="selectList" resultType="com.ruoyi.web.work.domain.Statement">
- <include refid="selectStatementVo"/>
- <where>
- <if test="companyId != null "> and s.company_id = #{companyId}</if>
- <if test="batchName != null and batchName != ''"> and s.batch_name like concat('%', #{batchName}, '%')</if>
- <if test="num != null and num != ''"> and s.num like concat('%', #{num}, '%')</if>
- <if test="projectId != null "> and s.project_id = #{projectId}</if>
- <if test="state != null "> and s.state = #{state}</if>
- <if test="give != null "> and s.give = #{give}</if>
- <if test="dateBegin != null and dateBegin != ''"> AND s.give_time BETWEEN #{dateBegin} AND #{dateEnd} + INTERVAL 1 DAY</if>
- <choose>
- <when test="auditors">
- <if test="audit == null "> and s.audit <![CDATA[ >= ]]> 1</if>
- <if test="audit != null "> and s.audit=#{audit} and s.audit <![CDATA[ >= ]]> 1</if>
- </when>
- <otherwise>
- <if test="audit != null "> and s.audit = #{audit}</if>
- </otherwise>
- </choose>
- </where>
- </select>
- <select id="selectPayList" resultType="com.ruoyi.web.work.domain.Statement">
- <include refid="selectStatementVo"/>
- <where>
- <if test="num != null and num != ''"> and s.num like concat('%', #{num}, '%')</if>
- <choose>
- <when test="give != null">and s.give=#{give} and s.give <![CDATA[ >= ]]> 1</when>
- <otherwise>and s.give <![CDATA[ >= ]]> 1</otherwise>
- </choose>
- <if test="dateBegin != null and dateBegin != ''"> AND s.give_time BETWEEN #{dateBegin} AND #{dateEnd} + INTERVAL 1 DAY</if>
- </where>
- </select>
- <select id="calculate" resultType="com.ruoyi.web.work.domain.Statement">
- SELECT
- s.id,
- s.audit,
- s.give,
- s.company_id,
- ( SELECT SUM( d.money ) FROM tb_statement_detail d WHERE d.statement_id = s.id ) AS money,
- ( SELECT SUM( d.real_money ) FROM tb_statement_detail d WHERE d.statement_id = s.id ) AS realMoney,
- ( SELECT SUM( d.service_money ) FROM tb_statement_detail d WHERE d.statement_id = s.id ) AS serviceMoney,
- ( SELECT COUNT( d.id ) FROM tb_statement_detail d WHERE d.statement_id = s.id ) AS peoples
- FROM
- tb_statement s
- WHERE
- s.id =#{id}
- </select>
- </mapper>
|