ClubReport.xml 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373
  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
  14. p.productID as productId,p.mainImage as image,p.name,p.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 cmc.`addTime` 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="teamId==null and serviceProviderId!=null">
  113. and cmc.serviceProviderId=#{serviceProviderId}
  114. </if>
  115. </where>
  116. ORDER BY cmc.`addTime` DESC
  117. </select>
  118. <select id="visitorReportRemarks" resultType="com.caimei365.user.model.vo.ReportVo">
  119. SELECT DISTINCT
  120. cmc.id AS reportId , cmc.productID as productId,cmc.serviceProviderID as serviceProviderId,cmc.questionManId AS questionManId, c.name AS clubName,c.`newDeal` AS
  121. newDeal,cmc.reportName AS reportName,cmc.`addTime` AS ADDTIME,p.`mainImage` AS mainImage,p.name AS
  122. productName,cmc.`reportText` as reportText,cmc.status AS status,cmc.`auditText` as auditText
  123. FROM cm_club_report cmc
  124. LEFT JOIN club c ON c.clubId=cmc.clubId
  125. LEFT JOIN cm_visitor_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. and cmc.clubID is null
  132. # and reportID is not null
  133. <if test="keyWord != null and keyWord != ''">
  134. AND p.name LIKE concat('%',#{keyWord},'%')
  135. or cmc.reportText LIKE CONCAT('%', #{keyWord}, '%')
  136. </if>
  137. <if test="teamId!=null">
  138. and csg.teamId = #{teamId}
  139. </if>
  140. <if test="teamId==null and serviceProviderId!=null">
  141. and cmc.serviceProviderId=#{serviceProviderId}
  142. </if>
  143. </where>
  144. ORDER BY cmc.`addTime` DESC
  145. </select>
  146. <select id="reportLeaderId" resultType="java.lang.Integer">
  147. SELECT DISTINCT id
  148. FROM cm_serviceteam_role csr
  149. LEFT JOIN serviceprovider s ON s.serviceProviderId = csr.leaderId
  150. WHERE s.serviceProviderID = #{serviceProviderId}
  151. </select>
  152. <select id="roeprtNa" resultType="java.lang.String">
  153. SELECT DISTINCT linkMan
  154. FROM serviceprovider
  155. WHERE serviceProviderID = #{serviceProviderId}
  156. LIMIT 1
  157. </select>
  158. <select id="visitorMan" resultType="java.lang.Integer">
  159. SELECT DISTINCT serviceProviderId
  160. FROM cm_visitor_remarks
  161. WHERE questionManId = #{questionManId}
  162. LIMIT 1
  163. </select>
  164. <select id="associated" resultType="com.caimei365.user.model.vo.RemarksVo">
  165. SELECT DISTINCT
  166. ccr.id AS remarksId, ccr.remarks,ccr.addTime,ccr.serviceProviderId AS serviceProviderId,
  167. csr.leaderId AS leaderId,IFNULL(ccr.consultType,'') AS consult, c.Name AS clubName,
  168. ccr.clubType AS clubType,ccr.pinceSensitve AS pinceSensitve,ccr.satisfied AS satisfied,ccr.followup AS
  169. followup,ccr.extra AS extra,
  170. (SELECT NAME FROM serviceprovider s WHERE s.serviceProviderID= csr.leaderId) AS leaderName,
  171. (SELECT linkMan FROM serviceprovider s WHERE s.serviceProviderID = ccr.serviceProviderID) AS
  172. recordName,c.newDeal AS newDeal,cmc.status AS status,cmc.`auditText` as auditText
  173. # (SELECT linkMan FROM serviceprovider s WHERE s.serviceProviderID = ccr.oldserviceProviderId) AS oldName
  174. FROM cm_club_remarks ccr
  175. LEFT JOIN serviceprovider s ON ccr.serviceProviderId = s.serviceProviderID
  176. LEFT JOIN club c ON c.clubId=ccr.clubId
  177. LEFT JOIN cm_serviceTeam_group csg ON ccr.serviceProviderId = csg.serviceId
  178. LEFT JOIN cm_serviceTeam_role csr ON csr.id = csg.teamId
  179. LEFT JOIN cm_club_report cmc ON cmc.Id = ccr.reportID
  180. <where>
  181. and cmc.id=#{reportId}
  182. and cmc.clubID is not null
  183. <if test="teamId!=null">
  184. and csg.teamId = #{teamId}
  185. </if>
  186. <if test="teamId==null and serviceProviderId!=null">
  187. and cmc.serviceProviderId=#{serviceProviderId}
  188. </if>
  189. and reportID is not null
  190. <if test="keyWord != null and keyWord !=''">
  191. and cmc.reportText LIKE CONCAT('%', #{keyWord}, '%')
  192. </if>
  193. <if test="leaderId != null and leaderId>0">
  194. and csr.leaderId = #{leaderId}
  195. </if>
  196. <if test="groupId != null and groupId>0">
  197. and ccr.serviceProviderId = #{groupId}
  198. </if>
  199. <if test="startAddTime !='' and startAddTime !=null">
  200. and ccr.addTime <![CDATA[ > ]]> #{startAddTime}
  201. </if>
  202. <if test="endAddTime != '' and endAddTime!=null">
  203. and ccr.addTime <![CDATA[ < ]]> #{endAddTime}
  204. </if>
  205. <if test="pinceSensitve != '' and pinceSensitve!=null">
  206. and ccr.pinceSensitve LIKE concat('%',#{pinceSensitve},'%')
  207. </if>
  208. <if test="satisfied != '' and satisfied!=null">
  209. and ccr.satisfied LIKE concat('%',#{satisfied},'%')
  210. </if>
  211. <if test="followup != '' and followup !=null">
  212. and ccr.followup LIKE concat('%',#{followup},'%')
  213. </if>
  214. <if test="newDeal !=null and newDeal != 0">
  215. and c.newDeal =#{newDeal}
  216. </if>
  217. <if test="status!=null and status!=0">
  218. and cmc.status=#{status}
  219. </if>
  220. <if test="con != null and con.size > 0">
  221. and
  222. <foreach collection="con" item="item" index="index" open="(" close=")" separator="OR">
  223. ccr.consultType LIKE CONCAT('%',#{consultType},'%')
  224. </foreach>
  225. </if>
  226. </where>
  227. ORDER BY cmc.`addTime` DESC
  228. </select>
  229. <select id="visitorAssociated" resultType="com.caimei365.user.model.vo.RemarksVo">
  230. SELECT DISTINCT
  231. ccr.id AS remarksId, ccr.remarks,ccr.addTime,ccr.questionMan,ccr.serviceProviderId AS serviceProviderId,
  232. csr.leaderId AS leaderId,IFNULL(ccr.consultType,'') AS consult, c.Name AS clubName,
  233. ccr.clubType AS clubType,ccr.pinceSensitve AS pinceSensitve,ccr.satisfied AS satisfied,ccr.followup AS
  234. followup,ccr.extra AS extra,
  235. (SELECT NAME FROM serviceprovider s WHERE s.serviceProviderID= csr.leaderId) AS leaderName,
  236. (SELECT linkMan FROM serviceprovider s WHERE s.serviceProviderID = ccr.serviceProviderID) AS
  237. recordName,c.newDeal AS newDeal,cmc.status AS status,cmc.`auditText` as auditText
  238. # (SELECT linkMan FROM serviceprovider s WHERE s.serviceProviderID = ccr.oldserviceProviderId) AS oldName
  239. FROM cm_visitor_remarks ccr
  240. LEFT JOIN serviceprovider s ON ccr.serviceProviderId = s.serviceProviderID
  241. LEFT JOIN club c ON c.clubId=ccr.clubId
  242. LEFT JOIN cm_serviceTeam_group csg ON ccr.serviceProviderId = csg.serviceId
  243. LEFT JOIN cm_serviceTeam_role csr ON csr.id = csg.teamId
  244. LEFT JOIN cm_club_report cmc ON cmc.Id = ccr.reportID
  245. <where>
  246. and cmc.id=#{reportId}
  247. and cmc.clubID is null
  248. and reportID is not null
  249. <if test="teamId!=null">
  250. and csg.teamId = #{teamId}
  251. </if>
  252. <if test="teamId==null and serviceProviderId!=null">
  253. and cmc.serviceProviderId=#{serviceProviderId}
  254. </if>
  255. <if test="keyWord != null and keyWord !=''">
  256. and cmc.reportText LIKE CONCAT('%', #{keyWord}, '%')
  257. </if>
  258. <if test="leaderId != null and leaderId>0">
  259. and csr.leaderId = #{leaderId}
  260. </if>
  261. <if test="groupId != null and groupId>0">
  262. and ccr.serviceProviderId = #{groupId}
  263. </if>
  264. <if test="startAddTime !='' and startAddTime !=null">
  265. and ccr.addTime <![CDATA[ > ]]> #{startAddTime}
  266. </if>
  267. <if test="endAddTime != '' and endAddTime!=null">
  268. and ccr.addTime <![CDATA[ < ]]> #{endAddTime}
  269. </if>
  270. <if test="pinceSensitve != '' and pinceSensitve!=null">
  271. and ccr.pinceSensitve LIKE concat('%',#{pinceSensitve},'%')
  272. </if>
  273. <if test="satisfied != '' and satisfied!=null">
  274. and ccr.satisfied LIKE concat('%',#{satisfied},'%')
  275. </if>
  276. <if test="status!=null and status!=0">
  277. and cmc.status=#{status}
  278. </if>
  279. <if test="followup != '' and followup !=null">
  280. and ccr.followup LIKE concat('%',#{followup},'%')
  281. </if>
  282. </where>
  283. ORDER BY cmc.`addTime` DESC
  284. </select>
  285. <update id="disassociation">
  286. UPDATE cm_club_remarks
  287. SET reportId=NULL
  288. # clubId=NULL
  289. WHERE Id = #{remarksId}
  290. </update>
  291. <update id="visitorDisassociation">
  292. UPDATE cm_visitor_remarks
  293. SET reportId=NULL
  294. # questionManId=NULL
  295. WHERE Id = #{remarksId}
  296. </update>
  297. <select id="visitorReportList" resultType="com.caimei365.user.model.vo.ReportVo">
  298. SELECT DISTINCT
  299. cmc.id as reportId,cmc.productID as productId,cmc.reportName as reportName,ccr.questionMan AS questionMan,cmc.`addTime`,p.`name` as
  300. productName,p.`mainImage` as mainImage,cmc.`reportText`,cmc.status AS status,cmc.`auditText` as auditText
  301. FROM cm_club_report cmc
  302. LEFT JOIN cm_visitor_remarks ccr ON cmc.Id = ccr.reportID
  303. LEFT JOIN serviceprovider s ON cmc.serviceProviderId = s.serviceProviderID
  304. LEFT JOIN product p ON p.productID = cmc.productID
  305. <where>
  306. and cmc.`questionManId`=#{questionManId} and cmc.clubID is null
  307. <if test="keyWord != null and keyWord !=''">
  308. AND (p.name LIKE concat('%',#{keyWord},'%')
  309. or cmc.reportText LIKE CONCAT('%', #{keyWord}, '%'))
  310. </if>
  311. </where>
  312. ORDER BY cmc.`addTime` DESC
  313. </select>
  314. <delete id="deleteReport">
  315. DELETE FROM cm_club_report WHERE id=#{reportId}
  316. </delete>
  317. <select id="questionManNameage" resultType="java.lang.String">
  318. SELECT ccr.questionMan FROM cm_club_report cmc
  319. LEFT JOIN cm_visitor_remarks ccr ON cmc.questionManId = ccr.questionManId
  320. <where>
  321. <if test="reportId!=null">
  322. cmc.id=#{reportId}
  323. </if>
  324. <if test="questionManId!='' and questionManId!=null">
  325. cmc.questionManId=#{questionManId}
  326. </if>
  327. <if test="serviceProviderId!=null">
  328. cmc.serviceProviderId=#{serviceProviderId}
  329. </if>
  330. </where>
  331. LIMIT 1
  332. </select>
  333. </mapper>