CmHeheProductMapper.xml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  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. ifnull(a.bigTypeId,0) AS "bigTypeId",
  8. ifnull(a.smallTypeId,0) AS "smallTypeId",
  9. a.validFlag AS "validFlag",
  10. a.includedTax AS "includedTax",
  11. a.invoiceType AS "invoiceType",
  12. a.clubTaxPoint AS "clubTaxPoint",
  13. a.shopTaxPoint AS "shopTaxPoint",
  14. a.oldProductId,
  15. a.addTime AS "addTime",
  16. p.name AS "name",
  17. p.mainImage AS "mainImage",
  18. s.name AS "shopName",
  19. chap.activityId,
  20. group_concat(chfp.floorId) as floorIds
  21. </sql>
  22. <sql id="cmHeheProductJoins">
  23. LEFT JOIN product p ON a.productId = p.productID
  24. LEFT JOIN shop s ON s.shopID = p.shopID
  25. left join cm_hehe_activity_product chap on a.productId = chap.productId
  26. left join cm_hehe_floor_product chfp on a.productId = chfp.productId
  27. </sql>
  28. <select id="get" resultType="CmHeheProduct">
  29. SELECT
  30. <include refid="cmHeheProductColumns"/>
  31. FROM cm_hehe_product a
  32. <include refid="cmHeheProductJoins"/>
  33. WHERE a.id = #{id}
  34. group by a.id
  35. </select>
  36. <select id="findList" resultType="CmHeheProduct">
  37. SELECT
  38. <include refid="cmHeheProductColumns"/>
  39. FROM cm_hehe_product a
  40. <include refid="cmHeheProductJoins"/>
  41. <where>
  42. <if test="productId != null and productId != ''">
  43. AND a.productId = #{productId}
  44. </if>
  45. <if test="validFlag != null and validFlag != ''">
  46. AND a.validFlag = #{validFlag}
  47. </if>
  48. <if test="includedTax != null and includedTax != ''">
  49. AND a.includedTax = #{includedTax}
  50. </if>
  51. <if test="invoiceType != null and invoiceType != ''">
  52. AND a.invoiceType = #{invoiceType}
  53. </if>
  54. <if test="id != null and id != ''">
  55. AND a.id = #{id}
  56. </if>
  57. <if test="name != null and name != ''">
  58. AND p.name LIKE CONCAT('%',#{name},'%')
  59. </if>
  60. <if test="shopName != null and shopName != ''">
  61. AND s.name LIKE CONCAT('%',#{shopName},'%')
  62. </if>
  63. </where>
  64. group by a.id
  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 addTime 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(productId,
  91. bigTypeId,
  92. smallTypeId,
  93. validFlag,
  94. includedTax,
  95. invoiceType,
  96. clubTaxPoint,
  97. shopTaxPoint,
  98. addTime)
  99. VALUES (#{productId},
  100. #{bigTypeId},
  101. #{smallTypeId},
  102. #{validFlag},
  103. #{includedTax},
  104. #{invoiceType},
  105. #{clubTaxPoint},
  106. #{shopTaxPoint},
  107. NOW())
  108. </insert>
  109. <insert id="addActivityProduct">
  110. insert into cm_hehe_activity_product (activityId, productId, addTime, delFlag)
  111. values (#{activityId}, #{productId}, NOW(), 0)
  112. </insert>
  113. <insert id="addFloorProduct">
  114. insert into cm_hehe_floor_product(floorId, productId, validFlag, recommend, sort, addTime)
  115. VALUES (#{floorId}, #{productId}, 1, 0, 1, NOW())
  116. </insert>
  117. <insert id="insertHeHeSkuPrice">
  118. insert into cm_hehe_sku(skuid, productid, price)
  119. values (#{skuId}, #{productId}, #{price})
  120. </insert>
  121. <update id="update">
  122. UPDATE cm_hehe_product
  123. SET productId = #{productId},
  124. bigTypeId = #{bigTypeId},
  125. smallTypeId = #{smallTypeId},
  126. validFlag = #{validFlag},
  127. includedTax = #{includedTax},
  128. invoiceType = #{invoiceType},
  129. clubTaxPoint = #{clubTaxPoint},
  130. shopTaxPoint = #{shopTaxPoint}
  131. WHERE id = #{id}
  132. </update>
  133. <delete id="delete">
  134. DELETE
  135. FROM cm_hehe_product
  136. WHERE id = #{id}
  137. </delete>
  138. <select id="findHeHeProductId" resultType="integer">
  139. SELECT productId
  140. FROM cm_hehe_product
  141. </select>
  142. <select id="findAllProduct" resultType="com.caimei.modules.product.entity.Product">
  143. SELECT
  144. a.*,s.name AS "shopName"
  145. FROM product a
  146. LEFT JOIN shop s on s.shopID = a.shopID
  147. <where>
  148. a.splitCode is not null and a.splitCode != ''
  149. <if test="productID != null">
  150. AND a.productID = #{productID}
  151. </if>
  152. <if test="name != null and name != ''">
  153. AND a.name LIKE concat('%',#{name},'%')
  154. </if>
  155. <if test="shopName != null and shopName != ''">
  156. AND s.name LIKE concat('%',#{shopName},'%')
  157. </if>
  158. <if test="ids != null and ids.size() > 0 ">
  159. AND a.productID NOT IN
  160. <foreach collection="ids" open="(" close=")" item="id" separator=",">
  161. #{id}
  162. </foreach>
  163. </if>
  164. </where>
  165. <choose>
  166. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  167. ORDER BY ${page.orderBy}
  168. </when>
  169. <otherwise>
  170. order by a.productID
  171. </otherwise>
  172. </choose>
  173. </select>
  174. <select id="findCouponProduct" resultType="com.caimei.modules.product.entity.Product">
  175. SELECT
  176. a.*,s.name AS "shopName"
  177. FROM cm_hehe_product
  178. product a
  179. LEFT JOIN shop s on s.shopID = a.shopID
  180. <where>
  181. <if test="productID != null">
  182. AND a.productID = #{productID}
  183. </if>
  184. <if test="name != null and name != ''">
  185. AND a.name LIKE concat('%',#{name},'%')
  186. </if>
  187. <if test="shopName != null and shopName != ''">
  188. AND s.name LIKE concat('%',#{shopName},'%')
  189. </if>
  190. <if test="ids != null and ids.size() > 0 ">
  191. AND a.productID NOT IN
  192. <foreach collection="ids" open="(" close=")" item="id" separator=",">
  193. #{id}
  194. </foreach>
  195. </if>
  196. </where>
  197. <choose>
  198. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  199. ORDER BY ${page.orderBy}
  200. </when>
  201. <otherwise>
  202. order by a.productID
  203. </otherwise>
  204. </choose>
  205. </select>
  206. <select id="findProductActivity" resultType="java.lang.Integer">
  207. select activityId
  208. from cm_hehe_activity_product
  209. where productId = #{productId}
  210. </select>
  211. <select id="getNewProductId" resultType="java.lang.Integer">
  212. select productId
  213. from cm_hehe_product
  214. where oldProductId = #{oldProductId}
  215. </select>
  216. <select id="findHeHeFloorProductIds" resultType="java.lang.Integer">
  217. select i.productId
  218. from new_page_floor_image i
  219. left join cm_page_centre c on i.centreId = c.id
  220. left join cm_page p on c.pageId = p.id
  221. where p.type = 8
  222. </select>
  223. <select id="findAllHeheProduct" resultType="com.caimei.modules.product.entity.Product">
  224. SELECT
  225. a.*,s.name AS "shopName"
  226. FROM cm_hehe_product chp left join product a on chp.productId = a.productID
  227. LEFT JOIN shop s on s.shopID = a.shopID
  228. <where>
  229. chp.validFlag = 1
  230. <if test="productID != null">
  231. AND a.productID = #{productID}
  232. </if>
  233. <if test="name != null and name != ''">
  234. AND a.name LIKE concat('%',#{name},'%')
  235. </if>
  236. <if test="shopName != null and shopName != ''">
  237. AND s.name LIKE concat('%',#{shopName},'%')
  238. </if>
  239. <if test="ids != null and ids.size() > 0 ">
  240. AND a.productID NOT IN
  241. <foreach collection="ids" open="(" close=")" item="id" separator=",">
  242. #{id}
  243. </foreach>
  244. </if>
  245. </where>
  246. <choose>
  247. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  248. ORDER BY ${page.orderBy}
  249. </when>
  250. <otherwise>
  251. order by a.productID
  252. </otherwise>
  253. </choose>
  254. </select>
  255. <select id="findActivityProductIds" resultType="java.lang.Integer">
  256. SELECT a.productId
  257. FROM cm_hehe_activity_product a
  258. LEFT JOIN cm_hehe_activity cha ON a.activityId = cha.id
  259. WHERE a.delFlag = 0
  260. AND cha.delFlag = 0
  261. </select>
  262. <select id="findCollageProductIds" resultType="java.lang.Integer">
  263. select productId
  264. from cm_hehe_collage_product
  265. </select>
  266. <select id="findDiscountProductIds" resultType="java.lang.Integer">
  267. select productId
  268. from hehe_discount_activity_product hdap
  269. left join cm_hehe_discount_activity chda on hdap.activityId = chda.id
  270. where chda.id is not null
  271. </select>
  272. <select id="findProductElement" resultType="com.caimei.modules.hehe.entity.CmHeheProduct">
  273. select ifnull(chs.price, 0) as price,
  274. ifnull(cs.costProportional, 0) as costProportional,
  275. ifnull(cs.costCheckFlag, 0) as costType,
  276. ifnull(cs.costPrice, 0) as costPrice
  277. from cm_sku cs
  278. left join cm_hehe_sku chs on cs.skuId = chs.skuId
  279. where cs.productId = #{productId}
  280. order by chs.price asc
  281. limit 1
  282. </select>
  283. <update id="deleteActivityProduct">
  284. UPDATE cm_hehe_activity_product
  285. SET delFlag = 1
  286. WHERE productId = #{productId}
  287. </update>
  288. <update id="updateProductId">
  289. update cm_hehe_product
  290. set oldProductId = #{oldProductId},
  291. productId = #{newProductId}
  292. where productId = #{oldProductId}
  293. </update>
  294. <update id="updateHeHeSkuPrice">
  295. update cm_hehe_sku
  296. set price=#{price}
  297. where skuId = #{skuId}
  298. </update>
  299. <select id="findLadderList" resultType="com.caimei.modules.product.entity.CmLadderPrice">
  300. select id,buyPrice,buyNum
  301. from cm_hehe_activity_ladder
  302. where skuId=#{skuId}
  303. </select>
  304. </mapper>