HeHeProductDao.xml 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  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.caimei365.manager.dao.hehe.HeHeProductDao">
  4. <select id="findProductList" resultType="com.caimei365.manager.entity.hehe.product.HeHeProduct">
  5. SELECT 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. FROM cm_hehe_product a
  22. LEFT JOIN product p ON a.productId = p.productID
  23. LEFT JOIN shop s ON s.shopID = p.shopID
  24. left join cm_hehe_activity_product chap on a.productId = chap.productId
  25. left join cm_hehe_floor_product chfp on a.productId = chfp.productId
  26. <where>
  27. <if test="productId != null and productId != ''">
  28. AND a.productId = #{productId}
  29. </if>
  30. <if test="validFlag != null and validFlag != ''">
  31. AND a.validFlag = #{validFlag}
  32. </if>
  33. <if test="includedTax != null and includedTax != ''">
  34. AND a.includedTax = #{includedTax}
  35. </if>
  36. <if test="invoiceType != null and invoiceType != ''">
  37. AND a.invoiceType = #{invoiceType}
  38. </if>
  39. <if test="id != null and id != ''">
  40. AND a.id = #{id}
  41. </if>
  42. <if test="name != null and name != ''">
  43. AND p.name LIKE CONCAT('%',#{name},'%')
  44. </if>
  45. <if test="shopName != null and shopName != ''">
  46. AND s.name LIKE CONCAT('%',#{shopName},'%')
  47. </if>
  48. </where>
  49. group by a.id
  50. ORDER BY addTime DESC
  51. </select>
  52. <select id="findProductElement" resultType="com.caimei365.manager.entity.hehe.product.HeHeProduct">
  53. select ifnull(chs.price, 0) as price,
  54. ifnull(cs.shopPercent, 0) as shopPercent,
  55. ifnull(cs.organizePercent, 0) as organizePercent,
  56. ifnull(cs.cmPercent, 0) as cmPercent,
  57. ifnull((SELECT costCheckFlag
  58. FROM cm_organize_product_info
  59. WHERE productId = cs.productId
  60. AND organizeId = cs.organizeId), 0) as costType,
  61. ifnull(cs.costPrice, 0) as costPrice,
  62. cs.organizeId
  63. from cm_sku cs
  64. left join cm_hehe_sku chs on cs.skuId = chs.skuId
  65. where cs.productId = #{productId}
  66. and cs.organizeId = (SELECT SUBSTRING(groundMall, 1, 1) FROM product WHERE productID = cs.productId)
  67. order by chs.price asc
  68. limit 1
  69. </select>
  70. <select id="findBigTypeList" resultType="com.caimei365.manager.entity.hehe.product.HeHeBigType">
  71. SELECT a.bigTypeID AS "bigTypeID",
  72. a.name AS "name",
  73. a.bigTypeCode AS "bigTypeCode",
  74. a.wwwValidFlag AS "wwwValidFlag",
  75. a.crmValidFlag AS "crmValidFlag",
  76. a.sortIndex AS "sortIndex",
  77. a.wwwIcon AS "wwwIcon",
  78. a.crmIcon AS "crmIcon",
  79. a.addTime AS "addTime",
  80. ifnull(a.typeSort,'0') AS "typeSort",
  81. a.mallType
  82. FROM bigtype a
  83. <where>
  84. <if test="bigTypeID != null and bigTypeID != ''">
  85. AND a.bigTypeID = #{bigTypeID}
  86. </if>
  87. <if test="name != null and name != ''">
  88. AND a.name LIKE concat('%',#{name},'%')
  89. </if>
  90. <if test="bigTypeCode != null and bigTypeCode != ''">
  91. AND a.bigTypeCode = #{bigTypeCode}
  92. </if>
  93. <if test="wwwValidFlag != null and wwwValidFlag != ''">
  94. AND a.wwwValidFlag = #{wwwValidFlag}
  95. </if>
  96. <if test="crmValidFlag != null and crmValidFlag != ''">
  97. AND a.crmValidFlag = #{crmValidFlag}
  98. </if>
  99. <if test="sortIndex != null and sortIndex != ''">
  100. AND a.sortIndex = #{sortIndex}
  101. </if>
  102. <if test="typeSort != null and typeSort != '' and typeSort != 'null'">
  103. AND a.typeSort = #{typeSort}
  104. </if>
  105. <if test="null != mallType">
  106. and mallType = #{mallType}
  107. </if>
  108. </where>
  109. ORDER BY ifnull(sortIndex,10000) ASC,addTime DESC
  110. </select>
  111. <select id="findActivityList" resultType="com.caimei365.manager.entity.hehe.product.HeHeActivity">
  112. SELECT a.id AS "id",
  113. a.name AS "name",
  114. a.status AS "status",
  115. a.listImage AS "listImage",
  116. a.detailsImage AS "detailsImage",
  117. a.beginTime AS "beginTime",
  118. a.endTime AS "endTime",
  119. a.addTime AS "addTime",
  120. a.delFlag AS "delFlag"
  121. FROM cm_hehe_activity a
  122. <where>
  123. a.delFlag = 0
  124. <if test="name != null and name != ''">
  125. AND a.name LIKE concat('%',#{name},'%')
  126. </if>
  127. <if test="status != null and status != ''">
  128. AND a.status = #{status}
  129. </if>
  130. <if test="activityStatus == 1">
  131. AND a.beginTime <![CDATA[ > ]]> NOW()
  132. </if>
  133. <if test="activityStatus == 2">
  134. AND NOW() BETWEEN a.beginTime AND a.endTime
  135. </if>
  136. <if test="activityStatus == 3">
  137. AND a.endTime <![CDATA[ < ]]> NOW()
  138. </if>
  139. </where>
  140. ORDER BY addTime DESC
  141. </select>
  142. <select id="findDiscountActivityList" resultType="com.caimei365.manager.entity.hehe.product.DiscountActivity">
  143. SELECT a.id AS "id",
  144. a.name AS "name",
  145. a.onlineTime AS "onlineTime",
  146. a.offlineTime AS "offlineTime",
  147. a.addTime AS "addTime"
  148. FROM cm_hehe_discount_activity a
  149. <where>
  150. <if test="name != null and name != ''">
  151. AND a.name LIKE concat('%',#{name},'%')
  152. </if>
  153. <if test="status != null">
  154. <if test="status == 1">
  155. and NOW() <![CDATA[ < ]]> a.onlineTime
  156. </if>
  157. <if test="status == 2">
  158. and NOW() <![CDATA[ >= ]]> a.onlineTime and NOW() <![CDATA[ <= ]]> a.offlineTime
  159. </if>
  160. <if test="status == 3">
  161. and NOW() <![CDATA[ > ]]> a.offlineTime
  162. </if>
  163. </if>
  164. </where>
  165. order by a.addTime desc
  166. </select>
  167. <select id="findShareReductionList" resultType="com.caimei365.manager.entity.hehe.product.ShareReduction">
  168. SELECT
  169. a.id AS "id",
  170. a.name AS "name",
  171. a.reducedAmount AS "reducedAmount",
  172. a.touchPrice AS "touchPrice",
  173. a.shareNum AS "shareNum",
  174. a.startTime AS "startTime",
  175. a.endTime AS "endTime",
  176. a.addTime AS "addTime"
  177. FROM cm_hehe_reduction a
  178. <where>
  179. <if test="name != null and name != ''">
  180. AND a.name LIKE concat('%',#{name},'%')
  181. <if test="status != null">
  182. <if test="status == 1">
  183. and NOW() <![CDATA[ < ]]> a.startTime
  184. </if>
  185. <if test="status == 2">
  186. and NOW() <![CDATA[ >= ]]> a.startTime and NOW() <![CDATA[ <= ]]> a.endTime
  187. </if>
  188. <if test="status == 3">
  189. and NOW() <![CDATA[ > ]]> a.endTime
  190. </if>
  191. </if>
  192. </where>
  193. order by a.addTime desc
  194. </select>
  195. <select id="findInsideDiscountList" resultType="com.caimei365.manager.entity.hehe.product.InsideDiscount">
  196. SELECT
  197. a.id AS "id",
  198. a.title AS "title",
  199. a.discount AS "discount",
  200. a.status AS "status",
  201. a.productType AS "productType",
  202. a.addTime AS "addTime"
  203. FROM cm_hehe_discount a
  204. <where>
  205. <if test="title != null and title != ''">
  206. AND a.title LIKE concat('%',#{title},'%')
  207. <if test="status != null and status != ''">
  208. AND a.status = #{status}
  209. </if>
  210. </where>
  211. order by addTime desc
  212. </select>
  213. </mapper>