ShopMapper.xml 38 KB

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