ClubReport.xml 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409
  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.ClubReportMapper">
  4. <insert id="addClubReport">
  5. INSERT INTO cm_club_report (serviceProviderID, clubID, productID, reportName, reportText, addTime)
  6. VALUES (#{serviceProviderId}, #{clubId}, #{productId}, #{reportName}, #{reportText}, now())
  7. </insert>
  8. <insert id="addVisitorReport">
  9. INSERT INTO cm_club_report (serviceProviderID, questionManId, productID, reportName, reportText, addTime)
  10. VALUES (#{serviceProviderId}, #{questionManId}, #{productId}, #{reportName}, #{reportText}, now())
  11. </insert>
  12. <select id="productList" resultType="com.caimei365.user.model.vo.ProductItemVo">
  13. SELECT DISTINCT p.productID as productId,p.mainImage as image,p.name,
  14. (select price from cm_sku where productId=p.productId order by price asc limit 1)as price,s.name as shopName
  15. FROM product p
  16. LEFT JOIN shop s ON s.shopID = p.shopID
  17. LEFT JOIN cm_club_report cmc ON cmc.productID = p.productID
  18. <where>
  19. (p.validFlag=9 or p.validFlag=2)
  20. <if test="keyWord != null and keyWord !=''">
  21. and p.name LIKE concat('%',#{keyWord},'%')
  22. </if>
  23. </where>
  24. ORDER BY p.productId DESC
  25. </select>
  26. <select id="reportList" resultType="com.caimei365.user.model.vo.ReportVo">
  27. SELECT DISTINCT
  28. cmc.Id as reportId,cmc.clubID as clubId,cmc.status as status,cmc.productID as productId,c.`name` as
  29. clubName,cmc.`addTime`,p.`name` as productName,p.`mainImage` as mainImage,cmc.`reportText` as
  30. reportText,cmc.`auditText` as auditText
  31. FROM cm_club_report cmc
  32. LEFT JOIN cm_club_remarks ccr ON ccr.clubID = cmc.clubID
  33. LEFT JOIN club c ON c.clubID = cmc.clubID
  34. LEFT JOIN product p ON cmc.productID = p.productID
  35. <where>
  36. and (cmc.`serviceProviderId`=#{serviceProviderId} and cmc.`clubID`=#{clubId} and cmc.clubID is not null)
  37. <if test="keyWord != null and keyWord !=''">
  38. AND (p.name LIKE concat('%',#{keyWord},'%')
  39. or cmc.reportText LIKE CONCAT('%', #{keyWord}, '%'))
  40. </if>
  41. </where>
  42. ORDER BY cmc.`addTime` DESC
  43. </select>
  44. <select id="reportDetailsList" resultType="com.caimei365.user.model.vo.ReportVo">
  45. SELECT DISTINCT
  46. cmc.Id as reportId,
  47. cmc.clubID as clubId,
  48. cmc.status as status,
  49. p.productID as productId,
  50. c.name AS clubName,
  51. ccr.questionMan as questionMan,
  52. c.linkMan,
  53. cmc.`reportName`,
  54. cmc.`addTime`,
  55. p.`name` as productName,
  56. p.`mainImage`,
  57. cmc.`reportText`,
  58. s.name as shopName,
  59. cmc.`auditText` as auditText
  60. FROM cm_club_report cmc
  61. LEFT JOIN club c ON c.clubID = cmc.clubID
  62. LEFT JOIN cm_club_remarks ccr ON cmc.Id = ccr.reportId
  63. LEFT JOIN product p ON p.productID = cmc.productID
  64. LEFT JOIN shop s ON s.shopID = p.shopID
  65. WHERE cmc.id = #{reportId}
  66. and cmc.clubID is not null
  67. ORDER BY cmc.`addTime` DESC
  68. </select>
  69. <select id="visitorReportsList" resultType="com.caimei365.user.model.vo.ReportVo">
  70. SELECT DISTINCT
  71. cmc.Id as reportId,
  72. cmc.clubID as clubId,
  73. cmc.status as status,
  74. p.productID as productId,
  75. ccr.questionMan as questionMan,
  76. cmc.`reportName`,
  77. cmc.`addTime`,
  78. p.`name` as productName,
  79. p.`mainImage`,
  80. cmc.`reportText`,
  81. s.name as shopName,
  82. cmc.`auditText` as auditText
  83. FROM cm_club_report cmc
  84. LEFT JOIN cm_visitor_remarks ccr ON cmc.Id = ccr.reportId
  85. LEFT JOIN product p ON p.productID = cmc.productID
  86. LEFT JOIN shop s ON s.shopID = p.shopID
  87. WHERE cmc.id = #{reportId}
  88. and cmc.clubID is null
  89. ORDER BY cmc.`addTime` DESC
  90. </select>
  91. <select id="reportRemarks" resultType="com.caimei365.user.model.vo.ReportVo">
  92. SELECT DISTINCT
  93. cmc.id AS reportId ,cmc.productID AS productId,ccr.serviceProviderID AS serviceProviderId, c.name AS clubName,c.`newDeal` AS newDeal,cmc.reportName AS
  94. reportName,cmc.`addTime` AS ADDTIME,p.`mainImage` AS mainImage,p.name AS productName,cmc.`reportText` AS
  95. reportText,cmc.status AS STATUS,cmc.`auditText` AS auditText,ccr.questionMan AS questionMan
  96. FROM cm_club_report cmc
  97. LEFT JOIN club c ON c.clubId=cmc.clubId
  98. LEFT JOIN cm_club_remarks ccr ON cmc.Id = ccr.reportId
  99. LEFT JOIN serviceprovider s ON ccr.serviceProviderId = s.serviceProviderID
  100. LEFT JOIN cm_serviceTeam_group csg ON ccr.serviceProviderId = csg.serviceId
  101. LEFT JOIN cm_serviceTeam_role csr ON csr.id = csg.teamId
  102. LEFT JOIN product p ON p.productID = cmc.productID
  103. <where>
  104. and cmc.clubID is not null
  105. <if test="keyWord != null and keyWord !=''">
  106. AND (p.name LIKE concat('%',#{keyWord},'%')
  107. or cmc.reportText LIKE CONCAT('%', #{keyWord}, '%'))
  108. </if>
  109. <if test="teamId!=null">
  110. and csg.teamId = #{teamId}
  111. </if>
  112. <if test="serviceProviderId!=null">
  113. and cmc.serviceProviderId=#{serviceProviderId}
  114. </if>
  115. </where>
  116. ORDER BY cmc.`addTime` DESC
  117. </select>
  118. <select id="repotRemark" resultType="com.caimei365.user.model.vo.ReportVo">
  119. SELECT DISTINCT
  120. cmc.id AS reportId ,cmc.productID AS productId,ccr.serviceProviderID AS serviceProviderId, c.name AS clubName,c.`newDeal` AS newDeal,cmc.reportName AS
  121. reportName,cmc.`addTime` AS ADDTIME,p.`mainImage` AS mainImage,p.name AS productName,cmc.`reportText` AS
  122. reportText,cmc.status AS STATUS,cmc.`auditText` AS auditText,ccr.questionMan AS questionMan
  123. FROM cm_club_report cmc
  124. LEFT JOIN club c ON c.clubId=cmc.clubId
  125. LEFT JOIN cm_club_remarks ccr ON cmc.Id = ccr.reportId
  126. LEFT JOIN serviceprovider s ON ccr.serviceProviderId = s.serviceProviderID
  127. LEFT JOIN cm_serviceTeam_group csg ON ccr.serviceProviderId = csg.serviceId
  128. LEFT JOIN cm_serviceTeam_role csr ON csr.id = csg.teamId
  129. LEFT JOIN product p ON p.productID = cmc.productID
  130. where
  131. cmc.clubID is not null
  132. ORDER BY cmc.`addTime` DESC
  133. </select>
  134. <select id="visitorReportRemarks" resultType="com.caimei365.user.model.vo.ReportVo">
  135. SELECT DISTINCT
  136. cmc.id AS reportId , cmc.productID as productId,cmc.serviceProviderID as serviceProviderId,cmc.questionManId AS questionManId, c.name AS clubName,c.`newDeal` AS
  137. newDeal,cmc.reportName AS reportName,cmc.`addTime` AS ADDTIME,p.`mainImage` AS mainImage,p.name AS
  138. productName,cmc.`reportText` as reportText,cmc.status AS status,cmc.`auditText` as auditText
  139. FROM cm_club_report cmc
  140. LEFT JOIN club c ON c.clubId=cmc.clubId
  141. LEFT JOIN cm_visitor_remarks ccr ON cmc.Id = ccr.reportId
  142. LEFT JOIN serviceprovider s ON ccr.serviceProviderId = s.serviceProviderID
  143. LEFT JOIN cm_serviceTeam_group csg ON ccr.serviceProviderId = csg.serviceId
  144. LEFT JOIN cm_serviceTeam_role csr ON csr.id = csg.teamId
  145. LEFT JOIN product p ON p.productID = cmc.productID
  146. <where>
  147. and cmc.clubID is null
  148. # and reportID is not null
  149. <if test="keyWord != null and keyWord != ''">
  150. AND p.name LIKE concat('%',#{keyWord},'%')
  151. or cmc.reportText LIKE CONCAT('%', #{keyWord}, '%')
  152. </if>
  153. <if test="teamId!=null">
  154. and csg.teamId = #{teamId}
  155. </if>
  156. <if test="teamId==null and serviceProviderId!=null">
  157. and cmc.serviceProviderId=#{serviceProviderId}
  158. </if>
  159. </where>
  160. ORDER BY cmc.`addTime` DESC
  161. </select>
  162. <select id="visitoReportRemark" resultType="com.caimei365.user.model.vo.ReportVo">
  163. SELECT DISTINCT
  164. cmc.id AS reportId , cmc.productID as productId,cmc.serviceProviderID as serviceProviderId,cmc.questionManId AS questionManId, c.name AS clubName,c.`newDeal` AS
  165. newDeal,cmc.reportName AS reportName,cmc.`addTime` AS ADDTIME,p.`mainImage` AS mainImage,p.name AS
  166. productName,cmc.`reportText` as reportText,cmc.status AS status,cmc.`auditText` as auditText
  167. FROM cm_club_report cmc
  168. LEFT JOIN club c ON c.clubId=cmc.clubId
  169. LEFT JOIN cm_visitor_remarks ccr ON cmc.Id = ccr.reportId
  170. LEFT JOIN serviceprovider s ON ccr.serviceProviderId = s.serviceProviderID
  171. LEFT JOIN cm_serviceTeam_group csg ON ccr.serviceProviderId = csg.serviceId
  172. LEFT JOIN cm_serviceTeam_role csr ON csr.id = csg.teamId
  173. LEFT JOIN product p ON p.productID = cmc.productID
  174. where
  175. cmc.clubID is null
  176. ORDER BY cmc.`addTime` DESC
  177. </select>
  178. <select id="reportLeaderId" resultType="java.lang.Integer">
  179. SELECT DISTINCT id
  180. FROM cm_serviceteam_role csr
  181. LEFT JOIN serviceprovider s ON s.serviceProviderId = csr.leaderId
  182. WHERE s.serviceProviderID = #{serviceProviderId}
  183. </select>
  184. <select id="roeprtNa" resultType="java.lang.String">
  185. SELECT DISTINCT linkMan
  186. FROM serviceprovider
  187. WHERE serviceProviderID = #{serviceProviderId}
  188. LIMIT 1
  189. </select>
  190. <select id="visitorMan" resultType="java.lang.Integer">
  191. SELECT DISTINCT serviceProviderId
  192. FROM cm_visitor_remarks
  193. WHERE questionManId = #{questionManId}
  194. LIMIT 1
  195. </select>
  196. <select id="associated" resultType="com.caimei365.user.model.vo.RemarksVo">
  197. SELECT DISTINCT
  198. ccr.id AS remarksId, ccr.remarks,ccr.addTime,ccr.serviceProviderId AS serviceProviderId,
  199. csr.leaderId AS leaderId,IFNULL(ccr.consultType,'') AS consult, c.Name AS clubName,
  200. ccr.clubType AS clubType,ccr.pinceSensitve AS pinceSensitve,ccr.satisfied AS satisfied,ccr.followup AS
  201. followup,ccr.extra AS extra,
  202. (SELECT NAME FROM serviceprovider s WHERE s.serviceProviderID= csr.leaderId) AS leaderName,
  203. (SELECT linkMan FROM serviceprovider s WHERE s.serviceProviderID = ccr.serviceProviderID) AS
  204. recordName,c.newDeal AS newDeal,cmc.status AS status,cmc.`auditText` as auditText
  205. # (SELECT linkMan FROM serviceprovider s WHERE s.serviceProviderID = ccr.oldserviceProviderId) AS oldName
  206. FROM cm_club_remarks ccr
  207. LEFT JOIN serviceprovider s ON ccr.serviceProviderId = s.serviceProviderID
  208. LEFT JOIN club c ON c.clubId=ccr.clubId
  209. LEFT JOIN cm_serviceTeam_group csg ON ccr.serviceProviderId = csg.serviceId
  210. LEFT JOIN cm_serviceTeam_role csr ON csr.id = csg.teamId
  211. LEFT JOIN cm_club_report cmc ON cmc.Id = ccr.reportID
  212. <where>
  213. and cmc.id=#{reportId}
  214. and cmc.clubID is not null
  215. <if test="teamId!=null">
  216. and csg.teamId = #{teamId}
  217. </if>
  218. <if test="teamId==null and serviceProviderId!=null">
  219. and cmc.serviceProviderId=#{serviceProviderId}
  220. </if>
  221. and reportID is not null
  222. <if test="keyWord != null and keyWord !=''">
  223. and cmc.reportText LIKE CONCAT('%', #{keyWord}, '%')
  224. </if>
  225. <if test="leaderId != null and leaderId>0">
  226. and csr.leaderId = #{leaderId}
  227. </if>
  228. <if test="groupId != null and groupId>0">
  229. and ccr.serviceProviderId = #{groupId}
  230. </if>
  231. <if test="startAddTime !='' and startAddTime !=null">
  232. and ccr.addTime <![CDATA[ > ]]> #{startAddTime}
  233. </if>
  234. <if test="endAddTime != '' and endAddTime!=null">
  235. and ccr.addTime <![CDATA[ < ]]> #{endAddTime}
  236. </if>
  237. <if test="pinceSensitve != '' and pinceSensitve!=null">
  238. and ccr.pinceSensitve LIKE concat('%',#{pinceSensitve},'%')
  239. </if>
  240. <if test="satisfied != '' and satisfied!=null">
  241. and ccr.satisfied LIKE concat('%',#{satisfied},'%')
  242. </if>
  243. <if test="followup != '' and followup !=null">
  244. and ccr.followup LIKE concat('%',#{followup},'%')
  245. </if>
  246. <if test="newDeal !=null and newDeal != 0">
  247. and c.newDeal =#{newDeal}
  248. </if>
  249. <if test="status!=null and status!=0">
  250. and cmc.status=#{status}
  251. </if>
  252. <if test="con != null and con.size > 0">
  253. and
  254. <foreach collection="con" item="item" index="index" open="(" close=")" separator="OR">
  255. ccr.consultType LIKE CONCAT('%',#{consultType},'%')
  256. </foreach>
  257. </if>
  258. </where>
  259. ORDER BY cmc.`addTime` DESC
  260. </select>
  261. <select id="visitorAssociated" resultType="com.caimei365.user.model.vo.RemarksVo">
  262. SELECT DISTINCT
  263. ccr.id AS remarksId, ccr.remarks,ccr.addTime,ccr.questionMan,ccr.serviceProviderId AS serviceProviderId,
  264. csr.leaderId AS leaderId,IFNULL(ccr.consultType,'') AS consult, c.Name AS clubName,
  265. ccr.clubType AS clubType,ccr.pinceSensitve AS pinceSensitve,ccr.satisfied AS satisfied,ccr.followup AS
  266. followup,ccr.extra AS extra,
  267. (SELECT NAME FROM serviceprovider s WHERE s.serviceProviderID= csr.leaderId) AS leaderName,
  268. (SELECT linkMan FROM serviceprovider s WHERE s.serviceProviderID = ccr.serviceProviderID) AS
  269. recordName,c.newDeal AS newDeal,cmc.status AS status,cmc.`auditText` as auditText
  270. # (SELECT linkMan FROM serviceprovider s WHERE s.serviceProviderID = ccr.oldserviceProviderId) AS oldName
  271. FROM cm_visitor_remarks ccr
  272. LEFT JOIN serviceprovider s ON ccr.serviceProviderId = s.serviceProviderID
  273. LEFT JOIN club c ON c.clubId=ccr.clubId
  274. LEFT JOIN cm_serviceTeam_group csg ON ccr.serviceProviderId = csg.serviceId
  275. LEFT JOIN cm_serviceTeam_role csr ON csr.id = csg.teamId
  276. LEFT JOIN cm_club_report cmc ON cmc.Id = ccr.reportID
  277. <where>
  278. and cmc.id=#{reportId}
  279. and cmc.clubID is null
  280. and reportID is not null
  281. <if test="teamId!=null">
  282. and csg.teamId = #{teamId}
  283. </if>
  284. <if test="teamId==null and serviceProviderId!=null">
  285. and cmc.serviceProviderId=#{serviceProviderId}
  286. </if>
  287. <if test="keyWord != null and keyWord !=''">
  288. and cmc.reportText LIKE CONCAT('%', #{keyWord}, '%')
  289. </if>
  290. <if test="leaderId != null and leaderId>0">
  291. and csr.leaderId = #{leaderId}
  292. </if>
  293. <if test="groupId != null and groupId>0">
  294. and ccr.serviceProviderId = #{groupId}
  295. </if>
  296. <if test="startAddTime !='' and startAddTime !=null">
  297. and ccr.addTime <![CDATA[ > ]]> #{startAddTime}
  298. </if>
  299. <if test="endAddTime != '' and endAddTime!=null">
  300. and ccr.addTime <![CDATA[ < ]]> #{endAddTime}
  301. </if>
  302. <if test="pinceSensitve != '' and pinceSensitve!=null">
  303. and ccr.pinceSensitve LIKE concat('%',#{pinceSensitve},'%')
  304. </if>
  305. <if test="satisfied != '' and satisfied!=null">
  306. and ccr.satisfied LIKE concat('%',#{satisfied},'%')
  307. </if>
  308. <if test="status!=null and status!=0">
  309. and cmc.status=#{status}
  310. </if>
  311. <if test="followup != '' and followup !=null">
  312. and ccr.followup LIKE concat('%',#{followup},'%')
  313. </if>
  314. </where>
  315. ORDER BY cmc.`addTime` DESC
  316. </select>
  317. <update id="disassociation">
  318. UPDATE cm_club_remarks
  319. SET reportId=NULL
  320. # clubId=NULL
  321. WHERE Id = #{remarksId}
  322. </update>
  323. <update id="visitorDisassociation">
  324. UPDATE cm_visitor_remarks
  325. SET reportId=NULL
  326. # questionManId=NULL
  327. WHERE Id = #{remarksId}
  328. </update>
  329. <select id="visitorReportList" resultType="com.caimei365.user.model.vo.ReportVo">
  330. SELECT DISTINCT
  331. cmc.id as reportId,cmc.productID as productId,cmc.reportName as reportName,ccr.questionMan AS questionMan,cmc.`addTime`,p.`name` as
  332. productName,p.`mainImage` as mainImage,cmc.`reportText`,cmc.status AS status,cmc.`auditText` as auditText
  333. FROM cm_club_report cmc
  334. LEFT JOIN cm_visitor_remarks ccr ON cmc.Id = ccr.reportID
  335. LEFT JOIN serviceprovider s ON cmc.serviceProviderId = s.serviceProviderID
  336. LEFT JOIN product p ON p.productID = cmc.productID
  337. <where>
  338. and cmc.`questionManId`=#{questionManId} and cmc.clubID is null
  339. <if test="keyWord != null and keyWord !=''">
  340. AND (p.name LIKE concat('%',#{keyWord},'%')
  341. or cmc.reportText LIKE CONCAT('%', #{keyWord}, '%'))
  342. </if>
  343. </where>
  344. ORDER BY cmc.`addTime` DESC
  345. </select>
  346. <delete id="deleteReport">
  347. DELETE FROM cm_club_report WHERE id=#{reportId}
  348. </delete>
  349. <select id="questionManNameage" resultType="java.lang.String">
  350. SELECT ccr.questionMan FROM cm_club_report cmc
  351. LEFT JOIN cm_visitor_remarks ccr ON cmc.questionManId = ccr.questionManId
  352. <where>
  353. <if test="reportId!=null">
  354. cmc.id=#{reportId}
  355. </if>
  356. <if test="questionManId!='' and questionManId!=null">
  357. cmc.questionManId=#{questionManId}
  358. </if>
  359. <if test="serviceProviderId!=null">
  360. cmc.serviceProviderId=#{serviceProviderId}
  361. </if>
  362. </where>
  363. LIMIT 1
  364. </select>
  365. </mapper>