ShopMapper.xml 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795
  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.caimei365.commodity.mapper.ShopMapper">
  4. <insert id="insertProduct" keyColumn="productID" keyProperty="productId"
  5. parameterType="com.caimei365.commodity.model.po.ProductPo" useGeneratedKeys="true">
  6. insert into product (
  7. groundMall, shopID, name, aliasName, commodityType, bigTypeID, smallTypeID, tinyTypeID, mainImage,
  8. brandID, productType, tags, includedTax,
  9. <if test="productCategory != null and productCategory != '' ">
  10. productCategory,
  11. </if>
  12. <if test="serviceNumber != null and serviceNumber != ''">
  13. serviceNumber,
  14. </if>
  15. <if test="supplierTaxPoint != null and supplierTaxPoint != ''">
  16. supplierTaxPoint,
  17. </if>
  18. <if test="addTime != null and addTime != ''">
  19. addTime,
  20. </if>
  21. <if test="hasSkuFlag != null and hasSkuFlag != ''">
  22. hasSkuFlag,
  23. </if>
  24. <if test="sellNumber != null and sellNumber != ''">
  25. sellNumber,
  26. </if>
  27. <if test="sortIndex != null and sortIndex != ''">
  28. sortIndex,
  29. </if>
  30. <if test="featuredFlag != null and featuredFlag != ''">
  31. featuredFlag,
  32. </if>
  33. <if test="recommendType != null and recommendType != ''">
  34. recommendType,
  35. </if>
  36. <if test="priceFlag != null and priceFlag != ''">
  37. priceFlag,
  38. </if>
  39. <if test="actFlag != null and actFlag != ''">
  40. actFlag,
  41. </if>
  42. <if test="visibility != null and visibility != ''">
  43. visibility,
  44. </if>
  45. <if test="commodityDetailsFlag != null and commodityDetailsFlag != ''">
  46. commodityDetailsFlag,
  47. </if>
  48. <if test="productCode != null and productCode != ''">
  49. productCode,
  50. </if>
  51. <if test="searchKey != null and searchKey != ''">
  52. searchKey,
  53. </if>
  54. <if test="allAreaFlag != null and allAreaFlag != ''">
  55. allAreaFlag,
  56. </if>
  57. <if test="step != null and step != ''">
  58. step,
  59. </if>
  60. <if test="provinceIds != null and provinceIds != ''">
  61. provinceIds,
  62. </if>
  63. <if test="machineType != null and machineType != ''">
  64. machineType,
  65. </if>
  66. <if test="qualificationImg != null and qualificationImg != ''">
  67. qualificationImg,
  68. </if>
  69. <if test="invoiceType != null and invoiceType != ''">
  70. invoiceType,
  71. </if>
  72. <if test="qualificationNo != null and qualificationNo != ''">
  73. qualificationNo,
  74. </if>
  75. <if test="productName != null and productName != ''">
  76. productName,
  77. </if>
  78. <if test="qualificationTime != null and qualificationTime != ''">
  79. qualificationTime,
  80. </if>
  81. updateTime,validFlag,newProductType,showFlag,newvalidFlag
  82. ) values (
  83. #{groundMall}, #{shopId}, #{name}, #{aliasName}, #{commodityType}, #{bigTypeId}, #{smallTypeId}, #{tinyTypeId}, #{mainImage},
  84. #{brandId}, #{productType}, #{tags}, #{includedTax},
  85. <if test="productCategory != null and productCategory != '' ">
  86. #{productCategory},
  87. </if>
  88. <if test="serviceNumber != null and serviceNumber != ''">
  89. #{serviceNumber},
  90. </if>
  91. <if test="supplierTaxPoint != null and supplierTaxPoint != ''">
  92. #{supplierTaxPoint},
  93. </if>
  94. <if test="addTime != null and addTime != ''">
  95. #{addTime},
  96. </if>
  97. <if test="hasSkuFlag != null and hasSkuFlag != ''">
  98. #{hasSkuFlag},
  99. </if>
  100. <if test="sellNumber != null and sellNumber != ''">
  101. #{sellNumber},
  102. </if>
  103. <if test="sortIndex != null and sortIndex != ''">
  104. #{sortIndex},
  105. </if>
  106. <if test="featuredFlag != null and featuredFlag != ''">
  107. #{featuredFlag},
  108. </if>
  109. <if test="recommendType != null and recommendType != ''">
  110. #{recommendType},
  111. </if>
  112. <if test="priceFlag != null and priceFlag != ''">
  113. #{priceFlag},
  114. </if>
  115. <if test="actFlag != null and actFlag != ''">
  116. #{actFlag},
  117. </if>
  118. <if test="visibility != null and visibility != ''">
  119. #{visibility},
  120. </if>
  121. <if test="commodityDetailsFlag != null and commodityDetailsFlag != ''">
  122. #{commodityDetailsFlag},
  123. </if>
  124. <if test="productCode != null and productCode != ''">
  125. #{productCode},
  126. </if>
  127. <if test="searchKey != null and searchKey != ''">
  128. #{searchKey},
  129. </if>
  130. <if test="allAreaFlag != null and allAreaFlag != ''">
  131. #{allAreaFlag},
  132. </if>
  133. <if test="step != null and step != ''">
  134. #{step},
  135. </if>
  136. <if test="provinceIds != null and provinceIds != ''">
  137. #{provinceIds},
  138. </if>
  139. <if test="machineType != null and machineType != ''">
  140. #{machineType},
  141. </if>
  142. <if test="qualificationImg != null and qualificationImg != ''">
  143. #{qualificationImg},
  144. </if>
  145. <if test="invoiceType != null and invoiceType != ''">
  146. #{invoiceType},
  147. </if>
  148. <if test="qualificationNo != null and qualificationNo != ''">
  149. #{qualificationNo},
  150. </if>
  151. <if test="productName != null and productName != ''">
  152. #{productName},
  153. </if>
  154. <if test="qualificationTime != null and qualificationTime != ''">
  155. #{qualificationTime},
  156. </if>
  157. #{updateTime}, #{validFlag},#{newProductType},#{showFlag},3
  158. )
  159. </insert>
  160. <update id="updateProduct">
  161. update product set
  162. groundMall = #{groundMall}, shopID = #{shopId}, name = #{name}, aliasName = #{aliasName}, commodityType = #{commodityType},
  163. bigTypeId = #{bigTypeId}, smallTypeId = #{smallTypeId}, tinyTypeId = #{tinyTypeId}, mainImage = #{mainImage},
  164. brandId = #{brandId}, productType = #{productType}, tags = #{tags}, includedTax = #{includedTax},newProductType=#{newProductType},
  165. <if test="qualificationNo !=null and qualificationNo != ''">
  166. qualificationNo=#{qualificationNo},
  167. </if>
  168. <if test="productName !=null and productName != ''">
  169. productName=#{productName},
  170. </if>
  171. <if test="qualificationTime !=null and qualificationTime != ''">
  172. qualificationTime=#{qualificationTime},
  173. </if>
  174. <if test="qualificationLink !=null and qualificationLink != ''">
  175. qualificationLink=#{qualificationLink},
  176. </if>
  177. <if test="productCategory != null and productCategory != ''">
  178. productCategory = #{productCategory},
  179. </if>
  180. <if test="trainingFee != null">
  181. trainingFee = #{trainingFee},
  182. </if>
  183. <if test="serviceNumber != null and serviceNumber != ''">
  184. serviceNumber = #{serviceNumber},
  185. </if>
  186. <if test="supplierTaxPoint != null and supplierTaxPoint != ''">
  187. supplierTaxPoint = #{supplierTaxPoint},
  188. </if>
  189. <if test="addTime != null and addTime != ''">
  190. addTime = #{addTime},
  191. </if>
  192. <if test="hasSkuFlag != null and hasSkuFlag != ''">
  193. hasSkuFlag = #{hasSkuFlag},
  194. </if>
  195. <if test="sellNumber != null and sellNumber != ''">
  196. sellNumber = #{sellNumber},
  197. </if>
  198. <if test="sortIndex != null and sortIndex != ''">
  199. sortIndex = #{sortIndex},
  200. </if>
  201. <if test="featuredFlag != null and featuredFlag != ''">
  202. featuredFlag = #{featuredFlag},
  203. </if>
  204. <if test="recommendType != null and recommendType != ''">
  205. recommendType = #{recommendType},
  206. </if>
  207. <if test="priceFlag != null and priceFlag != ''">
  208. priceFlag = #{priceFlag},
  209. </if>
  210. <if test="actFlag != null and actFlag != ''">
  211. actFlag = #{actFlag},
  212. </if>
  213. <if test="visibility != null and visibility != ''">
  214. visibility = #{visibility},
  215. </if>
  216. <if test="commodityDetailsFlag != null and commodityDetailsFlag != ''">
  217. commodityDetailsFlag = #{commodityDetailsFlag},
  218. </if>
  219. <if test="productCode != null and productCode != ''">
  220. productCode = #{productCode},
  221. </if>
  222. <if test="searchKey != null and searchKey != ''">
  223. searchKey = #{searchKey},
  224. </if>
  225. <if test="allAreaFlag != null and allAreaFlag != ''">
  226. allAreaFlag = #{allAreaFlag},
  227. </if>
  228. <if test="step != null and step != ''">
  229. step = #{step},
  230. </if>
  231. <if test="provinceIds != null and provinceIds != ''">
  232. provinceIds = #{provinceIds},
  233. </if>
  234. <if test="machineType != null and machineType != ''">
  235. machineType = #{machineType},
  236. </if>
  237. <if test="qualificationImg != null and qualificationImg != ''">
  238. qualificationImg = #{qualificationImg},
  239. </if>
  240. <if test="invoiceType != null and invoiceType != ''">
  241. invoiceType = #{invoiceType},
  242. </if>
  243. updateTime = #{updateTime},
  244. validFlag = #{validFlag},
  245. showFlag=#{showFlag}
  246. where productID = #{productId}
  247. </update>
  248. <insert id="insertVaildFlag">
  249. insert into cm_organize_product_info (organizeId, productId, validFlag)
  250. values (#{organizeId},#{productId},#{validFlag})
  251. </insert>
  252. <update id="updateVaildFlag">
  253. update cm_organize_product_info
  254. set validFlag = #{validFlag}
  255. where productId = #{productId} and organizeId = #{organizeId}
  256. </update>
  257. <insert id="insertProductImage">
  258. insert into productimage (productID, shopID, addTime, image, mainFlag, sortIndex)
  259. values (#{productId}, #{shopId}, #{addTime}, #{image}, #{mainFlag}, #{sortIndex})
  260. </insert>
  261. <insert id="insertProductParameters" parameterType="com.caimei365.commodity.model.po.ProductParameterPo">
  262. insert into cm_product_related_parameters (productId, paramsName, paramsContent, delFlag)
  263. values (#{productId}, #{paramsName}, #{paramsContent}, #{delFlag})
  264. </insert>
  265. <insert id="insertProductDetailInfo">
  266. insert into productdetailinfo (productID, propValueAlias, propValueImages,
  267. detailInfo, serviceInfo, orderInfo, detailInfoTxt, seoTitle,
  268. seoKeyword, seoDes)
  269. values (#{productId}, #{propValueAlias}, #{propValueImages},
  270. #{detailInfo}, #{serviceInfo}, #{orderInfo}, #{detailInfoTxt}, #{seoTitle},
  271. #{seoKeyword}, #{seoDes})
  272. </insert>
  273. <insert id="insertBrand" keyColumn="id" keyProperty="id" parameterType="com.caimei365.commodity.model.po.BrandPo"
  274. useGeneratedKeys="true">
  275. insert into cm_brand (name, source, userID, status, delFlag, createDate, updateDate, logo, description)
  276. values (#{name}, #{source}, #{userId}, #{status}, #{delFlag}, #{createDate}, #{updateDate}, #{logo},
  277. #{description})
  278. </insert>
  279. <insert id="insertSku">
  280. insert into cm_sku
  281. (productId,
  282. organizeId,
  283. normalPrice,
  284. price,
  285. costCheckFlag,
  286. costprice,
  287. stock,
  288. minBuyNumber,
  289. unit,
  290. ladderPriceFlag,
  291. shopPercent,
  292. organizePercent,
  293. cmPercent)
  294. values (#{productId},
  295. #{organizeId},
  296. #{normalPrice},
  297. #{price},
  298. ifnull(#{costCheckFlag}, 1),
  299. #{costPrice},
  300. #{stock},
  301. #{minBuyNumber},
  302. #{unit},
  303. ifnull(#{ladderPriceFlag}, 0),
  304. #{shopPercent},
  305. #{organizePercent},
  306. #{cmPercent})
  307. </insert>
  308. <insert id="insertProductInfo">
  309. insert into cm_organize_product_info (organizeId, productId, validFlag)
  310. values (#{organizeId}, #{productId}, #{validFlag})
  311. </insert>
  312. <update id="updateBrand">
  313. update cm_brand
  314. <set>
  315. <if test="name != null">
  316. `name` = #{name},
  317. </if>
  318. <if test="source != null">
  319. `source` = #{source},
  320. </if>
  321. <if test="userId != null">
  322. userID = #{userId},
  323. </if>
  324. <if test="status != null">
  325. `status` = #{status},
  326. </if>
  327. <if test="delFlag != null">
  328. delFlag = #{delFlag},
  329. </if>
  330. <if test="updateDate != null">
  331. updateDate = #{updateDate},
  332. </if>
  333. <if test="logo != null">
  334. logo = #{logo},
  335. </if>
  336. <if test="description != null">
  337. description = #{description},
  338. </if>
  339. </set>
  340. where id = #{id}
  341. </update>
  342. <update id="updateProductImage">
  343. update productimage
  344. set productID = #{productId},
  345. shopID = #{shopId},
  346. addTime = #{addTime},
  347. image = #{image},
  348. mainFlag = #{mainFlag},
  349. sortIndex = #{sortIndex}
  350. where productImageId = #{id}
  351. </update>
  352. <update id="updateProductDetailInfo">
  353. update productdetailinfo
  354. set propValueAlias = #{propValueAlias},
  355. propValueImages = #{propValueImages},
  356. detailInfo = #{detailInfo},
  357. detailInfoTxt = #{detailInfoTxt},
  358. seoTitle = #{seoTitle},
  359. seoKeyword = #{seoKeyword},
  360. seoDes = #{seoDes},
  361. serviceInfo = #{serviceInfo},
  362. orderInfo = #{orderInfo}
  363. where productDetailInfoID = #{productDetailInfoId}
  364. </update>
  365. <update id="updateProductFeatured">
  366. update product
  367. set featuredFlag = #{featuredFlag}
  368. where productID = #{productId}
  369. and shopID = #{shopId}
  370. </update>
  371. <update id="updateProductValidFlag">
  372. update cm_organize_product_info
  373. set validFlag = #{validFlag}
  374. where productId = #{productId}
  375. <if test="organizeId != 0">
  376. <if test="organizeId == 1">
  377. and organizeId = 0
  378. </if>
  379. <if test="organizeId == 2">
  380. and organizeId = 4
  381. </if>
  382. </if>
  383. </update>
  384. <update id="updateProductCode">
  385. update product
  386. set productCode = #{productCode}
  387. where productID = #{productId}
  388. </update>
  389. <update id="updateSku">
  390. update cm_sku
  391. set minBuyNumber=#{minBuyNumber},
  392. costPrice=#{costPrice},
  393. stock=#{stock},
  394. price=#{price},
  395. normalPrice=#{normalPrice},
  396. unit=#{unit}
  397. where skuId = #{skuId}
  398. </update>
  399. <delete id="deleteProductImage">
  400. delete
  401. from productimage
  402. where productImageID = #{id}
  403. </delete>
  404. <delete id="deleteProductParameters">
  405. delete
  406. from cm_product_related_parameters
  407. where productId = #{productId}
  408. </delete>
  409. <select id="getMainProducts" resultType="com.caimei365.commodity.model.search.ProductListVo">
  410. select
  411. p.productID as productId,
  412. p.actStatus,
  413. p.shopID as shopId,
  414. p.`name` as `name`,
  415. p.mainImage as image,
  416. (select price from cm_sku where productId=p.productID and organizeId = 0 order by price asc limit 1) as price,
  417. (select unit from cm_sku where productId=p.productID and organizeId = 0 order by price asc limit 1) as unit,
  418. p.priceFlag as priceFlag,
  419. IFNULL(p.visibility,3) as visibility,
  420. p.productType
  421. from product p
  422. where p.shopID = #{shopId}
  423. and p.visibility in
  424. <foreach collection="visibilityList" item="visibility" index="index" open="(" separator="," close=")">
  425. #{visibility}
  426. </foreach>
  427. and p.validFlag = 2 and p.featuredFlag=1
  428. order by p.productID desc limit 4
  429. </select>
  430. <select id="getShopProductsSelect" resultType="com.caimei365.commodity.model.vo.ProductItemVo">
  431. select DISTINCT
  432. p.productID as productId,
  433. p.actStatus,
  434. p.name,
  435. p.aliasName,
  436. p.mainImage as image,
  437. (select unit from cm_sku where productId=p.productId and organizeId = 0 order by price asc LIMIT 1) as unit,
  438. p.productCode as code,
  439. p.priceFlag,
  440. (select price from cm_sku where productId=p.productId and organizeId = 0 order by price asc LIMIT 1) as price,
  441. (select normalPrice from cm_sku where productId=p.productId and organizeId = 0 order by price asc LIMIT 1) as normalPrice,
  442. p.searchKey as keyword,
  443. (select minBuyNumber from cm_sku where productId=p.productId and organizeId = 0 order by price asc LIMIT 1) as minBuyNumber,
  444. (select ladderPriceFlag from cm_sku where productId=p.productId and organizeId = 0 order by price asc LIMIT 1) as ladderPriceFlag,
  445. p.step,
  446. p.shopID as shopId,
  447. p.taxPoint as taxRate,
  448. p.includedTax,
  449. p.invoiceType,
  450. p.productCategory as productCategory,
  451. IFNULL((SELECT validFlag FROM cm_organize_product_info WHERE productId = p.productID AND organizeId = 0), 999) AS validFlag,
  452. IFNULL((SELECT validFlag FROM cm_organize_product_info WHERE productId = p.productID AND organizeId = 4), 999) AS mallValidFlag,
  453. p.featuredFlag,
  454. p.commodityType,
  455. p.bigTypeID as bigTypeId,
  456. p.smallTypeID as smallTypeId,
  457. p.tinyTypeID as tinyTypeId,
  458. ifnull(p.newvalidFlag,3) as newvalidFlag,
  459. ifnull(p.showFlag,0) as showFlag,
  460. p.groundMall AS groundMall
  461. from product p
  462. LEFT JOIN cm_organize_product_info copi ON copi.productId = p.productID
  463. <where>
  464. p.shopID = #{shopId}
  465. <if test="productCode != null and productCode != ''">
  466. and p.productCode = #{productCode}
  467. </if>
  468. <if test="validFlag != null and validFlag != ''">
  469. and copi.validFlag = #{validFlag}
  470. </if>
  471. <if test="featuredFlag != null and featuredFlag != ''">
  472. and p.featuredFlag = #{featuredFlag}
  473. </if>
  474. <if test="tinyTypeId != null and tinyTypeId != 0">
  475. and p.tinyTypeID = #{tinyTypeId}
  476. </if>
  477. <if test="smallTypeId != null and smallTypeId != 0">
  478. and p.smallTypeID = #{smallTypeId}
  479. </if>
  480. <if test="bigTypeId != null and bigTypeId != 0">
  481. and p.bigTypeID = #{bigTypeId}
  482. </if>
  483. <if test="commodityType != null and commodityType != ''">
  484. and p.commodityType = #{commodityType}
  485. </if>
  486. <if test="name != null and name != ''">
  487. and p.name like CONCAT("%",#{name},"%")
  488. </if>
  489. <if test="groundMall != null and groundMall != ''">
  490. and p.groundMall like concat('%',#{groundMall},'%')
  491. </if>
  492. <if test="newvalidFlag !=null and newvalidFlag!=''">
  493. and newvalidFlag =#{newvalidFlag}
  494. </if>
  495. <if test="showFlag != null">
  496. and showFlag =#{showFlag}
  497. </if>
  498. </where>
  499. order by p.productID desc
  500. </select>
  501. <select id="getTypeName" resultType="java.lang.String">
  502. select CONCAT_WS("-", b.name, s.name, t.name)
  503. from bigtype b
  504. left join smalltype s on s.smallTypeID = #{smallTypeId}
  505. left join tinytype t on t.tinyTypeID = #{tinyTypeId}
  506. where b.bigTypeID = #{bigTypeId};
  507. </select>
  508. <select id="getUserIdByshopId" resultType="java.lang.Integer">
  509. select userID
  510. from user
  511. where shopID = #{shopId}
  512. </select>
  513. <select id="getMainProductsCount" resultType="java.lang.Integer">
  514. select count(*)
  515. from product
  516. where shopID = #{shopId}
  517. and validFlag = '2'
  518. and featuredFlag = '1'
  519. order by productID desc
  520. </select>
  521. <select id="getCodeByTypeId" resultType="java.lang.String">
  522. select
  523. CONCAT(IFNULL(b.bigTypeCode,''), IFNULL(s.smallTypeCode,''), IFNULL(t.tinyTypeCode,''))
  524. from bigtype b
  525. left join smalltype s on s.bigTypeID = b.bigTypeID
  526. left join tinytype t on t.smallTypeID = s.smallTypeID
  527. <where>
  528. <if test="bigTypeId != null">
  529. b.bigTypeID = #{bigTypeId}
  530. </if>
  531. <if test="smallTypeId != null">
  532. and s.smallTypeID = #{smallTypeId}
  533. </if>
  534. <if test="tinyTypeId != null">
  535. and t.tinyTypeID = #{tinyTypeId}
  536. </if>
  537. </where>
  538. </select>
  539. <select id="getImageByProductId" resultType="com.caimei365.commodity.model.po.ProductImagePo">
  540. select productImageID as id, productID as productId, shopID as shopId, addTime, image, mainFlag, sortIndex
  541. from productimage
  542. where productID = #{productId}
  543. order by mainFlag DESC
  544. </select>
  545. <select id="getProductForm" resultType="com.caimei365.commodity.model.vo.ProductFormVo">
  546. select productID as productId,
  547. groundMall,
  548. shopID as shopId,
  549. name,
  550. aliasName,
  551. commodityType,
  552. mainImage,
  553. (select stock from cm_sku where productId=p.productId and organizeId = 0 order by price asc LIMIT 1) as stock,
  554. invoiceType,
  555. bigTypeID as bigTypeId,
  556. smallTypeID as smallTypeId,
  557. tinyTypeID as tinyTypeId,
  558. searchKey,
  559. visibility,
  560. brandID as brandId,
  561. productType,
  562. tags,
  563. (select unit from cm_sku where productId=p.productId and organizeId = 0 order by price asc LIMIT 1)as unit,
  564. (select normalPrice from cm_sku where productId=p.productId and organizeId = 0 order by price asc LIMIT 1)as normalPrice,
  565. (select price from cm_sku where productId=p.productId and organizeId = 0 order by price asc LIMIT 1)as price,
  566. includedTax,
  567. (select minBuyNumber from cm_sku where productId=p.productId and organizeId = 0 order by price asc LIMIT 1)as minBuyNumber,
  568. productCategory,
  569. serviceNumber,
  570. supplierTaxPoint,
  571. priceFlag,
  572. actFlag,
  573. (select ladderPriceFlag from cm_sku where productId=p.productId and organizeId = 0 order by price asc LIMIT 1) as ladderPriceFlag,
  574. addTime,
  575. hasSkuFlag,
  576. sellNumber,
  577. sortIndex,
  578. featuredFlag,
  579. (select costCheckFlag from cm_sku where productId=p.productId and organizeId = 0 order by price asc LIMIT 1)as costCheckFlag,
  580. recommendType,
  581. machineType,
  582. productCode,
  583. updateTime,
  584. IFNULL((SELECT validFlag FROM cm_organize_product_info WHERE productId = p.productID AND organizeId = 0), 999) AS validFlag,
  585. IFNULL((SELECT validFlag FROM cm_organize_product_info WHERE productId = p.productID AND organizeId = 4), 999) AS mallValidFlag,
  586. searchKey,
  587. allAreaFlag,
  588. step,
  589. (select costPrice from cm_sku where productId=p.productId and organizeId = 0 order by price asc LIMIT 1)as costPrice,
  590. provinceIds,
  591. qualificationImg,
  592. trainingMethod,
  593. trainingType,
  594. trainingFee,
  595. ifnull(newProductType, 2) as newProductType,
  596. qualificationNo as qualificationNo,
  597. productName as productName,
  598. qualificationTime as qualificationTime,
  599. qualificationLink as qualificationLink
  600. from product p
  601. where productID = #{productId}
  602. </select>
  603. <select id="getBrandNameById" resultType="java.lang.String">
  604. select name
  605. from cm_brand
  606. where id = #{brandId}
  607. </select>
  608. <select id="getProductParameters" resultType="com.caimei365.commodity.model.po.ProductParameterPo">
  609. select id, productID as productId, paramsName, paramsContent
  610. from cm_product_related_parameters
  611. where productId = #{productId}
  612. AND delFlag = '0'
  613. </select>
  614. <select id="getProductImages" resultType="com.caimei365.commodity.model.po.ProductImagePo">
  615. select productImageID as id, productID as productId, shopId, addTime, image, mainFlag, sortIndex
  616. from productimage
  617. where productID = #{productId}
  618. UNION
  619. SELECT p.productImageID AS id, p.productID AS productId, p.shopId, p.ADDTIME, p.image, p.mainFlag, p.sortIndex
  620. FROM productimage p
  621. LEFT JOIN product pt ON p.productId = pt.productId
  622. WHERE pt.productId = #{productId}
  623. order by mainFlag desc
  624. </select>
  625. <select id="getProductDetailInfo" resultType="com.caimei365.commodity.model.po.ProductDetailInfoPo">
  626. select productDetailInfoId,
  627. productId,
  628. detailInfo,
  629. commonDetailInfo,
  630. serviceInfo,
  631. orderInfo,
  632. propValueAlias,
  633. propValueImages,
  634. detailInfoTxt,
  635. seoTitle,
  636. seoKeyword,
  637. seoDes
  638. from productdetailinfo
  639. where productId = #{productId}
  640. </select>
  641. <select id="getProductOrganizeDetailInfo" resultType="com.caimei365.commodity.model.po.ProductDetailInfoPo">
  642. SELECT p.productDetailInfoId,
  643. p.productId,
  644. p.detailInfo,
  645. p.commonDetailInfo,
  646. p.serviceInfo,
  647. p.orderInfo,
  648. p.propValueAlias,
  649. p.propValueImages,
  650. p.detailInfoTxt,
  651. p.seoTitle,
  652. p.seoKeyword,
  653. p.seoDes
  654. FROM productdetailinfo p
  655. LEFT JOIN product pt ON pt.productId = p.productId
  656. WHERE p.productId = #{productId}
  657. </select>
  658. <select id="getProductShopById" resultType="com.caimei365.commodity.model.vo.ShopVo">
  659. select userID as userId,
  660. shopID as shopId,
  661. name,
  662. sname as shortName,
  663. linkMan,
  664. contractMobile,
  665. contractEmail,
  666. contractEmail as email,
  667. provinceID as proviceId,
  668. cityID as cityId,
  669. townID as townId,
  670. address,
  671. socialCreditCode,
  672. businessLicenseImage as businessLicense,
  673. firstShopType,
  674. secondShopType,
  675. mainpro as mainProduct,
  676. productDesc as mainProductDesc,
  677. legalPerson,
  678. registeredCapital,
  679. fax as faxNumber,
  680. nature as companyNature,
  681. turnover,
  682. medicalPracticeLicenseImg1 as medicalPracticeLicense,
  683. info as shopDesc,
  684. businessScope,
  685. logo,
  686. addTime,
  687. status,
  688. contractPhone,
  689. validFlag,
  690. website,
  691. wxOfficialAccount,
  692. wxApplets
  693. from shop
  694. where shopID = #{shopId}
  695. </select>
  696. <select id="getProductNumById" resultType="java.lang.Integer">
  697. select COUNT(*) as normalNum
  698. from product p
  699. where p.shopID = #{shopId}
  700. and p.validFlag = 2
  701. group by p.shopID
  702. </select>
  703. <select id="getUserIdentityById" resultType="java.lang.Integer">
  704. select userIdentity
  705. from user
  706. where userID = #{userId}
  707. </select>
  708. <select id="getBrandAssociation" resultType="com.caimei365.commodity.model.vo.BrandVo">
  709. select id, name
  710. from cm_brand
  711. where status = '1'
  712. and delFlag = '0'
  713. and name like CONCAT("%", #{name}, "%")
  714. order by case
  715. when (source = '1' and userID = #{userId})
  716. then 0
  717. else 1
  718. end asc,
  719. LENGTH(name) asc
  720. </select>
  721. <select id="getBrandByName" resultType="com.caimei365.commodity.model.vo.BrandVo">
  722. select id, name
  723. from cm_brand
  724. where name = #{name}
  725. and delFlag = '0'
  726. </select>
  727. <select id="getShopBrandList" resultType="com.caimei365.commodity.model.vo.BrandVo">
  728. select id, name, source, userId, status, auditNote, sort, delFlag, logo, description, createDate, updateDate
  729. from cm_brand
  730. <where>
  731. userID = #{userId}
  732. and delFlag = '0'
  733. <if test="name != null and name != ''">
  734. and name like CONCAT("%",#{name},"%")
  735. </if>
  736. <if test="status != null and status != ''">
  737. and status = #{status}
  738. </if>
  739. </where>
  740. order by createDate desc
  741. </select>
  742. <select id="getPcBeautyStatusById" resultType="java.lang.Integer">
  743. select i.productId
  744. from new_page_floor_image i
  745. left join cm_page_centre c on i.centreId = c.id
  746. left join cm_page p on c.pageId = p.id
  747. where i.productId = #{productId}
  748. and i.pcStatus = 1
  749. and p.type = 7
  750. and c.enabledStatus = 1
  751. and p.enabledStatus = 1
  752. limit 1
  753. </select>
  754. <select id="getAppletsBeautyStatusById" resultType="java.lang.Integer">
  755. select i.productId
  756. from new_page_floor_image i
  757. left join cm_page_centre c on i.centreId = c.id
  758. left join cm_page p on c.pageId = p.id
  759. where i.productId = #{productId}
  760. and i.appletsStatus = 1
  761. and p.type = 7
  762. and c.crmEnabledStatus = 1
  763. and p.enabledStatus = 1
  764. limit 1
  765. </select>
  766. <select id="getShopNameByShopId" resultType="java.lang.String">
  767. select name
  768. from shop
  769. where shopID = #{shopId}
  770. </select>
  771. <select id="listingFee" resultType="java.lang.Integer">
  772. SELECT COUNT(*)
  773. FROM `cm_discern_receipt`
  774. WHERE newReceiptType = 1
  775. AND shopID = #{shopID}
  776. </select>
  777. <select id="listingfeeExpire" resultType="java.lang.Integer">
  778. SELECT COUNT(*)
  779. FROM `cm_discern_receipt`
  780. WHERE newReceiptType = 1
  781. AND shopID = #{shopID}
  782. AND NOW() > DATE_ADD(receiptDate, INTERVAL 1 YEAR)
  783. </select>
  784. <select id="receStatct" resultType="java.lang.Integer">
  785. SELECT COUNT(*)
  786. FROM `cm_discern_receipt`
  787. WHERE newReceiptType = 1
  788. AND shopID = #{shopID}
  789. AND receStatct = 2
  790. </select>
  791. </mapper>