ProductMapper.xml 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  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.caimei.mapper.ProductMapper">
  6. <select id="findImageAll" resultType="string">
  7. SELECT
  8. image
  9. FROM
  10. cm_hehe_image
  11. WHERE
  12. status = 1
  13. ORDER BY
  14. - sort DESC
  15. </select>
  16. <select id="findProductList" resultType="com.caimei.model.vo.ProductVo">
  17. SELECT
  18. a.productId,
  19. a.recommend,
  20. a.price,
  21. a.includedTax,
  22. a.invoiceType,
  23. a.clubTaxPoint,
  24. p.name,
  25. P.unit,
  26. p.mainImage
  27. FROM
  28. cm_hehe_product a
  29. LEFT JOIN product p ON a.productId = p.productID
  30. WHERE
  31. a.validFlag = 1
  32. <if test="name != null and name != ''">
  33. AND p.name LIKE CONCAT('%',#{name},'%')
  34. </if>
  35. ORDER BY
  36. a.recommend DESC,
  37. a.addTime DESC
  38. </select>
  39. <select id="findActivityByProductId" resultType="integer">
  40. SELECT
  41. activityId
  42. FROM
  43. cm_hehe_activity_product a
  44. LEFT JOIN cm_hehe_activity cha ON a.activityId = cha.id
  45. WHERE
  46. cha.delFlag = 0
  47. AND a.delFlag = 0
  48. AND NOW() BETWEEN cha.beginTime
  49. AND cha.endTime
  50. AND a.productId = #{productId}
  51. </select>
  52. <select id="findActivityLadder" resultType="com.caimei.model.vo.ActivityLadderVo">
  53. SELECT
  54. buyNum,
  55. buyPrice
  56. FROM
  57. cm_hehe_activity_ladder
  58. WHERE
  59. activityId = #{activityId}
  60. AND productId = #{productId}
  61. ORDER BY
  62. ladderNum
  63. </select>
  64. <select id="findProductByProductId" resultType="com.caimei.model.vo.ProductDetailsVo">
  65. SELECT
  66. a.productId,
  67. a.recommend,
  68. a.price,
  69. a.includedTax,
  70. a.invoiceType,
  71. a.clubTaxPoint,
  72. a.validFlag,
  73. p.name,
  74. p.mainImage,
  75. p.brandID AS "brandId",
  76. p.bigTypeID AS "bigTypeId",
  77. p.smallTypeID AS "smallTypeId",
  78. p.tinyTypeID AS "tinyTypeId",
  79. P.unit,
  80. P.stock,
  81. p.tags
  82. FROM
  83. cm_hehe_product a
  84. LEFT JOIN product p ON a.productId = p.productID
  85. WHERE
  86. a.productId = #{productId}
  87. </select>
  88. <select id="findProductImages" resultType="string">
  89. SELECT
  90. image
  91. FROM
  92. productimage
  93. WHERE
  94. productID = #{productId}
  95. ORDER BY
  96. mainFlag DESC
  97. </select>
  98. <select id="findProductDetail" resultType="com.caimei.model.po.ProductDetailInfoPo">
  99. select
  100. productDetailInfoID as productDetailInfoId,
  101. productID as productId,
  102. propValueAlias,
  103. propValueImages,
  104. detailInfo,
  105. detailInfoTxt,
  106. seoTitle,
  107. seoKeyword,
  108. seoDes,
  109. serviceInfo,
  110. orderInfo
  111. from
  112. productdetailinfo
  113. where
  114. productID = #{productId}
  115. </select>
  116. <select id="findTypeName" resultType="string">
  117. SELECT
  118. CONCAT_WS('-', b.name, s.name, t.name)
  119. FROM
  120. bigtype b
  121. LEFT JOIN smalltype s ON s.smallTypeID = #{smallTypeId}
  122. LEFT JOIN tinytype t ON t.tinyTypeID = #{tinyTypeId}
  123. WHERE
  124. b.bigTypeID = #{bigTypeId}
  125. </select>
  126. <select id="findBrandName" resultType="string">
  127. SELECT
  128. name
  129. FROM
  130. cm_brand
  131. WHERE
  132. id = #{brandId}
  133. and delFlag = '0'
  134. and status = '1'
  135. </select>
  136. <select id="findParameters" resultType="com.caimei.model.vo.RelatedParametersVo">
  137. SELECT
  138. paramsName,
  139. paramsContent
  140. FROM
  141. cm_product_related_parameters
  142. WHERE
  143. productId = #{productId}
  144. AND delFlag = '0'
  145. </select>
  146. <select id="findSearchHistory" resultType="integer">
  147. SELECT id FROM user_search_history WHERE searchWord = #{name} AND userId = #{userId} LIMIT 1
  148. </select>
  149. <update id="updateHistoryByDate">
  150. UPDATE user_search_history SET searchDate = NOW() WHERE id = #{recordId}
  151. </update>
  152. <insert id="insertSearchHistory">
  153. INSERT INTO `user_search_history` (
  154. `userId`, `searchWord`, `searchDate`,
  155. `delFlag`
  156. )
  157. VALUES
  158. (
  159. #{userId}, #{searchWord}, #{searchDate},
  160. #{delFlag}
  161. )
  162. </insert>
  163. <select id="searchHistory" resultType="string">
  164. SELECT
  165. searchWord
  166. FROM
  167. user_search_history
  168. WHERE
  169. userId = #{userId}
  170. ORDER BY
  171. searchDate DESC
  172. LIMIT
  173. 10
  174. </select>
  175. <delete id="deleteHistoryByUserId">
  176. DELETE FROM user_search_history
  177. WHERE userId=#{userId}
  178. AND id NOT IN (
  179. SELECT temp.id FROM (
  180. SELECT id FROM user_search_history WHERE userId=#{userId} ORDER BY id DESC LIMIT 10
  181. ) AS temp
  182. )
  183. </delete>
  184. <delete id="deleteHistory">
  185. DELETE FROM user_search_history WHERE userId + #{userId}
  186. </delete>
  187. </mapper>