| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161 |
- <?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="cn.start.tz.module.pressure2.dal.mysql.taskordernontaxapply.TaskOrderLeftJoinMapper">
- <!--
- 一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
- 无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
- 代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
- 文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
- -->
- <select id="selectTaskOrderPaymentPage" resultType="cn.start.tz.module.pressure2.controller.admin.taskordernontaxapply.vo.TaskOrderPaymentRespVO">
- SELECT
- t.id,
- t.order_no AS orderNo,
- t.dept_id AS deptId,
- t.payer_contact_name AS payerContactName,
- t.payer_contact AS payerContact,
- t.actual_amount AS actualAmount,
- t.should_amount AS shouldAmount,
- t.service_amount AS serviceAmount,
- t.use_unit_id AS useUnitId,
- t.use_unit_name AS useUnitName,
- t.check_type AS checkType,
- t.equip_num AS equipNum,
- t.check_date AS checkDate,
- t.payment_status AS paymentStatus,
- t.no_tax_payment_status AS noTaxPaymentStatus,
- t.confirm_date AS confirmDate,
- t.reduction_radio AS reductionRadio,
- t.equip_main_type AS equipMainType,
- p.remark AS followRemark,
- p.creator AS followId,
- p.create_time AS followTime,
- c.Is_Exempt as IsExempt
- FROM pressure_task_order t
- LEFT JOIN pressure2_payment_follow_record p ON p.task_order_id = t.id AND p.deleted = 0
- AND p.id IN (
- SELECT id FROM pressure2_payment_follow_record
- WHERE deleted = 0
- AND (task_order_id, create_time) IN (
- SELECT task_order_id, MAX(create_time)
- FROM pressure2_payment_follow_record
- WHERE deleted = 0
- GROUP BY task_order_id
- )
- )
- left join system_client_unit c on c.CODE = t.UNIT_CODE and c.deleted = 0
- WHERE t.deleted = 0 AND t.equip_main_type in (200,300)
- AND t.task_status = 800
- <if test="reqVO.paymentStatus != null">
- AND t.payment_status = #{reqVO.paymentStatus}
- </if>
- <if test="reqVO.noTaxPaymentStatus != null">
- AND t.no_tax_payment_status = #{reqVO.noTaxPaymentStatus}
- </if>
- <if test="reqVO.feeType != null">
- AND t.fee_type = #{reqVO.feeType}
- </if>
- <if test="reqVO.checkType != null">
- AND t.check_type = #{reqVO.checkType}
- </if>
- <if test="reqVO.payerContactName != null and reqVO.payerContactName != ''">
- AND t.payer_contact_name LIKE CONCAT('%', #{reqVO.payerContactName}, '%')
- </if>
- <if test="reqVO.payerContact != null and reqVO.payerContact != ''">
- AND t.payer_contact LIKE CONCAT('%', #{reqVO.payerContact}, '%')
- </if>
- <if test="reqVO.useUnitName != null and reqVO.useUnitName != ''">
- AND t.use_unit_name LIKE CONCAT('%', #{reqVO.useUnitName}, '%')
- </if>
- <if test="reqVO.orderNo != null and reqVO.orderNo != ''">
- AND t.order_no LIKE CONCAT('%', #{reqVO.orderNo}, '%')
- </if>
- <if test="reqVO.followById != null and reqVO.followById != ''">
- AND p.creator = #{reqVO.followById}
- </if>
- <if test="reqVO.isExempt != null and reqVO.isExempt != ''">
- AND c.Is_Exempt = #{reqVO.isExempt}
- </if>
- <if test="reqVO.useUnitId != null">
- AND t.use_unit_id = #{reqVO.useUnitId}
- </if>
- <if test="reqVO.checkDate != null and reqVO.checkDate.length > 0">
- AND t.check_date BETWEEN #{reqVO.checkDate[0]} AND #{reqVO.checkDate[1]}
- </if>
- <if test="reqVO.deptId != null and reqVO.deptId != ''">
- AND t.dept_id = #{reqVO.deptId}
- </if>
- <if test="reqVO.equipMainType != null">
- AND t.equip_main_type = #{reqVO.equipMainType}
- </if>
- ORDER BY t.create_time DESC
- OFFSET ${(reqVO.pageNo - 1) * reqVO.pageSize} ROWS FETCH NEXT #{reqVO.pageSize} ROWS ONLY
- </select>
- <select id="selectTaskOrderPaymentCount" resultType="java.lang.Long">
- SELECT COUNT(DISTINCT t.id)
- FROM pressure_task_order t
- LEFT JOIN pressure2_payment_follow_record p ON p.task_order_id = t.id AND p.deleted = 0
- AND p.id IN (
- SELECT id FROM pressure2_payment_follow_record
- WHERE deleted = 0
- AND (task_order_id, create_time) IN (
- SELECT task_order_id, MAX(create_time)
- FROM pressure2_payment_follow_record
- WHERE deleted = 0
- GROUP BY task_order_id
- )
- )
- left join system_client_unit c on c.CODE = t.UNIT_CODE and c.deleted = 0
- WHERE t.deleted = 0 AND t.equip_main_type in (200,300)
- AND t.task_status = 800
- <if test="reqVO.paymentStatus != null">
- AND t.payment_status = #{reqVO.paymentStatus}
- </if>
- <if test="reqVO.noTaxPaymentStatus != null">
- AND t.no_tax_payment_status = #{reqVO.noTaxPaymentStatus}
- </if>
- <if test="reqVO.feeType != null">
- AND t.fee_type = #{reqVO.feeType}
- </if>
- <if test="reqVO.checkType != null">
- AND t.check_type = #{reqVO.checkType}
- </if>
- <if test="reqVO.payerContactName != null and reqVO.payerContactName != ''">
- AND t.payer_contact_name LIKE CONCAT('%', #{reqVO.payerContactName}, '%')
- </if>
- <if test="reqVO.payerContact != null and reqVO.payerContact != ''">
- AND t.payer_contact LIKE CONCAT('%', #{reqVO.payerContact}, '%')
- </if>
- <if test="reqVO.useUnitName != null and reqVO.useUnitName != ''">
- AND t.use_unit_name LIKE CONCAT('%', #{reqVO.useUnitName}, '%')
- </if>
- <if test="reqVO.orderNo != null and reqVO.orderNo != ''">
- AND t.order_no LIKE CONCAT('%', #{reqVO.orderNo}, '%')
- </if>
- <if test="reqVO.followById != null and reqVO.followById != ''">
- AND p.creator = #{reqVO.followById}
- </if>
- <if test="reqVO.isExempt != null and reqVO.isExempt != ''">
- AND c.Is_Exempt = #{reqVO.isExempt}
- </if>
- <if test="reqVO.useUnitId != null">
- AND t.use_unit_id = #{reqVO.useUnitId}
- </if>
- <if test="reqVO.deptId != null and reqVO.deptId != ''">
- AND t.dept_id = #{reqVO.deptId}
- </if>
- <if test="reqVO.equipMainType != null">
- AND t.equip_main_type = #{reqVO.equipMainType}
- </if>
- </select>
- </mapper>
|