ClubReport.xml 18 KB

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