ProductModuleMapper.xml 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590
  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, 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, 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
  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. secondProductType,
  325. townId,
  326. brandName,
  327. provinceCityDistrict,
  328. address,
  329. productQuality,
  330. productDetails,
  331. viewingNum,
  332. payStatus,
  333. payAmount,
  334. payFormData,
  335. payType,
  336. payDate,
  337. submitDate,
  338. reviewedDate,
  339. onLineDate,
  340. source
  341. ) VALUES (
  342. #{productID},
  343. #{sold},
  344. #{secondHandType},
  345. #{instrumentType},
  346. #{fixedYears},
  347. #{maturityYears},
  348. #{companyName},
  349. #{detailTalkFlag},
  350. #{originalPrice},
  351. #{contactName},
  352. #{contactMobile},
  353. #{secondProductType},
  354. #{townId},
  355. #{brandName},
  356. #{provinceCityDistrict},
  357. #{address},
  358. #{productQuality},
  359. #{productDetails},
  360. #{viewingNum},
  361. #{payStatus},
  362. #{payAmount},
  363. #{payFormData},
  364. #{payType},
  365. #{payDate},
  366. #{submitDate},
  367. #{reviewedDate},
  368. #{onLineDate},
  369. #{source}
  370. )
  371. </insert>
  372. <!--删除大于10条的历史记录-->
  373. <delete id="deleteSearchHistoryByUserId">
  374. DELETE FROM user_search_history
  375. WHERE userId=#{userId}
  376. AND id NOT IN (
  377. SELECT temp.id FROM (
  378. SELECT id FROM user_search_history WHERE userId=#{userId} ORDER BY id DESC LIMIT 10
  379. ) AS temp
  380. )
  381. </delete>
  382. <select id="getAddressInfo" resultType="com.caimei.module.base.entity.vo.AddressVo">
  383. SELECT a.name as "province"
  384. ,b.name as "city"
  385. ,c.name as "town"
  386. ,c.townId as "townID"
  387. FROM province a
  388. RIGHT JOIN city b ON a.provinceId = b.provinceId
  389. RIGHT JOIN town c ON b.cityId = c.cityId WHERE c.townId = #{townId}
  390. </select>
  391. <delete id="deleteAllSearchHistory">
  392. DELETE FROM
  393. user_search_history
  394. WHERE
  395. userId=#{userId}
  396. </delete>
  397. <select id="findLadderPrice" resultType="com.caimei.module.base.entity.vo.LadderPriceVo">
  398. SELECT
  399. <include refid="LadderPrice_Column_List" />
  400. FROM
  401. product_ladder_price
  402. WHERE
  403. productId = #{productID}
  404. AND userType = '3'
  405. AND delFlag = '0'
  406. ORDER BY
  407. ladderNum ASC
  408. </select>
  409. <select id="getRecommendIds" resultType="java.lang.Integer">
  410. SELECT recommendProductID FROM cm_product_recommend WHERE productID=#{productID} ORDER BY sort ASC
  411. </select>
  412. <select id="getRecommendByIds" resultType="com.caimei.module.base.entity.vo.ProductVo">
  413. SELECT
  414. <include refid="Product_Column_List"/>
  415. FROM
  416. product
  417. WHERE
  418. validFlag = '2'
  419. AND productID IN
  420. <foreach collection="productIDs" open="(" separator="," close=")" item="productID">
  421. #{productID}
  422. </foreach>
  423. </select>
  424. <select id="getDeFaultRecommend" resultType="com.caimei.module.base.entity.vo.ProductVo">
  425. select
  426. <include refid="Product_Column_List" />
  427. from product
  428. where validFlag = 2
  429. and tinyTypeID = #{tinyTypeID}
  430. order by sellNumber desc,onlineTime desc
  431. limit 7
  432. </select>
  433. <select id="getSeconHandProductList" resultType="com.caimei.module.base.entity.po.SeconHandProduct">
  434. SELECT
  435. IF(p.brandID != 161,cb.name ,cshd.brandName) as "brandName",p.*,
  436. cshd.sold AS "sold",
  437. cshd.secondHandType AS "secondHandType",
  438. cshd.instrumentType AS "instrumentType",
  439. cshd.fixedYears AS "fixedYears",
  440. cshd.maturityYears AS "maturityYears",
  441. cshd.companyName AS "companyName",
  442. cshd.detailTalkFlag AS "detailTalkFlag",
  443. cshd.originalPrice AS "originalPrice",
  444. cshd.contactName AS "contactName",
  445. cshd.contactMobile AS "contactMobile",
  446. cshd.secondProductType AS "secondProductType",
  447. cshd.provinceCityDistrict AS "provinceCityDistrict",
  448. cshd.townId as "townId",
  449. cshd.address AS "address",
  450. cshd.productQuality AS "productQuality",
  451. cshd.productDetails AS "productDetails",
  452. cshd.viewingNum AS "viewingNum",
  453. cshd.payStatus AS "payStatus",
  454. cshd.payAmount AS "payAmount",
  455. cshd.payFormData AS "payFormData",
  456. cshd.payType AS "payType",
  457. cshd.payDate AS "payDate",
  458. cshd.submitDate AS "submitDate",
  459. cshd.reviewedDate AS "reviewedDate",
  460. cshd.onLineDate AS "onLineDate",
  461. cshd.source AS "source",
  462. cshd.showContactFlag AS "showContactFlag"
  463. FROM
  464. product p
  465. LEFT JOIN cm_second_hand_detail cshd ON p.productID = cshd.productID
  466. left join cm_brand cb on cb.id = p.brandID
  467. WHERE
  468. p.productCategory = 2
  469. AND p.validFlag = 2
  470. <if test="name != null and name != ''">
  471. and p.name like CONCAT('%',#{name},'%')
  472. </if>
  473. <if test="secondHandType != null and secondHandType != ''">
  474. and cshd.secondHandType = #{secondHandType}
  475. </if>
  476. <if test="instrumentType != null and instrumentType != '' and instrumentType != '0' and instrumentType != 0">
  477. and cshd.instrumentType like CONCAT('%',#{instrumentType},'%')
  478. </if>
  479. ORDER BY cshd.onLineDate DESC
  480. </select>
  481. <select id="getSencondHandProductDetail" resultType="com.caimei.module.base.entity.po.SeconHandProduct">
  482. SELECT
  483. IF(p.brandID != 161,cb.name ,cshd.brandName) as "brandName",p.*,cb.*,cshd.*,cb.description as "brandInfo"
  484. FROM
  485. product p
  486. LEFT JOIN cm_second_hand_detail cshd ON p.productID = cshd.productID
  487. left join cm_brand cb on cb.id = p.brandID
  488. WHERE
  489. p.productCategory = 2
  490. AND p.productID = #{productId}
  491. </select>
  492. <select id="getBrandList" resultType="com.caimei.module.base.entity.po.CmBrand">
  493. select b.id AS id, b.name AS name from cm_brand b
  494. where b.status = '1' and b.delFlag = '0' and b.description is not null and b.description != '' and b.id not in (161)
  495. order by b.sort
  496. </select>
  497. <select id="getSecondHandProductRecommend" resultType="com.caimei.module.base.entity.po.SeconHandProduct">
  498. 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};
  499. </select>
  500. <select id="getOrderSecondHandProductList" resultType="com.caimei.module.base.entity.po.SeconHandProduct">
  501. SELECT
  502. *
  503. FROM
  504. product p
  505. LEFT JOIN cm_second_hand_detail cshd ON cshd.productID = p.productID
  506. WHERE
  507. p.productCategory = 2 and p.validFlag = 2
  508. <if test="secondHandType != null and secondHandType != ''">
  509. and cshd.secondHandType = #{secondHandType}
  510. </if>
  511. <if test="instrumentType != null and instrumentType != ''">
  512. and cshd.instrumentType like CONCAT('%',#{instrumentType},'%')
  513. </if>
  514. <if test="searchKeyword != null and searchKeyword != ''">
  515. and p.name like CONCAT('%',#{searchKeyword},'%')
  516. </if>
  517. and cshd.sold != 1
  518. ORDER BY cshd.onLineDate DESC
  519. </select>
  520. <select id="getSeconHandProductByLimit" resultType="com.caimei.module.base.entity.po.SeconHandProduct">
  521. SELECT
  522. *
  523. FROM
  524. product p
  525. LEFT JOIN cm_second_hand_detail cshd ON p.productID = cshd.productID
  526. WHERE
  527. p.productCategory = 2
  528. AND p.validFlag = 2
  529. <if test="secondHandType != null and secondHandType != ''">
  530. and cshd.secondHandType = #{secondHandType}
  531. </if>
  532. ORDER BY cshd.onLineDate DESC
  533. limit 10
  534. </select>
  535. <select id="getSecondHandProductListByMaturity"
  536. resultType="com.caimei.module.base.entity.po.SeconHandProduct">
  537. SELECT
  538. *
  539. FROM
  540. cm_second_hand_detail cshd
  541. LEFT JOIN product p ON p.productID = cshd.productID
  542. WHERE
  543. p.validFlag = 2
  544. AND cshd.onLineDate <![CDATA[ < ]]> #{beforeDays}
  545. </select>
  546. <select id="findTypeName" resultType="java.lang.String">
  547. SELECT
  548. CONCAT_WS("-", b.name,s.name, t.name)
  549. FROM
  550. bigtype b
  551. LEFT JOIN smalltype s ON s.smallTypeID = #{smallTypeID}
  552. LEFT JOIN tinytype t ON t.tinyTypeID = #{tinyTypeID}
  553. WHERE
  554. b.bigTypeID = #{bigTypeID};
  555. </select>
  556. <select id="getBrand" resultType="com.caimei.module.base.entity.vo.BrandVo">
  557. SELECT * FROM cm_brand WHERE id = #{brandID}
  558. </select>
  559. <select id="getBigTypeIdBySmallTypeId" resultType="java.lang.Integer">
  560. select bigTypeID from smalltype where smallTypeID = #{typeId}
  561. </select>
  562. <select id="getBigTypeIdByTinyTypeId" resultType="java.lang.Integer">
  563. select bigTypeID from smalltype
  564. where smallTypeID =
  565. (SELECT smallTypeID from tinytype where tinyTypeID = #{typeId})
  566. </select>
  567. <select id="getBigTypeByBigTypeId" resultType="com.caimei.module.base.entity.vo.BigtypeVo">
  568. select
  569. <include refid="BigType_Column_List" />
  570. from bigtype
  571. where bigTypeID = #{bigTypeID}
  572. </select>
  573. </mapper>