ProductModuleMapper.xml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  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, productRemarks,
  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. order by id desc
  123. </select>
  124. <select id="getSearchHistoryIdByWord" resultType="java.lang.Long">
  125. select id
  126. from user_search_history
  127. where searchWord = #{searchWord,jdbcType=VARCHAR}
  128. limit 1
  129. </select>
  130. <select id="findLowerLadderPrice" resultType="com.caimei.module.base.entity.vo.LadderPriceVo">
  131. select
  132. <include refid="LadderPrice_Column_List" />
  133. from product_ladder_price
  134. WHERE delFlag = '0'
  135. AND productId = #{productId,jdbcType=BIGINT}
  136. ORDER BY ladderNum DESC
  137. LIMIT 1
  138. </select>
  139. <select id="findProductImage" resultType="com.caimei.module.base.entity.vo.ProductImageVo">
  140. select
  141. <include refid="Image_Column_List" />
  142. from productimage
  143. where productID = #{productID,jdbcType=INTEGER}
  144. ORDER BY mainFlag DESC
  145. </select>
  146. <select id="findProductImageString" resultType="string">
  147. select
  148. image
  149. from productimage
  150. where productID = #{productID,jdbcType=INTEGER}
  151. ORDER BY mainFlag DESC
  152. </select>
  153. <select id="findProductDetailById" resultType="com.caimei.module.base.entity.vo.ProductDetailVo">
  154. select
  155. <include refid="ProductDetail_Column_List" />
  156. from productdetailinfo
  157. where productId = #{productId,jdbcType=BIGINT}
  158. </select>
  159. <select id="findProductShopById" resultType="com.caimei.module.base.entity.vo.ShopVo">
  160. SELECT
  161. <include refid="Shop_Column_List" />
  162. FROM shop
  163. where shopID = #{shopID,jdbcType=INTEGER}
  164. </select>
  165. <!--新品上线(001) 优惠商品(010) 常用商品(100),三者同时存在111-->
  166. <select id="getProductsByPreferredFlag" resultType="com.caimei.module.base.entity.vo.ProductVo">
  167. select
  168. <include refid="Product_Column_List" />
  169. from product
  170. where validFlag = 2
  171. <if test="preferredFlag == 100">
  172. and preferredFlag in (100,101,110,111)
  173. </if>
  174. <if test="preferredFlag == 10">
  175. and preferredFlag in (10,11,110,111)
  176. </if>
  177. <if test="preferredFlag == 1">
  178. and preferredFlag in (1,11,101,111)
  179. </if>
  180. </select>
  181. <update id="updateSearchHistoryById" parameterType="com.caimei.module.base.entity.vo.SearchHistoryVo">
  182. update user_search_history
  183. <set>
  184. <if test="userId != null">
  185. userId = #{userId,jdbcType=BIGINT},
  186. </if>
  187. <if test="searchWord != null">
  188. searchWord = #{searchWord,jdbcType=VARCHAR},
  189. </if>
  190. <if test="searchDate != null">
  191. searchDate = #{searchDate,jdbcType=TIMESTAMP},
  192. </if>
  193. <if test="delFlag != null">
  194. delFlag = #{delFlag,jdbcType=VARCHAR},
  195. </if>
  196. </set>
  197. where id = #{id,jdbcType=BIGINT}
  198. </update>
  199. <insert id="insertSearchHistory" keyColumn="id" keyProperty="id" parameterType="com.caimei.module.base.entity.vo.SearchHistoryVo">
  200. insert into user_search_history
  201. <trim prefix="(" suffix=")" suffixOverrides=",">
  202. <if test="userId != null">
  203. userId,
  204. </if>
  205. <if test="searchWord != null">
  206. searchWord,
  207. </if>
  208. <if test="searchDate != null">
  209. searchDate,
  210. </if>
  211. <if test="delFlag != null">
  212. delFlag,
  213. </if>
  214. </trim>
  215. <trim prefix="values (" suffix=")" suffixOverrides=",">
  216. <if test="userId != null">
  217. #{userId,jdbcType=BIGINT},
  218. </if>
  219. <if test="searchWord != null">
  220. #{searchWord,jdbcType=VARCHAR},
  221. </if>
  222. <if test="searchDate != null">
  223. #{searchDate,jdbcType=TIMESTAMP},
  224. </if>
  225. <if test="delFlag != null">
  226. #{delFlag,jdbcType=VARCHAR},
  227. </if>
  228. </trim>
  229. </insert>
  230. <!--删除大于10条的历史记录-->
  231. <delete id="deleteSearchHistoryByUserId">
  232. DELETE FROM user_search_history
  233. WHERE userId=#{userId}
  234. AND id NOT IN (
  235. SELECT temp.id FROM (
  236. SELECT id FROM user_search_history WHERE userId=#{userId} ORDER BY id DESC LIMIT 10
  237. ) AS temp
  238. )
  239. </delete>
  240. <delete id="deleteAllSearchHistory">
  241. DELETE FROM
  242. user_search_history
  243. WHERE
  244. userId=#{userId}
  245. </delete>
  246. <select id="findLadderPrice" resultType="com.caimei.module.base.entity.vo.LadderPriceVo">
  247. SELECT
  248. <include refid="LadderPrice_Column_List" />
  249. FROM
  250. product_ladder_price
  251. WHERE
  252. productId = #{productID}
  253. AND userType = '3'
  254. AND delFlag = '0'
  255. ORDER BY
  256. ladderNum ASC
  257. </select>
  258. <select id="getRecommendIds" resultType="java.lang.Integer">
  259. SELECT recommendProductID FROM cm_product_recommend WHERE productID=#{productID} ORDER BY sort ASC
  260. </select>
  261. <select id="getRecommendByIds" resultType="com.caimei.module.base.entity.vo.ProductVo">
  262. SELECT
  263. <include refid="Product_Column_List"/>
  264. FROM
  265. product
  266. WHERE
  267. validFlag = '2'
  268. AND productID IN
  269. <foreach collection="productIDs" open="(" separator="," close=")" item="productID">
  270. #{productID}
  271. </foreach>
  272. </select>
  273. <select id="getDeFaultRecommend" resultType="com.caimei.module.base.entity.vo.ProductVo">
  274. select
  275. <include refid="Product_Column_List" />
  276. from product
  277. where validFlag = 2
  278. and tinyTypeID = #{tinyTypeID}
  279. order by sellNumber desc,onlineTime desc
  280. limit 7
  281. </select>
  282. </mapper>