SellCarTradeMapper.xml 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  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.jkcredit.invoice.mapper.waybill.SellCarTradeMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="BaseResultMap" type="com.jkcredit.invoice.model.entity.waybill.SelfCarTrade">
  6. <id column="id" property="id"/>
  7. <result column="customId" property="customId"/>
  8. <result column="companyNum" property="companyNum"/>
  9. <result column="cardId" property="cardId"/>
  10. <result column="tradeId" property="tradeId"/>
  11. <result column="exTime" property="exTime"/>
  12. <result column="aclTime" property="aclTime"/>
  13. <result column="fee" property="fee"/>
  14. <result column="status" property="status"/>
  15. <result column="applId" property="applId"/>
  16. <result column="days" property="days"/>
  17. <result column="companyName" property="companyName"/>
  18. <result column="companyReferencenum" property="companyReferencenum"/>
  19. </resultMap>
  20. <sql id="baseSql">
  21. id,
  22. customId,
  23. companyNum,
  24. cardId,
  25. tradeId,
  26. exTime,
  27. fee,
  28. status,
  29. applId,
  30. aclTime,
  31. companyName,
  32. companyReferencenum,
  33. interType
  34. </sql>
  35. <select id="selectAllByPage" resultMap="BaseResultMap">
  36. select
  37. <include refid="baseSql" />,timestampdiff(day,aclTime,now()) days
  38. from t_SellCarTrade
  39. <where>
  40. <if test="sellCarTrade.companyName != null and sellCarTrade.companyName != ''">
  41. and companyName = BINARY #{sellCarTrade.companyName}
  42. </if>
  43. <if test="sellCarTrade.cardIds != null">
  44. and cardId in
  45. <foreach collection="sellCarTrade.cardIds" item="cardId" index="index" separator="," open="(" close=")">
  46. #{cardId}
  47. </foreach>
  48. </if>
  49. <if test="sellCarTrade.tradeIds != null">
  50. and tradeId in
  51. <foreach collection="sellCarTrade.tradeIds" item="tradeId" index="index" separator="," open="(" close=")">
  52. #{tradeId}
  53. </foreach>
  54. </if>
  55. <if test="sellCarTrade.cardAndTradeVos != null">
  56. and (cardId,tradeId) in
  57. <foreach collection="sellCarTrade.cardAndTradeVos" item="cardAndTradeVo" index="index" separator="," open="(" close=")">
  58. (#{cardAndTradeVo.cardId},#{cardAndTradeVo.tradeId})
  59. </foreach>
  60. </if>
  61. <if test="sellCarTrade.companyReferencenum != null and sellCarTrade.companyReferencenum != ''">
  62. and companyReferencenum = BINARY #{sellCarTrade.companyReferencenum}
  63. </if>
  64. <if test="sellCarTrade.status != null and sellCarTrade.status != ''">
  65. and status = #{sellCarTrade.status}
  66. </if>
  67. <if test="sellCarTrade.exTimeBegin != null and sellCarTrade.exTimeBegin != ''">
  68. and exTime BETWEEN #{sellCarTrade.exTimeBegin} and #{sellCarTrade.exTimeEnd}
  69. </if>
  70. <if test="sellCarTrade.aclTimeBegin != null and sellCarTrade.aclTimeBegin != ''">
  71. and aclTime BETWEEN #{sellCarTrade.aclTimeBegin} and #{sellCarTrade.aclTimeEnd}
  72. </if>
  73. <if test="sellCarTrade.exceptionFlag != null and sellCarTrade.exceptionFlag != ''">
  74. and now()>date_add(aclTime,interval 10 day) and (status=2 or status =1)
  75. </if>
  76. </where>
  77. order by id desc
  78. </select>
  79. <select id="selectByTradeId" resultMap="BaseResultMap" parameterType="java.lang.String">
  80. select
  81. <include refid="baseSql" />
  82. from t_SellCarTrade where tradeId = BINARY #{tradeId,jdbcType=VARCHAR}
  83. </select>
  84. <insert id="insert" parameterType="com.jkcredit.invoice.model.entity.waybill.SelfCarTrade" >
  85. insert into t_SellCarTrade (
  86. customId,
  87. companyNum,
  88. cardId,
  89. tradeId,
  90. exTime,
  91. fee,
  92. status,
  93. applId,
  94. aclTime,
  95. companyName,
  96. companyReferencenum,interType,updateTime
  97. )
  98. values ( #{customId,jdbcType=VARCHAR}, #{companyNum,jdbcType=VARCHAR},
  99. #{cardId,jdbcType=VARCHAR}, #{tradeId,jdbcType=VARCHAR}, #{exTime,jdbcType=VARCHAR},
  100. #{fee,jdbcType=INTEGER}, #{status,jdbcType=INTEGER}, #{applId,jdbcType=VARCHAR},#{aclTime,jdbcType=VARCHAR},
  101. #{companyName,jdbcType=VARCHAR},#{companyReferencenum,jdbcType=VARCHAR}, #{interType,jdbcType=INTEGER},now()
  102. )
  103. </insert>
  104. <update id="updateByPrimaryKey" parameterType="com.jkcredit.invoice.model.entity.waybill.SelfCarTrade" >
  105. update t_SellCarTrade
  106. set customId = #{customId,jdbcType=VARCHAR},
  107. companyNum = #{companyNum,jdbcType=VARCHAR},
  108. cardId = #{cardId,jdbcType=VARCHAR},
  109. tradeId = #{tradeId,jdbcType=VARCHAR},
  110. exTime = #{exTime,jdbcType=VARCHAR},
  111. fee = #{fee,jdbcType=INTEGER},
  112. status = #{status,jdbcType=INTEGER},
  113. applId = #{applId,jdbcType=VARCHAR},
  114. aclTime = #{aclTime,jdbcType=VARCHAR},
  115. companyName = #{companyName,jdbcType=VARCHAR},
  116. companyReferencenum = #{companyReferencenum,jdbcType=VARCHAR}
  117. where id = #{id,jdbcType=INTEGER}
  118. </update>
  119. <update id="updateByTradeId" parameterType="com.jkcredit.invoice.model.entity.waybill.SelfCarTrade" >
  120. update t_SellCarTrade
  121. set customId = #{customId,jdbcType=VARCHAR},
  122. companyNum = #{companyNum,jdbcType=VARCHAR},
  123. cardId = #{cardId,jdbcType=VARCHAR},
  124. tradeId = #{tradeId,jdbcType=VARCHAR},
  125. exTime = #{exTime,jdbcType=VARCHAR},
  126. fee = #{fee,jdbcType=INTEGER},
  127. status = #{status,jdbcType=INTEGER},
  128. applId = #{applId,jdbcType=VARCHAR},
  129. aclTime = #{aclTime,jdbcType=VARCHAR},
  130. companyName = #{companyName,jdbcType=VARCHAR},
  131. companyReferencenum = #{companyReferencenum,jdbcType=VARCHAR},
  132. interType = #{interType,jdbcType=INTEGER},
  133. updateTime = now()
  134. where tradeId = BINARY #{tradeId,jdbcType=INTEGER}
  135. </update>
  136. <select id="selectByCardId" resultMap="BaseResultMap" parameterType="java.lang.String" >
  137. select
  138. <include refid="baseSql" />
  139. from t_SellCarTrade
  140. where cardId = BINARY #{cardId,jdbcType=VARCHAR}
  141. </select>
  142. <select id="selectByCardIdByStatus" resultMap="BaseResultMap" parameterType="com.jkcredit.invoice.model.entity.waybill.SelfCarTrade" >
  143. select
  144. <include refid="baseSql" />
  145. from t_SellCarTrade
  146. where cardId = BINARY #{cardId,jdbcType=VARCHAR} and status = #{status,jdbcType=VARCHAR}
  147. </select>
  148. <select id="selectByStatus" resultMap="BaseResultMap" parameterType="java.util.Map" >
  149. select
  150. <include refid="baseSql" />
  151. from t_SellCarTrade
  152. where status = #{status,jdbcType=VARCHAR}
  153. <if test="company != null and company != ''">
  154. and companyName = #{company,jdbcType=VARCHAR}
  155. </if>
  156. </select>
  157. <select id="selectNeedGetTrades" resultMap="BaseResultMap">
  158. select
  159. <include refid="baseSql" />
  160. from t_SellCarTrade
  161. where status = 2 and bindStatus=1 and aclTime >'2023-03-16 00:00:00'
  162. UNION ALL
  163. select
  164. <include refid="baseSql" />
  165. from t_SellCarTrade
  166. where status = 3 and
  167. updateTime >concat(date_sub(curdate(),interval 1 day),' 00:00:00')
  168. UNION ALL
  169. select
  170. <include refid="baseSql" />
  171. from t_SellCarTrade
  172. where aclTime is null and
  173. updateTime >concat(curdate(),' 00:00:00') and status>1
  174. </select>
  175. <update id="upDateCompany" parameterType="com.jkcredit.invoice.model.vo.CompanyVo">
  176. UPDATE t_SellCarTrade set companyName = #{newCompanyName} where companyName = #{oldCompanyName}
  177. </update>
  178. <update id="updatebindStatus" parameterType="java.util.Map">
  179. UPDATE t_SellCarTrade set bindStatus = #{bindStatus} where companyNum = #{companyNum} and cardId = #{etcCard}
  180. </update>
  181. <delete id="deletebyEtcAndTime" parameterType="com.jkcredit.invoice.service.lowerservice.vo.TradeRequestVo">
  182. delete from t_SellCarTrade where companyName = #{companyName,jdbcType=VARCHAR}
  183. and customId = #{customerName,jdbcType=VARCHAR}
  184. and cardId = #{etcId,jdbcType=VARCHAR}
  185. and exTime BETWEEN #{startTime,jdbcType=VARCHAR} and #{endTime,jdbcType=VARCHAR}
  186. and status = #{tradeStatus,jdbcType=INTEGER}
  187. </delete>
  188. <select id="sellectAllNullApplid" resultMap="BaseResultMap">
  189. select
  190. <include refid="baseSql" />
  191. from t_SellCarTrade t
  192. where t.status in(2,3) and t.aclTime is null and t.id> 1870702
  193. </select>
  194. </mapper>