ShopMapper.xml 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797
  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,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}, #{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. showFlag=#{showFlag}
  245. where productID = #{productId}
  246. </update>
  247. <insert id="insertVaildFlag">
  248. insert into cm_organize_product_info (organizeId, productId, validFlag)
  249. values (#{organizeId},#{productId},#{validFlag})
  250. </insert>
  251. <update id="updateVaildFlag">
  252. update cm_organize_product_info
  253. set validFlag = #{validFlag}
  254. where productId = #{productId} and organizeId = #{organizeId}
  255. </update>
  256. <insert id="insertProductImage">
  257. insert into productimage (productID, shopID, addTime, image, mainFlag, sortIndex)
  258. values (#{productId}, #{shopId}, #{addTime}, #{image}, #{mainFlag}, #{sortIndex})
  259. </insert>
  260. <insert id="insertProductParameters" parameterType="com.caimei365.commodity.model.po.ProductParameterPo">
  261. insert into cm_product_related_parameters (productId, paramsName, paramsContent, delFlag)
  262. values (#{productId}, #{paramsName}, #{paramsContent}, #{delFlag})
  263. </insert>
  264. <insert id="insertProductDetailInfo">
  265. insert into productdetailinfo (productID, propValueAlias, propValueImages,
  266. detailInfo, serviceInfo, orderInfo, detailInfoTxt, seoTitle,
  267. seoKeyword, seoDes)
  268. values (#{productId}, #{propValueAlias}, #{propValueImages},
  269. #{detailInfo}, #{serviceInfo}, #{orderInfo}, #{detailInfoTxt}, #{seoTitle},
  270. #{seoKeyword}, #{seoDes})
  271. </insert>
  272. <insert id="insertBrand" keyColumn="id" keyProperty="id" parameterType="com.caimei365.commodity.model.po.BrandPo"
  273. useGeneratedKeys="true">
  274. insert into cm_brand (name, source, userID, status, delFlag, createDate, updateDate, logo, description)
  275. values (#{name}, #{source}, #{userId}, #{status}, #{delFlag}, #{createDate}, #{updateDate}, #{logo},
  276. #{description})
  277. </insert>
  278. <insert id="insertSku">
  279. insert into cm_sku
  280. (productId,
  281. organizeId,
  282. normalPrice,
  283. price,
  284. costCheckFlag,
  285. costprice,
  286. stock,
  287. minBuyNumber,
  288. unit,
  289. ladderPriceFlag,
  290. shopPercent,
  291. organizePercent,
  292. cmPercent)
  293. values (#{productId},
  294. #{organizeId},
  295. #{normalPrice},
  296. #{price},
  297. ifnull(#{costCheckFlag}, 1),
  298. #{costPrice},
  299. #{stock},
  300. #{minBuyNumber},
  301. #{unit},
  302. ifnull(#{ladderPriceFlag}, 0),
  303. #{shopPercent},
  304. #{organizePercent},
  305. #{cmPercent})
  306. </insert>
  307. <insert id="insertProductInfo">
  308. insert into cm_organize_product_info (organizeId, productId, validFlag)
  309. values (#{organizeId}, #{productId}, #{validFlag})
  310. </insert>
  311. <update id="updateBrand">
  312. update cm_brand
  313. <set>
  314. <if test="name != null">
  315. `name` = #{name},
  316. </if>
  317. <if test="source != null">
  318. `source` = #{source},
  319. </if>
  320. <if test="userId != null">
  321. userID = #{userId},
  322. </if>
  323. <if test="status != null">
  324. `status` = #{status},
  325. </if>
  326. <if test="delFlag != null">
  327. delFlag = #{delFlag},
  328. </if>
  329. <if test="updateDate != null">
  330. updateDate = #{updateDate},
  331. </if>
  332. <if test="logo != null">
  333. logo = #{logo},
  334. </if>
  335. <if test="description != null">
  336. description = #{description},
  337. </if>
  338. </set>
  339. where id = #{id}
  340. </update>
  341. <update id="updateProductImage">
  342. update productimage
  343. set productID = #{productId},
  344. shopID = #{shopId},
  345. addTime = #{addTime},
  346. image = #{image},
  347. mainFlag = #{mainFlag},
  348. sortIndex = #{sortIndex}
  349. where productImageId = #{id}
  350. </update>
  351. <update id="updateProductDetailInfo">
  352. update productdetailinfo
  353. set propValueAlias = #{propValueAlias},
  354. propValueImages = #{propValueImages},
  355. detailInfo = #{detailInfo},
  356. detailInfoTxt = #{detailInfoTxt},
  357. seoTitle = #{seoTitle},
  358. seoKeyword = #{seoKeyword},
  359. seoDes = #{seoDes},
  360. serviceInfo = #{serviceInfo},
  361. orderInfo = #{orderInfo}
  362. where productDetailInfoID = #{productDetailInfoId}
  363. </update>
  364. <update id="updateProductFeatured">
  365. update product
  366. set featuredFlag = #{featuredFlag}
  367. where productID = #{productId}
  368. and shopID = #{shopId}
  369. </update>
  370. <update id="updateProductValidFlag">
  371. update cm_organize_product_info
  372. set validFlag = #{validFlag}
  373. where productId = #{productId}
  374. <if test="organizeId != 0">
  375. <if test="organizeId == 1">
  376. and organizeId = 0
  377. </if>
  378. <if test="organizeId == 2">
  379. and organizeId = 4
  380. </if>
  381. </if>
  382. </update>
  383. <update id="updateProductCode">
  384. update product
  385. set productCode = #{productCode}
  386. where productID = #{productId}
  387. </update>
  388. <update id="updateSku">
  389. update cm_sku
  390. set minBuyNumber=#{minBuyNumber},
  391. costPrice=#{costPrice},
  392. stock=#{stock},
  393. price=#{price},
  394. normalPrice=#{normalPrice},
  395. unit=#{unit}
  396. where skuId = #{skuId}
  397. </update>
  398. <delete id="deleteProductImage">
  399. delete
  400. from productimage
  401. where productImageID = #{id}
  402. </delete>
  403. <delete id="deleteProductParameters">
  404. delete
  405. from cm_product_related_parameters
  406. where productId = #{productId}
  407. </delete>
  408. <select id="getMainProducts" resultType="com.caimei365.commodity.model.search.ProductListVo">
  409. select
  410. p.productID as productId,
  411. p.actStatus,
  412. p.shopID as shopId,
  413. p.`name` as `name`,
  414. p.mainImage as image,
  415. (select price from cm_sku where productId=p.productID and organizeId = 0 order by price asc limit 1) as price,
  416. (select unit from cm_sku where productId=p.productID and organizeId = 0 order by price asc limit 1) as unit,
  417. p.priceFlag as priceFlag,
  418. IFNULL(p.visibility,3) as visibility,
  419. p.productType
  420. from product p
  421. left join cm_organize_product_info copi on copi.productId = p.productID and copi.organizeId = 0
  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 copi.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 p
  516. left join cm_organize_product_info copi on copi.productId = p.productId
  517. where p.shopID = #{shopId}
  518. and copi.validFlag = '2'
  519. and p.featuredFlag = '1'
  520. order by p.productID desc
  521. </select>
  522. <select id="getCodeByTypeId" resultType="java.lang.String">
  523. select
  524. CONCAT(IFNULL(b.bigTypeCode,''), IFNULL(s.smallTypeCode,''), IFNULL(t.tinyTypeCode,''))
  525. from bigtype b
  526. left join smalltype s on s.bigTypeID = b.bigTypeID
  527. left join tinytype t on t.smallTypeID = s.smallTypeID
  528. <where>
  529. <if test="bigTypeId != null">
  530. b.bigTypeID = #{bigTypeId}
  531. </if>
  532. <if test="smallTypeId != null">
  533. and s.smallTypeID = #{smallTypeId}
  534. </if>
  535. <if test="tinyTypeId != null">
  536. and t.tinyTypeID = #{tinyTypeId}
  537. </if>
  538. </where>
  539. </select>
  540. <select id="getImageByProductId" resultType="com.caimei365.commodity.model.po.ProductImagePo">
  541. select productImageID as id, productID as productId, shopID as shopId, addTime, image, mainFlag, sortIndex
  542. from productimage
  543. where productID = #{productId}
  544. order by mainFlag DESC
  545. </select>
  546. <select id="getProductForm" resultType="com.caimei365.commodity.model.vo.ProductFormVo">
  547. select productID as productId,
  548. groundMall,
  549. shopID as shopId,
  550. name,
  551. aliasName,
  552. commodityType,
  553. mainImage,
  554. (select stock from cm_sku where productId=p.productId and organizeId = 0 order by price asc LIMIT 1) as stock,
  555. invoiceType,
  556. bigTypeID as bigTypeId,
  557. smallTypeID as smallTypeId,
  558. tinyTypeID as tinyTypeId,
  559. searchKey,
  560. visibility,
  561. brandID as brandId,
  562. productType,
  563. tags,
  564. (select unit from cm_sku where productId=p.productId and organizeId = 0 order by price asc LIMIT 1)as unit,
  565. (select normalPrice from cm_sku where productId=p.productId and organizeId = 0 order by price asc LIMIT 1)as normalPrice,
  566. (select price from cm_sku where productId=p.productId and organizeId = 0 order by price asc LIMIT 1)as price,
  567. includedTax,
  568. (select minBuyNumber from cm_sku where productId=p.productId and organizeId = 0 order by price asc LIMIT 1)as minBuyNumber,
  569. productCategory,
  570. serviceNumber,
  571. supplierTaxPoint,
  572. priceFlag,
  573. actFlag,
  574. (select ladderPriceFlag from cm_sku where productId=p.productId and organizeId = 0 order by price asc LIMIT 1) as ladderPriceFlag,
  575. addTime,
  576. hasSkuFlag,
  577. sellNumber,
  578. sortIndex,
  579. featuredFlag,
  580. (select costCheckFlag from cm_sku where productId=p.productId and organizeId = 0 order by price asc LIMIT 1)as costCheckFlag,
  581. recommendType,
  582. machineType,
  583. productCode,
  584. updateTime,
  585. IFNULL((SELECT validFlag FROM cm_organize_product_info WHERE productId = p.productID AND organizeId = 0), 999) AS validFlag,
  586. IFNULL((SELECT validFlag FROM cm_organize_product_info WHERE productId = p.productID AND organizeId = 4), 999) AS mallValidFlag,
  587. searchKey,
  588. allAreaFlag,
  589. step,
  590. (select costPrice from cm_sku where productId=p.productId and organizeId = 0 order by price asc LIMIT 1)as costPrice,
  591. provinceIds,
  592. qualificationImg,
  593. trainingMethod,
  594. trainingType,
  595. trainingFee,
  596. ifnull(newProductType, 2) as newProductType,
  597. qualificationNo as qualificationNo,
  598. productName as productName,
  599. qualificationTime as qualificationTime,
  600. qualificationLink as qualificationLink
  601. from product p
  602. where productID = #{productId}
  603. </select>
  604. <select id="getBrandNameById" resultType="java.lang.String">
  605. select name
  606. from cm_brand
  607. where id = #{brandId}
  608. </select>
  609. <select id="getProductParameters" resultType="com.caimei365.commodity.model.po.ProductParameterPo">
  610. select id, productID as productId, paramsName, paramsContent
  611. from cm_product_related_parameters
  612. where productId = #{productId}
  613. AND delFlag = '0'
  614. </select>
  615. <select id="getProductImages" resultType="com.caimei365.commodity.model.po.ProductImagePo">
  616. select productImageID as id, productID as productId, shopId, addTime, image, mainFlag, sortIndex
  617. from productimage
  618. where productID = #{productId}
  619. UNION
  620. SELECT p.productImageID AS id, p.productID AS productId, p.shopId, p.ADDTIME, p.image, p.mainFlag, p.sortIndex
  621. FROM productimage p
  622. LEFT JOIN product pt ON p.productId = pt.productId
  623. WHERE pt.productId = #{productId}
  624. order by mainFlag desc
  625. </select>
  626. <select id="getProductDetailInfo" resultType="com.caimei365.commodity.model.po.ProductDetailInfoPo">
  627. select productDetailInfoId,
  628. productId,
  629. detailInfo,
  630. commonDetailInfo,
  631. serviceInfo,
  632. orderInfo,
  633. propValueAlias,
  634. propValueImages,
  635. detailInfoTxt,
  636. seoTitle,
  637. seoKeyword,
  638. seoDes
  639. from productdetailinfo
  640. where productId = #{productId}
  641. </select>
  642. <select id="getProductOrganizeDetailInfo" resultType="com.caimei365.commodity.model.po.ProductDetailInfoPo">
  643. SELECT p.productDetailInfoId,
  644. p.productId,
  645. p.detailInfo,
  646. p.commonDetailInfo,
  647. p.serviceInfo,
  648. p.orderInfo,
  649. p.propValueAlias,
  650. p.propValueImages,
  651. p.detailInfoTxt,
  652. p.seoTitle,
  653. p.seoKeyword,
  654. p.seoDes
  655. FROM productdetailinfo p
  656. LEFT JOIN product pt ON pt.productId = p.productId
  657. WHERE p.productId = #{productId}
  658. </select>
  659. <select id="getProductShopById" resultType="com.caimei365.commodity.model.vo.ShopVo">
  660. select userID as userId,
  661. shopID as shopId,
  662. name,
  663. sname as shortName,
  664. linkMan,
  665. contractMobile,
  666. contractEmail,
  667. contractEmail as email,
  668. provinceID as proviceId,
  669. cityID as cityId,
  670. townID as townId,
  671. address,
  672. socialCreditCode,
  673. businessLicenseImage as businessLicense,
  674. firstShopType,
  675. secondShopType,
  676. mainpro as mainProduct,
  677. productDesc as mainProductDesc,
  678. legalPerson,
  679. registeredCapital,
  680. fax as faxNumber,
  681. nature as companyNature,
  682. turnover,
  683. medicalPracticeLicenseImg1 as medicalPracticeLicense,
  684. info as shopDesc,
  685. businessScope,
  686. logo,
  687. addTime,
  688. status,
  689. contractPhone,
  690. validFlag,
  691. website,
  692. wxOfficialAccount,
  693. wxApplets
  694. from shop
  695. where shopID = #{shopId}
  696. </select>
  697. <select id="getProductNumById" resultType="java.lang.Integer">
  698. select COUNT(*) as normalNum
  699. from product p
  700. left join cm_organize_product_info copi on copi.productId = p.productID
  701. where p.shopID = #{shopId}
  702. and copi.validFlag = 2
  703. group by p.shopID
  704. </select>
  705. <select id="getUserIdentityById" resultType="java.lang.Integer">
  706. select userIdentity
  707. from user
  708. where userID = #{userId}
  709. </select>
  710. <select id="getBrandAssociation" resultType="com.caimei365.commodity.model.vo.BrandVo">
  711. select id, name
  712. from cm_brand
  713. where status = '1'
  714. and delFlag = '0'
  715. and name like CONCAT("%", #{name}, "%")
  716. order by case
  717. when (source = '1' and userID = #{userId})
  718. then 0
  719. else 1
  720. end asc,
  721. LENGTH(name) asc
  722. </select>
  723. <select id="getBrandByName" resultType="com.caimei365.commodity.model.vo.BrandVo">
  724. select id, name
  725. from cm_brand
  726. where name = #{name}
  727. and delFlag = '0'
  728. </select>
  729. <select id="getShopBrandList" resultType="com.caimei365.commodity.model.vo.BrandVo">
  730. select id, name, source, userId, status, auditNote, sort, delFlag, logo, description, createDate, updateDate
  731. from cm_brand
  732. <where>
  733. userID = #{userId}
  734. and delFlag = '0'
  735. <if test="name != null and name != ''">
  736. and name like CONCAT("%",#{name},"%")
  737. </if>
  738. <if test="status != null and status != ''">
  739. and status = #{status}
  740. </if>
  741. </where>
  742. order by createDate desc
  743. </select>
  744. <select id="getPcBeautyStatusById" resultType="java.lang.Integer">
  745. select i.productId
  746. from new_page_floor_image i
  747. left join cm_page_centre c on i.centreId = c.id
  748. left join cm_page p on c.pageId = p.id
  749. where i.productId = #{productId}
  750. and i.pcStatus = 1
  751. and p.type = 7
  752. and c.enabledStatus = 1
  753. and p.enabledStatus = 1
  754. limit 1
  755. </select>
  756. <select id="getAppletsBeautyStatusById" resultType="java.lang.Integer">
  757. select i.productId
  758. from new_page_floor_image i
  759. left join cm_page_centre c on i.centreId = c.id
  760. left join cm_page p on c.pageId = p.id
  761. where i.productId = #{productId}
  762. and i.appletsStatus = 1
  763. and p.type = 7
  764. and c.crmEnabledStatus = 1
  765. and p.enabledStatus = 1
  766. limit 1
  767. </select>
  768. <select id="getShopNameByShopId" resultType="java.lang.String">
  769. select name
  770. from shop
  771. where shopID = #{shopId}
  772. </select>
  773. <select id="listingFee" resultType="java.lang.Integer">
  774. SELECT COUNT(*)
  775. FROM `cm_discern_receipt`
  776. WHERE newReceiptType = 1
  777. AND shopID = #{shopID}
  778. </select>
  779. <select id="listingfeeExpire" resultType="java.lang.Integer">
  780. SELECT COUNT(*)
  781. FROM `cm_discern_receipt`
  782. WHERE newReceiptType = 1
  783. AND shopID = #{shopID}
  784. AND NOW() > DATE_ADD(receiptDate, INTERVAL 1 YEAR)
  785. </select>
  786. <select id="receStatct" resultType="java.lang.Integer">
  787. SELECT COUNT(*)
  788. FROM `cm_discern_receipt`
  789. WHERE newReceiptType = 1
  790. AND shopID = #{shopID}
  791. AND receStatct = 2
  792. </select>
  793. </mapper>