KwcContractTradeMapper.xml 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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
  61. on a.id = b.contract_id
  62. and b.unit_type = #{entType}
  63. and case when a.status != 3 then b.ent_id in
  64. <foreach collection="allEnt" separator="," open="(" close=")" item="item">
  65. #{item}
  66. </foreach>
  67. end
  68. and b.del_flag = 0
  69. left join kwc_contract_trade_track c on a.id = c.contract_id and c.del_flag = 0 and c.type = 1
  70. left join kwc_contract_trade_track d on a.id = d.contract_id and d.del_flag = 0 and d.type = 0
  71. left join kwc_contract_trade_unit e on a.id = e.contract_id and e.unit_type != #{entType} and e.del_flag = 0
  72. where a.del_flag = 0
  73. and case when a.status = 3 then a.ent_id = #{entId} and #{entType} = 1
  74. else (b.ent_id in
  75. <foreach collection="allEnt" separator="," open="(" close=")" item="item">
  76. #{item}
  77. </foreach>
  78. and b.id is not null)
  79. end
  80. <if test="startTime != null">
  81. and a.create_time >= #{startTime}
  82. </if>
  83. <if test="endTime != null">
  84. and a.create_time &lt;= #{endTime}
  85. </if>
  86. <if test="status != null">
  87. and a.status = #{status}
  88. </if>
  89. <if test="keywords != null and keywords != ''">
  90. and (b.firm_name like concat('%', #{keywords}, '%') or
  91. e.firm_name like concat('%', #{keywords}, '%') or
  92. b.contacts like concat('%', #{keywords}, '%') or
  93. b.phone like concat('%', #{keywords}, '%') or
  94. a.contract_no like concat('%', #{keywords}, '%') or
  95. b.sign_phone like concat('%', #{keywords}, '%'))
  96. </if>
  97. <if test="idList != null and idList.size() > 0">
  98. and a.id in
  99. <foreach collection="idList" open="(" close=")" separator="," item="item">
  100. #{item}
  101. </foreach>
  102. </if>
  103. <if test="trading != null">
  104. and a.trading = #{trading}
  105. </if>
  106. <if test="signingWay != null">
  107. and a.signing_way = #{signingWay}
  108. </if>
  109. <if test="charging != null">
  110. and a.charging = #{charging}
  111. </if>
  112. <if test="targetEntId != null">
  113. and e.ent_id = #{targetEntId}
  114. </if>
  115. order by a.create_time desc
  116. </select>
  117. </mapper>