ProductModuleMapper.xml 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631
  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, typeSort, `name`, bigTypeCode, wwwValidFlag, crmValidFlag, wwwIcon, crmIcon, addTime, sortIndex
  6. </sql>
  7. <sql id="SmallType_Column_List">
  8. smallTypeID, bigTypeID, `name`, smallTypeCode, wwwValidFlag, crmValidFlag, wwwIcon, crmIcon, addTime, sortIndex
  9. </sql>
  10. <sql id="Tinytype_Column_List">
  11. tinyTypeID, smallTypeID, `name`, tinyTypeCode, wwwValidFlag, crmValidFlag, wwwIcon, crmIcon, addTime, sortIndex
  12. </sql>
  13. <sql id="Product_Column_List">
  14. productID, brandID,bigTypeID,smallTypeID, tinyTypeID,productCategory, 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, price8Text as beautyActFlag, 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, taxPoint, supplierTaxPoint, includedTax,
  33. invoiceType,commodityType
  34. </sql>
  35. <sql id="ProductDetail_Column_List">
  36. productDetailInfoID, productID, propValueAlias, propValueImages, detailInfo, detailInfoTxt,
  37. seoTitle, seoKeyword, seoDes, serviceInfo, orderInfo
  38. </sql>
  39. <sql id="LadderPrice_Column_List">
  40. id, productId, userType, ladderNum, buyNum, buyPrice, createBy, createDate, updateBy,
  41. updateDate, delFlag
  42. </sql>
  43. <sql id="Image_Column_List">
  44. productImageID, productID, shopID, addTime, image, mainFlag, sortIndex
  45. </sql>
  46. <sql id="Shop_Column_List">
  47. s.shopID, s.userID, s.`name`, s.sname, s.nameEn, s.site, s.ledgerNo, s.logo, s.rebateAmount, s.`level`,
  48. s.score, s.productCount, s.legalPerson, s.businessLicense, s.businessLicenseImage, s.taxCertificate,
  49. s.taxCertificateImage, s.provinceID, s.cityID, s.townID, s.address, s.registeredCapital, s.nature,
  50. s.turnover, s.linkMan, s.contractPhone, s.contractMobile, s.fax, s.zipCode, s.linkMan1, s.duty1,
  51. s.contractPhone1, s.contractMobile1, s.contractQQ1, s.wechat1, s.contractEmail1, s.linkMan2,
  52. s.duty2, s.contractPhone2, s.contractMobile2, s.contractQQ2, s.wechat2, s.contractEmail2, s.`scope`,
  53. s.info, s.productDesc, s.lng, s.lat, s.addTime, s.auditStatus, s.auditTime, s.auditNote, s.favoriteTimes,
  54. s.validFlag, s.payFlag1, s.auditFlag1, s.payFlag2, s.auditFlag2, s.payFlag3, s.auditFlag3, s.note,
  55. s.`status`, s.sortIndex, s.rate1, s.rate2, s.masterFlag, s.erpFlag, s.shopSecret, s.masterLogo, s.cooperateFlag,
  56. s.bail, s.businessScope, s.socialCreditCode, s.mainpro, s.firstShopType, s.secondShopType, s.medicalPracticeLicenseImg1,
  57. s.medicalPracticeLicenseImg2, s.medicalPracticeLicenseImg3, s.bankAccount, s.bankAccountName,
  58. s.bankName, s.ableRebateAmount,s.authorizationCertificateImage
  59. </sql>
  60. <select id="getBigType" resultType="com.caimei.module.base.entity.vo.BigtypeVo">
  61. select
  62. <include refid="BigType_Column_List" />
  63. from bigtype
  64. where
  65. typeSort = #{typeSort}
  66. <if test="source == 'www'.toString()">
  67. and wwwValidFlag = '1'
  68. </if>
  69. <if test="source == 'crm'.toString()">
  70. and crmValidFlag = '1'
  71. </if>
  72. order by ifnull(sortIndex,10000) ASC,addTime DESC
  73. </select>
  74. <select id="getSmallType" resultType="com.caimei.module.base.entity.vo.SmalltypeVo">
  75. select
  76. <include refid="SmallType_Column_List" />
  77. from smalltype
  78. where bigTypeID = #{bigTypeID,jdbcType=INTEGER}
  79. <if test="source == 'www'.toString()">
  80. and wwwValidFlag = '1'
  81. </if>
  82. <if test="source == 'crm'.toString()">
  83. and crmValidFlag = '1'
  84. </if>
  85. order by ifnull(sortIndex,10000) ASC,addTime DESC
  86. </select>
  87. <select id="getTinytype" resultType="com.caimei.module.base.entity.vo.TinytypeVo">
  88. select
  89. <include refid="Tinytype_Column_List" />
  90. from tinytype
  91. where smallTypeID = #{smallTypeID,jdbcType=INTEGER}
  92. <if test="source == 'www'.toString()">
  93. and wwwValidFlag = '1'
  94. </if>
  95. <if test="source == 'crm'.toString()">
  96. and crmValidFlag = '1'
  97. </if>
  98. order by ifnull(sortIndex,10000) ASC,addTime DESC
  99. </select>
  100. <!-- sortType (3:价格升序, 4:价格降序, 7:人气, 8:销量) -->
  101. <select id="getProductsByTypeId" resultType="com.caimei.module.base.entity.vo.ProductVo" parameterType="java.lang.Integer">
  102. select
  103. <include refid="Product_Column_List" />
  104. from product
  105. <trim prefix="WHERE (" suffix=")" prefixOverrides="AND |OR ">
  106. <if test="bigTypeIDList != null and bigTypeIDList.size() > 0">
  107. OR bigTypeID in
  108. <foreach collection="bigTypeIDList" open="(" separator="," close=")" item="bigTypeID">
  109. #{bigTypeID}
  110. </foreach>
  111. </if>
  112. <if test="smallTypeIDList != null and smallTypeIDList.size() > 0">
  113. OR smallTypeID in
  114. <foreach collection="smallTypeIDList" open="(" separator="," close=")" item="smallTypeID">
  115. #{smallTypeID}
  116. </foreach>
  117. </if>
  118. <if test="tinyTypeIDList != null and tinyTypeIDList.size() > 0">
  119. OR tinyTypeID in
  120. <foreach collection="tinyTypeIDList" open="(" separator="," close=")" item="tinyTypeID">
  121. #{tinyTypeID}
  122. </foreach>
  123. </if>
  124. </trim>
  125. and validFlag = 2
  126. <choose>
  127. <when test="sortType == 1">
  128. order by price1 asc
  129. </when>
  130. <when test="sortType == 2">
  131. order by price1 desc
  132. </when>
  133. <when test="sortType == 3">
  134. order by favoriteTimes asc
  135. </when>
  136. <when test="sortType == 4">
  137. order by favoriteTimes desc
  138. </when>
  139. <when test="sortType == 5">
  140. order by sellNumber asc
  141. </when>
  142. <when test="sortType == 6">
  143. order by sellNumber desc
  144. </when>
  145. <otherwise>
  146. order by productID desc
  147. </otherwise>
  148. </choose>
  149. </select>
  150. <select id="searchProduct" resultType="com.caimei.module.base.entity.vo.ProductVo">
  151. select
  152. *
  153. from product
  154. where validFlag = 2
  155. and name like CONCAT('%',#{searchWord,jdbcType=VARCHAR},'%')
  156. </select>
  157. <select id="findProductById" resultType="com.caimei.module.base.entity.vo.ProductVo">
  158. select
  159. <include refid="Product_Column_List" />
  160. from product
  161. where validFlag in (2,3,9)
  162. and productId = #{productId,jdbcType=BIGINT}
  163. </select>
  164. <select id="findProductUnlimited" resultType="com.caimei.module.base.entity.vo.ProductVo">
  165. select
  166. <include refid="Product_Column_List" />
  167. from product
  168. where productId = #{productId,jdbcType=BIGINT}
  169. </select>
  170. <select id="getSearchHistoryList" resultType="com.caimei.module.base.entity.vo.SearchHistoryVo">
  171. select id, userId, searchWord, searchDate, delFlag
  172. from user_search_history
  173. where userId = #{userId,jdbcType=BIGINT}
  174. order by id desc
  175. </select>
  176. <select id="getSearchHistoryIdByWord" resultType="java.lang.Long">
  177. select id
  178. from user_search_history
  179. where searchWord = #{searchWord,jdbcType=VARCHAR}
  180. limit 1
  181. </select>
  182. <select id="findLowerLadderPrice" resultType="com.caimei.module.base.entity.vo.LadderPriceVo">
  183. select
  184. <include refid="LadderPrice_Column_List" />
  185. from product_ladder_price
  186. WHERE delFlag = '0'
  187. AND productId = #{productId,jdbcType=BIGINT}
  188. ORDER BY ladderNum DESC
  189. LIMIT 1
  190. </select>
  191. <select id="findProductImage" resultType="com.caimei.module.base.entity.vo.ProductImageVo">
  192. select
  193. <include refid="Image_Column_List" />
  194. from productimage
  195. where productID = #{productID,jdbcType=INTEGER}
  196. ORDER BY mainFlag DESC
  197. </select>
  198. <select id="findImageByProductId" resultType="String">
  199. select
  200. image
  201. from productimage
  202. where productID = #{productID,jdbcType=INTEGER}
  203. ORDER BY mainFlag DESC
  204. </select>
  205. <select id="findProductImageString" resultType="string">
  206. select
  207. image
  208. from productimage
  209. where productID = #{productID,jdbcType=INTEGER}
  210. ORDER BY mainFlag DESC
  211. </select>
  212. <select id="findProductDetailById" resultType="com.caimei.module.base.entity.vo.ProductDetailVo">
  213. select
  214. <include refid="ProductDetail_Column_List" />
  215. from productdetailinfo
  216. where productId = #{productId,jdbcType=BIGINT}
  217. </select>
  218. <select id="findProductShopById" resultType="com.caimei.module.base.entity.vo.ShopVo">
  219. SELECT
  220. <include refid="Shop_Column_List" />
  221. ,count(*) as normalNum
  222. FROM shop s
  223. left join product p on s.shopID = p.shopID and p.validFlag = 2
  224. where s.shopID = #{shopID,jdbcType=INTEGER}
  225. group by s.shopID
  226. </select>
  227. <select id="findProductNormalNumById" resultType="java.lang.Integer">
  228. SELECT
  229. count(*) as normalNum
  230. FROM product p
  231. where p.shopID = #{shopID,jdbcType=INTEGER}
  232. and p.validFlag = 2
  233. group by p.shopID
  234. </select>
  235. <!--新品上线(001) 优惠商品(010) 常用商品(100),三者同时存在111-->
  236. <select id="getProductsByPreferredFlag" resultType="com.caimei.module.base.entity.vo.ProductVo">
  237. select
  238. <include refid="Product_Column_List" />
  239. from product
  240. where validFlag = 2
  241. <if test="preferredFlag == 100">
  242. and preferredFlag in (100,101,110,111)
  243. </if>
  244. <if test="preferredFlag == 10">
  245. and preferredFlag in (10,11,110,111)
  246. </if>
  247. <if test="preferredFlag == 1">
  248. and preferredFlag in (1,11,101,111)
  249. </if>
  250. </select>
  251. <update id="updateSearchHistoryById" parameterType="com.caimei.module.base.entity.vo.SearchHistoryVo">
  252. update user_search_history
  253. <set>
  254. <if test="userId != null">
  255. userId = #{userId,jdbcType=BIGINT},
  256. </if>
  257. <if test="searchWord != null">
  258. searchWord = #{searchWord,jdbcType=VARCHAR},
  259. </if>
  260. <if test="searchDate != null">
  261. searchDate = #{searchDate,jdbcType=TIMESTAMP},
  262. </if>
  263. <if test="delFlag != null">
  264. delFlag = #{delFlag,jdbcType=VARCHAR},
  265. </if>
  266. </set>
  267. where id = #{id,jdbcType=BIGINT}
  268. </update>
  269. <update id="updateViewingNum">
  270. UPDATE cm_second_hand_detail SET
  271. viewingNum = #{viewingNum}
  272. WHERE productID = #{productID}
  273. </update>
  274. <update id="updatSecondHnadproductSold">
  275. UPDATE cm_second_hand_detail SET sold = 1 where productID = #{productID}
  276. </update>
  277. <update id="updateProductValidFlag">
  278. UPDATE product SET validFlag = #{validFlag} where productID = #{productID}
  279. </update>
  280. <insert id="insertSearchHistory" keyColumn="id" keyProperty="id" parameterType="com.caimei.module.base.entity.vo.SearchHistoryVo">
  281. insert into user_search_history
  282. <trim prefix="(" suffix=")" suffixOverrides=",">
  283. <if test="userId != null">
  284. userId,
  285. </if>
  286. <if test="searchWord != null">
  287. searchWord,
  288. </if>
  289. <if test="searchDate != null">
  290. searchDate,
  291. </if>
  292. <if test="delFlag != null">
  293. delFlag,
  294. </if>
  295. </trim>
  296. <trim prefix="values (" suffix=")" suffixOverrides=",">
  297. <if test="userId != null">
  298. #{userId,jdbcType=BIGINT},
  299. </if>
  300. <if test="searchWord != null">
  301. #{searchWord,jdbcType=VARCHAR},
  302. </if>
  303. <if test="searchDate != null">
  304. #{searchDate,jdbcType=TIMESTAMP},
  305. </if>
  306. <if test="delFlag != null">
  307. #{delFlag,jdbcType=VARCHAR},
  308. </if>
  309. </trim>
  310. </insert>
  311. <insert id="saveSencondHandProduct" parameterType="com.caimei.module.base.entity.po.SeconHandProduct" keyProperty="id" useGeneratedKeys="true">
  312. INSERT INTO cm_second_hand_detail(
  313. productID,
  314. sold,
  315. secondHandType,
  316. instrumentType,
  317. fixedYears,
  318. maturityYears,
  319. companyName,
  320. detailTalkFlag,
  321. originalPrice,
  322. contactName,
  323. contactMobile,
  324. dockingPeopleName,
  325. dockingPeopleMobile,
  326. secondProductType,
  327. townId,
  328. brandName,
  329. provinceCityDistrict,
  330. address,
  331. productQuality,
  332. productDetails,
  333. viewingNum,
  334. payStatus,
  335. payAmount,
  336. payFormData,
  337. payType,
  338. payDate,
  339. submitDate,
  340. reviewedDate,
  341. onLineDate,
  342. source,
  343. publisher
  344. ) VALUES (
  345. #{productID},
  346. #{sold},
  347. #{secondHandType},
  348. #{instrumentType},
  349. #{fixedYears},
  350. #{maturityYears},
  351. #{companyName},
  352. #{detailTalkFlag},
  353. #{originalPrice},
  354. #{contactName},
  355. #{contactMobile},
  356. #{dockingPeopleName},
  357. #{dockingPeopleMobile},
  358. #{secondProductType},
  359. #{townId},
  360. #{brandName},
  361. #{provinceCityDistrict},
  362. #{address},
  363. #{productQuality},
  364. #{productDetails},
  365. #{viewingNum},
  366. #{payStatus},
  367. #{payAmount},
  368. #{payFormData},
  369. #{payType},
  370. #{payDate},
  371. #{submitDate},
  372. #{reviewedDate},
  373. #{onLineDate},
  374. #{source},
  375. #{publisher}
  376. )
  377. </insert>
  378. <!--删除大于10条的历史记录-->
  379. <delete id="deleteSearchHistoryByUserId">
  380. DELETE FROM user_search_history
  381. WHERE userId=#{userId}
  382. AND id NOT IN (
  383. SELECT temp.id FROM (
  384. SELECT id FROM user_search_history WHERE userId=#{userId} ORDER BY id DESC LIMIT 10
  385. ) AS temp
  386. )
  387. </delete>
  388. <select id="getAddressInfo" resultType="com.caimei.module.base.entity.vo.AddressVo">
  389. SELECT a.name as "province"
  390. ,b.name as "city"
  391. ,c.name as "town"
  392. ,c.townId as "townID"
  393. FROM province a
  394. RIGHT JOIN city b ON a.provinceId = b.provinceId
  395. RIGHT JOIN town c ON b.cityId = c.cityId WHERE c.townId = #{townId}
  396. </select>
  397. <delete id="deleteAllSearchHistory">
  398. DELETE FROM
  399. user_search_history
  400. WHERE
  401. userId=#{userId}
  402. </delete>
  403. <select id="findLadderPrice" resultType="com.caimei.module.base.entity.vo.LadderPriceVo">
  404. SELECT
  405. <include refid="LadderPrice_Column_List" />
  406. FROM
  407. product_ladder_price
  408. WHERE
  409. productId = #{productID}
  410. AND userType = '3'
  411. AND delFlag = '0'
  412. ORDER BY
  413. ladderNum ASC
  414. </select>
  415. <select id="getRecommendIds" resultType="java.lang.Integer">
  416. SELECT recommendProductID FROM cm_product_recommend WHERE productID=#{productID} ORDER BY sort ASC
  417. </select>
  418. <select id="getRecommendByIds" resultType="com.caimei.module.base.entity.vo.ProductVo">
  419. SELECT
  420. <include refid="Product_Column_List"/>
  421. FROM
  422. product
  423. WHERE
  424. validFlag = '2'
  425. AND productID IN
  426. <foreach collection="productIDs" open="(" separator="," close=")" item="productID">
  427. #{productID}
  428. </foreach>
  429. </select>
  430. <select id="getDeFaultRecommend" resultType="com.caimei.module.base.entity.vo.ProductVo">
  431. select
  432. <include refid="Product_Column_List" />
  433. from product
  434. where validFlag = 2
  435. and tinyTypeID = #{tinyTypeID}
  436. order by sellNumber desc,onlineTime desc
  437. limit 7
  438. </select>
  439. <select id="getSeconHandProductList" resultType="com.caimei.module.base.entity.po.SeconHandProduct">
  440. SELECT
  441. IF(p.brandID != 161,cb.name ,cshd.brandName) as "brandName",p.*,
  442. cshd.sold AS "sold",
  443. cshd.secondHandType AS "secondHandType",
  444. cshd.instrumentType AS "instrumentType",
  445. cshd.fixedYears AS "fixedYears",
  446. cshd.maturityYears AS "maturityYears",
  447. cshd.companyName AS "companyName",
  448. cshd.detailTalkFlag AS "detailTalkFlag",
  449. cshd.originalPrice AS "originalPrice",
  450. cshd.contactName AS "contactName",
  451. cshd.contactMobile AS "contactMobile",
  452. cshd.secondProductType AS "secondProductType",
  453. cshd.provinceCityDistrict AS "provinceCityDistrict",
  454. cshd.townId as "townId",
  455. cshd.address AS "address",
  456. cshd.productQuality AS "productQuality",
  457. cshd.productDetails AS "productDetails",
  458. cshd.viewingNum AS "viewingNum",
  459. cshd.payStatus AS "payStatus",
  460. cshd.payAmount AS "payAmount",
  461. cshd.payFormData AS "payFormData",
  462. cshd.payType AS "payType",
  463. cshd.payDate AS "payDate",
  464. cshd.submitDate AS "submitDate",
  465. cshd.reviewedDate AS "reviewedDate",
  466. cshd.onLineDate AS "onLineDate",
  467. cshd.source AS "source",
  468. cshd.showContactFlag AS "showContactFlag"
  469. FROM
  470. product p
  471. LEFT JOIN cm_second_hand_detail cshd ON p.productID = cshd.productID
  472. left join cm_brand cb on cb.id = p.brandID
  473. WHERE
  474. p.productCategory = 2
  475. AND p.validFlag = 2
  476. <if test="name != null and name != ''">
  477. and p.name like CONCAT('%',#{name},'%')
  478. </if>
  479. <if test="secondHandType != null and secondHandType != ''">
  480. and cshd.secondHandType = #{secondHandType}
  481. </if>
  482. <if test="instrumentType != null and instrumentType != '' and instrumentType != '0' and instrumentType != 0">
  483. and cshd.instrumentType like CONCAT('%',#{instrumentType},'%')
  484. </if>
  485. ORDER BY cshd.onLineDate DESC
  486. </select>
  487. <select id="getSencondHandProductDetail" resultType="com.caimei.module.base.entity.po.SeconHandProduct">
  488. SELECT
  489. IF(p.brandID != 161,cb.name ,cshd.brandName) as "brandName",p.*,cb.*,cshd.*,cb.description as "brandInfo"
  490. FROM
  491. product p
  492. LEFT JOIN cm_second_hand_detail cshd ON p.productID = cshd.productID
  493. left join cm_brand cb on cb.id = p.brandID
  494. WHERE
  495. p.productCategory = 2
  496. AND p.productID = #{productId}
  497. </select>
  498. <select id="getBrandList" resultType="com.caimei.module.base.entity.po.CmBrand">
  499. select b.id AS id, b.name AS name from cm_brand b
  500. where b.status = '1' and b.delFlag = '0' and b.description is not null and b.description != '' and b.id not in (161)
  501. order by b.sort
  502. </select>
  503. <select id="getSecondHandProductRecommend" resultType="com.caimei.module.base.entity.po.SeconHandProduct">
  504. select * from cm_second_hand_recommend cshr LEFT JOIN product p on cshr.recommendProductID = p.productID where cshr.delFlag = 0 and p.validFlag = 2 and cshr.secondHandProductID = #{productId};
  505. </select>
  506. <select id="getOrderSecondHandProductList" resultType="com.caimei.module.base.entity.po.SeconHandProduct">
  507. SELECT
  508. *
  509. FROM
  510. product p
  511. LEFT JOIN cm_second_hand_detail cshd ON cshd.productID = p.productID
  512. WHERE
  513. p.productCategory = 2 and p.validFlag = 2
  514. <if test="secondHandType != null and secondHandType != ''">
  515. and cshd.secondHandType = #{secondHandType}
  516. </if>
  517. <if test="instrumentType != null and instrumentType != ''">
  518. and cshd.instrumentType like CONCAT('%',#{instrumentType},'%')
  519. </if>
  520. <if test="searchKeyword != null and searchKeyword != ''">
  521. and p.name like CONCAT('%',#{searchKeyword},'%')
  522. </if>
  523. and cshd.sold != 1
  524. ORDER BY cshd.onLineDate DESC
  525. </select>
  526. <select id="getSeconHandProductByLimit" resultType="com.caimei.module.base.entity.po.SeconHandProduct">
  527. SELECT
  528. *
  529. FROM
  530. product p
  531. LEFT JOIN cm_second_hand_detail cshd ON p.productID = cshd.productID
  532. WHERE
  533. p.productCategory = 2
  534. AND p.validFlag = 2
  535. <if test="secondHandType != null and secondHandType != ''">
  536. and cshd.secondHandType = #{secondHandType}
  537. </if>
  538. ORDER BY cshd.onLineDate DESC
  539. limit 10
  540. </select>
  541. <select id="getSecondHandProductListByMaturity"
  542. resultType="com.caimei.module.base.entity.po.SeconHandProduct">
  543. SELECT
  544. *
  545. FROM
  546. cm_second_hand_detail cshd
  547. LEFT JOIN product p ON p.productID = cshd.productID
  548. WHERE
  549. p.validFlag = 2
  550. AND cshd.onLineDate <![CDATA[ < ]]> #{beforeDays}
  551. </select>
  552. <select id="findTypeName" resultType="java.lang.String">
  553. SELECT
  554. CONCAT_WS("-", b.name,s.name, t.name)
  555. FROM
  556. bigtype b
  557. LEFT JOIN smalltype s ON s.smallTypeID = #{smallTypeID}
  558. LEFT JOIN tinytype t ON t.tinyTypeID = #{tinyTypeID}
  559. WHERE
  560. b.bigTypeID = #{bigTypeID};
  561. </select>
  562. <select id="getBrand" resultType="com.caimei.module.base.entity.vo.BrandVo">
  563. SELECT * FROM cm_brand WHERE id = #{brandID}
  564. </select>
  565. <select id="getBigTypeIdBySmallTypeId" resultType="java.lang.Integer">
  566. select bigTypeID from smalltype where smallTypeID = #{typeId}
  567. </select>
  568. <select id="getBigTypeIdByTinyTypeId" resultType="java.lang.Integer">
  569. select bigTypeID from smalltype
  570. where smallTypeID =
  571. (SELECT smallTypeID from tinytype where tinyTypeID = #{typeId})
  572. </select>
  573. <select id="getBigTypeByBigTypeId" resultType="com.caimei.module.base.entity.vo.BigtypeVo">
  574. select
  575. <include refid="BigType_Column_List" />
  576. from bigtype
  577. where bigTypeID = #{bigTypeID}
  578. </select>
  579. <select id="findAuthProductByProductId" resultType="com.caimei.module.base.entity.vo.AuthProductVo">
  580. select p.name as productName,
  581. p.snCode,
  582. p.image as productImage,
  583. p.certificateImage,
  584. b.authLogo,
  585. b.name as brandName,
  586. c.name as productionPlace,
  587. a.id as authId,
  588. a.authParty,
  589. u.authUserId as authUserId,
  590. u.name as shopName,
  591. i.securityLink,
  592. i.type as shopType,
  593. i.statementType,
  594. i.statementContent,
  595. i.statementLink,
  596. i.statementImage
  597. from cm_brand_auth_product p
  598. left join cm_brand_auth a on p.authId = a.id
  599. left join cm_brand_auth_user u on a.authUserId = u.authUserId
  600. left join cm_brand_auth_shop_info i on u.authUserId = i.authUserId
  601. left join cm_brand b on i.brandId = b.id
  602. left join country c on i.countryId = c.countryId
  603. where p.id = #{productId} and p.status = 1
  604. </select>
  605. <select id="getParamsByProductId" resultType="com.caimei.module.base.entity.po.CmBrandProductParamPo">
  606. select name,content from cm_brand_product_param where productId = #{productId}
  607. </select>
  608. <select id="findStatementFileByAuthUserId" resultType="com.caimei.module.base.entity.vo.StatementFileVo">
  609. select name,ossName,md5Hex,uploadTime
  610. from cm_brand_auth_file
  611. where authUserId = #{authUserId}
  612. limit 1
  613. </select>
  614. </mapper>