ProductModuleMapper.xml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  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.module.product.dao.ProductModuleDao">
  4. <sql id="BigType_Column_List">
  5. bigTypeID, `name`, bigTypeCode, validFlag, sortIndex, seo, displayOnHomePageFlag
  6. </sql>
  7. <sql id="SmallType_Column_List">
  8. smallTypeID, bigTypeID, `name`, smallTypeCode, validFlag, sortIndex, seo, displayOnHomePageFlag
  9. </sql>
  10. <sql id="Tinytype_Column_List">
  11. tinyTypeID, smallTypeID, `name`, tinyTypeCode, icon, validFlag, seo, sortIndex
  12. </sql>
  13. <sql id="Product_Column_List">
  14. productID, brandID, tinyTypeID, preferredFlag, selfTypeID, shopID, `name`, aliasName, searchKey,
  15. normalPrice, price, highestUserLevelPrice, lowestUserLevelPrice, lowestUserLevelID,
  16. price0, price0Grade, price0Text, price0TextFlag, price1, price1Grade, price1Text,
  17. price1TextFlag, price8, price8Grade, price8Text, price8TextFlag, ladderPriceFlag,
  18. price2, price3, price4, price5, price6, price7, fee, stock, hasSkuFlag, mainImage,
  19. propertiesInfo, addTime, updateTime, sellNumber, weekSellNumber, beforeValidFlag,
  20. validFlag, favoriteTimes, commentScore, commentTimes, selfRecommendFlag, sysRecommendFlag,
  21. sortIndex, featuredFlag, featuredSortIndex, productCode, rate1, rate2, unit, synToERPFlag,
  22. allAreaFlag, provinceIDs, serviceNumber, maxBuyNumber, virtualFlag, minBuyNumber,
  23. packageCount, byFlag, normalProductFlag, wholeSaleProductFlag, promotionProductFlag,
  24. groupBuyProductFlag, step, speCommisionFlag, speCommision, videourl, props, providers,
  25. serviceCommissionRatio, reCommissionRatio, pushToERPName, prodBeans, useBeansFlag,
  26. privateFlag, invisibleServiceProviderIDs, displayOnCRMFlag, needServiceFlag, actFlag,
  27. actSort, actPrice0, actPrice1, actPrice2, actPrice3, actPrice4, actPrice5, actPrice6,
  28. actPrice7, actType, actCreateTime, beginTime, endTime, shopIndexModuleID, onlineTime,
  29. downlineTime, freePostFlag, crmBigTypeId, crmSmallTypeId, costPrice, costProportional,
  30. costCheckFlag, precisehKey, docBoost, cmbeanFlag, cmbeanPrice, cmbeanSort, actBuyGiftNum,
  31. actFullGiftAmount, actFullReduceAmount, actReduceAmount, visibility, surplusTime,
  32. priceType, tags, recommendType, machineType
  33. </sql>
  34. <sql id="ProductDetail_Column_List">
  35. productDetailInfoID, productID, propValueAlias, propValueImages, detailInfo, detailInfoTxt,
  36. seoTitle, seoKeyword, seoDes, serviceInfo, orderInfo
  37. </sql>
  38. <sql id="LadderPrice_Column_List">
  39. id, productId, userType, ladderNum, buyNum, buyPrice, createBy, createDate, updateBy,
  40. updateDate, delFlag
  41. </sql>
  42. <sql id="Image_Column_List">
  43. productImageID, productID, shopID, addTime, image, mainFlag, sortIndex
  44. </sql>
  45. <sql id="Shop_Column_List">
  46. shopID, userID, `name`, sname, nameEn, site, ledgerNo, logo, rebateAmount, `level`,
  47. score, productCount, legalPerson, businessLicense, businessLicenseImage, taxCertificate,
  48. taxCertificateImage, provinceID, cityID, townID, address, registeredCapital, nature,
  49. turnover, linkMan, contractPhone, contractMobile, fax, zipCode, linkMan1, duty1,
  50. contractPhone1, contractMobile1, contractQQ1, wechat1, contractEmail1, linkMan2,
  51. duty2, contractPhone2, contractMobile2, contractQQ2, wechat2, contractEmail2, `scope`,
  52. info, productDesc, lng, lat, addTime, auditStatus, auditTime, auditNote, favoriteTimes,
  53. validFlag, payFlag1, auditFlag1, payFlag2, auditFlag2, payFlag3, auditFlag3, note,
  54. `status`, sortIndex, rate1, rate2, masterFlag, erpFlag, shopSecret, masterLogo, cooperateFlag,
  55. bail, businessScope, socialCreditCode, mainpro, firstShopType, secondShopType, medicalPracticeLicenseImg1,
  56. medicalPracticeLicenseImg2, medicalPracticeLicenseImg3, bankAccount, bankAccountName,
  57. bankName, ableRebateAmount
  58. </sql>
  59. <select id="getBigType" resultType="com.caimei.module.base.entity.vo.BigtypeVo">
  60. select
  61. <include refid="BigType_Column_List" />
  62. from bigtype
  63. </select>
  64. <select id="getSmallType" resultType="com.caimei.module.base.entity.vo.SmalltypeVo">
  65. select
  66. <include refid="SmallType_Column_List" />
  67. from smalltype
  68. where bigTypeID = #{bigTypeID,jdbcType=INTEGER}
  69. </select>
  70. <select id="getTinytype" resultType="com.caimei.module.base.entity.vo.TinytypeVo">
  71. select
  72. <include refid="Tinytype_Column_List" />
  73. from tinytype
  74. where smallTypeID = #{smallTypeID,jdbcType=INTEGER}
  75. </select>
  76. <!-- sortType (3:价格升序, 4:价格降序, 7:人气, 8:销量) -->
  77. <select id="getProductsByTinyType" resultType="com.caimei.module.base.entity.vo.ProductVo" parameterType="java.lang.Integer">
  78. select
  79. <include refid="Product_Column_List" />
  80. from product
  81. where validFlag = 2
  82. and tinyTypeID = #{tinyTypeID,jdbcType=INTEGER}
  83. <choose>
  84. <when test="sortType == 3">
  85. order by price1 asc
  86. </when>
  87. <when test="sortType == 4">
  88. order by price1 desc
  89. </when>
  90. <when test="sortType == 7">
  91. order by favoriteTimes desc
  92. </when>
  93. <when test="sortType == 8">
  94. order by sellNumber desc
  95. </when>
  96. <otherwise>
  97. order by onlineTime desc
  98. </otherwise>
  99. </choose>
  100. </select>
  101. <select id="searchProduct" resultType="com.caimei.module.base.entity.vo.ProductVo">
  102. select
  103. *
  104. from product
  105. where validFlag = 2
  106. and name like CONCAT('%',#{searchWord,jdbcType=VARCHAR},'%')
  107. </select>
  108. <select id="findProductById" resultType="com.caimei.module.base.entity.vo.ProductVo">
  109. select
  110. <include refid="Product_Column_List" />
  111. from product
  112. where validFlag in (2,3)
  113. and productId = #{productId,jdbcType=BIGINT}
  114. </select>
  115. <select id="getSearchHistoryList" resultType="com.caimei.module.base.entity.vo.SearchHistoryVo">
  116. select id, userId, searchWord, searchDate, delFlag
  117. from user_search_history
  118. where userId = #{userId,jdbcType=BIGINT}
  119. </select>
  120. <select id="getSearchHistoryIdByWord" resultType="java.lang.Long">
  121. select id
  122. from user_search_history
  123. where searchWord = #{searchWord,jdbcType=VARCHAR}
  124. limit 1
  125. </select>
  126. <select id="findLowerLadderPrice" resultType="com.caimei.module.base.entity.vo.LadderPriceVo">
  127. select
  128. <include refid="LadderPrice_Column_List" />
  129. from product_ladder_price
  130. WHERE delFlag = '0'
  131. AND productId = #{productId,jdbcType=BIGINT}
  132. ORDER BY ladderNum DESC
  133. LIMIT 1
  134. </select>
  135. <select id="findProductImage" resultType="com.caimei.module.base.entity.vo.ProductImageVo">
  136. select
  137. <include refid="Image_Column_List" />
  138. from productimage
  139. where productID = #{productID,jdbcType=INTEGER}
  140. ORDER BY mainFlag DESC
  141. </select>
  142. <select id="findProductDetailById" resultType="com.caimei.module.base.entity.vo.ProductDetailVo">
  143. select
  144. <include refid="ProductDetail_Column_List" />
  145. from productdetailinfo
  146. where productId = #{productId,jdbcType=BIGINT}
  147. </select>
  148. <select id="findProductShopById" resultType="com.caimei.module.base.entity.vo.ShopVo">
  149. SELECT
  150. <include refid="Shop_Column_List" />
  151. FROM shop
  152. where shopID = #{shopID,jdbcType=INTEGER}
  153. </select>
  154. <!--新品上线(001) 优惠商品(010) 常用商品(100),三者同时存在111-->
  155. <select id="getProductsByPreferredFlag" resultType="com.caimei.module.base.entity.vo.ProductVo">
  156. select
  157. <include refid="Product_Column_List" />
  158. from product
  159. where validFlag = 2
  160. <if test="preferredFlag == 100">
  161. and preferredFlag in (100,101,110,111)
  162. </if>
  163. <if test="preferredFlag == 10">
  164. and preferredFlag in (10,11,110,111)
  165. </if>
  166. <if test="preferredFlag == 1">
  167. and preferredFlag in (1,11,101,111)
  168. </if>
  169. </select>
  170. <update id="updateSearchHistoryById" parameterType="com.caimei.module.base.entity.vo.SearchHistoryVo">
  171. update user_search_history
  172. <set>
  173. <if test="userId != null">
  174. userId = #{userId,jdbcType=BIGINT},
  175. </if>
  176. <if test="searchWord != null">
  177. searchWord = #{searchWord,jdbcType=VARCHAR},
  178. </if>
  179. <if test="searchDate != null">
  180. searchDate = #{searchDate,jdbcType=TIMESTAMP},
  181. </if>
  182. <if test="delFlag != null">
  183. delFlag = #{delFlag,jdbcType=VARCHAR},
  184. </if>
  185. </set>
  186. where id = #{id,jdbcType=BIGINT}
  187. </update>
  188. <insert id="insertSearchHistory" keyColumn="id" keyProperty="id" parameterType="com.caimei.module.base.entity.vo.SearchHistoryVo">
  189. insert into user_search_history
  190. <trim prefix="(" suffix=")" suffixOverrides=",">
  191. <if test="userId != null">
  192. userId,
  193. </if>
  194. <if test="searchWord != null">
  195. searchWord,
  196. </if>
  197. <if test="searchDate != null">
  198. searchDate,
  199. </if>
  200. <if test="delFlag != null">
  201. delFlag,
  202. </if>
  203. </trim>
  204. <trim prefix="values (" suffix=")" suffixOverrides=",">
  205. <if test="userId != null">
  206. #{userId,jdbcType=BIGINT},
  207. </if>
  208. <if test="searchWord != null">
  209. #{searchWord,jdbcType=VARCHAR},
  210. </if>
  211. <if test="searchDate != null">
  212. #{searchDate,jdbcType=TIMESTAMP},
  213. </if>
  214. <if test="delFlag != null">
  215. #{delFlag,jdbcType=VARCHAR},
  216. </if>
  217. </trim>
  218. </insert>
  219. <!--删除大于10条的历史记录-->
  220. <delete id="deleteSearchHistoryByUserId" parameterType="java.lang.Long">
  221. DELETE tb FROM user_search_history AS tb,(
  222. SELECT id FROM user_search_history
  223. WHERE userId=#{userId,jdbcType=BIGINT}
  224. ORDER BY id DESC
  225. LIMIT 1,10
  226. ) AS temp
  227. WHERE userId=#{userId,jdbcType=BIGINT}
  228. AND (temp.id > tb.id)
  229. </delete>
  230. <delete id="deleteAllSearchHistory">
  231. DELETE FROM
  232. user_search_history
  233. WHERE
  234. userId=#{userId,jdbcType=BIGINT}
  235. </delete>
  236. <select id="findLadderPrice" resultType="com.caimei.module.base.entity.vo.LadderPriceVo">
  237. SELECT
  238. <include refid="LadderPrice_Column_List" />
  239. FROM
  240. product_ladder_price
  241. WHERE
  242. productId = #{productID}
  243. AND userType = '3'
  244. AND delFlag = '0'
  245. ORDER BY
  246. ladderNum ASC
  247. </select>
  248. <select id="getRecommendIds" resultType="java.lang.Integer">
  249. SELECT recommendProductID FROM cm_product_recommend WHERE productID=#{productID} ORDER BY sort ASC
  250. </select>
  251. <select id="getRecommendByIds" resultType="com.caimei.module.base.entity.vo.ProductVo">
  252. SELECT
  253. <include refid="Product_Column_List"/>
  254. FROM
  255. product
  256. WHERE
  257. validFlag = '2'
  258. AND productID IN
  259. <foreach collection="productIDs" open="(" separator="," close=")" item="productID">
  260. #{productID}
  261. </foreach>
  262. </select>
  263. <select id="getDeFaultRecommend" resultType="com.caimei.module.base.entity.vo.ProductVo">
  264. select
  265. <include refid="Product_Column_List" />
  266. from product
  267. where validFlag = 2
  268. and tinyTypeID = #{tinyTypeID}
  269. order by sellNumber desc,onlineTime desc
  270. </select>
  271. </mapper>