KwcContractTradeMapper.xml 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.sckw.contract.dao.KwcContractTradeMapper">
  6. <resultMap id="BaseResultMap" type="com.sckw.contract.model.entity.KwcContractTrade">
  7. <id property="id" column="id" jdbcType="BIGINT"/>
  8. <result property="ent_id" column="ent_id" jdbcType="BIGINT"/>
  9. <result property="contract_no" column="contract_no" jdbcType="VARCHAR"/>
  10. <result property="name" column="name" jdbcType="VARCHAR"/>
  11. <result property="signing_way" column="signing_way" jdbcType="BIGINT"/>
  12. <result property="trading" column="trading" jdbcType="BIGINT"/>
  13. <result property="start_time" column="start_time" jdbcType="TIMESTAMP"/>
  14. <result property="end_time" column="end_time" jdbcType="TIMESTAMP"/>
  15. <result property="amount" column="amount" jdbcType="DECIMAL"/>
  16. <result property="performed_amount" column="performed_amount" jdbcType="DECIMAL"/>
  17. <result property="signing_url" column="signing_url" jdbcType="VARCHAR"/>
  18. <result property="signed_url" column="signed_url" jdbcType="VARCHAR"/>
  19. <result property="signing_no" column="signing_no" jdbcType="VARCHAR"/>
  20. <result property="contract_pid" column="contract_pid" jdbcType="BIGINT"/>
  21. <result property="remark" column="remark" jdbcType="VARCHAR"/>
  22. <result property="status" column="status" jdbcType="INTEGER"/>
  23. <result property="create_by" column="create_by" jdbcType="BIGINT"/>
  24. <result property="create_time" column="create_time" jdbcType="TIMESTAMP"/>
  25. <result property="update_by" column="update_by" jdbcType="BIGINT"/>
  26. <result property="update_time" column="update_time" jdbcType="TIMESTAMP"/>
  27. <result property="del_flag" column="del_flag" jdbcType="INTEGER"/>
  28. </resultMap>
  29. <sql id="Base_Column_List">
  30. id,ent_id,contract_no,
  31. name,signing_way,trading,
  32. start_time,end_time,amount,
  33. performed_amount,signing_url,signed_url,
  34. signing_no,contract_pid,remark,
  35. status,create_by,create_time,
  36. update_by,update_time,del_flag
  37. </sql>
  38. <select id="queryList" resultType="com.sckw.contract.model.dto.res.QueryListResDto">
  39. select a.amount,
  40. a.trading,
  41. a.name contractName,
  42. a.contract_no,
  43. c.create_by initiateBy,
  44. c.create_time initiateTime,
  45. a.create_time,
  46. a.start_time,
  47. a.end_time,
  48. a.id,
  49. a.remark,
  50. a.signing_way,
  51. d.create_time signTime,
  52. a.status,
  53. b.unit_type,
  54. b.ent_id,
  55. b.firm_name entName,
  56. e.ent_id targetEntId,
  57. e.firm_name targetEntName,
  58. a.contract_pid contractPid
  59. from kwc_contract_trade a
  60. left join kwc_contract_trade_unit b on a.id = b.contract_id and b.unit_type = #{entType} and b.del_flag = 0
  61. left join kwc_contract_trade_track c on a.id = c.contract_id and c.del_flag = 0 and c.type = 1
  62. left join kwc_contract_trade_track d on a.id = d.contract_id and d.del_flag = 0 and d.type = 0
  63. left join kwc_contract_trade_unit e on a.id = e.contract_id and e.unit_type != #{entType} and e.del_flag = 0
  64. where a.del_flag = 0
  65. and case when a.status = 3 then a.ent_id = #{entId} else b.ent_id = #{entId} end
  66. <if test="startTime != null">
  67. and a.create_time >= #{startTime}
  68. </if>
  69. <if test="endTime != null">
  70. and a.create_time &lt;= #{endTime}
  71. </if>
  72. <if test="status != null">
  73. and a.status = #{status}
  74. </if>
  75. <if test="keywords != null and keywords != ''">
  76. and (b.firm_name like concat('%', #{keywords}, '%') or
  77. e.firm_name like concat('%', #{keywords}, '%') or
  78. b.contacts like concat('%', #{keywords}, '%') or
  79. b.phone like concat('%', #{keywords}, '%') or
  80. b.sign_phone like concat('%', #{keywords}, '%'))
  81. </if>
  82. <if test="idList != null and idList.size() > 0">
  83. and a.id in
  84. <foreach collection="idList" open="(" close=")" separator="," item="item">
  85. #{item}
  86. </foreach>
  87. </if>
  88. <if test="trading != null">
  89. and a.trading = #{trading}
  90. </if>
  91. <if test="signingWay != null">
  92. and a.signing_way = #{signingWay}
  93. </if>
  94. <if test="charging != null">
  95. and a.charging = #{charging}
  96. </if>
  97. <if test="targetEntId != null">
  98. and e.ent_id = #{targetEntId}
  99. </if>
  100. order by a.create_time desc
  101. </select>
  102. </mapper>