ShopMapper.xml 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704
  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="getShopCategory" resultType="com.caimei365.user.model.vo.CmShopCategoryVo">
  155. SELECT
  156. csc.id,
  157. csc.shopId,
  158. csc.category,
  159. csc.sort,
  160. csc.addTime,
  161. csc.delFlag,
  162. (SELECT COUNT(id) FROM cm_shop_category_product WHERE categoryId = csc.id) as productNumber
  163. FROM cm_shop_category csc
  164. WHERE csc.delFlag = 0 AND csc.shopId = #{shopId}
  165. <if test="category != null and category != ''">
  166. and csc.category like concat('%', #{category}, '%')
  167. </if>
  168. order by csc.sort asc
  169. </select>
  170. <update id="updateCategorySort">
  171. update cm_shop_category
  172. set sort = #{sort}
  173. where id = #{id}
  174. </update>
  175. <select id="getShopCategoryById" resultType="com.caimei365.user.model.vo.CmShopCategoryVo">
  176. SELECT
  177. id,
  178. shopId,
  179. category,
  180. sort,
  181. addTime,
  182. delFlag
  183. FROM cm_shop_category
  184. WHERE delFlag = 0 AND id = #{id}
  185. limit 1
  186. </select>
  187. <select id="getCategoryProductById" resultType="com.caimei365.user.model.vo.ProductItemVo">
  188. SELECT
  189. cscp.id,
  190. cscp.categoryId,
  191. cscp.productId,
  192. p.name,
  193. p.mainImage as image,
  194. s.shopId,
  195. s.name AS shopName
  196. FROM cm_shop_category_product cscp
  197. LEFT JOIN product p ON p.productId = cscp.productId
  198. LEFT JOIN shop s ON s.shopId = p.shopId
  199. WHERE cscp.delFlag = 0 AND cscp.categoryId = #{categoryId}
  200. </select>
  201. <select id="getShopProductList" resultType="com.caimei365.user.model.vo.ProductItemVo">
  202. SELECT
  203. p.productId,
  204. p.name,
  205. p.mainImage as image,
  206. s.shopId,
  207. s.name AS shopName
  208. FROM product p
  209. LEFT JOIN cm_organize_product_info copi ON copi.productId = p.productId
  210. LEFT JOIN shop s ON s.shopId = p.shopId
  211. <where>
  212. copi.organizeId = 0 AND copi.validFlag = 2
  213. and p.shopId = #{shopId}
  214. <if test="name != null and name != ''">
  215. and p.name like concat('%', #{name}, '%')
  216. </if>
  217. </where>
  218. </select>
  219. <select id="getCategoryProductIdList" resultType="java.lang.Integer">
  220. SELECT
  221. cscp.productId
  222. FROM cm_shop_category_product cscp
  223. LEFT JOIN cm_shop_category csc ON csc.id = cscp.categoryId
  224. WHERE csc.shopId = #{shopId} and cscp.categoryId = #{categoryId} and cscp.delFlag = 0
  225. </select>
  226. <insert id="insertCategory" keyColumn="id" keyProperty="id" useGeneratedKeys="true">
  227. insert into cm_shop_category(shopId, category, sort, addTime, delFlag)
  228. values (#{shopId}, #{category}, #{sort}, now(), 0)
  229. </insert>
  230. <insert id="insertCategoryProduct">
  231. insert into cm_shop_category_product(categoryId, productId, addTime, delFlag)
  232. values (#{categoryId}, #{productId}, now(), 0)
  233. </insert>
  234. <update id="updateCategory">
  235. update cm_shop_category
  236. set category = #{category},
  237. sort = #{sort}
  238. where id = #{id}
  239. </update>
  240. <update id="updateCategoryProduct">
  241. update cm_shop_category_product
  242. set delFlag = 1
  243. where categoryId = #{categoryId}
  244. <if test="productIdList.size()>0">
  245. and productId not in
  246. <foreach collection="productIdList" item="productId" open="(" separator="," close=")">
  247. #{productId}
  248. </foreach>
  249. </if>
  250. </update>
  251. <select id="getCategoryProductIds" resultType="java.lang.Integer">
  252. select productId from cm_shop_category_product where categoryId = #{categoryId}
  253. </select>
  254. <update id="deleteCategory">
  255. update cm_shop_category
  256. set delFlag = 1
  257. where id = #{id}
  258. </update>
  259. <select id="getShopHomeImages" resultType="com.caimei365.user.model.vo.ShopBannerVo">
  260. select shopBannerID AS id,
  261. shopID AS shopId,
  262. image,
  263. link,
  264. title,
  265. info,
  266. sort,
  267. addTime
  268. from shopbanner
  269. where shopID = #{shopId}
  270. <if test="title != null and title != ''">
  271. and title like concat('%', #{title}, '%')
  272. </if>
  273. order by sort asc
  274. </select>
  275. <update id="updateShopBannerSort">
  276. update shopbanner
  277. set sort = #{sort}
  278. where shopBannerID = #{id}
  279. </update>
  280. <select id="getShopPromotionsByShopId" resultType="com.caimei365.user.model.vo.PromotionsVo">
  281. select pr.id,
  282. pr.name,
  283. pr.description,
  284. pr.type,
  285. pr.mode,
  286. pr.touchPrice,
  287. pr.reducedPrice,
  288. pr.beginTime,
  289. pr.endTime,
  290. pr.status,
  291. prp.productId,
  292. prp.supplierId
  293. from cm_promotions pr
  294. left join cm_promotions_product prp on pr.id = prp.promotionsId
  295. where prp.supplierId = #{shopId}
  296. and (pr.status = 1 or ( pr.status = 2 and (NOW() between pr.beginTime and pr.endTime)))
  297. and pr.type=3
  298. and pr.delFlag not in (1,2)
  299. order by pr.type desc
  300. limit 1
  301. </select>
  302. <select id="getPromotionsGifts" resultType="com.caimei365.user.model.vo.ProductItemVo">
  303. select
  304. cpg.id as id,
  305. p.productID as productId,
  306. p.shopID as shopId,
  307. p.`name` as `name`,
  308. p.mainImage as image,
  309. cpg.number as number,
  310. 0 as price,
  311. 2 as productType,
  312. (select price from cm_sku where productId=p.productId order by price asc limit 1)as originalPrice,
  313. (select unit from cm_sku where productId=p.productId order by price asc limit 1)as unit,
  314. copi.validFlag as validFlag,
  315. (select stock from cm_sku where productId=p.productId order by price asc limit 1)as stock
  316. from product p
  317. left join cm_organize_product_info copi on copi.productId = p.productID and copi.organizeId = 0
  318. left join cm_promotions_gift cpg on cpg.productId = p.productID
  319. where cpg.promotionsId = #{promotionsId}
  320. order by cpg.addTime desc
  321. </select>
  322. <select id="getShopProductCount" resultType="java.lang.Integer">
  323. SELECT COUNT(*)
  324. FROM product p
  325. left join cm_organize_product_info copi on p.productID = copi.productId
  326. WHERE p.shopID = #{shopId} and copi.organizeId = #{productOrganize}
  327. and p.groundMall LIKE concat('%',#{productOrganize},'%')
  328. <if test="validFlag != null">
  329. AND copi.validFlag = #{validFlag}
  330. </if>
  331. </select>
  332. <select id="getSalesRankingList" resultType="java.util.Map">
  333. SELECT cop.productID AS productId, SUM(cop.num) AS total
  334. FROM cm_order_product cop JOIN cm_order co ON co.orderID = cop.orderID
  335. WHERE cop.shopID = #{shopId} and cop.organizeID = #{organizeId}
  336. AND co.STATUS NOT IN ('0', '6', '7')
  337. AND co.delFlag = '0'
  338. AND co.secondHandOrderFlag != '1'
  339. GROUP BY productID
  340. ORDER BY total DESC
  341. LIMIT 5
  342. </select>
  343. <select id="getProductShown" resultType="com.caimei365.user.model.vo.ProductItemVo">
  344. SELECT name, mainImage AS image
  345. FROM product
  346. WHERE productId = #{productId}
  347. </select>
  348. <select id="getSalesStatistics" resultType="java.util.Map">
  349. SELECT COUNT(DISTINCT so.shopOrderID) AS orderQuantity,
  350. IFNULL(SUM(o.productTotalFee),0) AS orderAmount
  351. FROM cm_order o
  352. JOIN cm_shop_order so ON o.orderID = so.orderID
  353. WHERE o.status NOT IN('0', '6', '7')
  354. AND o.delFlag = '0'
  355. AND so.delFlag = '0'
  356. AND so.shopID = #{shopId}
  357. AND so.organizeID = #{organizeId}
  358. AND o.secondHandOrderFlag != '1'
  359. <if test="startTime != null and startTime != ''">
  360. AND o.orderTime <![CDATA[ >= ]]> #{startTime}
  361. </if>
  362. <if test="endTime != null and endTime != ''">
  363. AND o.orderTime <![CDATA[ <= ]]> #{endTime}
  364. </if>
  365. </select>
  366. <select id="getShopIsMark" resultType="java.lang.Integer">
  367. select id from cm_shop_statistics where shopId = #{shopId} and delFlag = 0 limit 1
  368. </select>
  369. <select id="getShopHomeImageCount" resultType="java.lang.Integer">
  370. SELECT COUNT(*) FROM shopbanner WHERE shopID = #{shopId}
  371. </select>
  372. <insert id="insertShopHomeImage">
  373. INSERT INTO shopbanner (shopID,title,link,info,image, sort, addTime)
  374. VALUES (#{shopId},#{title},#{link},#{info},#{image}, #{sort}, now())
  375. </insert>
  376. <update id="updateShopHomeImage">
  377. UPDATE shopbanner
  378. SET title = #{title}, link = #{link}, info = #{info}, image = #{image}, sort = #{sort}
  379. WHERE shopBannerID = #{id}
  380. </update>
  381. <delete id="deleteShopHomeImage">
  382. DELETE FROM shopbanner WHERE shopBannerID = #{id}
  383. </delete>
  384. <select id="getUserShopId" resultType="java.lang.Integer">
  385. select shopId from shop where userId = #{userId}
  386. </select>
  387. <select id="getMarketCode" resultType="java.lang.String">
  388. select code from cm_market_code where marketReportId = #{marketReportId} and recodeTime <![CDATA[ > ]]> now() and delFlag = 0
  389. </select>
  390. <select id="getShopInfoById" resultType="com.caimei365.user.model.vo.CmMarketShopVo">
  391. SELECT css.id,
  392. s.shopId,
  393. s.name,
  394. s.linkMan,
  395. s.contractMobile,
  396. cmr.addTime,
  397. <if test="type == 1">
  398. (SELECT reportDate FROM cm_market_report WHERE id = #{marketReportId} LIMIT 1) AS reportDate,
  399. </if>
  400. <if test="type != 1">
  401. (SELECT reportDate FROM cm_market_report WHERE marketId = css.id ORDER BY addTime ASC LIMIT 1) AS startDate,
  402. (SELECT reportDate FROM cm_market_report WHERE marketId = css.id ORDER BY addTime DESC LIMIT 1) AS endDate,
  403. </if>
  404. css.logo
  405. FROM cm_shop_statistics css
  406. left join cm_shop_product csp on csp.statisticsId = css.id
  407. LEFT JOIN cm_market_report cmr ON cmr.marketId = csp.id
  408. LEFT JOIN shop s ON s.shopId = css.shopId
  409. WHERE css.delFlag = 0
  410. <if test="type == 1">
  411. and cmr.id = #{marketReportId}
  412. </if>
  413. <if test="type != 1">
  414. and css.shopId = #{shopId}
  415. </if>
  416. ORDER BY cmr.addTime DESC
  417. limit 1
  418. </select>
  419. <select id="getMarketReportIds" resultType="java.lang.Integer">
  420. select id from cm_market_report
  421. where delFlag = 0
  422. <if test="type == 1">
  423. and id = #{marketReportId}
  424. </if>
  425. <if test="type != 1">
  426. and marketId = #{marketId}
  427. and visible = 1
  428. </if>
  429. <if test="startTime != null and startTime != ''">
  430. and reportDate <![CDATA[ >= ]]> #{startTime}
  431. </if>
  432. <if test="endTime != null and endTime != ''">
  433. and reportDate <![CDATA[ <= ]]> #{endTime}
  434. </if>
  435. <if test="marketReportId == null">
  436. <if test="startTime == null or startTime == '' ">
  437. <if test="endTime == null or endTime == ''">
  438. order by addTime desc
  439. limit 1
  440. </if>
  441. </if>
  442. </if>
  443. </select>
  444. <select id="getMarketStage" resultType="com.caimei365.user.model.vo.StageVo">
  445. SELECT cms.id,
  446. cms.stage,
  447. cms.theme,
  448. cms.addTime,
  449. cmr.reportDate
  450. FROM cm_market_stage cms
  451. LEFT JOIN cm_market_report cmr ON cmr.id = cms.marketReportId
  452. where cms.marketReportId in
  453. <foreach collection="marketReportIds" item="marketReportId" open="(" separator="," close=")">
  454. #{marketReportId}
  455. </foreach>
  456. </select>
  457. <select id="getMarketFunnelModel" resultType="com.caimei365.user.model.vo.FunnelModelVo">
  458. SELECT id,
  459. impressions,
  460. hits,
  461. visits,
  462. consultation,
  463. report
  464. FROM cm_market_funnelModel
  465. WHERE marketReportId in
  466. <foreach collection="marketReportIds" item="marketReportId" open="(" separator="," close=")">
  467. #{marketReportId}
  468. </foreach>
  469. </select>
  470. <select id="getMarketArticleReadVolume" resultType="com.caimei365.user.model.vo.ArticleReadVolumeVo">
  471. SELECT id,
  472. firstTime,
  473. title,
  474. link,
  475. titleReferred,
  476. type,
  477. keyword,
  478. channel,
  479. touchNumber,
  480. wechatNumber
  481. FROM cm_market_articleReadVolume
  482. WHERE marketReportId in
  483. <foreach collection="marketReportIds" item="marketReportId" open="(" separator="," close=")">
  484. #{marketReportId}
  485. </foreach>
  486. </select>
  487. <select id="getMarketImpressions" resultType="com.caimei365.user.model.vo.ImpressionsVo">
  488. SELECT id,
  489. generalNumber,
  490. microBlog,
  491. redBookNumber,
  492. otherNumber
  493. FROM cm_market_impressions
  494. WHERE marketReportId in
  495. <foreach collection="marketReportIds" item="marketReportId" open="(" separator="," close=")">
  496. #{marketReportId}
  497. </foreach>
  498. </select>
  499. <select id="getMarketReadVolume" resultType="com.caimei365.user.model.vo.ReadVolumeVo">
  500. SELECT id,
  501. generalNumber,
  502. microBlog,
  503. redBookNumber,
  504. otherNumber
  505. FROM cm_market_readVolume
  506. WHERE marketReportId in
  507. <foreach collection="marketReportIds" item="marketReportId" open="(" separator="," close=")">
  508. #{marketReportId}
  509. </foreach>
  510. </select>
  511. <select id="getMarketSummary" resultType="com.caimei365.user.model.vo.SummaryVo">
  512. SELECT id,
  513. keyword,
  514. seoRanking,
  515. searchVolume
  516. FROM cm_market_summary
  517. WHERE marketReportId in
  518. <foreach collection="marketReportIds" item="marketReportId" open="(" separator="," close=")">
  519. #{marketReportId}
  520. </foreach>
  521. </select>
  522. <select id="getMarketVisits" resultType="com.caimei365.user.model.vo.VisitsVo">
  523. SELECT id,
  524. clubNumber,
  525. touristNumber
  526. FROM cm_market_visits
  527. WHERE marketReportId in
  528. <foreach collection="marketReportIds" item="marketReportId" open="(" separator="," close=")">
  529. #{marketReportId}
  530. </foreach>
  531. </select>
  532. <select id="getMarketProportion" resultType="com.caimei365.user.model.vo.ProportionVo">
  533. SELECT id,
  534. search,
  535. general,
  536. microBlog,
  537. directAccess
  538. FROM cm_market_proportion
  539. WHERE marketReportId in
  540. <foreach collection="marketReportIds" item="marketReportId" open="(" separator="," close=")">
  541. #{marketReportId}
  542. </foreach>
  543. </select>
  544. <select id="getMarketPageDuration" resultType="com.caimei365.user.model.vo.PageDurationVo">
  545. SELECT id,
  546. pageLabel,
  547. accessDuration
  548. FROM cm_market_pageDuration
  549. WHERE marketReportId in
  550. <foreach collection="marketReportIds" item="marketReportId" open="(" separator="," close=")">
  551. #{marketReportId}
  552. </foreach>
  553. </select>
  554. <select id="getMarketAdvertHits" resultType="com.caimei365.user.model.vo.AdvertHitsVo">
  555. SELECT id,
  556. POSITION,
  557. home,
  558. infoCenter,
  559. hits
  560. FROM cm_market_advertHits
  561. WHERE marketReportId in
  562. <foreach collection="marketReportIds" item="marketReportId" open="(" separator="," close=")">
  563. #{marketReportId}
  564. </foreach>
  565. </select>
  566. <select id="getMarketRemark" resultType="com.caimei365.user.model.vo.CmMarketRemarkVo">
  567. SELECT id,
  568. remarkNumber,
  569. addTime
  570. FROM cm_market_remark
  571. WHERE marketReportId in
  572. <foreach collection="marketReportIds" item="marketReportId" open="(" separator="," close=")">
  573. #{marketReportId}
  574. </foreach>
  575. </select>
  576. <select id="getShopKeyword" resultType="java.lang.String">
  577. SELECT cusf.keyword
  578. FROM cm_user_search_frequency cusf
  579. LEFT JOIN cm_shop_label csl ON csl.keywordId = cusf.id
  580. LEFT JOIN cm_shop_relevance csr ON csr.id = csl.relevanceId
  581. where csr.shopId = #{shopId}
  582. </select>
  583. <select id="getRegion" resultType="java.lang.String">
  584. SELECT region FROM cm_behavior_record_index
  585. where
  586. (
  587. <foreach collection="labels" item="label" open="(" separator="or" close=")">
  588. label LIKE concat('%', #{label}, '%')
  589. </foreach>
  590. )
  591. <if test="startTime != null and startTime != ''">
  592. and accessDate <![CDATA[ >= ]]> #{startTime}
  593. </if>
  594. <if test="startTime != null and startTime != ''">
  595. AND accessDate <![CDATA[ <= ]]> #{endTime}
  596. </if>
  597. </select>
  598. <!--用户身份-->
  599. <select id="getUserIdentity" resultType="com.caimei365.user.model.vo.ReturnEntityVo">
  600. SELECT
  601. (CASE c.linkManIdentity
  602. WHEN 1 THEN '老板'
  603. WHEN 2 THEN '采购'
  604. WHEN 3 THEN '运营'
  605. WHEN 4 THEN '运营'
  606. END) AS name,
  607. COUNT(c.userId) as value
  608. FROM cm_behavior_record_index cbri
  609. LEFT JOIN club c ON c.userId = cbri.userId
  610. LEFT JOIN USER u ON u.userId = cbri.userId
  611. WHERE
  612. cbri.userId != 0
  613. AND u.userIdentity = 2
  614. <if test="startTime != null and startTime != ''">
  615. and cbri.accessDate <![CDATA[ >= ]]> #{startTime}
  616. </if>
  617. <if test="startTime != null and startTime != ''">
  618. AND cbri.accessDate <![CDATA[ <= ]]> #{endTime}
  619. </if>
  620. AND (
  621. <foreach collection="labels" item="label" open="(" separator="or" close=")">
  622. cbri.label LIKE concat('%', #{label}, '%')
  623. </foreach>
  624. )
  625. GROUP BY c.linkManIdentity
  626. </select>
  627. <!--机构类型-->
  628. <select id="getClubType" resultType="com.caimei365.user.model.vo.ReturnEntityVo">
  629. SELECT
  630. (CASE c.firstClubType
  631. WHEN 1 THEN '医美'
  632. WHEN 2 THEN '生美'
  633. WHEN 3 THEN '其他'
  634. WHEN 4 THEN '其他'
  635. WHEN 5 THEN '其他'
  636. END) AS name,
  637. COUNT(c.userId) as value
  638. FROM cm_behavior_record_index cbri
  639. LEFT JOIN club c ON c.userId = cbri.userId
  640. LEFT JOIN USER u ON u.userId = cbri.userId
  641. WHERE
  642. cbri.userId != 0
  643. AND u.userIdentity = 2
  644. <if test="startTime != null and startTime != ''">
  645. and cbri.accessDate <![CDATA[ >= ]]> #{startTime}
  646. </if>
  647. <if test="startTime != null and startTime != ''">
  648. AND cbri.accessDate <![CDATA[ <= ]]> #{endTime}
  649. </if>
  650. AND (
  651. <foreach collection="labels" item="label" open="(" separator="or" close=")">
  652. cbri.label LIKE concat('%', #{label}, '%')
  653. </foreach>
  654. )
  655. GROUP BY c.firstClubType
  656. </select>
  657. <select id="getMarketReportDataList" resultType="java.lang.String">
  658. select cmr.reportDate
  659. from cm_market_report cmr
  660. left join cm_shop_statistics css on css.id = cmr.marketId
  661. where cmr.delFlag = 0 and cmr.visible = 1 and css.shopId = #{shopId}
  662. </select>
  663. </mapper>