CmHeheProductMapper.xml 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  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.hehe.dao.CmHeheProductDao">
  4. <sql id="cmHeheProductColumns">
  5. a.id AS "id",
  6. a.productId AS "productId",
  7. a.sort AS "sort",
  8. a.recommend AS "recommend",
  9. a.validFlag AS "validFlag",
  10. a.price AS "price",
  11. a.includedTax AS "includedTax",
  12. a.invoiceType AS "invoiceType",
  13. a.clubTaxPoint AS "clubTaxPoint",
  14. a.shopTaxPoint AS "shopTaxPoint",
  15. p.costCheckFlag AS "costType",
  16. p.costPrice AS "costPrice",
  17. p.costProportional AS "costProportional",
  18. a.addTime AS "addTime",
  19. p.name AS "name",
  20. p.mainImage AS "mainImage",
  21. s.name AS "shopName"
  22. </sql>
  23. <sql id="cmHeheProductJoins">
  24. LEFT JOIN product p ON a.productId = p.productID
  25. LEFT JOIN shop s ON s.shopID = p.shopID
  26. </sql>
  27. <select id="get" resultType="CmHeheProduct">
  28. SELECT
  29. <include refid="cmHeheProductColumns"/>
  30. FROM cm_hehe_product a
  31. <include refid="cmHeheProductJoins"/>
  32. WHERE a.id = #{id}
  33. </select>
  34. <select id="findList" resultType="CmHeheProduct">
  35. SELECT
  36. <include refid="cmHeheProductColumns"/>
  37. FROM cm_hehe_product a
  38. <include refid="cmHeheProductJoins"/>
  39. <where>
  40. <if test="productId != null and productId != ''">
  41. AND a.productId = #{productId}
  42. </if>
  43. <if test="validFlag != null and validFlag != ''">
  44. AND a.validFlag = #{validFlag}
  45. </if>
  46. <if test="includedTax != null and includedTax != ''">
  47. AND a.includedTax = #{includedTax}
  48. </if>
  49. <if test="invoiceType != null and invoiceType != ''">
  50. AND a.invoiceType = #{invoiceType}
  51. </if>
  52. <if test="id != null and id != ''">
  53. AND a.id = #{id}
  54. </if>
  55. <if test="name != null and name != ''">
  56. AND p.name LIKE CONCAT('%',#{name},'%')
  57. </if>
  58. <if test="shopName != null and shopName != ''">
  59. AND s.shopName LIKE CONCAT('%',#{shopName},'%')
  60. </if>
  61. <if test="recommend != null and recommend != ''">
  62. AND a.recommend = #{recommend}
  63. </if>
  64. </where>
  65. <choose>
  66. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  67. ORDER BY ${page.orderBy}
  68. </when>
  69. <otherwise>
  70. ORDER BY -sort DESC
  71. </otherwise>
  72. </choose>
  73. </select>
  74. <select id="findAllList" resultType="CmHeheProduct">
  75. SELECT
  76. <include refid="cmHeheProductColumns"/>
  77. FROM cm_hehe_product a
  78. <include refid="cmHeheProductJoins"/>
  79. <where>
  80. </where>
  81. <choose>
  82. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  83. ORDER BY ${page.orderBy}
  84. </when>
  85. <otherwise>
  86. </otherwise>
  87. </choose>
  88. </select>
  89. <insert id="insert" parameterType="CmHeheProduct" keyProperty="id" useGeneratedKeys="true">
  90. INSERT INTO cm_hehe_product(
  91. productId,
  92. sort,
  93. recommend,
  94. validFlag,
  95. price,
  96. includedTax,
  97. invoiceType,
  98. clubTaxPoint,
  99. shopTaxPoint,
  100. addTime
  101. ) VALUES (
  102. #{productId},
  103. #{sort},
  104. #{recommend},
  105. #{validFlag},
  106. #{price},
  107. #{includedTax},
  108. #{invoiceType},
  109. #{clubTaxPoint},
  110. #{shopTaxPoint},
  111. NOW()
  112. )
  113. </insert>
  114. <update id="update">
  115. UPDATE cm_hehe_product SET
  116. productId = #{productId},
  117. sort = #{sort},
  118. recommend = #{recommend},
  119. validFlag = #{validFlag},
  120. price = #{price},
  121. includedTax = #{includedTax},
  122. invoiceType = #{invoiceType},
  123. clubTaxPoint = #{clubTaxPoint},
  124. shopTaxPoint = #{shopTaxPoint}
  125. WHERE id = #{id}
  126. </update>
  127. <delete id="delete">
  128. DELETE FROM cm_hehe_product
  129. WHERE id = #{id}
  130. </delete>
  131. <select id="findHeHeProductId" resultType="integer">
  132. SELECT productId FROM cm_hehe_product
  133. </select>
  134. <select id="findAllProduct" resultType="com.caimei.modules.product.entity.Product">
  135. SELECT
  136. a.*,s.name AS "shopName"
  137. FROM product a
  138. LEFT JOIN shop s on s.shopID = a.shopID
  139. <where>
  140. <if test="productID != null" >
  141. AND a.productID = #{productID}
  142. </if>
  143. <if test="name != null and name != ''">
  144. AND a.name LIKE concat('%',#{name},'%')
  145. </if>
  146. <if test="shopName != null and shopName != ''">
  147. AND s.name LIKE concat('%',#{shopName},'%')
  148. </if>
  149. <if test="ids != null and ids.size() > 0 ">
  150. AND a.productID NOT IN
  151. <foreach collection="ids" open="(" close=")" item="id" separator=",">
  152. #{id}
  153. </foreach>
  154. </if>
  155. </where>
  156. <choose>
  157. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  158. ORDER BY ${page.orderBy}
  159. </when>
  160. <otherwise>
  161. order by a.productID
  162. </otherwise>
  163. </choose>
  164. </select>
  165. <update id="saveSort">
  166. UPDATE cm_hehe_product SET sort = #{sort} WHERE id = #{id}
  167. </update>
  168. <update id="deleteActivityProduct">
  169. UPDATE cm_hehe_activity_product SET delFlag = 1 WHERE productId = #{productId}
  170. </update>
  171. </mapper>