12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631 |
- <?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.caimei.modules.user.dao.NewCmClubDao">
- <sql id="newCmClubColumns">
- a.checkMan as "checkMan",
- a.clubID AS "clubID",
- a.userID AS "userID",
- u.name AS "name",
- a.sname AS "sname",
- a.logo AS "logo",
- a.legalPerson AS "legalPerson",
- a.provinceID AS "provinceID",
- a.cityID AS "cityID",
- a.townID AS "townID",
- a.flag AS "flag",
- a.inviterBindID AS "inviterBindID",
- a.inviterName AS "inviterName",
- a.spID AS "spID",
- a.mainServiceProviderID AS "mainServiceProviderID",
- a.scanTime AS "scanTime",
- a.address AS "address",
- a.linkMan AS "linkMan",
- a.linkManIdentity AS "linkManIdentity",
- a.contractPhone AS "contractPhone",
- a.contractMobile AS "contractMobile",
- a.contractEmail AS "contractEmail",
- a.fax AS "fax",
- a.info AS "info",
- a.addTime AS "addTime",
- a.auditTime AS "auditTime",
- a.auditNote AS "auditNote",
- a.status AS "status",
- a.businessLicenseImage AS "businessLicenseImage",
- a.defaultServiceProviderID AS "defaultServiceProviderID",
- a.defaultServiceProviderUpdTime AS "defaultServiceProviderUpdTime",
- a.mainpro AS "mainpro",
- a.scanFlag AS "scanFlag",
- a.headpic AS "headpic",
- a.socialCreditCode AS "socialCreditCode",
- a.lastModify AS "lastModify",
- a.firstClubType AS "firstClubType",
- a.secondClubType AS "secondClubType",
- a.department AS "department",
- a.medicalPracticeLicenseImg AS "medicalPracticeLicenseImg",
- a.newDeal as "newDeal"
- </sql>
- <sql id="otherColumns">
- ,case sp.status when 91 then '采美默认协销经理(官方账号)' else sp.linkMan end AS "spName",
- d.name AS "province",
- c.name AS "city",
- b.name AS "town",
- u.account AS "account",
- u.registerTime AS "registerTime",
- u.registerIP AS "registerIP",
- u.userName AS "userName",
- u.bindMobile AS "bindMobile",
- u.email AS "email",
- u.userOrganizeID AS "userOrganizeID",
- u.userIdentity AS "userIdentity",
- if(csu.delFlag = '0' and now() <![CDATA[ < ]]> csu.endTime,1,0) as svipUserFlag
- </sql>
- <sql id="newCmClubJoins">
- LEFT JOIN user u ON u.userID = a.userID
- LEFT JOIN cm_svip_user csu ON csu.userId = u.userID
- LEFT JOIN serviceprovider sp ON sp.serviceProviderID = a.spID
- LEFT JOIN town b ON b.townID=a.townID
- LEFT JOIN city c ON c.cityID=a.cityID
- LEFT JOIN province d ON d.provinceID=a.provinceID
- </sql>
- <select id="get" resultType="NewCmClub">
- SELECT
- <include refid="newCmClubColumns"/>
- <include refid="otherColumns"/>
- FROM club a
- <include refid="newCmClubJoins"/>
- WHERE a.clubID = #{id}
- </select>
- <select id="getclubByUserId" resultType="com.caimei.modules.user.entity.NewCmClub">
- SELECT
- <include refid="newCmClubColumns"/>
- FROM club a
- <include refid="newCmClubJoins"/>
- WHERE a.userID = #{userID}
- </select>
- <select id="textUserValue" resultType="com.caimei.modules.user.entity.NewCmClub">
- SELECT u.userID AS valueID, coas.activeState, covs.customerValue
- FROM USER u
- LEFT JOIN cm_organ_value_system covs ON covs.userId = u.userId
- LEFT JOIN cm_organ_active_system coas ON coas.userId = u.userId
- WHERE covs.stage = 0 AND covs.delType = 1 AND coas.stage = 0 AND coas.delType = 1
- </select>
- <select id="findList" resultType="NewCmClub">
- SELECT
- <include refid="newCmClubColumns"/>
- <include refid="otherColumns"/>,u.userPermission,u.source, coas.activeState,covs.customerValue,u.loginTime
- FROM club a
- <include refid="newCmClubJoins"/>
- LEFT JOIN (SELECT DISTINCT clubId, createTime FROM cm_provider_record GROUP BY clubId ORDER BY id DESC ) cpr ON a.clubId = cpr.clubId
- LEFT JOIN (SELECT DISTINCT clubID, checkTime FROM clubchangesprecord WHERE checkStatus = 1 GROUP BY clubID ORDER BY clubChangeSpRecordID DESC )ccs ON ccs.clubId = a.clubId
- LEFT JOIN (SELECT userID, customerValue FROM cm_organ_value_system WHERE stage = 0 AND delType = 1) covs ON a.userID = covs.userID
- LEFT JOIN (SELECT userID, activeState FROM cm_organ_active_system WHERE stage = 0 AND delType = 1) AS coas ON coas.userID = a.userID
- <where>
- (u.userOrganizeID IN(0,1) or u.clubStatus != 92) and u.userOrganizeID != 4 AND u.userIdentity != 8
- <if test="clubID != null and clubID != ''">
- AND a.clubID = #{clubID}
- </if>
- <if test="clubID == 0">
- AND a.clubID = #{clubID}
- </if>
- <if test="userID != null and userID != ''">
- AND a.userID = #{userID}
- </if>
- <if test="account != null and account != ''">
- AND u.account = #{account}
- </if>
- <if test="name != null and name != ''">
- AND u.name LIKE concat('%',#{name},'%')
- </if>
- <if test="userName != null and userName != ''">
- AND u.userName LIKE concat('%',#{userName},'%')
- </if>
- <if test="townID != null and townID != ''">
- AND d.provinceID = #{provinceID}
- </if>
- <if test="cityID != null and cityID != ''">
- AND c.cityID = #{cityID}
- </if>
- <if test="townID != null and townID != ''">
- AND b.townID = #{townID}
- </if>
- <if test="status != null and status != ''">
- AND a.status = #{status}
- </if>
- <if test="bindMobile != null and bindMobile != ''">
- AND u.bindMobile LIKE concat('%',#{bindMobile},'%')
- </if>
- <if test="email != null and email != ''">
- AND u.email LIKE concat('%',#{email},'%')
- </if>
- <if test="linkMan != null and linkMan != ''">
- AND a.linkMan LIKE concat('%',#{linkMan},'%')
- </if>
- <if test="startTime != null and startTime != ''">
- AND (u.registerTime > #{startTime} OR u.registerTime = #{startTime})
- </if>
- <if test="endTime != null and endTime != ''">
- AND (u.registerTime < #{endTime} OR u.registerTime = #{endTime})
- </if>
- <if test="allocationStartTime != null and allocationStartTime != ''">
- AND (ccs.checkTime <![CDATA[ >= ]]> #{allocationStartTime}
- OR cpr.createTime <![CDATA[ >= ]]> #{allocationStartTime})
- </if>
- <if test="allocationEndTime != null and allocationEndTime != ''">
- AND (ccs.checkTime <![CDATA[ <= ]]> #{allocationEndTime}
- OR cpr.createTime <![CDATA[ <= ]]> #{allocationEndTime})
- </if>
- <if test="trendsLabel != null and trendsLabel != ''">
- AND a.clubId in (select clubId from cm_club_label where label like concat('%', #{trendsLabel}, '%') AND dynamicStatus = 0)
- </if>
- <if test="stateLabel != null and stateLabel != ''">
- AND a.clubId in (select clubId from cm_club_label where label like concat('%', #{stateLabel}, '%') AND dynamicStatus = 1)
- </if>
- <if test="labelStartTime != null and labelStartTime != ''">
- AND a.clubId in (select clubId from cm_club_label where addTime <![CDATA[ >= ]]> #{labelStartTime})
- </if>
- <if test="labelEndTime != null and labelEndTime != ''">
- AND a.clubId in (select clubId from cm_club_label where addTime <![CDATA[ <= ]]> #{labelEndTime})
- </if>
- <if test="startLoginTime != null and startLoginTime != ''">
- AND (u.loginTime >= DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH) OR a.clubId in (select a.clubId
- FROM ((
- select
- c.clubId,ccr.addTime AS time,c.spID
- FROM club c
- LEFT JOIN user u ON u.userID = c.userID
- LEFT JOIN cm_club_remarks ccr ON ccr.clubId = c.clubId
- LEFT JOIN serviceprovider sp ON sp.serviceProviderID = c.spID
- where c.status=90 and sp.status=90
- and ccr.addTime >= DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH)
- GROUP BY c.clubId
- )UNION(
- select c.clubId,cr.orderTime AS time,c.spID
- FROM club c
- LEFT JOIN user u ON u.userID = c.userID
- LEFT JOIN cm_order cr ON cr.clubId = c.clubId
- LEFT JOIN serviceprovider sp ON sp.serviceProviderID = c.spID
- where c.status=90 and sp.status=90
- and cr.orderTime >= DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH)
- GROUP BY c.clubId
- )) a where a.time is not null
- and a.spID=#{spID}
- GROUP BY a.clubId ))
- </if>
- <if test="endLoginTime != null and endLoginTime != ''">
- AND (u.loginTime <![CDATA[ < ]]> DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH) or u.loginTime is null) and a.clubId not in (select a.clubId
- FROM ((
- select
- c.clubId,ccr.addTime AS time,c.spID
- FROM club c
- LEFT JOIN user u ON u.userID = c.userID
- LEFT JOIN cm_club_remarks ccr ON ccr.clubId = c.clubId
- LEFT JOIN serviceprovider sp ON sp.serviceProviderID = c.spID
- where c.status=90 and sp.status=90
- and ccr.addTime >= DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH)
- GROUP BY c.clubId
- )UNION(
- select c.clubId,cr.orderTime AS time,c.spID
- FROM club c
- LEFT JOIN user u ON u.userID = c.userID
- LEFT JOIN cm_order cr ON cr.clubId = c.clubId
- LEFT JOIN serviceprovider sp ON sp.serviceProviderID = c.spID
- where c.status=90 and sp.status=90
- and cr.orderTime >= DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH)
- GROUP BY c.clubId
- )) a where a.time is not null
- and a.spID=#{spID}
- GROUP BY a.clubId )
- </if>
- <if test="userIdentity != null and userIdentity != '' and userIdentity != '8'.toString()">
- AND u.userIdentity = #{userIdentity}
- </if>
- <if test="userIdentity != null and userIdentity != '' and userIdentity == '8'.toString()">
- AND csu.delFlag = '0' and now() <![CDATA[ < ]]> csu.endTime
- </if>
- <if test="newDeal != null">
- AND a.newDeal =#{newDeal}
- </if>
- <if test="activeState != null and activeState != ''">
- AND coas.activeState = #{activeState}
- </if>
- <if test="customerValue != null and customerValue != ''">
- AND covs.customerValue = #{customerValue}
- </if>
- <if test="spID != null and spID != ''">
- AND sp.serviceProviderID = #{spID}
- </if>
- </where>
- <choose>
- <when test="page !=null and page.orderBy != null and page.orderBy != ''">
- ORDER BY ${page.orderBy}
- </when>
- <otherwise>
- ORDER BY case when a.status = 91 then 0 else 1 end desc, a.addTime DESC
- </otherwise>
- </choose>
- </select>
- <select id="spNameList" resultType="com.caimei.modules.project.model.ServiceProviderModel">
- SELECT serviceProviderID, name
- FROM serviceprovider
- WHERE NAME NOT LIKE concat('%', '测试', '%')
- AND validFlag = 1
- AND STATUS = 90
- </select>
- <select id="getClubLabel" resultType="com.caimei.modules.user.entity.CmClubLabel">
- SELECT label, dynamicStatus FROM cm_club_label
- </select>
- <select id="findAllList" resultType="NewCmClub">
- SELECT
- <include refid="newCmClubColumns"/>
- <include refid="otherColumns"/>
- FROM club a
- <include refid="newCmClubJoins"/>
- <where>
- </where>
- <choose>
- <when test="page !=null and page.orderBy != null and page.orderBy != ''">
- ORDER BY ${page.orderBy}
- </when>
- <otherwise>
- </otherwise>
- </choose>
- </select>
- <select id="findProviderList" resultType="NewCmClub">
- SELECT
- <include refid="newCmClubColumns"/>
- ,case sp.status when 91 then '采美默认协销经理(官方账号)' else sp.linkMan end AS "spName"
- ,u.userPermission,u.source,u.loginTime,cpr.createTime AS providerTime,
- u.account AS "account",
- u.registerTime AS "registerTime",
- u.registerIP AS "registerIP",
- u.userName AS "userName",
- u.bindMobile AS "bindMobile",
- u.email AS "email",
- u.userOrganizeID AS "userOrganizeID",
- u.userIdentity AS "userIdentity",
- if(csu.delFlag = '0' and now() <![CDATA[ < ]]> csu.endTime,1,0) as svipUserFlag
- from cm_provider_record cpr
- LEFT JOIN serviceprovider sp ON sp.serviceProviderID =cpr.spID
- LEFT JOIN club a ON cpr.clubId = a.clubId
- LEFT JOIN user u ON u.userID = a.userID
- LEFT JOIN cm_svip_user csu ON csu.userId = u.userID
- <where>
- (u.userOrganizeID IN(0,1) or u.clubStatus != 92) and u.userOrganizeID != 4 and sp.status=90
- <if test="clubID != null and clubID != ''">
- AND a.clubID = #{clubID}
- </if>
- <if test="clubID == 0">
- AND a.clubID = #{clubID}
- </if>
- <if test="userID != null and userID != ''">
- AND a.userID = #{userID}
- </if>
- <if test="account != null and account != ''">
- AND u.account = #{account}
- </if>
- <if test="name != null and name != ''">
- AND u.name LIKE concat('%',#{name},'%')
- </if>
- <if test="userName != null and userName != ''">
- AND u.userName LIKE concat('%',#{userName},'%')
- </if>
- <if test="status != null and status != ''">
- AND a.status = #{status}
- </if>
- <if test="bindMobile != null and bindMobile != ''">
- AND u.bindMobile LIKE concat('%',#{bindMobile},'%')
- </if>
- <if test="email != null and email != ''">
- AND u.email LIKE concat('%',#{email},'%')
- </if>
- <if test="linkMan != null and linkMan != ''">
- AND a.linkMan LIKE concat('%',#{linkMan},'%')
- </if>
- <if test="startTime != null and startTime != ''">
- AND (u.registerTime > #{startTime} OR u.registerTime = #{startTime})
- </if>
- <if test="endTime != null and endTime != ''">
- AND (u.registerTime < #{endTime} OR u.registerTime = #{endTime})
- </if>
- <if test="startLoginTime != null and startLoginTime != ''">
- AND (u.loginTime > #{startLoginTime} OR u.loginTime = #{startLoginTime})
- </if>
- <if test="endLoginTime != null and endLoginTime != ''">
- AND (u.loginTime < #{endLoginTime} OR u.loginTime = #{endLoginTime})
- </if>
- <if test="providerTime != null and providerTime != ''">
- AND cpr.id in (
- (SELECT max(cp.id)
- from cm_provider_record cp
- WHERE DATE(cp.createTime) = DATE(#{providerTime})
- group by cp.clubId))
- </if>
- <if test="userIdentity != null and userIdentity != '' and userIdentity != '8'.toString()">
- AND u.userIdentity = #{userIdentity}
- </if>
- <if test="userIdentity != null and userIdentity != '' and userIdentity == '8'.toString()">
- AND csu.delFlag = '0' and now() <![CDATA[ < ]]> csu.endTime
- </if>
- <if test="newDeal != null">
- AND a.newDeal =#{newDeal}
- </if>
- <if test="spID != null and spID != ''">
- AND sp.serviceProviderID = #{spID}
- </if>
- </where>
- group by cpr.clubId
- <choose>
- <when test="page !=null and page.orderBy != null and page.orderBy != ''">
- ORDER BY ${page.orderBy}
- </when>
- <otherwise>
- ORDER BY case when a.status = 91 then 0 else 1 end desc, cpr.createTime DESC
- </otherwise>
- </choose>
- </select>
- <insert id="insert" parameterType="NewCmClub" keyProperty="clubID" useGeneratedKeys="true">
- INSERT INTO club(userID,
- name,
- sname,
- logo,
- legalPerson,
- provinceID,
- cityID,
- townID,
- flag,
- inviterBindID,
- inviterName,
- spID,
- mainServiceProviderID,
- scanTime,
- address,
- linkMan,
- linkManIdentity,
- contractPhone,
- contractMobile,
- contractEmail,
- fax,
- info,
- addTime,
- auditTime,
- auditNote,
- status,
- businessLicenseImage,
- defaultServiceProviderID,
- defaultServiceProviderUpdTime,
- mainpro,
- scanFlag,
- headpic,
- lastModify,
- firstClubType,
- socialCreditCode,
- secondClubType,
- department,
- medicalPracticeLicenseImg)
- VALUES (#{userID},
- #{name},
- #{sname},
- #{logo},
- #{legalPerson},
- #{provinceID},
- #{cityID},
- #{townID},
- #{flag},
- #{inviterBindID},
- #{inviterName},
- #{spID},
- #{mainServiceProviderID},
- #{scanTime},
- #{address},
- #{linkMan},
- #{linkManIdentity},
- #{contractPhone},
- #{contractMobile},
- #{contractEmail},
- #{fax},
- #{info},
- #{addTime},
- #{auditTime},
- #{auditNote},
- #{status},
- #{businessLicenseImage},
- #{defaultServiceProviderID},
- #{defaultServiceProviderUpdTime},
- #{mainpro},
- #{scanFlag},
- #{headpic},
- #{lastModify},
- #{firstClubType},
- #{socialCreditCode},
- #{secondClubType},
- #{department},
- #{medicalPracticeLicenseImg})
- </insert>
- <update id="update">
- UPDATE club SET
- <if test="checkMan != null and checkMan != ''">
- checkMan = #{checkMan},
- </if>
- <if test="name != null and name != ''">
- name = #{name},
- </if>
- <if test="sname != null">
- sname = #{sname},
- </if>
- <if test="logo != null and logo != ''">
- logo = #{logo},
- </if>
- <if test="legalPerson != null and legalPerson != ''">
- legalPerson = #{legalPerson},
- </if>
- <if test="provinceID != null and provinceID != ''">
- provinceID = #{provinceID},
- </if>
- <if test="cityID != null and cityID != ''">
- cityID = #{cityID},
- </if>
- <if test="townID != null and townID != ''">
- townID = #{townID},
- </if>
- <if test="flag != null and flag != ''">
- flag = #{flag},
- </if>
- <if test="inviterBindID != null and inviterBindID != ''">
- inviterBindID = #{inviterBindID},
- </if>
- <if test="inviterName != null and inviterName != ''">
- inviterName = #{inviterName},
- </if>
- <if test="spID != null and spID != ''">
- spID = #{spID},
- </if>
- <if test="mainServiceProviderID != null and mainServiceProviderID != ''">
- mainServiceProviderID = #{mainServiceProviderID},
- </if>
- <if test="scanTime != null">
- scanTime = #{scanTime},
- </if>
- <if test="address != null and address != ''">
- address = #{address},
- </if>
- <if test="linkMan != null and linkMan != ''">
- linkMan = #{linkMan},
- </if>
- <if test="linkManIdentity != null and linkManIdentity != ''">
- linkManIdentity = #{linkManIdentity},
- </if>
- <if test="contractPhone != null and contractPhone != ''">
- contractPhone = #{contractPhone},
- </if>
- <if test="contractMobile != null and contractMobile != ''">
- contractMobile = #{contractMobile},
- </if>
- <if test="contractEmail != null and contractEmail != ''">
- contractEmail = #{contractEmail},
- </if>
- <if test="fax != null and fax != ''">
- fax = #{fax},
- </if>
- <if test="info != null and info != ''">
- info = #{info},
- </if>
- <if test="addTime != null">
- addTime = #{addTime},
- </if>
- <if test="auditTime != null">
- auditTime = #{auditTime},
- </if>
- <if test="auditNote != null and auditNote != ''">
- auditNote = #{auditNote},
- </if>
- <if test="status != null and status != ''">
- status = #{status},
- </if>
- <if test="businessLicenseImage != null">
- businessLicenseImage = #{businessLicenseImage},
- </if>
- <if test="socialCreditCode != null and socialCreditCode != ''">
- socialCreditCode = #{socialCreditCode},
- </if>
- <if test="defaultServiceProviderID != null and defaultServiceProviderID != ''">
- defaultServiceProviderID = #{defaultServiceProviderID},
- </if>
- <if test="defaultServiceProviderUpdTime != null and defaultServiceProviderUpdTime != ''">
- defaultServiceProviderUpdTime = #{defaultServiceProviderUpdTime},
- </if>
- <if test="mainpro != null and mainpro != ''">
- mainpro = #{mainpro},
- </if>
- <if test="scanFlag != null and scanFlag != ''">
- scanFlag = #{scanFlag},
- </if>
- <if test="headpic != null">
- headpic = #{headpic},
- </if>
- <if test="lastModify != null and lastModify != ''">
- lastModify = DATE_FORMAT(#{lastModify},'%Y-%m-%d %H:%i:%s'),
- </if>
- <if test="firstClubType != null and firstClubType != ''">
- firstClubType=#{firstClubType},
- </if>
- <if test="secondClubType != null and secondClubType != ''">
- secondClubType=#{secondClubType},
- </if>
- <if test="department != null and department != ''">
- department=#{department},
- </if>
- <if test="medicalPracticeLicenseImg != null and medicalPracticeLicenseImg != ''">
- medicalPracticeLicenseImg=#{medicalPracticeLicenseImg},
- </if>
- userID = #{userID}
- WHERE (clubID = #{clubID}
- <if test="clubID == null or clubID == ''">or userID = #{userID}</if>
- )
- </update>
- <delete id="delete">
- DELETE
- FROM club
- WHERE clubID = #{clubID}
- </delete>
- <select id="findDistributionCLubList" resultType="com.caimei.modules.user.entity.NewCmClub">
- SELECT
- <include refid="newCmClubColumns"/>,
- u.registerTime,
- u.userName,
- u.bindMobile
- FROM club a
- LEFT JOIN user u ON u.userID = a.userID
- <where>
- (u.userOrganizeID IN(0,1) or u.clubStatus != 92) and u.userOrganizeID != 4 and a.status != 92
- <if test="clubID != null and clubID != ''">
- AND a.clubID = #{clubID}
- </if>
- <if test="userID != null and userID != ''">
- AND a.userID = #{userID}
- </if>
- <if test="account != null and account != ''">
- AND u.account = #{account}
- </if>
- <if test="name != null and name != ''">
- AND u.name LIKE concat('%',#{name},'%')
- </if>
- <if test="userName != null and userName != ''">
- AND u.userName LIKE concat('%',#{userName},'%')
- </if>
- <if test="status != null and status != ''">
- AND a.status = #{status}
- </if>
- <if test="bindMobile != null and bindMobile != ''">
- AND u.bindMobile LIKE concat('%',#{bindMobile},'%')
- </if>
- <if test="email != null and email != ''">
- AND u.email LIKE concat('%',#{email},'%')
- </if>
- <if test="linkMan != null and linkMan != ''">
- AND a.linkMan LIKE concat('%',#{linkMan},'%')
- </if>
- <if test="startTime != null and startTime != ''">
- AND (u.registerTime > #{startTime} OR u.registerTime = #{startTime})
- </if>
- <if test="endTime != null and endTime != ''">
- AND (u.registerTime < #{endTime} OR u.registerTime = #{endTime})
- </if>
- <if test="startLoginTime != null and startLoginTime != ''">
- AND (u.loginTime > #{startLoginTime} OR u.loginTime = #{startLoginTime})
- </if>
- <if test="endLoginTime != null and endLoginTime != ''">
- AND (u.loginTime < #{endLoginTime} OR u.loginTime = #{endLoginTime})
- </if>
- <if test="userIdentity != null and userIdentity != ''">
- AND u.userIdentity = #{userIdentity}
- </if>
- <if test="newDeal != null">
- AND a.newDeal =#{newDeal}
- </if>
- <if test="spID != null and spID != ''">
- AND a.spID = #{spID}
- </if>
- </where>
- group by a.clubId
- <choose>
- <when test="page !=null and page.orderBy != null and page.orderBy != ''">
- ORDER BY ${page.orderBy}
- </when>
- <otherwise>
- ORDER BY case when a.status = 91 then 0 else 1 end desc, u.registerTime DESC
- </otherwise>
- </choose>
- </select>
- <select id="findClubById" resultType="com.caimei.modules.user.entity.NewCmClub">
- SELECT
- <include refid="newCmClubColumns"/>
- , CONCAT(d.name,c.name ,b.name ,a.`address` ) address
- FROM club a
- LEFT JOIN user u ON u.userID = a.userID
- LEFT JOIN town b ON a.townID =b.townID
- LEFT JOIN city c ON b.cityID=c.cityID
- JOIN province d ON c.`provinceID` =d.`provinceID`
- WHERE a.clubID=#{clubID}
- </select>
- <select id="findSpId" resultType="java.lang.Integer">
- select serviceProviderID
- from serviceprovider
- where serviceProviderID = #{spID}
- and status = 90
- </select>
- <select id="findRemarksList" resultType="com.caimei.modules.user.entity.CmClubRemarks">
- select DISTINCT ccr.id as remarksId,
- ccr.remarks,
- s.linkMan as spName,
- ccr.addTime,
- ccr.questionMan,
- ccr.consultType as consult,
- ccr.clubType,
- ccr.pinceSensitve,
- ccr.satisfied,
- ccr.followup,
- ccr.extra,
- (SELECT NAME FROM serviceprovider s WHERE s.serviceProviderID = csr.leaderId) AS leaderName
- from cm_club_remarks ccr
- 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
- where clubId = #{clubId}
- order by addTime desc
- </select>
- <select id="getRemarksImageList" resultType="java.lang.String">
- select imageUrl
- from cm_club_remarks_file
- where remarksId = #{remarksId}
- and fileType = 1
- </select>
- <select id="getRemarksFileList" resultType="com.caimei.modules.user.entity.RemarksFileVo">
- select fileName, ossName
- from cm_club_remarks_file
- where remarksId = #{remarksId}
- and fileType = 2
- </select>
- <insert id="insertBeansHistory">
- INSERT INTO `user_beans_history` (`userId`, `type`, `beansType`, `orderId`,
- `num`, `pushStatus`, `addTime`, delFlag)
- VALUES (#{userId}, #{type}, #{beansType}, #{orderId},
- #{num}, #{pushStatus}, #{addTime}, 0)
- </insert>
- <select id="findLowOrder" resultType="com.caimei.modules.user.entity.UserBeansHistory">
- select userId, type, beansType, orderId, num, addTime
- from user_beans_history
- where orderId = #{orderId}
- and delFlag = 0
- and type = 2
- and num = 500
- </select>
- <select id="findRegistList" resultType="com.caimei.modules.user.entity.CmClubRemarks">
- SELECT DISTINCT
- ccr.id AS remarksId, ccr.remarks,s.linkman AS spName, ccr.addTime,ccr.questionMan,
- csr.leaderId AS leaderId,IFNULL(ccr.consultType,'') AS consult, c.Name AS
- clubName,ccr.clubType,ccr.pinceSensitve,ccr.satisfied,ccr.followup,ccr.extra,c.newDeal,c.contractMobile,
- (SELECT NAME FROM serviceprovider s WHERE s.serviceProviderID= csr.leaderId) AS leaderName,
- (SELECT mainImage FROM product p WHERE p.productID= ccre.productID) AS productMainImage,
- (SELECT NAME FROM product p WHERE p.productID= ccre.productID) AS proName,
- # (SELECT linkMan FROM serviceprovider s WHERE s.serviceProviderID= ccr.serviceProviderID) AS oldName
- ccre.reportText AS reportText,ccre.status AS reportStatus,ccre.auditName AS auditName,ccre.auditTime AS
- auditTime,p.mainImage
- AS mainImage,p.name AS productName,sh.name AS shopName
- FROM cm_club_remarks ccr
- LEFT JOIN serviceprovider s ON ccr.createServiceProviderId = s.serviceProviderID
- LEFT JOIN club c ON c.clubId=ccr.clubId
- # 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 cm_club_report ccre ON ccre.Id= ccr.reportID
- LEFT JOIN product p ON p.productID = ccr.productID
- LEFT JOIN shop sh ON sh.shopID = p.shopID
- <where>
- <if test="remarks != null and remarks !=''">
- AND ccr.remarks LIKE concat('%',#{remarks},'%')
- </if>
- <if test="clubId != null">
- AND c.clubID = #{clubId}
- </if>
- <if test="contractMobile != null and contractMobile != ''">
- AND c.contractMobile = #{contractMobile}
- </if>
- <if test="clubName !=null and clubName !=''">
- AND c.Name like concat('%',#{clubName},'%')
- </if>
- <if test="leaderId != null">
- and csr.leaderId = #{leaderId}
- </if>
- <if test="serviceProviderId != null">
- and csg.serviceId = #{serviceProviderId}
- </if>
- <if test="startAddTime != null and startAddTime != ''">
- and ccr.addTime <![CDATA[ > ]]> #{startAddTime}
- </if>
- <if test="endAddTime != null and endAddTime != ''">
- and ccr.addTime <![CDATA[ < ]]> #{endAddTime}
- </if>
- <if test="newDeal !=null">
- and c.newDeal=#{newDeal}
- </if>
- <if test="reportID !=null">
- and ccr.reportID=#{reportID}
- </if>
- </where>
- -- group by p.productID
- ORDER BY ADDTIME DESC
- <choose>
- <when test="page !=null and page.orderBy != null and page.orderBy != ''">
- ORDER BY ${page.orderBy}
- </when>
- </choose>
- </select>
- <select id="findConsults" resultType="com.caimei.modules.consult.entity.type.CmConsulttype">
- select id, className, createdTime
- from cm_consulttype
- where delflag = 0
- </select>
- <select id="findTeams" resultType="com.caimei.modules.user.entity.CmSaleMan">
- select csr.leaderId, s.name as leaderName
- from cm_serviceteam_role csr
- left join serviceprovider s on s.serviceProviderID = csr.leaderId
- where csr.delflag = 0
- </select>
- <select id="findGroup" resultType="com.caimei.modules.project.model.ServiceProviderModel">
- SELECT serviceId as serviceProviderID, s.name
- FROM cm_serviceteam_group csg
- LEFT JOIN cm_serviceTeam_role csr ON csr.id = csg.teamid
- LEFT JOIN serviceprovider s ON s.serviceProviderID = csg.serviceId
- WHERE csr.leaderId = #{leaderId}
- </select>
- <select id="findClassName" resultType="java.lang.String">
- select className
- from cm_consulttype
- where id = #{string}
- </select>
- <delete id="deleteRamarks">
- DELETE
- FROM `cm_remarks`
- WHERE remarksId = #{remarksId}
- </delete>
- <insert id="addRemarks">
- INSERT INTO `cm_remarks`(remarks, `addtime`)
- VALUES (#{remarks}, #{addtime})
- </insert>
- <update id="upremarks">
- UPDATE `cm_remarks`
- SET remarks = #{remarks}
- WHERE remarksId = #{remarksId}
- </update>
- <select id="upremakasList" resultType="java.lang.String">
- SELECT remarks
- FROM `cm_remarks`
- WHERE remarksId = #{remarksId}
- </select>
- <select id="ClubsIds" resultType="java.lang.Integer">
- select oldserviceProviderId
- FROM `cm_club_remarks`
- WHERE clubId = #{clubID}
- </select>
- <update id="oldname">
- UPDATE cm_club_remarks
- SET oldserviceProviderId = #{oldserviceProviderId},
- serviceProviderId=#{newSpID}
- WHERE clubId = #{clubID}
- AND serviceProviderId = #{oldSpID}
- </update>
- <update id="oldnames">
- UPDATE cm_club_remarks
- SET serviceProviderId=#{newSpID}
- WHERE clubId = #{clubID}
- AND serviceProviderId = #{oldSpID}
- </update>
- <select id="ReportList" resultType="com.caimei.modules.user.entity.CmReport">
- SELECT ccr.Id as reportId, p.mainImage AS mainImage,p.`name` AS productName,c.`name` AS clubName,ccr.reportName
- AS reportName,
- ccr.reportText AS reportText,ccr.addTime AS ADDTIME,ccr.status AS STATUS,ccr.auditName AS
- auditName,ccr.auditTime AS auditTime,c.newDeal,ccr.auditText
- FROM cm_club_report ccr
- LEFT JOIN product p ON p.productID = ccr.productID
- LEFT JOIN club c ON c.clubID = ccr.clubID
- <where>
- <if test="reportId!=null and reportId!=''">
- AND ccr.id=#{reportId}
- </if>
- <if test="productName!=null and productName!=''">
- AND p.name LIKE concat('%',#{productName},'%')
- </if>
- <if test="clubID != null">
- c.clubID = #{clubID}
- </if>
- <if test="clubName!=null and clubName!=''">
- AND c.name LIKE concat('%',#{clubName},'%')
- </if>
- <if test="newDeal!=null">
- AND c.newDeal =#{newDeal}
- </if>
- <if test="startAddTime != null and startAddTime != ''">
- and ccr.addTime <![CDATA[ > ]]> #{startAddTime}
- </if>
- <if test="endAddTime != null and endAddTime != ''">
- and ccr.addTime <![CDATA[ < ]]> #{endAddTime}
- </if>
- </where>
- -- group by p.productID
- ORDER BY ccr.`addTime` DESC
- </select>
- <select id="findRegistLists" resultType="com.caimei.modules.user.entity.VisitRemarkVo">
- SELECT DISTINCT
- ccr.id AS remarksId, ccr.remarks,s.name AS spName, ccr.addTime,ccr.questionMan,
- csr.leaderId AS leaderId,IFNULL(ccr.consultType,'') AS
- consult,ccr.clubType,ccr.pinceSensitve,ccr.satisfied,ccr.followup,ccr.extra,
- (SELECT linkMan FROM serviceprovider s WHERE s.serviceProviderID = ccr.serviceProviderId) AS serviceName,
- (SELECT NAME FROM serviceprovider s WHERE s.serviceProviderID = csr.leaderId) AS leaderName,
- (SELECT mainImage FROM product p WHERE p.productID= ccre.productID) AS productMainImage,
- (SELECT NAME FROM product p WHERE p.productID= ccre.productID) AS proName,
- ccre.reportText AS reportText,ccre.status AS reportStatus,ccre.auditName,ccre.auditTime AS auditTime,p.mainImage
- AS mainImage,p.name AS productName,sh.name AS shopName
- FROM cm_visitor_remarks ccr
- 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 cm_club_report ccre ON ccre.Id= ccr.reportID
- LEFT JOIN product p ON p.productID = ccr.productID
- LEFT JOIN shop sh ON sh.shopID = p.shopID
- LEFT JOIN club c ON c.clubID = ccr.clubID
- <where>
- <if test="remarks != null and remarks !=''">
- AND ccr.remarks LIKE concat('%',#{remarks},'%')
- </if>
- <if test="leaderId != null">
- and csr.leaderId = #{leaderId}
- </if>
- <if test="serviceProviderId != null">
- and csg.serviceId = #{serviceProviderId}
- </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="reportID !=null">
- and ccr.reportID=#{reportID}
- </if>
- <if test="newDeal !=null">
- and c.newDeal=#{newDeal}
- </if>
- and ccr.remarks IS NOT NULL
- </where>
- -- group by p.productID
- ORDER BY ADDTIME DESC
- </select>
- <select id="visitorRemarksConut" resultType="integer">
- SELECT COUNT(*)
- FROM cm_visitor_remarks
- WHERE reportID = #{reportID}
- </select>
- <select id="clubRemarksConut" resultType="integer">
- SELECT COUNT(*)
- FROM cm_club_remarks
- WHERE reportID = #{reportID}
- </select>
- <update id="updateAuditRemarks">
- UPDATE cm_club_report
- SET status=#{status},
- auditName=#{auditName},
- auditText=#{auditText},
- auditTime=now()
- WHERE id = #{reportID}
- </update>
- <update id="updateClubRemarks">
- UPDATE cm_club_remarks
- SET reportID=null
- WHERE id = #{remarksId}
- </update>
- <update id="updateVisitorRemarks">
- UPDATE cm_visitor_remarks
- SET reportID=null
- WHERE id = #{remarksId}
- </update>
- <delete id="deleteClubRemarks">
- DELETE
- FROM cm_club_report
- WHERE id = #{reportID}
- </delete>
- <insert id="addRecordLinkage">
- INSERT INTO `record_link`(`describe`, `link`, clubId, addTime)
- VALUES (#{describe}, #{link}, #{clubId}, now())
- </insert>
- <select id="recordLinkage" resultType="string">
- SELECT link
- from record_link
- where clubId = #{clubId}
- ORDER BY id DESC
- LIMIT 1
- </select>
- <select id="recordDescribe" resultType="string">
- SELECT `describe`
- from record_link
- where clubId = #{clubId}
- ORDER BY id DESC
- LIMIT 1
- </select>
- <select id="selRegisterIP" resultType="com.caimei.modules.user.entity.CmBehaviorRecord">
- SELECT u.registerIP, u.ipAddress AS region, u.registerTime
- FROM USER u
- LEFT JOIN club c ON u.userID = c.userID
- WHERE c.clubID = #{clubId}
- </select>
- <select id="selStatisticsList" resultType="com.caimei.modules.user.entity.ClubStatistics">
- SELECT
- u.userId,
- c.clubID,
- c.name,
- c.linkMan,
- c.contractMobile,
- c.linkManIdentity,
- c.address,
- c.businessLicenseImage,
- u.userIdentity,
- c.sname,
- c.contractEmail,
- c.contractPhone,
- c.fax,
- c.headpic,
- c.socialCreditCode,
- c.info,
- (CASE WHEN c.linkManIdentity=1 THEN '老板'
- WHEN c.linkManIdentity=2 THEN '采购'
- WHEN c.linkManIdentity=3 THEN '运营'
- WHEN c.linkManIdentity=4 THEN '其他'
- END) AS linkManStatus,
- (CASE WHEN c.status = 1 THEN '待审核'
- WHEN c.status=91 THEN '已下线'
- WHEN c.status=90 THEN '已上线'
- WHEN c.status=92 THEN '审核未通过'
- WHEN c.status=93 THEN '已确认'
- ELSE '已冻结' END) AS clubStatus,
- (CASE WHEN u.userIdentity=2 THEN '资质机构'
- ELSE '个人机构' END) AS clubRank,
- (CASE WHEN c.firstClubType=1 THEN '医美'
- WHEN c.firstClubType=2 THEN '生美'
- WHEN c.firstClubType=3 THEN '项目公司'
- WHEN c.firstClubType=4 THEN '个人'
- ELSE '其他' END) AS firstClubType,
- (CASE WHEN c.secondClubType=1 THEN '诊所'
- WHEN c.secondClubType=2 THEN '门诊'
- WHEN c.secondClubType=3 THEN '医院'
- WHEN c.secondClubType=5 THEN '美容院'
- WHEN c.secondClubType=6 THEN '养生馆'
- WHEN c.secondClubType=7 THEN '其他'
- END) AS classify,
- c.addTime AS addTime,
- IF(csu.delFlag = '0' AND NOW() <![CDATA[ < ]]> csu.endTime,1,0) AS svipUserFlag,
- case sp.status when 91 then '采美默认协销经理(官方账号)' else sp.linkMan end AS spName,
- IFNULL(orderMonth.payTotalMonth,0) AS payTotalMonth,
- IFNULL(orderMonth.orderCountMonth,0) AS orderCountMonth,
- IFNULL(orderYesr.payTotalYesr,0) AS payTotalYear,
- IFNULL(orderYesr.orderCountYesr,0) AS orderCountYear,
- IFNULL(orderTotal.payTotal,0) AS payTotal,
- ordr.lastOrderTime AS lastOrderTime
- FROM club c
- # LEFT JOIN cm_order cor ON c.userID = cor.userID
- LEFT JOIN USER u ON u.userId=c.userId
- LEFT JOIN cm_svip_user csu ON csu.userId = u.userID
- LEFT JOIN serviceprovider sp ON sp.serviceProviderID = c.spID
- LEFT JOIN
- (SELECT userId,SUM(co.payTotalFee) AS payTotalMonth,
- COUNT(co.orderid) AS orderCountMonth
- FROM cm_order co
- <where>
- co.status NOT IN (0,6,7)
- <if test="monthStartTime != null and monthStartTime != '' and monthEndTime != null and monthEndTime != ''">
- AND co.orderTime BETWEEN #{monthStartTime} AND #{monthEndTime}
- </if>
- </where>
- GROUP BY co.userid) AS orderMonth ON c.userId=orderMonth.userId
- LEFT JOIN
- (SELECT userId,SUM(co.payTotalFee) AS payTotalYesr,
- COUNT(co.orderid) AS orderCountYesr
- FROM cm_order co
- <where>
- co.status NOT IN (0,6,7)
- <if test="yearStartTime != null and yearStartTime != '' and yearEndTime != null and yearEndTime != ''">
- AND co.orderTime BETWEEN #{yearStartTime} AND #{yearEndTime}
- </if>
- </where>
- GROUP BY co.userid) AS orderYesr ON c.userId=orderYesr.userId
- LEFT JOIN
- (SELECT userId,SUM(co.payTotalFee) AS payTotal,
- COUNT(co.orderid) AS 21OrderCount
- FROM cm_order co
- <where>
- co.status NOT IN (0,6,7)
- <if test="customStartTime != null and customStartTime != ''">
- AND (co.orderTime > #{customStartTime} or co.orderTime = #{customStartTime})
- </if>
- <if test="customEndTime != null and customEndTime != ''">
- AND co.orderTime <![CDATA[ <= ]]> #{customEndTime}
- </if>
- </where>
- GROUP BY co.userid) AS orderTotal ON c.userId=orderTotal.userId
- LEFT JOIN (
- SELECT userID, MAX(orderTime) AS lastOrderTime FROM cm_order GROUP BY userID
- ) AS ordr ON c.userID = ordr.userID
- <where>
- u.userOrganizeID != 4
- <if test="registerStartTime != null and registerStartTime != ''">
- AND (c.addTime > #{registerStartTime} or c.addTime = #{registerStartTime} )
- </if>
- <if test="registerEndTime != null and registerEndTime != ''">
- AND c.addTime <![CDATA[ <= ]]> #{registerEndTime}
- </if>
- <if test="searchStartTime != null and searchStartTime != ''">
- AND (ordr.lastOrderTime > #{searchStartTime} or ordr.lastOrderTime = #{searchStartTime} )
- </if>
- <if test=" searchEndTime != null and searchEndTime != ''">
- AND ordr.lastOrderTime <![CDATA[ <= ]]> #{searchEndTime}
- </if>
- <if test="customerValue != null and customerValue != ''">
- AND c.firstClubType = #{customerValue}
- </if>
- <if test="searchUserIdentity != null and searchUserIdentity != '' and searchUserIdentity != '8'.toString()">
- AND u.userIdentity = #{searchUserIdentity}
- </if>
- <if test="searchUserIdentity != null and searchUserIdentity != '' and searchUserIdentity == '8'.toString()">
- AND csu.delFlag = '0' and now() <![CDATA[ < ]]> csu.endTime
- </if>
- <if test="searchStatus != null and searchStatus != ''">
- AND c.status = #{searchStatus}
- </if>
- <if test="linkManIdentity != null and linkManIdentity != ''">
- AND c.linkManIdentity = #{linkManIdentity}
- </if>
- <if test="payTotalMonth != null and payTotalMonth != ''">
- <if test="payTotalMonth==1">
- AND orderMonth.payTotalMonth <![CDATA[ < ]]> 10000
- </if>
- <if test="payTotalMonth==2">
- AND orderMonth.payTotalMonth BETWEEN 10000 AND 100000
- </if>
- <if test="payTotalMonth==3">
- AND orderMonth.payTotalMonth BETWEEN 100000 AND 1000000
- </if>
- <if test="payTotalMonth==4">
- AND orderMonth.payTotalMonth <![CDATA[ > ]]> 1000000
- </if>
- </if>
- <if test="payTotalYear != null and payTotalYear != ''">
- <if test="payTotalYear==1">
- AND orderYesr.payTotalYesr <![CDATA[ < ]]> 10000
- </if>
- <if test="payTotalYear==2">
- AND orderYesr.payTotalYesr BETWEEN 10000 AND 100000
- </if>
- <if test="payTotalYear==3">
- AND orderYesr.payTotalYesr BETWEEN 100000 AND 1000000
- </if>
- <if test="payTotalYear==4">
- AND orderYesr.payTotalYesr <![CDATA[ > ]]> 1000000
- </if>
- </if>
- <if test="payTotal != null and payTotal != ''">
- <if test="payTotal==1">
- AND orderTotal.payTotal <![CDATA[ < ]]> 10000
- </if>
- <if test="payTotal==2">
- AND orderTotal.payTotal BETWEEN 10000 AND 100000
- </if>
- <if test="payTotal==3">
- AND orderTotal.payTotal BETWEEN 100000 AND 1000000
- </if>
- <if test="payTotal==4">
- AND orderTotal.payTotal <![CDATA[ > ]]> 1000000
- </if>
- </if>
- </where>
- GROUP BY c.userID ORDER BY
- <if test="payTotalMonthType == null and orderCountMonthType == null and payTotalYearType == null and orderCountYearType == null and payTotalType == null">
- ordr.lastOrderTime DESC
- </if>
- <if test="orderCountMonthType != null">
- <if test="orderCountMonthType == 0">
- orderMonth.orderCountMonth
- </if>
- <if test="orderCountMonthType == 1">
- orderMonth.orderCountMonth DESC
- </if>
- </if>
- <if test="orderCountYearType != null">
- <if test="orderCountYearType == 0">
- orderYesr.orderCountYesr
- </if>
- <if test="orderCountYearType == 1">
- orderYesr.orderCountYesr DESC
- </if>
- </if>
- <if test="payTotalMonthType != null">
- <if test="payTotalMonthType == 0">
- orderMonth.payTotalMonth
- </if>
- <if test="payTotalMonthType == 1">
- orderMonth.payTotalMonth DESC
- </if>
- </if>
- <if test="payTotalYearType != null">
- <if test="payTotalYearType == 0">
- orderYesr.payTotalYesr
- </if>
- <if test="payTotalYearType == 1">
- orderYesr.payTotalYesr DESC
- </if>
- </if>
- <if test="payTotalType != null">
- <if test="payTotalType == 0">
- orderTotal.payTotal
- </if>
- <if test="payTotalType == 1">
- orderTotal.payTotal DESC
- </if>
- </if>
- </select>
- <select id="selPageLable" resultType="com.caimei.modules.user.entity.CmBehaviorRecord">
- SELECT c.userID, COUNT(pageType) AS number, cbr.pageLabel
- FROM club c
- LEFT JOIN cm_behavior_record cbr ON cbr.userID = c.userID
- WHERE cbr.userID = c.userID
- AND cbr.pageType in (8, 9)
- GROUP BY c.userID, cbr.pageLabel
- </select>
- <select id="findExcelList" resultType="com.caimei.modules.user.entity.easyExcel">
- SELECT
- u.userId,
- c.clubID,
- c.name,
- c.linkMan,
- c.contractMobile,
- c.linkManIdentity,
- c.address,
- c.businessLicenseImage,
- u.userIdentity,
- c.sname,
- c.contractEmail,
- c.contractPhone,
- c.fax,
- c.headpic,
- c.socialCreditCode,
- c.info,
- (CASE WHEN c.linkManIdentity=1 THEN '老板'
- WHEN c.linkManIdentity=2 THEN '采购'
- WHEN c.linkManIdentity=3 THEN '运营'
- WHEN c.linkManIdentity=4 THEN '其他'
- END) AS linkManStatus,
- (CASE WHEN c.status = 1 THEN '待审核'
- WHEN c.status=91 THEN '已下线'
- WHEN c.status=90 THEN '已上线'
- WHEN c.status=92 THEN '审核未通过'
- WHEN c.status=93 THEN '已确认'
- ELSE '已冻结' END) AS clubStatus,
- (CASE WHEN u.userIdentity=2 THEN '资质机构'
- ELSE '个人机构' END) AS clubRank,
- (CASE WHEN c.firstClubType=1 THEN '医美'
- WHEN c.firstClubType=2 THEN '生美'
- WHEN c.firstClubType=3 THEN '项目公司'
- WHEN c.firstClubType=4 THEN '个人'
- ELSE '其他' END) AS firstClubType,
- (CASE WHEN c.secondClubType=1 THEN '诊所'
- WHEN c.secondClubType=2 THEN '门诊'
- WHEN c.secondClubType=3 THEN '医院'
- WHEN c.secondClubType=5 THEN '美容院'
- WHEN c.secondClubType=6 THEN '养生馆'
- WHEN c.secondClubType=7 THEN '其他'
- END) AS classify,
- c.addTime AS addTime,
- IF(csu.delFlag = '0' AND NOW() <![CDATA[ < ]]> csu.endTime,1,0) AS svipUserFlag,
- case sp.status when 91 then '采美默认协销经理(官方账号)' else sp.linkMan end AS spName,
- IFNULL(orderMonth.payTotalMonth,0) AS payTotalMonth,
- IFNULL(orderMonth.orderCountMonth,0) AS orderCountMonth,
- IFNULL(orderYesr.payTotalYesr,0) AS payTotalYear,
- IFNULL(orderYesr.orderCountYesr,0) AS orderCountYear,
- IFNULL(orderTotal.payTotal,0) AS payTotal,
- pb.pageLabel,
- ordr.lastOrderTime AS lastOrderTime
- FROM club c
- # LEFT JOIN cm_order cor ON c.userID = cor.userID
- LEFT JOIN USER u ON u.userId=c.userId
- LEFT JOIN cm_svip_user csu ON csu.userId = u.userID
- LEFT JOIN serviceprovider sp ON sp.serviceProviderID = c.spID
- LEFT JOIN
- (SELECT userId,SUM(co.payTotalFee) AS payTotalMonth,
- COUNT(co.orderid) AS orderCountMonth
- FROM cm_order co
- <where>
- co.status NOT IN (0,6,7)
- <if test="monthStartTime != null and monthStartTime != '' and monthEndTime != null and monthEndTime != ''">
- AND co.orderTime BETWEEN #{monthStartTime} AND #{monthEndTime}
- </if>
- </where>
- GROUP BY co.userid) AS orderMonth ON c.userId=orderMonth.userId
- LEFT JOIN
- (SELECT userId,SUM(co.payTotalFee) AS payTotalYesr,
- COUNT(co.orderid) AS orderCountYesr
- FROM cm_order co
- <where>
- co.status NOT IN (0,6,7)
- <if test="yearStartTime != null and yearStartTime != '' and yearEndTime != null and yearEndTime != ''">
- AND co.orderTime BETWEEN #{yearStartTime} AND #{yearEndTime}
- </if>
- </where>
- GROUP BY co.userid) AS orderYesr ON c.userId=orderYesr.userId
- LEFT JOIN
- (SELECT userId,SUM(co.payTotalFee) AS payTotal,
- COUNT(co.orderid) AS 21OrderCount
- FROM cm_order co
- <where>
- co.status NOT IN (0,6,7)
- <if test="customStartTime != null and customStartTime != ''">
- AND (co.orderTime > #{customStartTime} or co.orderTime = #{customStartTime})
- </if>
- <if test="customEndTime != null and customEndTime != ''">
- AND co.orderTime <![CDATA[ <= ]]> #{customEndTime}
- </if>
- </where>
- GROUP BY co.userid) AS orderTotal ON c.userId=orderTotal.userId
- LEFT JOIN
- (
- SELECT c.userID, COUNT(cbr.pageLabel), cbr.pageLabel
- FROM cm_behavior_record cbr
- LEFT JOIN club c ON cbr.userID = c.userID
- <where>cbr.userID = c.userID</where>
- GROUP BY cbr.pageLabel) AS pb ON c.userID = pb.userID
- LEFT JOIN (
- SELECT userID, MAX(orderTime) AS lastOrderTime FROM cm_order GROUP BY userID
- ) AS ordr ON c.userID = ordr.userID
- <where>
- <if test="registerStartTime != null and registerStartTime != ''">
- AND (c.addTime > #{registerStartTime} or c.addTime = #{registerStartTime} )
- </if>
- <if test="registerEndTime != null and registerEndTime != ''">
- AND c.addTime <![CDATA[ <= ]]> #{registerEndTime}
- </if>
- <if test="searchStartTime != null and searchStartTime != ''">
- AND (ordr.lastOrderTime > #{searchStartTime} or ordr.lastOrderTime = #{searchStartTime} )
- </if>
- <if test=" searchEndTime != null and searchEndTime != ''">
- AND ordr.lastOrderTime <![CDATA[ <= ]]> #{searchEndTime}
- </if>
- <if test="customerValue != null and customerValue != ''">
- AND c.firstClubType = #{customerValue}
- </if>
- <if test="searchUserIdentity != null and searchUserIdentity != '' and searchUserIdentity != '8'.toString()">
- AND u.userIdentity = #{searchUserIdentity}
- </if>
- <if test="searchUserIdentity != null and searchUserIdentity != '' and searchUserIdentity == '8'.toString()">
- AND csu.delFlag = '0' and now() <![CDATA[ < ]]> csu.endTime
- </if>
- <if test="searchStatus != null and searchStatus != ''">
- AND c.status = #{searchStatus}
- </if>
- <if test="linkManIdentity != null and linkManIdentity != ''">
- AND c.linkManIdentity = #{linkManIdentity}
- </if>
- <if test="searchStatus != null and searchStatus != ''">
- AND c.status = #{searchStatus}
- </if>
- <if test="payTotalMonth != null and payTotalMonth != ''">
- <if test="payTotalMonth==1">
- AND orderMonth.payTotalMonth <![CDATA[ < ]]> 10000
- </if>
- <if test="payTotalMonth==2">
- AND orderMonth.payTotalMonth BETWEEN 10000 AND 100000
- </if>
- <if test="payTotalMonth==3">
- AND orderMonth.payTotalMonth BETWEEN 100000 AND 1000000
- </if>
- <if test="payTotalMonth==4">
- AND orderMonth.payTotalMonth <![CDATA[ > ]]> 1000000
- </if>
- </if>
- <if test="payTotalYear != null and payTotalYear != ''">
- <if test="payTotalYear==1">
- AND orderYesr.payTotalYesr <![CDATA[ < ]]> 10000
- </if>
- <if test="payTotalYear==2">
- AND orderYesr.payTotalYesr BETWEEN 10000 AND 100000
- </if>
- <if test="payTotalYear==3">
- AND orderYesr.payTotalYesr BETWEEN 100000 AND 1000000
- </if>
- <if test="payTotalYear==4">
- AND orderYesr.payTotalYesr <![CDATA[ > ]]> 1000000
- </if>
- </if>
- <if test="payTotal != null and payTotal != ''">
- <if test="payTotal==1">
- AND orderTotal.payTotal <![CDATA[ < ]]> 10000
- </if>
- <if test="payTotal==2">
- AND orderTotal.payTotal BETWEEN 10000 AND 100000
- </if>
- <if test="payTotal==3">
- AND orderTotal.payTotal BETWEEN 100000 AND 1000000
- </if>
- <if test="payTotal==4">
- AND orderTotal.payTotal <![CDATA[ > ]]> 1000000
- </if>
- </if>
- </where>
- GROUP BY c.userID ORDER BY ordr.lastOrderTime DESC
- </select>
- <select id="getClubIds" resultType="String">
- SELECT
- a.clubID
- FROM club a
- <include refid="newCmClubJoins"/>
- <where>
- AND a.status =90 and u.userOrganizeID IN(0,1) AND u.userIdentity != 8
- </where>
- </select>
- <select id="getActiveClubInfo" resultType="com.caimei.modules.user.entity.ActiveClub">
- SELECT
- DISTINCT u.userId,
- coas.activeStatus,
- c.clubID,
- c.name,
- c.linkMan,
- c.contractMobile,
- c.linkManIdentity,
- c.address,
- u.userIdentity,
- u.registerTime,
- c.sname,
- c.info,
- d.name AS province,
- c.name AS city,
- b.name AS town,
- (CASE WHEN c.linkManIdentity=1 THEN '老板'
- WHEN c.linkManIdentity=2 THEN '采购'
- WHEN c.linkManIdentity=3 THEN '运营'
- WHEN c.linkManIdentity=4 THEN '其他'
- END) AS linkManStatus,
- (CASE WHEN c.status = 1 THEN '待审核'
- WHEN c.status=91 THEN '已下线'
- WHEN c.status=90 THEN '已上线'
- WHEN c.status=92 THEN '审核未通过'
- WHEN c.status=93 THEN '已确认'
- ELSE '已冻结' END) AS clubStatus,
- (CASE WHEN u.userIdentity=2 THEN '资质机构'
- ELSE '个人机构' END) AS clubRank,
- (CASE WHEN c.firstClubType=1 THEN '医美'
- WHEN c.firstClubType=2 THEN '生美'
- WHEN c.firstClubType=3 THEN '项目公司'
- WHEN c.firstClubType=4 THEN '个人'
- ELSE '其他' END) AS firstClubType,
- (CASE WHEN c.secondClubType=1 THEN '诊所'
- WHEN c.secondClubType=2 THEN '门诊'
- WHEN c.secondClubType=3 THEN '医院'
- WHEN c.secondClubType=5 THEN '美容院'
- WHEN c.secondClubType=6 THEN '养生馆'
- WHEN c.secondClubType=7 THEN '其他'
- END) AS classify,
- c.addTime AS addTime,
- IF(csu.delFlag = '0' AND NOW() <![CDATA[ < ]]> csu.endTime,1,0) AS svipUserFlag,
- CASE sp.status WHEN 91 THEN '采美默认协销经理(官方账号)' ELSE sp.linkMan END AS spName,
- cb.accessTime AS behaviorTime,
- ccr.addTime AS recentlyTime,
- cso.orderTime as lastOrderTime
- FROM club c
- LEFT JOIN cm_organ_active_system coas ON coas.userId = c.userID
- LEFT JOIN USER u ON u.userId = c.userId
- LEFT JOIN cm_svip_user csu ON csu.userId = u.userID
- LEFT JOIN serviceprovider sp ON sp.serviceProviderID = c.spID
- LEFT JOIN town b ON b.townID = c.townID
- LEFT JOIN city ct ON ct.cityID = c.cityID
- LEFT JOIN province d ON d.provinceID = c.provinceID
- LEFT JOIN (SELECT userId, MAX(accessTime) AS accessTime FROM cm_behavior_record WHERE delFlag = 0 AND userId != 0 GROUP BY userId) cb ON cb.userId = c.userId
- LEFT JOIN (SELECT clubId, ADDTIME FROM (SELECT clubId, ADDTIME FROM cm_club_remarks
- UNION SELECT clubId, ADDTIME FROM cm_visitor_remarks WHERE clubId IS NOT NULL AND clubId != '') remark
- GROUP BY remark.clubId ORDER BY remark.addTime DESC) ccr ON ccr.clubId = c.clubId
- LEFT JOIN (SELECT userId, MAX(orderTime) AS orderTime FROM cm_shop_order GROUP BY userId) cso ON cso.userId = c.userId
- <where>
- coas.stage = 0
- <if test="activeStatus == 0">
- and coas.activeStatus = 0
- </if>
- <if test="activeStatus == 1">
- and coas.activeStatus = 1
- </if>
- <if test="clubID != null and clubID != ''">
- AND c.clubID = #{clubID}
- </if>
- <if test="name != null and name != ''">
- AND c.name LIKE concat('%',#{name},'%')
- </if>
- <if test="linkMan != null and linkMan != ''">
- AND c.linkMan LIKE concat('%',#{linkMan},'%')
- </if>
- <if test="contractMobile != null and contractMobile != ''">
- AND c.contractMobile LIKE concat('%',#{contractMobile},'%')
- </if>
- <if test="spID != null and spID != ''">
- AND c.spID = #{spID}
- </if>
- <if test="firstClubType != null and firstClubType != ''">
- AND c.firstClubType = #{firstClubType}
- </if>
- <if test="linkManIdentity != null and linkManIdentity != ''">
- AND c.linkManIdentity = #{linkManIdentity}
- </if>
- <if test="userIdentity != null and userIdentity != ''">
- AND u.userIdentity = #{userIdentity}
- </if>
- <if test="registerStartTime != null and registerStartTime != ''">
- AND u.registerTime <![CDATA[ >= ]]> #{registerStartTime}
- </if>
- <if test="registerEndTime != null and registerEndTime != ''">
- AND u.registerTime <![CDATA[ <= ]]> #{registerEndTime}
- </if>
- <if test="behaviorStartTime != null and behaviorStartTime != ''">
- AND cb.accessTime <![CDATA[ >= ]]> #{behaviorStartTime}
- </if>
- <if test="behaviorEndTime != null and behaviorEndTime != ''">
- AND cb.accessTime <![CDATA[ <= ]]> #{behaviorEndTime}
- </if>
- <if test="recentlyStartTime != null and recentlyStartTime != ''">
- AND ccr.addTime <![CDATA[ >= ]]> #{recentlyStartTime}
- </if>
- <if test="recentlyEndTime != null and recentlyEndTime != ''">
- AND ccr.addTime <![CDATA[ <= ]]> #{recentlyEndTime}
- </if>
- <if test="orderStartTime != null and orderStartTime != ''">
- AND cso.orderTime <![CDATA[ >= ]]> #{orderStartTime}
- </if>
- <if test="orderEndTime != null and orderEndTime != ''">
- AND cso.orderTime <![CDATA[ <= ]]> #{orderEndTime}
- </if>
- </where>
- <if test="orderByType == null or orderByType == 1">
- ORDER BY cb.accessTime DESC
- </if>
- <if test="orderByType == 2">
- ORDER BY cb.accessTime asc
- </if>
- </select>
- <select id="getTouristClubInfo" resultType="com.caimei.modules.user.entity.ActiveClub">
- SELECT
- cvr.id,
- cvr.serviceProviderId as spId,
- s.linkMan as spLinkMan,
- cvr.questionMan,
- cvr.addTime as visAddTime
- FROM cm_visitor_remarks cvr
- LEFT JOIN serviceprovider s ON s.serviceProviderID = cvr.serviceProviderId
- <where>
- cvr.clubId IS NULL OR cvr.clubId = '' and cvr.addTime <![CDATA[ >= ]]> #{visAddTime}
- <if test="recentlyStartTime != null and recentlyStartTime != ''">
- AND cvr.addTime <![CDATA[ >= ]]> #{recentlyStartTime}
- </if>
- <if test="recentlyEndTime != null and recentlyEndTime != ''">
- AND cvr.addTime <![CDATA[ <= ]]> #{recentlyEndTime}
- </if>
- </where>
- <if test="orderByType == null or orderByType == 1">
- ORDER BY cvr.addTime DESC
- </if>
- <if test="orderByType == 2">
- ORDER BY cvr.addTime asc
- </if>
- </select>
- <select id="getBehaviorInfo" resultType="com.caimei.modules.user.entity.CmBehaviorInfo">
- SELECT
- cbi.id,
- cbi.operateObject,
- cbi.clubId,
- cbi.spId,
- cbi.type,
- cbi.pageType,
- cbi.label,
- cbi.pagePath,
- cbi.productId,
- cbi.shopOrderId,
- cbi.allocation,
- cbi.addTime,
- cbi.delFlag,
- (CASE WHEN c.name IS NOT NULL THEN c.name
- WHEN c.name IS NULL OR c.name = '' THEN c.linkMan END) AS clubName,
- s.linkMan AS spName,
- (SELECT COUNT(recordId) FROM cm_behavior_record WHERE userId = c.userId AND accessDate = cbi.dateTime) AS number,
- p.name AS productName
- FROM cm_behavior_info cbi
- LEFT JOIN club c ON c.clubId = cbi.clubId
- LEFT JOIN serviceprovider s ON s.serviceProviderID = cbi.spId
- LEFT JOIN product p ON p.productId = cbi.productId
- <where>
- cbi.delFlag = 0
- <if test="operateObject != null">
- and cbi.operateObject = #{operateObject}
- </if>
- <if test="clubId != null">
- and c.clubId = #{clubId}
- </if>
- <if test="spId != null">
- and s.serviceProviderID = #{spId}
- </if>
- <if test="spName != null and spName != ''">
- and s.name like concat('%', #{spName}, '%')
- </if>
- <if test="type != null">
- and cbi.type = #{type}
- </if>
- <if test="behaviorStartTime != null and behaviorStartTime != ''">
- AND cbi.addTime <![CDATA[ >= ]]> #{behaviorStartTime}
- </if>
- <if test="behaviorEndTime != null and behaviorEndTime != ''">
- AND cbi.addTime <![CDATA[ <= ]]> #{behaviorEndTime}
- </if>
- </where>
- </select>
- </mapper>
|