ProductModuleMapper.xml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  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, actStatus,
  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. where validFlag = '1'
  64. </select>
  65. <select id="getSmallType" resultType="com.caimei.module.base.entity.vo.SmalltypeVo">
  66. select
  67. <include refid="SmallType_Column_List" />
  68. from smalltype
  69. where bigTypeID = #{bigTypeID,jdbcType=INTEGER}
  70. and validFlag = '1'
  71. </select>
  72. <select id="getTinytype" resultType="com.caimei.module.base.entity.vo.TinytypeVo">
  73. select
  74. <include refid="Tinytype_Column_List" />
  75. from tinytype
  76. where smallTypeID = #{smallTypeID,jdbcType=INTEGER}
  77. and validFlag = '1'
  78. </select>
  79. <!-- sortType (3:价格升序, 4:价格降序, 7:人气, 8:销量) -->
  80. <select id="getProductsByTinyType" resultType="com.caimei.module.base.entity.vo.ProductVo" parameterType="java.lang.Integer">
  81. select
  82. <include refid="Product_Column_List" />
  83. from product
  84. where validFlag = 2
  85. and tinyTypeID = #{tinyTypeID,jdbcType=INTEGER}
  86. <choose>
  87. <when test="sortType == 3">
  88. order by price1 asc
  89. </when>
  90. <when test="sortType == 4">
  91. order by price1 desc
  92. </when>
  93. <when test="sortType == 7">
  94. order by favoriteTimes desc
  95. </when>
  96. <when test="sortType == 8">
  97. order by sellNumber desc
  98. </when>
  99. <otherwise>
  100. order by onlineTime desc
  101. </otherwise>
  102. </choose>
  103. </select>
  104. <select id="searchProduct" resultType="com.caimei.module.base.entity.vo.ProductVo">
  105. select
  106. *
  107. from product
  108. where validFlag = 2
  109. and name like CONCAT('%',#{searchWord,jdbcType=VARCHAR},'%')
  110. </select>
  111. <select id="findProductById" resultType="com.caimei.module.base.entity.vo.ProductVo">
  112. select
  113. <include refid="Product_Column_List" />
  114. from product
  115. where validFlag in (2,3,9)
  116. and productId = #{productId,jdbcType=BIGINT}
  117. </select>
  118. <select id="getSearchHistoryList" resultType="com.caimei.module.base.entity.vo.SearchHistoryVo">
  119. select id, userId, searchWord, searchDate, delFlag
  120. from user_search_history
  121. where userId = #{userId,jdbcType=BIGINT}
  122. </select>
  123. <select id="getSearchHistoryIdByWord" resultType="java.lang.Long">
  124. select id
  125. from user_search_history
  126. where searchWord = #{searchWord,jdbcType=VARCHAR}
  127. limit 1
  128. </select>
  129. <select id="findLowerLadderPrice" resultType="com.caimei.module.base.entity.vo.LadderPriceVo">
  130. select
  131. <include refid="LadderPrice_Column_List" />
  132. from product_ladder_price
  133. WHERE delFlag = '0'
  134. AND productId = #{productId,jdbcType=BIGINT}
  135. ORDER BY ladderNum DESC
  136. LIMIT 1
  137. </select>
  138. <select id="findProductImage" resultType="com.caimei.module.base.entity.vo.ProductImageVo">
  139. select
  140. <include refid="Image_Column_List" />
  141. from productimage
  142. where productID = #{productID,jdbcType=INTEGER}
  143. ORDER BY mainFlag DESC
  144. </select>
  145. <select id="findProductDetailById" resultType="com.caimei.module.base.entity.vo.ProductDetailVo">
  146. select
  147. <include refid="ProductDetail_Column_List" />
  148. from productdetailinfo
  149. where productId = #{productId,jdbcType=BIGINT}
  150. </select>
  151. <select id="findProductShopById" resultType="com.caimei.module.base.entity.vo.ShopVo">
  152. SELECT
  153. <include refid="Shop_Column_List" />
  154. FROM shop
  155. where shopID = #{shopID,jdbcType=INTEGER}
  156. </select>
  157. <!--新品上线(001) 优惠商品(010) 常用商品(100),三者同时存在111-->
  158. <select id="getProductsByPreferredFlag" resultType="com.caimei.module.base.entity.vo.ProductVo">
  159. select
  160. <include refid="Product_Column_List" />
  161. from product
  162. where validFlag = 2
  163. <if test="preferredFlag == 100">
  164. and preferredFlag in (100,101,110,111)
  165. </if>
  166. <if test="preferredFlag == 10">
  167. and preferredFlag in (10,11,110,111)
  168. </if>
  169. <if test="preferredFlag == 1">
  170. and preferredFlag in (1,11,101,111)
  171. </if>
  172. </select>
  173. <update id="updateSearchHistoryById" parameterType="com.caimei.module.base.entity.vo.SearchHistoryVo">
  174. update user_search_history
  175. <set>
  176. <if test="userId != null">
  177. userId = #{userId,jdbcType=BIGINT},
  178. </if>
  179. <if test="searchWord != null">
  180. searchWord = #{searchWord,jdbcType=VARCHAR},
  181. </if>
  182. <if test="searchDate != null">
  183. searchDate = #{searchDate,jdbcType=TIMESTAMP},
  184. </if>
  185. <if test="delFlag != null">
  186. delFlag = #{delFlag,jdbcType=VARCHAR},
  187. </if>
  188. </set>
  189. where id = #{id,jdbcType=BIGINT}
  190. </update>
  191. <insert id="insertSearchHistory" keyColumn="id" keyProperty="id" parameterType="com.caimei.module.base.entity.vo.SearchHistoryVo">
  192. insert into user_search_history
  193. <trim prefix="(" suffix=")" suffixOverrides=",">
  194. <if test="userId != null">
  195. userId,
  196. </if>
  197. <if test="searchWord != null">
  198. searchWord,
  199. </if>
  200. <if test="searchDate != null">
  201. searchDate,
  202. </if>
  203. <if test="delFlag != null">
  204. delFlag,
  205. </if>
  206. </trim>
  207. <trim prefix="values (" suffix=")" suffixOverrides=",">
  208. <if test="userId != null">
  209. #{userId,jdbcType=BIGINT},
  210. </if>
  211. <if test="searchWord != null">
  212. #{searchWord,jdbcType=VARCHAR},
  213. </if>
  214. <if test="searchDate != null">
  215. #{searchDate,jdbcType=TIMESTAMP},
  216. </if>
  217. <if test="delFlag != null">
  218. #{delFlag,jdbcType=VARCHAR},
  219. </if>
  220. </trim>
  221. </insert>
  222. <!--删除大于10条的历史记录-->
  223. <delete id="deleteSearchHistoryByUserId" parameterType="java.lang.Long">
  224. DELETE tb FROM user_search_history AS tb,(
  225. SELECT id FROM user_search_history
  226. WHERE userId=#{userId,jdbcType=BIGINT}
  227. ORDER BY id DESC
  228. LIMIT 1,10
  229. ) AS temp
  230. WHERE userId=#{userId}
  231. AND (temp.id > tb.id)
  232. </delete>
  233. <delete id="deleteAllSearchHistory">
  234. DELETE FROM
  235. user_search_history
  236. WHERE
  237. userId=#{userId}
  238. </delete>
  239. <select id="findLadderPrice" resultType="com.caimei.module.base.entity.vo.LadderPriceVo">
  240. SELECT
  241. <include refid="LadderPrice_Column_List" />
  242. FROM
  243. product_ladder_price
  244. WHERE
  245. productId = #{productID}
  246. AND userType = '3'
  247. AND delFlag = '0'
  248. ORDER BY
  249. ladderNum ASC
  250. </select>
  251. <select id="getRecommendIds" resultType="java.lang.Integer">
  252. SELECT recommendProductID FROM cm_product_recommend WHERE productID=#{productID} ORDER BY sort ASC
  253. </select>
  254. <select id="getRecommendByIds" resultType="com.caimei.module.base.entity.vo.ProductVo">
  255. SELECT
  256. <include refid="Product_Column_List"/>
  257. FROM
  258. product
  259. WHERE
  260. validFlag = '2'
  261. AND productID IN
  262. <foreach collection="productIDs" open="(" separator="," close=")" item="productID">
  263. #{productID}
  264. </foreach>
  265. </select>
  266. <select id="getDeFaultRecommend" resultType="com.caimei.module.base.entity.vo.ProductVo">
  267. select
  268. <include refid="Product_Column_List" />
  269. from product
  270. where validFlag = 2
  271. and tinyTypeID = #{tinyTypeID}
  272. order by sellNumber desc,onlineTime desc
  273. limit 7
  274. </select>
  275. </mapper>