RepairPayRecordMapper.xml 3.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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.repair.mapper.RepairPayRecordMapper">
  4. <resultMap type="com.repair.model.pojo.RepairPayRecord" id="repairPayMap">
  5. <result property="id" column="id"/>
  6. <result property="recordId" column="record_id"/>
  7. <result property="userId" column="user_id"/>
  8. <result property="payNo" column="pay_no"/>
  9. <result property="payPrice" column="pay_price"/>
  10. <result property="isSuccess" column="is_success"/>
  11. <result property="remark" column="remark"/>
  12. </resultMap>
  13. <select id="queryPaymentData" resultType="com.repair.model.pojo.RepairPayRecord" resultMap="repairPayMap">
  14. select rpr.id,rpr.record_id,rpr.user_id,rpr.pay_no,rpr.pay_price,rpr.is_success,rpr.remark from repair_pay_record rpr
  15. inner join repair_record rr on rr.deleted = 0 and rr.record_no = #{recordNo} and rr.id = rpr.record_id
  16. where rpr.deleted = 0
  17. </select>
  18. <select id="queryExport" resultType="com.repair.model.vo.QueryExportVo">
  19. SELECT row_number() over ( ORDER BY dc.pay_time ) AS id, dc.*
  20. FROM
  21. (SELECT
  22. rpr.create_time AS pay_time,
  23. rr.record_no AS record_no,
  24. rpr.pay_no AS pay_no,
  25. ru.user_name as user_name,
  26. rpr.pay_price as pay_price,
  27. (SELECT SUM(rrr.refund_price) FROM repair_refund_record rrr WHERE rrr.record_id=rpr.record_id and
  28. rrr.is_success=2 and rrr.deleted=0) as refund_total_price
  29. FROM
  30. `repair_pay_record` rpr
  31. LEFT JOIN repair_record rr ON rr.deleted = 0
  32. AND rpr.record_id = rr.id
  33. LEFT JOIN repair_user ru on rpr.user_id=ru.id and ru.deleted=0
  34. where
  35. rpr.is_success=2 AND rpr.deleted=0
  36. <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
  37. and rpr.create_time between #{startTime} and #{endTime}
  38. </if>
  39. ) dc
  40. <where>
  41. <if test="keyWord != null and keyWord !='' ">
  42. and (dc.user_name like '%' #{keyWord} '%' or dc.record_no like '%' #{keyWord} '%')
  43. </if>
  44. </where>
  45. </select>
  46. <resultMap type="com.repair.model.vo.ProsperityRepairPayRecordsVo" id="repairPayPage">
  47. <result property="id" column="id"/>
  48. <result property="payTime" column="pay_time"/>
  49. <result property="recordId" column="record_id"/>
  50. <result property="recordNo" column="record_no"/>
  51. <result property="payNo" column="pay_no"/>
  52. <result property="userName" column="user_name"/>
  53. <result property="payPrice" column="pay_price"/>
  54. <result property="state" column="state"/>
  55. </resultMap>
  56. <select id="queryPayPage" resultType="com.repair.model.vo.ProsperityRepairPayRecordsVo" resultMap="repairPayPage">
  57. select rpr.id,rpr.create_time as pay_time,rpr.record_id,rr.record_no,rpr.pay_no,ru.user_name,rpr.pay_price,rpr.is_success as state from repair_pay_record rpr
  58. left join repair_record rr on rr.deleted = 0 and rr.id = rpr.record_id
  59. left join repair_user ru on ru.deleted = 0 and ru.id = rpr.user_id
  60. where rpr.deleted = 0 and rpr.is_success = 2
  61. <if test="keyWord != null and keyWord !='' ">
  62. and (rpr.user_id in (select id from repair_user where deleted = 0 and user_name like '%' #{keyWord} '%')
  63. or rpr.record_id in (select id from repair_record where deleted = 0 and record_no like '%' #{keyWord} '%'))
  64. </if>
  65. <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
  66. and rpr.create_time between #{startTime} and #{endTime}
  67. </if>
  68. order by rpr.create_time desc
  69. </select>
  70. </mapper>