123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127 |
- <?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.dayou.mapper.FinanceFineRefundMapper">
- <!-- 通用查询映射结果 -->
- <resultMap id="BaseResultMap" type="com.dayou.entity.FinanceFineRefund">
- <result column="id" property="id" />
- <result column="deleted" property="deleted" />
- <result column="modified" property="modified" />
- <result column="created" property="created" />
- <result column="fine_id" property="fineId" />
- <result column="refund_amount" property="refundAmount" />
- <result column="refund_reason" property="refundReason" />
- <result column="status" property="status" />
- <result column="user_id" property="userId" />
- <result column="refund_date" property="refundDate" />
- </resultMap>
- <!-- 通用查询结果列 -->
- <sql id="Base_Column_List">
- id,
- deleted,
- modified,
- created,
- fine_id, refund_amount, refund_reason, statue, user_id, refund_date
- </sql>
- <sql id="financeFineRefundVOSql">
- SELECT refund.id AS id,
- refund.fine_id AS fineId,
- oFund.order_id AS orderId,
- oFund.order_name AS orderName,
- <if test="dto != null and dto.businessType == 'ASSET_BUSINESS' or dto.businessType == 'MAJOR_BUSINESS'">
- pFund.production_no AS productionNo,
- `order`.bailor AS bailor,
- </if>
- <if test="dto != null and dto.businessType == 'PERSONAL_BUSINESS'">
- `order`.order_id AS productionNo,
- CONCAT(`order`.bailorA, IF(`order`.bailorB IS NOT NULL AND `order`.bailorB != '', ',', ''), `order`.bailorB) AS bailor,
- </if>
- <if test="dto != null and dto.businessType == 'ASSET_BUSINESS'">
- CASE pFund.production_type WHEN 'LETTER' THEN '意见函' WHEN 'CONSULT' THEN '咨询报告' WHEN 'REPORT' THEN '评估报告' ELSE '-' END AS productionType,
- </if>
- <if test="dto != null and dto.businessType == 'MAJOR_BUSINESS'">
- CASE pFund.production_type WHEN 'LETTER' THEN '复评函' WHEN 'REPORT' THEN '报告' WHEN 'STATEMENT' THEN '价值意见书' ELSE '-' END AS productionType,
- </if>
- <if test="dto != null and dto.businessType == 'PERSONAL_BUSINESS'">
- CASE pro.production WHEN 'FINAL' THEN '结果报告' WHEN 'TECHNIC' THEN '技术报告' ELSE '-' END AS productionType,
- </if>
- user.name AS clientManagerName,
- customer.name AS customerName,
- subCustomer.name AS customerSubName,
- fine.real_fine_amount AS finedAmount,
- fine.created AS punishDate,
- refund.refund_amount AS refundAmount,
- refund.refund_date AS refundDate,
- refund.refund_amount AS refundAmount,
- refund.refund_reason AS refundReason,
- refund.status AS status,
- operator.name AS operator,
- refund.refund_date AS refundDate
- FROM finance_fine_refund AS refund
- LEFT JOIN finance_fine AS fine ON fine.deleted = 0 AND fine.id = refund.fine_id
- LEFT JOIN order_fund AS oFund ON oFund.deleted = 0 AND oFund.id = fine.order_fund_id
- <if test="dto != null and dto.businessType == 'ASSET_BUSINESS'">
- LEFT JOIN production_fund AS pFund ON pFund.deleted = 0 AND pFund.id = fine.production_fund_id AND pFund.order_fund_id = fine.order_fund_id
- LEFT JOIN ( SELECT business_id, production_no, repertory_out_time FROM assets_production WHERE deleted = 0 AND repertory_out_time IS NOT NULL AND production_type != 'STATEMENT') AS pro
- ON pFund.business_id = pro.business_id AND pFund.production_no = pro.production_no
- LEFT JOIN assets AS `order` ON `order`.deleted = 0 AND `order`.id = pFund.business_id
- </if>
- <if test="dto != null and dto.businessType == 'MAJOR_BUSINESS'">
- LEFT JOIN production_fund AS pFund ON pFund.deleted = 0 AND pFund.id = fine.production_fund_id AND pFund.order_fund_id = fine.order_fund_id
- LEFT JOIN ( SELECT major_id AS business_id, report_no AS production_no, repertory_out_time, production FROM major_production WHERE deleted = 0 AND repertory_out_time IS NOT NULL) AS pro
- ON pFund.business_id = pro.business_id AND pFund.production_no = pro.production_no AND production = pFund.production_type
- LEFT JOIN major AS `order` ON `order`.deleted = 0 AND `order`.id = pFund.business_id
- </if>
- <if test="dto != null and dto.businessType == 'PERSONAL_BUSINESS'">
- LEFT JOIN personal_target pt ON pt.personal_id = oFund.business_id
- LEFT JOIN ( SELECT target_id,repertory_out_time, production FROM personal_production WHERE repertory_out_time IS NOT NULL GROUP BY target_id ) AS pro ON pro.target_id = pt.id
- LEFT JOIN personal AS `order` ON `order`.deleted = 0 AND `order`.id = oFund.business_id
- </if>
- LEFT JOIN customer_company AS customer ON customer.id = `order`.clientele_id
- LEFT JOIN customer_company AS subCustomer ON subCustomer.id = `order`.clientele_sub_id
- LEFT JOIN user ON `order`.client_manager_id = user.id AND user.deleted = 0
- LEFT JOIN user AS operator ON user.deleted = 0 AND user.id = refund.user_id
- WHERE oFund.business_type = #{dto.businessType}
- <if test="dto != null and dto.keyWord != null and dto.keyWord != ''">
- AND (`order`.order_id LIKE CONCAT('%', #{dto.keyWord},'%')
- <if test="dto != null and dto.businessType == 'ASSET_BUSINESS' or dto.businessType == 'MAJOR_BUSINESS'">
- OR pFund.production_no LIKE CONCAT('%', #{dto.keyWord},'%')
- </if>
- )
- </if>
- <if test="dto != null and dto.finedAmount != null">
- AND fine.real_fine_amount = #{dto.finedAmount}
- </if>
- <if test="dto != null and dto.refundAmount != null">
- AND refund.refund_amount = #{dto.refundAmount}
- </if>
- <if test="dto != null and dto.clientManagerName != null and dto.clientManagerName != ''">
- AND user.name = #{dto.clientManagerName}
- </if>
- <if test="dto != null and dto.status != null">
- AND fine.status = #{dto.status}
- </if>
- <if test="dto != null and dto.startPunishDate != null and dto.endPunishDate!= null">
- AND fine.created BETWEEN #{dto.startPunishDate} AND #{dto.endPunishDate}
- </if>
- <if test="dto != null and dto.startRefundDate != null and dto.startRefundDate!= null">
- AND refund.refund_date BETWEEN #{dto.startRefundDate} AND #{dto.startRefundDate}
- </if>
- <if test="dto != null and dto.clientManagerId != null">
- AND `order`.client_manager_id = #{dto.clientManagerId}
- </if>
- </sql>
- <!--条件分页查询罚款退款记录-->
- <select id="selectPage" resultType="com.dayou.vo.FinanceFineRefundVO">
- <include refid="financeFineRefundVOSql" />
- </select>
- <!--导出罚款退款记录-->
- <select id="exportList" resultType="com.dayou.vo.FinanceFineRefundVO">
- <include refid="financeFineRefundVOSql" />
- </select>
- </mapper>
|