CustomerServiceDao.xml 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405
  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.manager.dao.user.CustomerServiceDao">
  4. <select id="getCustomerShopList" resultType="com.caimei365.manager.entity.caimei.cmUser.CmShopStatistics">
  5. SELECT
  6. DISTINCT css.id as id,
  7. css.shopID AS shopId,
  8. s.name as shopName,
  9. s.linkMan,
  10. s.contractMobile AS mobile,
  11. s.status AS shopStatus,
  12. css.status,
  13. css.addTime
  14. FROM cm_shop_statistics css
  15. LEFT JOIN shop s ON css.shopId = s.shopId
  16. <where>
  17. css.delFlag = 0
  18. <if test="shopName != null and shopName != ''">
  19. and s.name like concat('%',#{shopName},'%')
  20. </if>
  21. <if test="status != null">
  22. and css.status = #{status}
  23. </if>
  24. </where>
  25. order by css.addTime desc, s.addTime desc
  26. </select>
  27. <select id="getCustomerShopId" resultType="java.lang.Integer">
  28. SELECT shopId FROM cm_shop_statistics where delFlag = 0
  29. </select>
  30. <select id="getShopList" resultType="com.caimei365.manager.entity.caimei.CmShop">
  31. select * from shop
  32. where status = 90 and shopType = 1
  33. <if test="shopName != null and shopName != ''">
  34. and name like concat('%',#{shopName},'%')
  35. </if>
  36. <if test="shopId != null">
  37. and shopId = #{shopId}
  38. </if>
  39. order by addTime desc
  40. </select>
  41. <insert id="insertCustomerShop">
  42. insert into cm_shop_statistics (shopId, status, addTime, delFlag)
  43. values (#{shopId}, #{status}, now(), #{delFlag})
  44. </insert>
  45. <update id="updateCustomerShop">
  46. update cm_shop_statistics
  47. set status = #{status}
  48. where id = #{id}
  49. </update>
  50. <select id="getCmInformationList" resultType="com.caimei365.manager.entity.caimei.cmUser.CmRoosInformation">
  51. SELECT cri.id,
  52. cri.IP,
  53. cri.shopId,
  54. cri.followUpStatus,
  55. cri.consultName,
  56. cri.consultMobile,
  57. cri.isClick,
  58. cri.serviceProviderId,
  59. (select linkMan from serviceprovider where serviceProviderID = cri.serviceProviderId) as name,
  60. cri.createTime
  61. FROM cm_roos_information cri
  62. <where>
  63. shopId = #{shopId}
  64. AND consultName IS NOT NULL
  65. AND consultMobile IS NOT NULL
  66. <if test="consultName != null and consultName != ''">
  67. and consultName like concat('%',#{consultName},'%')
  68. </if>
  69. <if test="consultMobile != null and consultMobile != ''">
  70. and consultMobile like concat('%',#{consultMobile},'%')
  71. </if>
  72. <if test="followUpStatus != null">
  73. and followUpStatus = #{followUpStatus}
  74. </if>
  75. </where>
  76. order by createTime desc
  77. </select>
  78. <select id="updateInformation">
  79. update cm_roos_information
  80. set followUpStatus = #{followUpStatus}
  81. <if test="serviceProviderId != null">
  82. , serviceProviderId = #{serviceProviderId}
  83. </if>
  84. where id = #{id}
  85. </select>
  86. <insert id="insertInformationNote" keyProperty="id" useGeneratedKeys="true" keyColumn="id">
  87. insert into cm_information_notes(informationId, note, noteUser, addTime)
  88. values (#{informationId}, #{note}, #{noteUser}, now())
  89. </insert>
  90. <insert id="insertInformationNoteImage">
  91. insert into cm_information_notes_image(informationNoteId, image)
  92. values (#{informationNoteId}, #{image})
  93. </insert>
  94. <select id="getInformationNotes" resultType="com.caimei365.manager.entity.caimei.cmUser.CmInformationNotes">
  95. select
  96. id,
  97. informationId,
  98. note,
  99. noteUser,
  100. addTime
  101. from cm_information_notes
  102. where informationId = #{informationId}
  103. order by addTime desc
  104. </select>
  105. <select id="getinformationNotesImage" resultType="java.lang.String">
  106. select image from cm_information_notes_image where informationNoteId = #{informationNoteId};
  107. </select>
  108. <select id="getShopInfoList" resultType="com.caimei365.manager.entity.caimei.cmUser.CmShopInfo">
  109. SELECT
  110. csi.id,
  111. csi.infoId,
  112. i.guidanceImage,
  113. i.title,
  114. i.pubdate,
  115. csi.status,
  116. csi.addTime
  117. FROM cm_shop_info csi
  118. LEFT JOIN info i ON i.id = csi.infoId
  119. <where>
  120. csi.shopId = #{shopId} and csi.delFlag = 0 and i.delFlag = 0
  121. <if test="infoId != null">
  122. and csi.infoId = #{infoId}
  123. </if>
  124. <if test="title != null and title != ''">
  125. and i.title like concat('%',#{title},'%')
  126. </if>
  127. <if test="status != null">
  128. and csi.status = #{status}
  129. </if>
  130. </where>
  131. order by csi.addTime desc, i.pubdate desc
  132. </select>
  133. <select id="getShopInfoId" resultType="java.lang.Integer">
  134. select infoId from cm_shop_info where delFlag = 0
  135. </select>
  136. <select id="getInfoList" resultType="com.caimei365.manager.entity.caimei.cmUser.Info">
  137. select * from info
  138. where delFlag = 0 and onlineStatus = 2
  139. <if test="id != null">
  140. and id = #{id}
  141. </if>
  142. <if test="title != null and title != ''">
  143. and title like concat('%',#{title},'%')
  144. </if>
  145. order by pubdate desc
  146. </select>
  147. <insert id="insertShopInfo">
  148. insert into cm_shop_info (shopId, infoId, status, addTime, delFlag)
  149. values (#{shopId}, #{infoId}, #{status}, now(), #{delFlag})
  150. </insert>
  151. <update id="updateShopInfoStatus">
  152. update cm_shop_info
  153. set status = #{status}
  154. where id = #{id}
  155. </update>
  156. <update id="delShopInfo">
  157. update cm_shop_info
  158. set delFlag = 1
  159. where id = #{id}
  160. </update>
  161. <select id="getShopKeyword" resultType="com.caimei365.manager.entity.caimei.cmUser.CmShopKeyword">
  162. SELECT
  163. csk.id,
  164. csk.shopId,
  165. cusf.keyword,
  166. cusf.frequency as number,
  167. cusf.searchTime,
  168. csk.status,
  169. csk.addTime
  170. FROM cm_shop_keyword csk
  171. LEFT JOIN cm_user_search_frequency cusf ON cusf.id = csk.searchId
  172. <where>
  173. csk.shopId = #{shopId}
  174. and csk.delFlag = 0 and cusf.delStatus = 1
  175. <if test="keyword != null and keyword != ''">
  176. and cusf.keyword like concat('%',#{keyword},'%')
  177. </if>
  178. <if test="status != null">
  179. and csk.status = #{status}
  180. </if>
  181. </where>
  182. order by csk.addTime desc, (SELECT COUNT(recordID) FROM cm_behavior_record WHERE pageType = 8 AND pageLabel = cusf.keyword) desc
  183. </select>
  184. <select id="getShopKeywordId" resultType="java.lang.Integer">
  185. select searchId from cm_shop_keyword where delFlag = 0
  186. </select>
  187. <select id="getSearchFrequencyList" resultType="com.caimei365.manager.entity.caimei.cmUser.CmUserSearchFrequency">
  188. select * from cm_user_search_frequency
  189. where delStatus = 1 and trueStatus = 1
  190. <if test="keyword != null and keyword != ''">
  191. and keyword like concat('%',#{keyword},'%')
  192. </if>
  193. order by searchTime desc
  194. </select>
  195. <insert id="insertShopKeyword">
  196. insert into cm_shop_keyword (shopId, searchId, status, addTime, delFlag)
  197. values (#{shopId}, #{searchId}, #{status}, now(), #{delFlag})
  198. </insert>
  199. <update id="updateShopKeywordStatus">
  200. update cm_shop_keyword
  201. set status = #{status}
  202. where id = #{id}
  203. </update>
  204. <update id="delShopKeyword">
  205. update cm_shop_keyword
  206. set delFlag = 1
  207. where id = #{id}
  208. </update>
  209. <select id="getShopPopUp" resultType="com.caimei365.manager.entity.caimei.cmUser.CmShopPopUp">
  210. select
  211. id,
  212. shopId,
  213. image,
  214. guidingOne,
  215. guidingTwo,
  216. addTime
  217. from cm_shop_popUp
  218. where shopId = #{shopId}
  219. </select>
  220. <insert id="insertShopPopUp">
  221. insert into cm_shop_popUp(shopId, image, guidingOne, guidingTwo, addTime)
  222. values (#{shopId}, #{image}, #{guidingOne}, #{guidingTwo}, now())
  223. </insert>
  224. <update id="updateShopPopUp">
  225. update cm_shop_popUp
  226. set image = #{image},
  227. guidingOne = #{guidingOne},
  228. guidingTwo = #{guidingTwo}
  229. where id = #{id}
  230. </update>
  231. <select id="getShopAdvertisingImage" resultType="com.caimei365.manager.entity.caimei.cmUser.CmShopAdvertisingImage">
  232. select
  233. csa.id,
  234. csa.shopId,
  235. s.name as shopName,
  236. csa.pcImage,
  237. csa.appImage,
  238. csa.jumpLink,
  239. csa.sort,
  240. csa.addTime,
  241. csa.status,
  242. csa.delFlag
  243. ,IFNULL((select sum(c.pv) from cm_praise_statistics c where c.delFlag = 0 and c.type = 5 and csa.id = c.authorId <if test="startPvCreateTime != null ">AND c.createTime >= #{startPvCreateTime} </if><if test="endPvCreateTime != null ">AND c.createTime <![CDATA[ <= ]]> #{endPvCreateTime} </if>), 0) as pv
  244. from cm_shop_advertisingImage csa
  245. left join shop s on s.shopId = csa.shopId
  246. <where>
  247. csa.delFlag = 0
  248. <if test="shopName != null and shopName != ''">
  249. and s.name like concat('%',#{shopName},'%')
  250. </if>
  251. <if test="status != null">
  252. and csa.status = #{status}
  253. </if>
  254. </where>
  255. order by csa.sort asc, csa.addTime desc
  256. </select>
  257. <select id="getShopAdvertisingImageById" resultType="com.caimei365.manager.entity.caimei.cmUser.CmShopAdvertisingImage">
  258. select id, shopId, pcImage, appImage, jumpLink, sort, addTime, status, delFlag
  259. from cm_shop_advertisingImage
  260. where id = #{id}
  261. </select>
  262. <insert id="insertShopAdvertisingImage">
  263. insert into cm_shop_advertisingImage (shopId, pcImage, appImage, jumpLink, sort, addTime, status, delFlag)
  264. values (#{shopId}, #{pcImage}, #{appImage}, #{jumpLink}, #{sort}, now(), #{status}, #{delFlag})
  265. </insert>
  266. <update id="updateShopAdvertisingImage">
  267. update cm_shop_advertisingImage
  268. set shopId = #{shopId},
  269. pcImage = #{pcImage},
  270. appImage = #{appImage},
  271. jumpLink = #{jumpLink},
  272. status = #{status}
  273. where id = #{id}
  274. </update>
  275. <update id="updateShopAdvertisingImageSort">
  276. update cm_shop_advertisingImage
  277. set sort = #{sort}
  278. where id = #{id}
  279. </update>
  280. <update id="updateShopAdvertisingImageStatus">
  281. update cm_shop_advertisingImage
  282. set status = #{status}
  283. where id = #{id}
  284. </update>
  285. <update id="delShopAdvertisingImage">
  286. update cm_shop_advertisingImage
  287. set delFlag = 1
  288. where id = #{id}
  289. </update>
  290. <select id="getPageShop" resultType="com.caimei365.manager.entity.caimei.cmUser.CmPageShop">
  291. SELECT
  292. cps.id,
  293. cps.shopId,
  294. s.name AS shopName,
  295. cps.shopLink,
  296. IFNULL(SUM(cps.accessNumber), 0) AS accessNumber,
  297. IFNULL(SUM(cps.accessDuration), 0) AS accessDuration,
  298. IFNULL((IFNULL(SUM(cps.accessDuration), 0) / IFNULL(SUM(cps.accessNumber), 0)), 0) AS averageDuration
  299. FROM cm_page_shop cps
  300. LEFT JOIN shop s ON s.shopId = cps.shopId
  301. <where>
  302. cps.shopId = #{shopId}
  303. <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
  304. and cps.accessDate BETWEEN #{startTime} and #{endTime}
  305. </if>
  306. </where>
  307. group by cps.shopId
  308. </select>
  309. <select id="getPageShopProduct" resultType="com.caimei365.manager.entity.caimei.cmUser.CmPageShopProduct">
  310. SELECT
  311. cpsp.id,
  312. cpsp.shopId,
  313. cpsp.productId,
  314. p.name as productName,
  315. p.mainImage,
  316. copi.validFlag,
  317. cpsp.link,
  318. IFNULL(SUM(cpsp.accessNumber), 0) AS accessNumber,
  319. IFNULL(SUM(cpsp.accessDuration), 0) AS accessDuration,
  320. IFNULL((IFNULL(SUM(cpsp.accessDuration), 0) / IFNULL(SUM(cpsp.accessNumber), 0)), 0) AS averageDuration
  321. FROM cm_page_shop_product cpsp
  322. LEFT JOIN product p ON p.productId = cpsp.productId
  323. LEFT JOIN cm_organize_product_info copi ON copi.productId = cpsp.productId
  324. WHERE cpsp.shopId = #{shopId} and copi.organizeId = 0
  325. <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
  326. and cpsp.accessDate BETWEEN #{startTime} and #{endTime}
  327. </if>
  328. group by cpsp.productId
  329. </select>
  330. <select id="getPageShopInfo" resultType="com.caimei365.manager.entity.caimei.cmUser.CmPageShopInfo">
  331. SELECT
  332. cpsi.id,
  333. cpsi.shopId,
  334. cpsi.infoId,
  335. i.guidanceImage,
  336. i.title,
  337. i.onlineStatus,
  338. cpsi.link,
  339. IFNULL(SUM(cpsi.accessNumber), 0) AS accessNumber,
  340. IFNULL(SUM(cpsi.accessDuration), 0) AS accessDuration,
  341. IFNULL((IFNULL(SUM(cpsi.accessDuration), 0) / IFNULL(SUM(cpsi.accessNumber), 0)), 0) AS averageDuration
  342. FROM cm_page_shop_info cpsi
  343. LEFT JOIN info i ON i.id = cpsi.infoId
  344. WHERE cpsi.shopId = #{shopId}
  345. <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
  346. and cpsi.accessDate BETWEEN #{startTime} and #{endTime}
  347. </if>
  348. group by cpsi.infoId
  349. </select>
  350. <select id="getPageShopKeyword" resultType="com.caimei365.manager.entity.caimei.cmUser.CmPageShopKeyword">
  351. SELECT
  352. cpsk.id,
  353. cpsk.shopId,
  354. cusf.keyword,
  355. cpsk.link,
  356. IFNULL(SUM(cpsk.accessNumber), 0) AS accessNumber,
  357. IFNULL(SUM(cpsk.accessDuration), 0) AS accessDuration,
  358. IFNULL((IFNULL(SUM(cpsk.accessDuration), 0) / IFNULL(SUM(cpsk.accessNumber), 0)), 0) AS averageDuration
  359. FROM cm_page_shop_keyword cpsk
  360. LEFT JOIN cm_user_search_frequency cusf ON cusf.id = cpsk.searchId
  361. WHERE cpsk.shopId = #{shopId}
  362. <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
  363. and cpsk.accessDate BETWEEN #{startTime} and #{endTime}
  364. </if>
  365. group by cpsk.searchId
  366. </select>
  367. </mapper>