FinanceFineRefundMapper.xml 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.dayou.mapper.FinanceFineRefundMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="BaseResultMap" type="com.dayou.entity.FinanceFineRefund">
  6. <result column="id" property="id" />
  7. <result column="deleted" property="deleted" />
  8. <result column="modified" property="modified" />
  9. <result column="created" property="created" />
  10. <result column="fine_id" property="fineId" />
  11. <result column="refund_amount" property="refundAmount" />
  12. <result column="refund_reason" property="refundReason" />
  13. <result column="status" property="status" />
  14. <result column="user_id" property="userId" />
  15. <result column="refund_date" property="refundDate" />
  16. </resultMap>
  17. <!-- 通用查询结果列 -->
  18. <sql id="Base_Column_List">
  19. id,
  20. deleted,
  21. modified,
  22. created,
  23. fine_id, refund_amount, refund_reason, statue, user_id, refund_date
  24. </sql>
  25. <sql id="financeFineRefundVOSql">
  26. SELECT refund.id AS id,
  27. refund.fine_id AS fineId,
  28. oFund.order_id AS orderId,
  29. oFund.order_name AS orderName,
  30. <if test="dto != null and dto.businessType == 'ASSET_BUSINESS' or dto.businessType == 'MAJOR_BUSINESS'">
  31. pFund.production_no AS productionNo,
  32. `order`.bailor AS bailor,
  33. </if>
  34. <if test="dto != null and dto.businessType == 'PERSONAL_BUSINESS'">
  35. `order`.order_id AS productionNo,
  36. CONCAT(`order`.bailorA, IF(`order`.bailorB IS NOT NULL AND `order`.bailorB != '', ',', ''), `order`.bailorB) AS bailor,
  37. </if>
  38. <if test="dto != null and dto.businessType == 'ASSET_BUSINESS'">
  39. CASE pFund.production_type WHEN 'LETTER' THEN '意见函' WHEN 'CONSULT' THEN '咨询报告' WHEN 'REPORT' THEN '评估报告' ELSE '-' END AS productionType,
  40. </if>
  41. <if test="dto != null and dto.businessType == 'MAJOR_BUSINESS'">
  42. CASE pFund.production_type WHEN 'LETTER' THEN '复评函' WHEN 'REPORT' THEN '报告' WHEN 'STATEMENT' THEN '价值意见书' ELSE '-' END AS productionType,
  43. </if>
  44. <if test="dto != null and dto.businessType == 'PERSONAL_BUSINESS'">
  45. CASE pro.production WHEN 'FINAL' THEN '结果报告' WHEN 'TECHNIC' THEN '技术报告' ELSE '-' END AS productionType,
  46. </if>
  47. user.name AS clientManagerName,
  48. customer.name AS customerName,
  49. subCustomer.name AS customerSubName,
  50. fine.real_fine_amount AS finedAmount,
  51. fine.created AS punishDate,
  52. refund.refund_amount AS refundAmount,
  53. refund.refund_date AS refundDate,
  54. refund.refund_amount AS refundAmount,
  55. refund.refund_reason AS refundReason,
  56. refund.status AS status,
  57. operator.name AS operator,
  58. refund.refund_date AS refundDate
  59. FROM finance_fine_refund AS refund
  60. LEFT JOIN finance_fine AS fine ON fine.deleted = 0 AND fine.id = refund.fine_id
  61. LEFT JOIN order_fund AS oFund ON oFund.deleted = 0 AND oFund.id = fine.order_fund_id
  62. <if test="dto != null and dto.businessType == 'ASSET_BUSINESS'">
  63. 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
  64. 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
  65. ON pFund.business_id = pro.business_id AND pFund.production_no = pro.production_no
  66. LEFT JOIN assets AS `order` ON `order`.deleted = 0 AND `order`.id = pFund.business_id
  67. </if>
  68. <if test="dto != null and dto.businessType == 'MAJOR_BUSINESS'">
  69. 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
  70. 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
  71. ON pFund.business_id = pro.business_id AND pFund.production_no = pro.production_no AND production = pFund.production_type
  72. LEFT JOIN major AS `order` ON `order`.deleted = 0 AND `order`.id = pFund.business_id
  73. </if>
  74. <if test="dto != null and dto.businessType == 'PERSONAL_BUSINESS'">
  75. LEFT JOIN personal_target pt ON pt.personal_id = oFund.business_id
  76. 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
  77. LEFT JOIN personal AS `order` ON `order`.deleted = 0 AND `order`.id = oFund.business_id
  78. </if>
  79. LEFT JOIN customer_company AS customer ON customer.id = `order`.clientele_id
  80. LEFT JOIN customer_company AS subCustomer ON subCustomer.id = `order`.clientele_sub_id
  81. LEFT JOIN user ON `order`.client_manager_id = user.id AND user.deleted = 0
  82. LEFT JOIN user AS operator ON user.deleted = 0 AND user.id = refund.user_id
  83. WHERE oFund.business_type = #{dto.businessType}
  84. <if test="dto != null and dto.keyWord != null and dto.keyWord != ''">
  85. AND (`order`.order_id LIKE CONCAT('%', #{dto.keyWord},'%')
  86. <if test="dto != null and dto.businessType == 'ASSET_BUSINESS' or dto.businessType == 'MAJOR_BUSINESS'">
  87. OR pFund.production_no LIKE CONCAT('%', #{dto.keyWord},'%')
  88. </if>
  89. )
  90. </if>
  91. <if test="dto != null and dto.finedAmount != null">
  92. AND fine.real_fine_amount = #{dto.finedAmount}
  93. </if>
  94. <if test="dto != null and dto.refundAmount != null">
  95. AND refund.refund_amount = #{dto.refundAmount}
  96. </if>
  97. <if test="dto != null and dto.clientManagerName != null and dto.clientManagerName != ''">
  98. AND user.name = #{dto.clientManagerName}
  99. </if>
  100. <if test="dto != null and dto.status != null">
  101. AND fine.status = #{dto.status}
  102. </if>
  103. <if test="dto != null and dto.startPunishDate != null and dto.endPunishDate!= null">
  104. AND fine.created BETWEEN #{dto.startPunishDate} AND #{dto.endPunishDate}
  105. </if>
  106. <if test="dto != null and dto.startRefundDate != null and dto.startRefundDate!= null">
  107. AND refund.refund_date BETWEEN #{dto.startRefundDate} AND #{dto.startRefundDate}
  108. </if>
  109. <if test="dto != null and dto.clientManagerId != null">
  110. AND `order`.client_manager_id = #{dto.clientManagerId}
  111. </if>
  112. </sql>
  113. <!--条件分页查询罚款退款记录-->
  114. <select id="selectPage" resultType="com.dayou.vo.FinanceFineRefundVO">
  115. <include refid="financeFineRefundVOSql" />
  116. </select>
  117. <!--导出罚款退款记录-->
  118. <select id="exportList" resultType="com.dayou.vo.FinanceFineRefundVO">
  119. <include refid="financeFineRefundVOSql" />
  120. </select>
  121. </mapper>