123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410 |
- <?xml version="1.0" encoding="UTF-8" ?>
- <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="com.caimei365.user.mapper.ClubReportMapper">
- <insert id="addClubReport">
- INSERT INTO cm_club_report (serviceProviderID, clubID, productID, reportName, reportText, addTime, createServiceProviderId)
- VALUES (#{serviceProviderId}, #{clubId}, #{productId}, #{reportName}, #{reportText}, now(), #{serviceProviderId})
- </insert>
- <insert id="addVisitorReport">
- INSERT INTO cm_club_report (serviceProviderID, questionManId, productID, reportName, reportText, addTime, createServiceProviderId)
- VALUES (#{serviceProviderId}, #{questionManId}, #{productId}, #{reportName}, #{reportText}, now(), #{serviceProviderId})
- </insert>
- <select id="productList" resultType="com.caimei365.user.model.vo.ProductItemVo">
- SELECT DISTINCT p.productID as productId,p.mainImage as image,p.name,
- (select price from cm_sku where productId=p.productId order by price asc limit 1)as price,s.name as shopName
- FROM product p
- LEFT JOIN shop s ON s.shopID = p.shopID
- LEFT JOIN cm_club_report cmc ON cmc.productID = p.productID
- <where>
- (p.validFlag=9 or p.validFlag=2)
- <if test="keyWord != null and keyWord !=''">
- and p.name LIKE concat('%',#{keyWord},'%')
- </if>
- </where>
- ORDER BY p.productId DESC
- </select>
- <select id="reportList" resultType="com.caimei365.user.model.vo.ReportVo">
- SELECT DISTINCT
- cmc.Id as reportId,cmc.clubID as clubId,cmc.status as status,cmc.productID as productId,c.`name` as
- clubName,cmc.`addTime`,p.`name` as productName,p.`mainImage` as mainImage,cmc.`reportText` as
- reportText,cmc.`auditText` as auditText
- FROM cm_club_report cmc
- LEFT JOIN cm_club_remarks ccr ON ccr.clubID = cmc.clubID
- LEFT JOIN club c ON c.clubID = cmc.clubID
- LEFT JOIN product p ON cmc.productID = p.productID
- <where>
- and (cmc.`serviceProviderId`=#{serviceProviderId} and cmc.`clubID`=#{clubId} and cmc.clubID is not null)
- <if test="keyWord != null and keyWord !=''">
- AND (p.name LIKE concat('%',#{keyWord},'%')
- or cmc.reportText LIKE CONCAT('%', #{keyWord}, '%'))
- </if>
- </where>
- ORDER BY cmc.`addTime` DESC
- </select>
- <select id="reportDetailsList" resultType="com.caimei365.user.model.vo.ReportVo">
- SELECT DISTINCT
- cmc.Id as reportId,
- cmc.clubID as clubId,
- cmc.status as status,
- p.productID as productId,
- c.name AS clubName,
- ccr.questionMan as questionMan,
- c.linkMan,
- cmc.`reportName`,
- cmc.`addTime`,
- p.`name` as productName,
- p.`mainImage`,
- cmc.`reportText`,
- s.name as shopName,
- cmc.`auditText` as auditText
- FROM cm_club_report cmc
- LEFT JOIN club c ON c.clubID = cmc.clubID
- LEFT JOIN cm_club_remarks ccr ON cmc.Id = ccr.reportId
- LEFT JOIN product p ON p.productID = cmc.productID
- LEFT JOIN shop s ON s.shopID = p.shopID
- WHERE cmc.id = #{reportId}
- and cmc.clubID is not null
- ORDER BY cmc.`addTime` DESC
- </select>
- <select id="visitorReportsList" resultType="com.caimei365.user.model.vo.ReportVo">
- SELECT DISTINCT
- cmc.Id as reportId,
- cmc.clubID as clubId,
- cmc.status as status,
- p.productID as productId,
- ccr.questionMan as questionMan,
- cmc.`reportName`,
- cmc.`addTime`,
- p.`name` as productName,
- p.`mainImage`,
- cmc.`reportText`,
- s.name as shopName,
- cmc.`auditText` as auditText
- FROM cm_club_report cmc
- LEFT JOIN cm_visitor_remarks ccr ON cmc.Id = ccr.reportId
- LEFT JOIN product p ON p.productID = cmc.productID
- LEFT JOIN shop s ON s.shopID = p.shopID
- WHERE cmc.id = #{reportId}
- and cmc.clubID is null
- ORDER BY cmc.`addTime` DESC
- </select>
- <select id="reportRemarks" resultType="com.caimei365.user.model.vo.ReportVo">
- SELECT DISTINCT
- cmc.id AS reportId ,cmc.productID AS productId,ccr.serviceProviderID AS serviceProviderId, cmc.createServiceProviderId as createServiceProviderId,
- c.name AS clubName,c.`newDeal` AS newDeal, cmc.reportName AS reportName,cmc.`addTime` AS ADDTIME,
- p.`mainImage` AS mainImage,p.name AS productName,cmc.`reportText` AS
- reportText,cmc.status AS STATUS,cmc.`auditText` AS auditText,ccr.questionMan AS questionMan
- FROM cm_club_report cmc
- LEFT JOIN club c ON c.clubId=cmc.clubId
- LEFT JOIN cm_club_remarks ccr ON cmc.Id = ccr.reportId
- LEFT JOIN serviceprovider s ON ccr.serviceProviderId = s.serviceProviderID
- LEFT JOIN cm_serviceTeam_group csg ON ccr.createServiceProviderId = csg.serviceId
- LEFT JOIN cm_serviceTeam_role csr ON csr.id = csg.teamId
- LEFT JOIN product p ON p.productID = cmc.productID
- <where>
- and cmc.clubID is not null
- <if test="keyWord != null and keyWord !=''">
- AND (p.name LIKE concat('%',#{keyWord},'%')
- or cmc.reportText LIKE CONCAT('%', #{keyWord}, '%'))
- </if>
- <if test="teamId!=null">
- and csg.teamId = #{teamId}
- </if>
- <if test="serviceProviderId!=null">
- and cmc.serviceProviderId=#{serviceProviderId}
- </if>
- </where>
- ORDER BY cmc.`addTime` DESC
- </select>
- <select id="repotRemark" resultType="com.caimei365.user.model.vo.ReportVo">
- SELECT DISTINCT
- cmc.id AS reportId ,cmc.productID AS productId,ccr.serviceProviderID AS serviceProviderId, cmc.createServiceProviderId as createServiceProviderId,
- c.name AS clubName,c.`newDeal` AS newDeal,cmc.reportName AS reportName,cmc.`addTime` AS ADDTIME,
- p.`mainImage` AS mainImage,p.name AS productName,cmc.`reportText` AS
- reportText,cmc.status AS STATUS,cmc.`auditText` AS auditText,ccr.questionMan AS questionMan
- FROM cm_club_report cmc
- LEFT JOIN club c ON c.clubId=cmc.clubId
- LEFT JOIN cm_club_remarks ccr ON cmc.Id = ccr.reportId
- LEFT JOIN serviceprovider s ON ccr.serviceProviderId = s.serviceProviderID
- LEFT JOIN cm_serviceTeam_group csg ON ccr.createServiceProviderId = csg.serviceId
- LEFT JOIN cm_serviceTeam_role csr ON csr.id = csg.teamId
- LEFT JOIN product p ON p.productID = cmc.productID
- where
- cmc.clubID is not null
- ORDER BY cmc.`addTime` DESC
- </select>
- <select id="visitorReportRemarks" resultType="com.caimei365.user.model.vo.ReportVo">
- SELECT DISTINCT
- cmc.id AS reportId , cmc.productID as productId,cmc.serviceProviderID as serviceProviderId,cmc.questionManId AS questionManId, c.name AS clubName,c.`newDeal` AS
- newDeal,cmc.reportName AS reportName,cmc.`addTime` AS ADDTIME,p.`mainImage` AS mainImage,p.name AS
- productName,cmc.`reportText` as reportText,cmc.status AS status,cmc.`auditText` as auditText
- FROM cm_club_report cmc
- LEFT JOIN club c ON c.clubId=cmc.clubId
- LEFT JOIN cm_visitor_remarks ccr ON cmc.Id = ccr.reportId
- LEFT JOIN serviceprovider s ON ccr.serviceProviderId = s.serviceProviderID
- LEFT JOIN cm_serviceTeam_group csg ON ccr.serviceProviderId = csg.serviceId
- LEFT JOIN cm_serviceTeam_role csr ON csr.id = csg.teamId
- LEFT JOIN product p ON p.productID = cmc.productID
- <where>
- and cmc.clubID is null
- # and reportID is not null
- <if test="keyWord != null and keyWord != ''">
- AND p.name LIKE concat('%',#{keyWord},'%')
- or cmc.reportText LIKE CONCAT('%', #{keyWord}, '%')
- </if>
- <if test="teamId!=null">
- and csg.teamId = #{teamId}
- </if>
- <if test="teamId==null and serviceProviderId!=null">
- and cmc.serviceProviderId=#{serviceProviderId}
- </if>
- </where>
- ORDER BY cmc.`addTime` DESC
- </select>
- <select id="visitoReportRemark" resultType="com.caimei365.user.model.vo.ReportVo">
- SELECT DISTINCT
- cmc.id AS reportId , cmc.productID as productId,cmc.serviceProviderID as serviceProviderId,cmc.questionManId AS questionManId, c.name AS clubName,c.`newDeal` AS
- newDeal,cmc.reportName AS reportName,cmc.`addTime` AS ADDTIME,p.`mainImage` AS mainImage,p.name AS
- productName,cmc.`reportText` as reportText,cmc.status AS status,cmc.`auditText` as auditText
- FROM cm_club_report cmc
- LEFT JOIN club c ON c.clubId=cmc.clubId
- LEFT JOIN cm_visitor_remarks ccr ON cmc.Id = ccr.reportId
- LEFT JOIN serviceprovider s ON ccr.serviceProviderId = s.serviceProviderID
- LEFT JOIN cm_serviceTeam_group csg ON ccr.serviceProviderId = csg.serviceId
- LEFT JOIN cm_serviceTeam_role csr ON csr.id = csg.teamId
- LEFT JOIN product p ON p.productID = cmc.productID
- where
- cmc.clubID is null
- ORDER BY cmc.`addTime` DESC
- </select>
- <select id="reportLeaderId" resultType="java.lang.Integer">
- SELECT DISTINCT id
- FROM cm_serviceteam_role csr
- LEFT JOIN serviceprovider s ON s.serviceProviderId = csr.leaderId
- WHERE s.serviceProviderID = #{serviceProviderId}
- </select>
- <select id="roeprtNa" resultType="java.lang.String">
- SELECT DISTINCT linkMan
- FROM serviceprovider
- WHERE serviceProviderID = #{serviceProviderId}
- LIMIT 1
- </select>
- <select id="visitorMan" resultType="java.lang.Integer">
- SELECT DISTINCT serviceProviderId
- FROM cm_visitor_remarks
- WHERE questionManId = #{questionManId}
- LIMIT 1
- </select>
- <select id="associated" resultType="com.caimei365.user.model.vo.RemarksVo">
- SELECT DISTINCT
- ccr.id AS remarksId, ccr.remarks,ccr.addTime,ccr.serviceProviderId AS serviceProviderId, ccr.createServiceProviderId as createServiceProviderId,
- csr.leaderId AS leaderId,IFNULL(ccr.consultType,'') AS consult, c.Name AS clubName,
- ccr.clubType AS clubType,ccr.pinceSensitve AS pinceSensitve,ccr.satisfied AS satisfied,ccr.followup AS followup,ccr.extra AS extra,
- (SELECT NAME FROM serviceprovider s WHERE s.serviceProviderID= csr.leaderId) AS leaderName,
- (SELECT linkMan FROM serviceprovider s WHERE s.serviceProviderID = ccr.createServiceProviderId) AS recordName,
- c.newDeal AS newDeal,cmc.status AS status,cmc.`auditText` as auditText
- # (SELECT linkMan FROM serviceprovider s WHERE s.serviceProviderID = ccr.oldserviceProviderId) AS oldName
- FROM cm_club_remarks ccr
- LEFT JOIN serviceprovider s ON ccr.serviceProviderId = s.serviceProviderID
- LEFT JOIN club c ON c.clubId=ccr.clubId
- LEFT JOIN cm_serviceTeam_group csg ON ccr.createServiceProviderId = csg.serviceId
- LEFT JOIN cm_serviceTeam_role csr ON csr.id = csg.teamId
- LEFT JOIN cm_club_report cmc ON cmc.Id = ccr.reportID
- <where>
- and cmc.id=#{reportId}
- and cmc.clubID is not null
- <if test="teamId!=null">
- and csg.teamId = #{teamId}
- </if>
- <if test="teamId==null and serviceProviderId!=null">
- and cmc.serviceProviderId=#{serviceProviderId}
- </if>
- and reportID is not null
- <if test="keyWord != null and keyWord !=''">
- and cmc.reportText LIKE CONCAT('%', #{keyWord}, '%')
- </if>
- <if test="leaderId != null and leaderId>0">
- and csr.leaderId = #{leaderId}
- </if>
- <if test="groupId != null and groupId>0">
- and ccr.serviceProviderId = #{groupId}
- </if>
- <if test="startAddTime !='' and startAddTime !=null">
- and ccr.addTime <![CDATA[ > ]]> #{startAddTime}
- </if>
- <if test="endAddTime != '' and endAddTime!=null">
- and ccr.addTime <![CDATA[ < ]]> #{endAddTime}
- </if>
- <if test="pinceSensitve != '' and pinceSensitve!=null">
- and ccr.pinceSensitve LIKE concat('%',#{pinceSensitve},'%')
- </if>
- <if test="satisfied != '' and satisfied!=null">
- and ccr.satisfied LIKE concat('%',#{satisfied},'%')
- </if>
- <if test="followup != '' and followup !=null">
- and ccr.followup LIKE concat('%',#{followup},'%')
- </if>
- <if test="newDeal !=null and newDeal != 0">
- and c.newDeal =#{newDeal}
- </if>
- <if test="status!=null and status!=0">
- and cmc.status=#{status}
- </if>
- <if test="con != null and con.size > 0">
- and
- <foreach collection="con" item="item" index="index" open="(" close=")" separator="OR">
- ccr.consultType LIKE CONCAT('%',#{consultType},'%')
- </foreach>
- </if>
- </where>
- ORDER BY cmc.`addTime` DESC
- </select>
- <select id="visitorAssociated" resultType="com.caimei365.user.model.vo.RemarksVo">
- SELECT DISTINCT
- ccr.id AS remarksId, ccr.remarks,ccr.addTime,ccr.questionMan,ccr.serviceProviderId AS serviceProviderId,
- csr.leaderId AS leaderId,IFNULL(ccr.consultType,'') AS consult, c.Name AS clubName,
- ccr.clubType AS clubType,ccr.pinceSensitve AS pinceSensitve,ccr.satisfied AS satisfied,ccr.followup AS
- followup,ccr.extra AS extra,
- (SELECT NAME FROM serviceprovider s WHERE s.serviceProviderID= csr.leaderId) AS leaderName,
- (SELECT linkMan FROM serviceprovider s WHERE s.serviceProviderID = ccr.serviceProviderID) AS
- recordName,c.newDeal AS newDeal,cmc.status AS status,cmc.`auditText` as auditText
- # (SELECT linkMan FROM serviceprovider s WHERE s.serviceProviderID = ccr.oldserviceProviderId) AS oldName
- FROM cm_visitor_remarks ccr
- LEFT JOIN serviceprovider s ON ccr.serviceProviderId = s.serviceProviderID
- LEFT JOIN club c ON c.clubId=ccr.clubId
- LEFT JOIN cm_serviceTeam_group csg ON ccr.serviceProviderId = csg.serviceId
- LEFT JOIN cm_serviceTeam_role csr ON csr.id = csg.teamId
- LEFT JOIN cm_club_report cmc ON cmc.Id = ccr.reportID
- <where>
- and cmc.id=#{reportId}
- and cmc.clubID is null
- and reportID is not null
- <if test="teamId!=null">
- and csg.teamId = #{teamId}
- </if>
- <if test="teamId==null and serviceProviderId!=null">
- and cmc.serviceProviderId=#{serviceProviderId}
- </if>
- <if test="keyWord != null and keyWord !=''">
- and cmc.reportText LIKE CONCAT('%', #{keyWord}, '%')
- </if>
- <if test="leaderId != null and leaderId>0">
- and csr.leaderId = #{leaderId}
- </if>
- <if test="groupId != null and groupId>0">
- and ccr.serviceProviderId = #{groupId}
- </if>
- <if test="startAddTime !='' and startAddTime !=null">
- and ccr.addTime <![CDATA[ > ]]> #{startAddTime}
- </if>
- <if test="endAddTime != '' and endAddTime!=null">
- and ccr.addTime <![CDATA[ < ]]> #{endAddTime}
- </if>
- <if test="pinceSensitve != '' and pinceSensitve!=null">
- and ccr.pinceSensitve LIKE concat('%',#{pinceSensitve},'%')
- </if>
- <if test="satisfied != '' and satisfied!=null">
- and ccr.satisfied LIKE concat('%',#{satisfied},'%')
- </if>
- <if test="status!=null and status!=0">
- and cmc.status=#{status}
- </if>
- <if test="followup != '' and followup !=null">
- and ccr.followup LIKE concat('%',#{followup},'%')
- </if>
- </where>
- ORDER BY cmc.`addTime` DESC
- </select>
- <update id="disassociation">
- UPDATE cm_club_remarks
- SET reportId=NULL
- # clubId=NULL
- WHERE Id = #{remarksId}
- </update>
- <update id="visitorDisassociation">
- UPDATE cm_visitor_remarks
- SET reportId=NULL
- # questionManId=NULL
- WHERE Id = #{remarksId}
- </update>
- <select id="visitorReportList" resultType="com.caimei365.user.model.vo.ReportVo">
- SELECT DISTINCT
- cmc.id as reportId,cmc.productID as productId,cmc.reportName as reportName,ccr.questionMan AS questionMan,cmc.`addTime`,p.`name` as
- productName,p.`mainImage` as mainImage,cmc.`reportText`,cmc.status AS status,cmc.`auditText` as auditText
- FROM cm_club_report cmc
- LEFT JOIN cm_visitor_remarks ccr ON cmc.Id = ccr.reportID
- LEFT JOIN serviceprovider s ON cmc.serviceProviderId = s.serviceProviderID
- LEFT JOIN product p ON p.productID = cmc.productID
- <where>
- and cmc.`questionManId`=#{questionManId} and cmc.clubID is null
- <if test="keyWord != null and keyWord !=''">
- AND (p.name LIKE concat('%',#{keyWord},'%')
- or cmc.reportText LIKE CONCAT('%', #{keyWord}, '%'))
- </if>
- </where>
- ORDER BY cmc.`addTime` DESC
- </select>
- <delete id="deleteReport">
- DELETE FROM cm_club_report WHERE id=#{reportId}
- </delete>
- <select id="questionManNameage" resultType="java.lang.String">
- SELECT ccr.questionMan FROM cm_club_report cmc
- LEFT JOIN cm_visitor_remarks ccr ON cmc.questionManId = ccr.questionManId
- <where>
- <if test="reportId!=null">
- cmc.id=#{reportId}
- </if>
- <if test="questionManId!='' and questionManId!=null">
- cmc.questionManId=#{questionManId}
- </if>
- <if test="serviceProviderId!=null">
- cmc.serviceProviderId=#{serviceProviderId}
- </if>
- </where>
- LIMIT 1
- </select>
- </mapper>
|