ShopMapper.xml 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519
  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" parameterType="com.caimei365.commodity.model.po.ProductPo" useGeneratedKeys="true">
  5. insert into product (
  6. shopID, name, aliasName, commodityType, bigTypeID, smallTypeID, tinyTypeID, mainImage,
  7. brandID, productType, tags, unit, normalPrice, price, price1, includedTax, minBuyNumber, stock,
  8. <if test="productCategory != null and productCategory != ''">
  9. productCategory,
  10. </if>
  11. <if test="serviceNumber != null and serviceNumber != ''">
  12. serviceNumber,
  13. </if>
  14. <if test="supplierTaxPoint != null and supplierTaxPoint != ''">
  15. supplierTaxPoint,
  16. </if>
  17. <if test="addTime != null and addTime != ''">
  18. addTime,
  19. </if>
  20. <if test="hasSkuFlag != null and hasSkuFlag != ''">
  21. hasSkuFlag,
  22. </if>
  23. <if test="sellNumber != null and sellNumber != ''">
  24. sellNumber,
  25. </if>
  26. <if test="sortIndex != null and sortIndex != ''">
  27. sortIndex,
  28. </if>
  29. <if test="featuredFlag != null and featuredFlag != ''">
  30. featuredFlag,
  31. </if>
  32. <if test="costCheckFlag != null and costCheckFlag != ''">
  33. costCheckFlag,
  34. </if>
  35. <if test="recommendType != null and recommendType != ''">
  36. recommendType,
  37. </if>
  38. <if test="priceFlag != null and priceFlag != ''">
  39. price1TextFlag,
  40. </if>
  41. <if test="actFlag != null and actFlag != ''">
  42. actFlag,
  43. </if>
  44. <if test="ladderPriceFlag != null and ladderPriceFlag != ''">
  45. ladderPriceFlag,
  46. </if>
  47. <if test="visibility != null and visibility != ''">
  48. visibility,
  49. </if>
  50. <if test="productCode != null and productCode != ''">
  51. productCode,
  52. </if>
  53. <if test="searchKey != null and searchKey != ''">
  54. searchKey,
  55. </if>
  56. <if test="allAreaFlag != null and allAreaFlag != ''">
  57. allAreaFlag,
  58. </if>
  59. <if test="step != null and step != ''">
  60. step,
  61. </if>
  62. <if test="costPrice != null and costPrice != ''">
  63. costPrice,
  64. </if>
  65. <if test="provinceIds != null and provinceIds != ''">
  66. provinceIds,
  67. </if>
  68. <if test="machineType != null and machineType != ''">
  69. machineType,
  70. </if>
  71. <if test="qualificationImg != null and qualificationImg != ''">
  72. qualificationImg,
  73. </if>
  74. <if test="invoiceType != null and invoiceType != ''">
  75. invoiceType,
  76. </if>
  77. updateTime, validFlag
  78. ) values (
  79. #{shopId}, #{name}, #{aliasName}, #{commodityType}, #{bigTypeId}, #{smallTypeId}, #{tinyTypeId}, #{mainImage},
  80. #{brandId}, #{productType}, #{tags}, #{unit}, #{normalPrice}, #{price}, #{price}, #{includedTax}, #{minBuyNumber}, #{stock},
  81. <if test="productCategory != null and productCategory != ''">
  82. #{productCategory},
  83. </if>
  84. <if test="serviceNumber != null and serviceNumber != ''">
  85. #{serviceNumber},
  86. </if>
  87. <if test="supplierTaxPoint != null and supplierTaxPoint != ''">
  88. #{supplierTaxPoint},
  89. </if>
  90. <if test="addTime != null and addTime != ''">
  91. #{addTime},
  92. </if>
  93. <if test="hasSkuFlag != null and hasSkuFlag != ''">
  94. #{hasSkuFlag},
  95. </if>
  96. <if test="sellNumber != null and sellNumber != ''">
  97. #{sellNumber},
  98. </if>
  99. <if test="sortIndex != null and sortIndex != ''">
  100. #{sortIndex},
  101. </if>
  102. <if test="featuredFlag != null and featuredFlag != ''">
  103. #{featuredFlag},
  104. </if>
  105. <if test="costCheckFlag != null and costCheckFlag != ''">
  106. #{costCheckFlag},
  107. </if>
  108. <if test="recommendType != null and recommendType != ''">
  109. #{recommendType},
  110. </if>
  111. <if test="priceFlag != null and priceFlag != ''">
  112. #{priceFlag},
  113. </if>
  114. <if test="actFlag != null and actFlag != ''">
  115. #{actFlag},
  116. </if>
  117. <if test="ladderPriceFlag != null and ladderPriceFlag != ''">
  118. #{ladderPriceFlag},
  119. </if>
  120. <if test="visibility != null and visibility != ''">
  121. #{visibility},
  122. </if>
  123. <if test="productCode != null and productCode != ''">
  124. #{productCode},
  125. </if>
  126. <if test="searchKey != null and searchKey != ''">
  127. #{searchKey},
  128. </if>
  129. <if test="allAreaFlag != null and allAreaFlag != ''">
  130. #{allAreaFlag},
  131. </if>
  132. <if test="step != null and step != ''">
  133. #{step},
  134. </if>
  135. <if test="costPrice != null and costPrice != ''">
  136. #{costPrice},
  137. </if>
  138. <if test="provinceIds != null and provinceIds != ''">
  139. #{provinceIds},
  140. </if>
  141. <if test="machineType != null and machineType != ''">
  142. #{machineType},
  143. </if>
  144. <if test="qualificationImg != null and qualificationImg != ''">
  145. #{qualificationImg},
  146. </if>
  147. <if test="invoiceType != null and invoiceType != ''">
  148. #{invoiceType},
  149. </if>
  150. #{updateTime}, #{validFlag}
  151. )
  152. </insert>
  153. <update id="updateProduct">
  154. update product set
  155. shopID = #{shopId}, name = #{name}, aliasName = #{aliasName}, commodityType = #{commodityType},
  156. bigTypeId = #{bigTypeId}, smallTypeId = #{smallTypeId}, tinyTypeId = #{tinyTypeId}, mainImage = #{mainImage},
  157. brandId = #{brandId}, productType = #{productType}, tags = #{tags}, unit = #{unit}, normalPrice = #{normalPrice},
  158. price = #{price}, price1 = #{price}, includedTax = #{includedTax}, minBuyNumber = #{minBuyNumber}, stock = #{stock},
  159. <if test="productCategory != null and productCategory != ''">
  160. productCategory = #{productCategory},
  161. </if>
  162. <if test="serviceNumber != null and serviceNumber != ''">
  163. serviceNumber = #{serviceNumber},
  164. </if>
  165. <if test="supplierTaxPoint != null and supplierTaxPoint != ''">
  166. supplierTaxPoint = #{supplierTaxPoint},
  167. </if>
  168. <if test="addTime != null and addTime != ''">
  169. addTime = #{addTime},
  170. </if>
  171. <if test="hasSkuFlag != null and hasSkuFlag != ''">
  172. hasSkuFlag = #{hasSkuFlag},
  173. </if>
  174. <if test="sellNumber != null and sellNumber != ''">
  175. sellNumber = #{sellNumber},
  176. </if>
  177. <if test="sortIndex != null and sortIndex != ''">
  178. sortIndex = #{sortIndex},
  179. </if>
  180. <if test="featuredFlag != null and featuredFlag != ''">
  181. featuredFlag = #{featuredFlag},
  182. </if>
  183. <if test="costCheckFlag != null and costCheckFlag != ''">
  184. costCheckFlag = #{costCheckFlag},
  185. </if>
  186. <if test="recommendType != null and recommendType != ''">
  187. recommendType = #{recommendType},
  188. </if>
  189. <if test="priceFlag != null and priceFlag != ''">
  190. price1TextFlag = #{priceFlag},
  191. </if>
  192. <if test="actFlag != null and actFlag != ''">
  193. actFlag = #{actFlag},
  194. </if>
  195. <if test="ladderPriceFlag != null and ladderPriceFlag != ''">
  196. ladderPriceFlag = #{ladderPriceFlag},
  197. </if>
  198. <if test="visibility != null and visibility != ''">
  199. visibility = #{visibility},
  200. </if>
  201. <if test="productCode != null and productCode != ''">
  202. productCode = #{productCode},
  203. </if>
  204. <if test="searchKey != null and searchKey != ''">
  205. searchKey = #{searchKey},
  206. </if>
  207. <if test="allAreaFlag != null and allAreaFlag != ''">
  208. allAreaFlag = #{allAreaFlag},
  209. </if>
  210. <if test="step != null and step != ''">
  211. step = #{step},
  212. </if>
  213. <if test="costPrice != null and costPrice != ''">
  214. costPrice = #{costPrice},
  215. </if>
  216. <if test="provinceIds != null and provinceIds != ''">
  217. provinceIds = #{provinceIds},
  218. </if>
  219. <if test="machineType != null and machineType != ''">
  220. machineType = #{machineType},
  221. </if>
  222. <if test="qualificationImg != null and qualificationImg != ''">
  223. qualificationImg = #{qualificationImg},
  224. </if>
  225. <if test="invoiceType != null and invoiceType != ''">
  226. invoiceType = #{invoiceType},
  227. </if>
  228. updateTime = #{updateTime}, validFlag = #{validFlag}
  229. where productID = #{productId}
  230. </update>
  231. <insert id="insertProductImage">
  232. insert into productimage (productID, shopID, addTime, image, mainFlag, sortIndex)
  233. values (#{productId}, #{shopId}, #{addTime}, #{image}, #{mainFlag}, #{sortIndex})
  234. </insert>
  235. <insert id="insertProductParameters" parameterType="com.caimei365.commodity.model.po.ProductParameterPo">
  236. insert into cm_product_related_parameters (productId, paramsName, paramsContent, delFlag)
  237. values (#{productId}, #{paramsName}, #{paramsContent}, #{delFlag})
  238. </insert>
  239. <insert id="insertProductDetailInfo">
  240. insert into productdetailinfo (
  241. productID, propValueAlias, propValueImages,
  242. detailInfo, serviceInfo, orderInfo, detailInfoTxt, seoTitle,
  243. seoKeyword, seoDes
  244. ) values (
  245. #{productId}, #{propValueAlias}, #{propValueImages},
  246. #{detailInfo}, #{serviceInfo}, #{orderInfo}, #{detailInfoTxt}, #{seoTitle},
  247. #{seoKeyword}, #{seoDes}
  248. )
  249. </insert>
  250. <insert id="insertBrand" keyColumn="id" keyProperty="id" parameterType="com.caimei365.commodity.model.po.BrandPo" useGeneratedKeys="true">
  251. insert into cm_brand (name, source, userID, status, delFlag, createDate, updateDate, logo, description)
  252. values (#{name},#{source},#{userId},#{status}, #{delFlag},#{createDate},#{updateDate},#{logo},#{description})
  253. </insert>
  254. <update id="updateBrand">
  255. update cm_brand
  256. <set>
  257. <if test="name != null">
  258. `name` = #{name},
  259. </if>
  260. <if test="source != null">
  261. `source` = #{source},
  262. </if>
  263. <if test="userId != null">
  264. userID = #{userId},
  265. </if>
  266. <if test="status != null">
  267. `status` = #{status},
  268. </if>
  269. <if test="delFlag != null">
  270. delFlag = #{delFlag},
  271. </if>
  272. <if test="updateDate != null">
  273. updateDate = #{updateDate},
  274. </if>
  275. <if test="logo != null">
  276. logo = #{logo},
  277. </if>
  278. <if test="description != null">
  279. description = #{description},
  280. </if>
  281. </set>
  282. where id = #{id}
  283. </update>
  284. <update id="updateProductImage">
  285. update productimage set productID = #{productId}, shopID = #{shopId}, addTime = #{addTime},
  286. image = #{image}, mainFlag = #{mainFlag}, sortIndex = #{sortIndex}
  287. where productImageId = #{id}
  288. </update>
  289. <update id="updateProductDetailInfo">
  290. update productdetailinfo set
  291. propValueAlias = #{propValueAlias},
  292. propValueImages = #{propValueImages},
  293. detailInfo = #{detailInfo},
  294. detailInfoTxt = #{detailInfoTxt},
  295. seoTitle = #{seoTitle},
  296. seoKeyword = #{seoKeyword},
  297. seoDes = #{seoDes},
  298. serviceInfo = #{serviceInfo},
  299. orderInfo = #{orderInfo}
  300. where
  301. productDetailInfoID = #{productDetailInfoId}
  302. </update>
  303. <update id="updateProductFeatured">
  304. update product set featuredFlag = #{featuredFlag}
  305. where productID = #{productId}
  306. and shopID = #{shopId}
  307. </update>
  308. <update id="updateProductValidFlag">
  309. update product set validFlag = #{validFlag} where productID = #{productId}
  310. </update>
  311. <update id="updateProductCode">
  312. update product set productCode = #{productCode} where productID = #{productId}
  313. </update>
  314. <delete id="deleteProductImage">
  315. delete from productimage where productImageID = #{id}
  316. </delete>
  317. <delete id="deleteProductParameters">
  318. delete from cm_product_related_parameters where productId = #{productId}
  319. </delete>
  320. <select id="getMainProducts" resultType="com.caimei365.commodity.model.search.ProductListVo">
  321. select
  322. p.productID as productId,
  323. p.actStatus,
  324. p.shopID as shopId,
  325. p.`name` as `name`,
  326. p.mainImage as image,
  327. p.price1 as price,
  328. p.unit as unit,
  329. p.price1TextFlag as priceFlag,
  330. IFNULL(p.visibility,3) as visibility,
  331. p.price8Text as beautyActFlag
  332. from product p
  333. where p.shopID = #{shopId}
  334. and p.visibility in
  335. <foreach collection="visibilityList" item="visibility" index="index" open="(" separator="," close=")">
  336. #{visibility}
  337. </foreach>
  338. and p.validFlag = 2 and p.featuredFlag=1
  339. order by p.productID desc limit 4
  340. </select>
  341. <select id="getShopProductsSelect" resultType="com.caimei365.commodity.model.vo.ProductItemVo">
  342. select
  343. p.productID as productId,
  344. p.actStatus,
  345. p.name,
  346. p.aliasName,
  347. p.mainImage as image,
  348. p.unit,
  349. p.productCode as code,
  350. p.price1TextFlag as priceFlag,
  351. p.price1 as price,
  352. p.shopID as shopId,
  353. p.searchKey as keyword,
  354. p.price8Text as beautyActFlag,
  355. p.minBuyNumber as minBuyNumber,
  356. p.maxBuyNumber as maxBuyNumber,
  357. p.ladderPriceFlag,
  358. p.normalPrice,
  359. p.step,
  360. p.shopID as shopId,
  361. p.taxPoint as taxRate,
  362. p.includedTax,
  363. p.invoiceType,
  364. p.productCategory as productCategory,
  365. p.validFlag,
  366. p.featuredFlag,
  367. p.commodityType,
  368. p.bigTypeID as bigTypeId,
  369. p.smallTypeID as smallTypeId,
  370. p.tinyTypeID as tinyTypeId
  371. from product p
  372. <where>
  373. p.shopID = #{shopId}
  374. <if test="productCode != null and productCode != ''">
  375. and p.productCode = #{productCode}
  376. </if>
  377. <if test="validFlag != null and validFlag != ''">
  378. and p.validFlag = #{validFlag}
  379. </if>
  380. <if test="featuredFlag != null and featuredFlag != ''">
  381. and p.featuredFlag = #{featuredFlag}
  382. </if>
  383. <if test="tinyTypeId != null and tinyTypeId != 0">
  384. and p.tinyTypeID = #{tinyTypeId}
  385. </if>
  386. <if test="smallTypeId != null and smallTypeId != 0">
  387. and p.smallTypeID = #{smallTypeId}
  388. </if>
  389. <if test="bigTypeId != null and bigTypeId != 0">
  390. and p.bigTypeID = #{bigTypeId}
  391. </if>
  392. <if test="commodityType != null and commodityType != ''">
  393. and p.commodityType = #{commodityType}
  394. </if>
  395. <if test="name != null and name != ''">
  396. and p.name like CONCAT("%",#{name},"%")
  397. </if>
  398. </where>
  399. order by p.productID desc
  400. </select>
  401. <select id="getTypeName" resultType="java.lang.String">
  402. select
  403. CONCAT_WS("-", b.name, s.name, t.name)
  404. from
  405. bigtype b
  406. left join smalltype s on s.smallTypeID = #{smallTypeId}
  407. left join tinytype t on t.tinyTypeID = #{tinyTypeId}
  408. where
  409. b.bigTypeID = #{bigTypeId};
  410. </select>
  411. <select id="getUserIdByshopId" resultType="java.lang.Integer">
  412. select userID from user where shopID = #{shopId}
  413. </select>
  414. <select id="getMainProductsCount" resultType="java.lang.Integer">
  415. select count(*) from product where shopID = #{shopId}
  416. and validFlag = '2' and featuredFlag='1' order by productID desc
  417. </select>
  418. <select id="getCodeByTypeId" resultType="java.lang.String">
  419. select
  420. CONCAT(IFNULL(b.bigTypeCode,''), IFNULL(s.smallTypeCode,''), IFNULL(t.tinyTypeCode,''))
  421. from bigtype b
  422. left join smalltype s on s.bigTypeID = b.bigTypeID
  423. left join tinytype t on t.smallTypeID = s.smallTypeID
  424. <where>
  425. <if test="bigTypeId != null">
  426. b.bigTypeID = #{bigTypeId}
  427. </if>
  428. <if test="smallTypeId != null">
  429. and s.smallTypeID = #{smallTypeId}
  430. </if>
  431. <if test="tinyTypeId != null">
  432. and t.tinyTypeID = #{tinyTypeId}
  433. </if>
  434. </where>
  435. </select>
  436. <select id="getImageByProductId" resultType="com.caimei365.commodity.model.po.ProductImagePo">
  437. select productImageID as id, productID as productId, shopID as shopId, addTime, image, mainFlag, sortIndex
  438. from productimage
  439. where productID = #{productId}
  440. order by mainFlag DESC
  441. </select>
  442. <select id="getProductForm" resultType="com.caimei365.commodity.model.vo.ProductFormVo">
  443. select productID as productId, shopID as shopId, name, aliasName, commodityType, mainImage, stock, invoiceType,
  444. bigTypeID as bigTypeId, smallTypeID as smallTypeId, tinyTypeID as tinyTypeId, searchKey, visibility,
  445. brandID as brandId, productType, tags, unit, normalPrice, price1 as price, includedTax, minBuyNumber,
  446. productCategory, serviceNumber, supplierTaxPoint, price1TextFlag as priceFlag, actFlag, ladderPriceFlag,
  447. addTime, hasSkuFlag, sellNumber, sortIndex, featuredFlag, costCheckFlag, recommendType, machineType,
  448. productCode, updateTime, validFlag, searchKey, allAreaFlag, step, costPrice, provinceIds, qualificationImg
  449. from product
  450. where productID = #{productId}
  451. </select>
  452. <select id="getBrandNameById" resultType="java.lang.String">
  453. select name from cm_brand where id = #{brandId}
  454. </select>
  455. <select id="getProductParameters" resultType="com.caimei365.commodity.model.po.ProductParameterPo">
  456. select id, productID as productId, paramsName, paramsContent
  457. from cm_product_related_parameters
  458. where productId = #{productId} AND delFlag='0'
  459. </select>
  460. <select id="getProductImages" resultType="com.caimei365.commodity.model.po.ProductImagePo">
  461. select productImageID as id, productID as productId, shopId, addTime, image, mainFlag, sortIndex
  462. from productimage
  463. where productID = #{productId} order by mainFlag desc
  464. </select>
  465. <select id="getProductDetailInfo" resultType="com.caimei365.commodity.model.po.ProductDetailInfoPo">
  466. select productDetailInfoId, productId, detailInfo, serviceInfo, orderInfo, propValueAlias,
  467. propValueImages, detailInfoTxt, seoTitle, seoKeyword, seoDes
  468. from productdetailinfo
  469. where productId = #{productId}
  470. </select>
  471. <select id="getProductShopById" resultType="com.caimei365.commodity.model.vo.ShopVo">
  472. select userID as userId, shopID as shopId, name, sname as shortName, linkMan, contractMobile,
  473. contractEmail1 as contractEmail, contractEmail1 as email, provinceID as proviceId, cityID as cityId, townID as townId,
  474. address, socialCreditCode, businessLicenseImage as businessLicense, firstShopType, secondShopType,
  475. mainpro as mainProduct, productDesc as mainProductDesc,legalPerson,registeredCapital,fax as faxNumber,
  476. nature as companyNature, turnover, medicalPracticeLicenseImg1 as medicalPracticeLicense, info as shopDesc,
  477. businessScope, logo, addTime, status, contractPhone, validFlag, website, wxOfficialAccount, wxApplets
  478. from shop where shopID = #{shopId}
  479. </select>
  480. <select id="getProductNumById" resultType="java.lang.Integer">
  481. select COUNT(*) as normalNum from product p
  482. where p.shopID = #{shopId} and p.validFlag = 2
  483. group by p.shopID
  484. </select>
  485. <select id="getUserIdentityById" resultType="java.lang.Integer">
  486. select userIdentity from user
  487. where userID = #{userId}
  488. </select>
  489. <select id="getBrandAssociation" resultType="com.caimei365.commodity.model.vo.BrandVo">
  490. select id, name from cm_brand
  491. where
  492. status = '1' and delFlag = '0'
  493. and name like CONCAT("%",#{name},"%")
  494. order by
  495. case when ( source = '1' and userID = #{userId} )
  496. then 0
  497. else 1
  498. end asc,
  499. LENGTH(name) asc
  500. </select>
  501. <select id="getBrandByName" resultType="com.caimei365.commodity.model.vo.BrandVo">
  502. select id, name from cm_brand where name = #{name} and delFlag = '0'
  503. </select>
  504. <select id="getShopBrandList" resultType="com.caimei365.commodity.model.vo.BrandVo">
  505. select id, name, source, userId, status, auditNote, sort, delFlag, logo, description, createDate, updateDate
  506. from cm_brand
  507. <where>
  508. userID = #{userId}
  509. and delFlag = '0'
  510. <if test="name != null and name != ''">
  511. and name like CONCAT("%",#{name},"%")
  512. </if>
  513. <if test="status != null and status != ''">
  514. and status = #{status}
  515. </if>
  516. </where>
  517. order by createDate desc
  518. </select>
  519. </mapper>