ShopMapper.xml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  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. contractEmail = #{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. <if test="website != null and website != ''">
  81. website = #{website},
  82. </if>
  83. <if test="wxApplets != null and wxApplets != ''">
  84. wxApplets = #{wxApplets},
  85. </if>
  86. <if test="wxOfficialAccount != null and wxOfficialAccount != ''">
  87. wxOfficialAccount = #{wxOfficialAccount},
  88. </if>
  89. name = #{name}
  90. </set>
  91. where shopID = #{shopId}
  92. </update>
  93. <delete id="deleteShopCertByShopId">
  94. DELETE FROM shopcert WHERE shopID = #{shopId}
  95. </delete>
  96. <select id="getShopCert" resultType="java.lang.String">
  97. SELECT image FROM shopcert WHERE shopID = #{shopId} AND shopCertTypeID = #{shopCertTypeId}
  98. </select>
  99. <select id="getShopByUserId" resultType="com.caimei365.user.model.vo.UserLoginVo">
  100. select
  101. u.userID as userId,
  102. u.userOrganizeID as organizeId,
  103. u.clubID as clubId,
  104. u.shopID as shopId,
  105. u.serviceProviderId as serviceProviderId,
  106. u.userName as userName,
  107. u.name as name,
  108. u.mobile as mobile,
  109. u.bindMobile as bindMobile,
  110. u.email as email,
  111. u.userPermission as userPermission,
  112. u.userIdentity as userIdentity,
  113. u.password as password,
  114. u.guideFlag as guideFlag,
  115. u.clubStatus as clubStatus,
  116. u.manufacturerStatus as shopStatus
  117. from user u
  118. where u.userId = #{userId}
  119. </select>
  120. <select id="getShopById" resultType="com.caimei365.user.model.vo.ShopVo">
  121. select userID as userId, shopID as shopId, name, sname as shortName, linkMan, contractMobile,
  122. contractEmail, contractEmail as email, provinceID as proviceId, cityID as cityId, townID as townId,
  123. address, socialCreditCode, businessLicenseImage as businessLicense, firstShopType, secondShopType,
  124. mainpro as mainProduct, productDesc as mainProductDesc,legalPerson,registeredCapital,fax as faxNumber,
  125. nature as companyNature, turnover, medicalPracticeLicenseImg1 as medicalPracticeLicense, info as shopDesc,
  126. businessScope, logo, addTime, status, contractPhone, validFlag, website, wxOfficialAccount, wxApplets
  127. from shop where shopID = #{shopId}
  128. </select>
  129. <select id="getShopHomeData" resultType="com.caimei365.user.model.vo.ShopHomeVo">
  130. select
  131. s.shopID as id,
  132. s.userID as userId,
  133. s.name,
  134. s.sname as abbr,
  135. s.logo,
  136. s.address,
  137. s.businessScope,
  138. s.businessLicenseImage as businessLicense,
  139. s.taxCertificateImage as taxCertificate,
  140. s.authorizationCertificateImage as certificate,
  141. s.info,
  142. s.productDesc,
  143. count(*) as normalNum
  144. from shop s
  145. where s.shopID = #{supplierId}
  146. group by s.shopID
  147. </select>
  148. <select id="getShopCertById" resultType="java.lang.String">
  149. SELECT image FROM shopcert WHERE shopID = #{shopId} AND shopCertTypeID = #{shopCertTypeId}
  150. </select>
  151. <select id="medicalPracticeLicense" resultType="java.lang.String">
  152. SELECT medicalPracticeLicenseImg1 FROM shop WHERE shopID = #{shopId}
  153. </select>
  154. <select id="getShopHomeImages" resultType="com.caimei365.user.model.vo.ShopBannerVo">
  155. select shopBannerID AS id, shopID AS shopId, image, link, title, info
  156. from shopbanner where shopID = #{shopId}
  157. </select>
  158. <select id="getShopPromotionsByShopId" resultType="com.caimei365.user.model.vo.PromotionsVo">
  159. select pr.id,
  160. pr.name,
  161. pr.description,
  162. pr.type,
  163. pr.mode,
  164. pr.touchPrice,
  165. pr.reducedPrice,
  166. pr.beginTime,
  167. pr.endTime,
  168. pr.status,
  169. prp.productId,
  170. prp.supplierId
  171. from cm_promotions pr
  172. left join cm_promotions_product prp on pr.id = prp.promotionsId
  173. where prp.supplierId = #{shopId}
  174. and (pr.status = 1 or ( pr.status = 2 and (NOW() between pr.beginTime and pr.endTime)))
  175. and pr.type=3
  176. and pr.delFlag not in (1,2)
  177. order by pr.type desc
  178. limit 1
  179. </select>
  180. <select id="getPromotionsGifts" resultType="com.caimei365.user.model.vo.ProductItemVo">
  181. select
  182. cpg.id as id,
  183. p.productID as productId,
  184. p.shopID as shopId,
  185. p.`name` as `name`,
  186. p.mainImage as image,
  187. cpg.number as number,
  188. 0 as price,
  189. 2 as productType,
  190. (select price from cm_sku where productId=p.productId order by price asc limit 1)as originalPrice,
  191. (select unit from cm_sku where productId=p.productId order by price asc limit 1)as unit,
  192. copi.validFlag as validFlag,
  193. (select stock from cm_sku where productId=p.productId order by price asc limit 1)as stock
  194. from product p
  195. left join cm_organize_product_info copi on copi.productId = p.productID and copi.organizeId = 0
  196. left join cm_promotions_gift cpg on cpg.productId = p.productID
  197. where cpg.promotionsId = #{promotionsId}
  198. order by cpg.addTime desc
  199. </select>
  200. <select id="getShopProductCount" resultType="java.lang.Integer">
  201. SELECT COUNT(*)
  202. FROM product p
  203. left join cm_organize_product_info copi on p.productID = copi.productId
  204. WHERE p.shopID = #{shopId} and copi.organizeId = #{productOrganize}
  205. and p.groundMall LIKE concat('%',#{productOrganize},'%')
  206. <if test="validFlag != null">
  207. AND copi.validFlag = #{validFlag}
  208. </if>
  209. </select>
  210. <select id="getSalesRankingList" resultType="java.util.Map">
  211. SELECT cop.productID AS productId, SUM(cop.num) AS total
  212. FROM cm_order_product cop JOIN cm_order co ON co.orderID = cop.orderID
  213. WHERE cop.shopID = #{shopId} and cop.organizeID = #{organizeId}
  214. AND co.STATUS NOT IN ('0', '6', '7')
  215. AND co.delFlag = '0'
  216. AND co.secondHandOrderFlag != '1'
  217. GROUP BY productID
  218. ORDER BY total DESC
  219. LIMIT 5
  220. </select>
  221. <select id="getProductShown" resultType="com.caimei365.user.model.vo.ProductItemVo">
  222. SELECT name, mainImage AS image
  223. FROM product
  224. WHERE productId = #{productId}
  225. </select>
  226. <select id="getSalesStatistics" resultType="java.util.Map">
  227. SELECT COUNT(DISTINCT so.shopOrderID) AS orderQuantity,
  228. IFNULL(SUM(o.productTotalFee),0) AS orderAmount
  229. FROM cm_order o
  230. JOIN cm_shop_order so ON o.orderID = so.orderID
  231. WHERE o.status NOT IN('0', '6', '7')
  232. AND o.delFlag = '0'
  233. AND so.delFlag = '0'
  234. AND so.shopID = #{shopId}
  235. AND so.organizeID = #{organizeId}
  236. AND o.secondHandOrderFlag != '1'
  237. <if test="startTime != null and startTime != ''">
  238. AND o.orderTime <![CDATA[ >= ]]> #{startTime}
  239. </if>
  240. <if test="endTime != null and endTime != ''">
  241. AND o.orderTime <![CDATA[ <= ]]> #{endTime}
  242. </if>
  243. </select>
  244. <select id="getShopHomeImageCount" resultType="java.lang.Integer">
  245. SELECT COUNT(*) FROM shopbanner WHERE shopID = #{shopId}
  246. </select>
  247. <insert id="insertShopHomeImage">
  248. INSERT INTO shopbanner (shopID,title,link,info,image)
  249. VALUES (#{shopId},#{title},#{link},#{info},#{image})
  250. </insert>
  251. <update id="updateShopHomeImage">
  252. UPDATE shopbanner
  253. SET title = #{title}, link = #{link}, info = #{info}, image = #{image}
  254. WHERE shopBannerID = #{id}
  255. </update>
  256. <delete id="deleteShopHomeImage">
  257. DELETE FROM shopbanner WHERE shopBannerID = #{id}
  258. </delete>
  259. </mapper>