CmSecondHandTransactionMapper.xml 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  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.caimei.modules.product.dao.CmSecondHandTransactionDao">
  4. <sql id="cmSecondHandTransactionColumns">
  5. a.id AS "id",
  6. a.userId AS "userId",
  7. ifnull(a.type,0) AS "type",
  8. ifnull(a.sold,0) AS "sold",
  9. ifnull(a.viewingNum,0) AS "viewingNum",
  10. a.transactionType AS "transactionType",
  11. a.productType AS "productType",
  12. a.productName AS "productName",
  13. a.productQuality AS "productQuality",
  14. a.address AS "address",
  15. a.contactName AS "contactName",
  16. a.contactMobile AS "contactMobile",
  17. a.fixedYears AS "fixedYears",
  18. a.mechanismName AS "mechanismName",
  19. a.image1 AS "image1",
  20. a.image2 AS "image2",
  21. a.image3 AS "image3",
  22. a.image4 AS "image4",
  23. a.image5 AS "image5",
  24. a.productDetails AS "productDetails",
  25. date_format(a.submitDate, '%Y-%m-%d %H:%i:%s') AS submitDate,
  26. date_format(a.updateDate, '%Y-%m-%d %H:%i:%s') AS updateDate,
  27. a.operationType AS operationType,
  28. a.payStatus AS payStatus,
  29. a.productStatus AS productStatus,
  30. a.payAmount AS payAmount,
  31. a.provinceCityDistrict AS provinceCityDistrict,
  32. a.townId AS townId,
  33. a.brandId AS brandId,
  34. (case when a.brandId != '-1' then
  35. (select cb.name from cm_brand cb where cb.id = a.brandId)
  36. else
  37. a.brandName
  38. end
  39. ) AS brandName,
  40. a.useBalanceAmount AS useBalanceAmount,
  41. a.revieweReason AS revieweReason,
  42. a.payFormData AS payFormData,
  43. date_format(a.reviewedDate, '%Y-%m-%d %H:%i:%s') AS reviewedDate,
  44. date_format(a.onLineDate, '%Y-%m-%d %H:%i:%s') AS onLineDate,
  45. a.reviewerUserID AS reviewerUserID,
  46. a.source AS source,
  47. (select su.name from sys_user su where su.id = a.reviewerUserID) AS reviewerUserName
  48. </sql>
  49. <sql id="cmSecondHandTransactionJoins">
  50. </sql>
  51. <select id="get" resultType="CmSecondHandTransaction">
  52. SELECT
  53. <include refid="cmSecondHandTransactionColumns"/>
  54. FROM cm_second_hand_transaction a
  55. <include refid="cmSecondHandTransactionJoins"/>
  56. WHERE a.id = #{id}
  57. </select>
  58. <select id="brandList" resultType="com.caimei.modules.brand.entity.CmBrand">
  59. select b.id AS id, b.name AS name from cm_brand b
  60. where b.status = '1' and b.delFlag = '0' and b.description is not null and b.description != ''
  61. order by b.sort
  62. </select>
  63. <select id="findList" resultType="CmSecondHandTransaction">
  64. SELECT
  65. <include refid="cmSecondHandTransactionColumns"/>
  66. ,u.userName AS "userName"
  67. FROM cm_second_hand_transaction a
  68. LEFT JOIN user u ON u.userId = a.userId
  69. <include refid="cmSecondHandTransactionJoins"/>
  70. <where>
  71. <if test="id != null and id != ''">
  72. AND a.id = #{id}
  73. </if>
  74. <if test="brandId != null and brandId != ''">
  75. AND a.brandId = #{brandId}
  76. </if>
  77. <if test="transactionType != null and transactionType != ''">
  78. AND a.transactionType = #{transactionType}
  79. </if>
  80. <if test="productType != null and productType != ''">
  81. AND a.productType = #{productType}
  82. </if>
  83. <if test="productName != null and productName != ''">
  84. AND a.productName LIKE concat('%',#{productName},'%')
  85. </if>
  86. <if test="payStatus != null and payStatus != ''">
  87. AND a.payStatus = #{payStatus}
  88. </if>
  89. <if test="source != null and source != ''">
  90. AND a.source = #{source}
  91. </if>
  92. <if test="productStatus != null and productStatus != ''">
  93. AND a.productStatus = #{productStatus}
  94. </if>
  95. <if test="operationType != null and operationType != ''">
  96. AND a.operationType = #{operationType}
  97. </if>
  98. </where>
  99. <choose>
  100. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  101. ORDER BY ${page.orderBy}
  102. </when>
  103. <otherwise>
  104. order by a.submitDate desc
  105. </otherwise>
  106. </choose>
  107. </select>
  108. <select id="findAllList" resultType="CmSecondHandTransaction">
  109. SELECT
  110. <include refid="cmSecondHandTransactionColumns"/>
  111. FROM cm_second_hand_transaction a
  112. <include refid="cmSecondHandTransactionJoins"/>
  113. <where>
  114. </where>
  115. <choose>
  116. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  117. ORDER BY ${page.orderBy}
  118. </when>
  119. <otherwise>
  120. </otherwise>
  121. </choose>
  122. </select>
  123. <insert id="insert" parameterType="CmSecondHandTransaction" keyProperty="id" useGeneratedKeys="true">
  124. INSERT INTO cm_second_hand_transaction(
  125. userId,
  126. type,
  127. sold,
  128. viewingNum,
  129. productType,
  130. productName,
  131. productQuality,
  132. address,
  133. townId,
  134. contactName,
  135. contactMobile,
  136. fixedYears,
  137. mechanismName,
  138. image1,
  139. image2,
  140. image3,
  141. image4,
  142. image5,
  143. productDetails,
  144. submitDate,
  145. payStatus,
  146. productStatus,
  147. payAmount,
  148. provinceCityDistrict,
  149. brandId,
  150. brandName,
  151. useBalanceAmount,
  152. revieweReason,
  153. payFormData,
  154. reviewedDate,
  155. onLineDate,
  156. updateDate,
  157. reviewerUserID,
  158. source
  159. ) VALUES (
  160. #{userId},
  161. #{type},
  162. #{sold},
  163. #{viewingNum},
  164. #{productType},
  165. #{productName},
  166. #{productQuality},
  167. #{address},
  168. #{townId},
  169. #{contactName},
  170. #{contactMobile},
  171. #{fixedYears},
  172. #{mechanismName},
  173. #{image1},
  174. #{image2},
  175. #{image3},
  176. #{image4},
  177. #{image5},
  178. #{productDetails},
  179. #{submitDate},
  180. #{payStatus},
  181. #{productStatus},
  182. #{payAmount},
  183. #{provinceCityDistrict},
  184. #{brandId},
  185. #{brandName},
  186. #{useBalanceAmount},
  187. #{revieweReason},
  188. #{payFormData},
  189. #{reviewedDate},
  190. #{onLineDate},
  191. #{updateDate},
  192. #{reviewerUserID},
  193. #{source}
  194. )
  195. </insert>
  196. <update id="update">
  197. UPDATE cm_second_hand_transaction SET
  198. userId = #{userId},
  199. type = #{type},
  200. sold = #{sold},
  201. viewingNum = #{viewingNum},
  202. productType = #{productType},
  203. productName = #{productName},
  204. productQuality = #{productQuality},
  205. address = #{address},
  206. townId = #{townId},
  207. contactName = #{contactName},
  208. contactMobile = #{contactMobile},
  209. fixedYears = #{fixedYears},
  210. mechanismName = #{mechanismName},
  211. image1 = #{image1},
  212. image2 = #{image2},
  213. image3 = #{image3},
  214. image4 = #{image4},
  215. image5 = #{image5},
  216. productDetails = #{productDetails},
  217. submitDate = #{submitDate},
  218. payStatus = #{payStatus},
  219. productStatus = #{productStatus},
  220. payAmount = #{payAmount},
  221. provinceCityDistrict = #{provinceCityDistrict},
  222. brandId = #{brandId},
  223. brandName = #{brandName},
  224. useBalanceAmount = #{useBalanceAmount},
  225. revieweReason = #{revieweReason},
  226. payFormData = #{payFormData},
  227. reviewedDate = #{reviewedDate},
  228. onLineDate = #{onLineDate},
  229. updateDate = #{updateDate},
  230. reviewerUserID = #{reviewerUserID},
  231. source = #{source}
  232. WHERE id = #{id}
  233. </update>
  234. <delete id="delete">
  235. DELETE FROM cm_second_hand_transaction
  236. WHERE id = #{id}
  237. </delete>
  238. </mapper>