ShopMapper.xml 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  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.user.mapper.ShopMapper">
  4. <insert id="insertShopCert">
  5. insert into shopcert (shopID, shopCertTypeID, `name`,
  6. image, organization, effectDate,
  7. loseEfficacyDate)
  8. values (#{shopId}, #{shopCertTypeId}, #{name},
  9. #{image}, #{organization}, #{effectDate},
  10. #{loseEfficacyDate})
  11. </insert>
  12. <update id="updateShopUserByUpdateInfo">
  13. update user
  14. set name = #{name}, userName = #{userName}, email = #{email}
  15. where userID = #{userId}
  16. </update>
  17. <update id="updateShopByUpdateInfo">
  18. update shop
  19. <set>
  20. <if test="shortName != null and shortName != ''">
  21. sname = #{shortName},
  22. </if>
  23. <if test="contractEmail != null and contractEmail != ''">
  24. contractEmail1 = #{contractEmail},
  25. </if>
  26. <if test="contractPhone != null and contractPhone != ''">
  27. contractPhone = #{contractPhone},
  28. </if>
  29. <if test="linkMan != null and linkMan != ''">
  30. linkMan = #{linkMan},
  31. </if>
  32. <if test="townId != null and townId != ''">
  33. provinceID = #{provinceId}, cityID = #{cityId}, townID = #{townId},address = #{address},
  34. </if>
  35. <if test="socialCreditCode != null and socialCreditCode != ''">
  36. socialCreditCode = #{socialCreditCode},
  37. </if>
  38. <if test="businessLicense != null and businessLicense != ''">
  39. businessLicenseImage = #{businessLicense},
  40. </if>
  41. <if test="firstShopType != null and firstShopType != ''">
  42. firstShopType = #{firstShopType},
  43. </if>
  44. <if test="secondShopType != null and secondShopType != ''">
  45. secondShopType = #{secondShopType},
  46. </if>
  47. <if test="mainProduct != null and mainProduct != ''">
  48. mainpro = #{mainProduct},
  49. </if>
  50. <if test="mainProductDesc != null and mainProductDesc != ''">
  51. productDesc = #{mainProductDesc},
  52. </if>
  53. <if test="legalPerson != null and legalPerson != ''">
  54. legalPerson = #{legalPerson},
  55. </if>
  56. <if test="registeredCapital != null and registeredCapital != ''">
  57. registeredCapital = #{registeredCapital},
  58. </if>
  59. <if test="faxNumber != null and faxNumber != ''">
  60. fax = #{faxNumber},
  61. </if>
  62. <if test="companyNature != null and companyNature != ''">
  63. nature = #{companyNature},
  64. </if>
  65. <if test="turnover != null and turnover != ''">
  66. turnover = #{turnover},
  67. </if>
  68. <if test="medicalPracticeLicense != null and medicalPracticeLicense != ''">
  69. medicalPracticeLicenseImg1 = #{medicalPracticeLicense},
  70. </if>
  71. <if test="shopDesc != null and shopDesc != ''">
  72. info = #{shopDesc},
  73. </if>
  74. <if test="businessScope != null and businessScope != ''">
  75. businessScope = #{businessScope},
  76. </if>
  77. <if test="logo != null and logo != ''">
  78. logo = #{logo},
  79. </if>
  80. name = #{name}
  81. </set>
  82. where shopID = #{shopId}
  83. </update>
  84. <delete id="deleteShopCertByShopId">
  85. DELETE FROM shopcert WHERE shopID = #{shopId}
  86. </delete>
  87. <select id="getShopCert" resultType="java.lang.String">
  88. SELECT image FROM shopcert WHERE shopID = #{shopId} AND shopCertTypeID = #{shopCertTypeId}
  89. </select>
  90. <select id="getShopById" resultType="com.caimei365.user.model.vo.ShopVo">
  91. select userID as userId, shopID as shopId, name, sname as shortName, linkMan, contractMobile,
  92. contractEmail1 as contractEmail, contractEmail1 as email, provinceID as proviceId, cityID as cityId, townID as townId,
  93. address, socialCreditCode, businessLicenseImage as businessLicense, firstShopType, secondShopType,
  94. mainpro as mainProduct, productDesc as mainProductDesc,legalPerson,registeredCapital,fax as faxNumber,
  95. nature as companyNature, turnover, medicalPracticeLicenseImg1 as medicalPracticeLicense, info as shopDesc,
  96. businessScope, logo, addTime, status, contractPhone, validFlag, website, wxOfficialAccount, wxApplets
  97. from shop where shopID = #{shopId}
  98. </select>
  99. <select id="getShopHomeData" resultType="com.caimei365.user.model.vo.ShopHomeVo">
  100. select
  101. s.shopID as id,
  102. s.userID as userId,
  103. s.name,
  104. s.sname as abbr,
  105. s.logo,
  106. s.address,
  107. s.businessScope,
  108. s.businessLicenseImage as businessLicense,
  109. s.taxCertificateImage as taxCertificate,
  110. s.authorizationCertificateImage as certificate,
  111. s.info,
  112. s.productDesc,
  113. s.site,
  114. count(*) as normalNum
  115. from shop s
  116. where s.shopID = #{supplierId}
  117. group by s.shopID
  118. </select>
  119. <select id="getShopCertById" resultType="java.lang.String">
  120. SELECT image FROM shopcert WHERE shopID = #{shopId} AND shopCertTypeID = #{shopCertTypeId}
  121. </select>
  122. <select id="getShopHomeImages" resultType="com.caimei365.user.model.vo.ShopBannerVo">
  123. select shopBannerID AS id, shopID AS shopId, image, link, title, info
  124. from shopbanner where shopID = #{shopId}
  125. </select>
  126. <select id="getShopPromotionsByShopId" resultType="com.caimei365.user.model.vo.PromotionsVo">
  127. select pr.id,
  128. pr.name,
  129. pr.description,
  130. pr.type,
  131. pr.mode,
  132. pr.touchPrice,
  133. pr.reducedPrice,
  134. pr.beginTime,
  135. pr.endTime,
  136. pr.status,
  137. prp.productId,
  138. prp.supplierId
  139. from cm_promotions pr
  140. left join cm_promotions_product prp on pr.id = prp.promotionsId
  141. where prp.supplierId = #{shopId}
  142. and (pr.status = 1 or ( pr.status = 2 and (NOW() between pr.beginTime and pr.endTime)))
  143. and pr.type=3
  144. and pr.delFlag not in (1,2)
  145. order by pr.type desc
  146. limit 1
  147. </select>
  148. <select id="getPromotionsGifts" resultType="com.caimei365.user.model.vo.ProductItemVo">
  149. select
  150. cpg.id as id,
  151. p.productID as productId,
  152. p.shopID as shopId,
  153. p.`name` as `name`,
  154. p.mainImage as image,
  155. cpg.number as number,
  156. 0 as price,
  157. 2 as productType,
  158. p.price1 as originalPrice,
  159. p.unit as unit,
  160. p.validFlag as validFlag,
  161. p.stock as stock
  162. from product p
  163. left join cm_promotions_gift cpg on cpg.productId = p.productID
  164. where cpg.promotionsId = #{promotionsId}
  165. order by cpg.addTime desc
  166. </select>
  167. <select id="getShopProductCount" resultType="java.lang.Integer">
  168. SELECT COUNT(*) FROM product
  169. WHERE shopID = #{shopId}
  170. <if test="validFlag != null">
  171. AND validFlag = #{validFlag}
  172. </if>
  173. </select>
  174. <select id="getSalesRankingList" resultType="java.util.Map">
  175. SELECT cop.productID AS productId, SUM(cop.num) AS total
  176. FROM cm_order_product cop JOIN cm_order co ON co.orderID = cop.orderID
  177. WHERE cop.shopID = #{shopId}
  178. AND co.STATUS NOT IN ('0', '6', '7')
  179. AND co.delFlag = '0'
  180. AND co.secondHandOrderFlag != '1'
  181. GROUP BY productID
  182. ORDER BY total DESC
  183. LIMIT 5
  184. </select>
  185. <select id="getProductShown" resultType="com.caimei365.user.model.vo.ProductItemVo">
  186. SELECT name, mainImage AS image
  187. FROM product
  188. WHERE productId = #{productId}
  189. </select>
  190. <select id="getSalesStatistics" resultType="java.util.Map">
  191. SELECT COUNT(DISTINCT so.shopOrderID) AS orderQuantity,
  192. IFNULL(SUM(o.productTotalFee),0) AS orderAmount
  193. FROM cm_order o
  194. JOIN cm_shop_order so ON o.orderID = so.orderID
  195. WHERE o.status NOT IN('0', '6', '7')
  196. AND o.delFlag = '0'
  197. AND so.delFlag = '0'
  198. AND so.shopID = #{shopId}
  199. AND o.secondHandOrderFlag != '1'
  200. <if test="startTime != null and startTime != ''">
  201. AND o.orderTime <![CDATA[ >= ]]> #{startTime}
  202. </if>
  203. <if test="endTime != null and endTime != ''">
  204. AND o.orderTime <![CDATA[ <= ]]> #{endTime}
  205. </if>
  206. </select>
  207. <select id="getShopHomeImageCount" resultType="java.lang.Integer">
  208. SELECT COUNT(*) FROM shopbanner WHERE shopID = #{shopId}
  209. </select>
  210. <insert id="insertShopHomeImage">
  211. INSERT INTO shopbanner (shopID,title,link,info,image)
  212. VALUES (#{shopId},#{title},#{link},#{info},#{image})
  213. </insert>
  214. <update id="updateShopHomeImage">
  215. UPDATE shopbanner
  216. SET title = #{title}, link = #{link}, info = #{info}, image = #{image}
  217. WHERE shopBannerID = #{id}
  218. </update>
  219. <delete id="deleteShopHomeImage">
  220. DELETE FROM shopbanner WHERE shopBannerID = #{id}
  221. </delete>
  222. </mapper>