| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051 |
- <?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.goafanti.common.dao.UserMapper">
- <select id="selectPersonalCustomerList" resultType="com.goafanti.customer.bo.CustomerListOut">
- select
- a.id as uid,
- a.identify_name as name,
- date_format(a.create_time,'%Y-%m-%d %H:%i:%S') as createTime,
- dg1.name as province,
- dg2.name as city,
- dg3.name as area,
- d.name as adminName
- from user a
- left join user_identity b on a.id = b.uid
- left join district_glossory dg1 on b.province = dg1.id
- left join district_glossory dg2 on b.city = dg2.id
- left join district_glossory dg3 on b.area = dg3.id
- left join admin d on a.aid = d.id
- where a.type = 0 and a.status != 1
- <if test="aid != null and aid !=''">
- and a.aid = #{aid,jdbcType=VARCHAR}
- </if>
- <if test="name != null and name != ''">
- and a.identify_name like concat('%',#{name},'%')
- </if>
- <if test="startDate != null and startDate != ''">
- and a.transfer_time > #{startDate}
- </if>
- <if test="endDate != null and endDate != ''">
- and a.transfer_time < #{endDate}
- </if>
- <if test="province != null">
- and b.province = #{province,jdbcType=INTEGER}
- </if>
- <if test="city != null">
- and b.city = #{city,jdbcType=INTEGER}
- </if>
- <if test="area != null">
- and b.area = #{area,jdbcType=INTEGER}
- </if>
- <if test="page_sql != null">
- ${page_sql}
- </if>
- </select>
- <select id="selectPersonalCustomerCount" resultType="java.lang.Integer">
- select
- count(0)
- from user a
- left join user_identity b on a.id = b.uid
- left join district_glossory dg1 on b.province = dg1.id
- left join district_glossory dg2 on b.city = dg2.id
- left join district_glossory dg3 on b.area = dg3.id
- left join admin d on a.aid = d.id
- where a.type = 0 and a.status != 1
- <if test="aid != null and aid !=''">
- and a.aid = #{aid,jdbcType=VARCHAR}
- </if>
- <if test="name != null and name != ''">
- and a.identify_name like concat('%',#{name},'%')
- </if>
- <if test="startDate != null and startDate != ''">
- and a.transfer_time > #{startDate}
- </if>
- <if test="endDate != null and endDate != ''">
- and a.transfer_time < #{endDate}
- </if>
- <if test="province != null">
- and b.province = #{province,jdbcType=INTEGER}
- </if>
- <if test="city != null">
- and b.city = #{city,jdbcType=INTEGER}
- </if>
- <if test="area != null">
- and b.area = #{area,jdbcType=INTEGER}
- </if>
- </select>
- <select id="selectPrivatePersonalCustomerList" resultType="com.goafanti.customer.bo.CustomerListOut">
- select t0.id as uid,
- t0.aid,
- date_format(t0.transfer_time,'%Y-%m-%d %H:%i:%S') as transferTime,
- date_format(t0.create_time,'%Y-%m-%d %H:%i:%S') as createTime,
- t0.identify_name as name,
- t0.society_tag as societyTag,
- date_format(t1.last_follow_time,'%Y-%m-%d %H:%i:%S') as lastFollowTime,
- date_format(t2.last_sign_time,'%Y-%m-%d %H:%i:%S') as lastSignTime,
- b.contacts,
- b.contact_mobile as contactMobile,
- dg1.name as province,
- dg2.name as city,
- dg3.name as area,
- ifnull(t1.last_follow_time,t0.transfer_time) as orderTime,
- c.name as industry,
- d.name as adminName
- from
- (select id,aid,type,share_type,create_time,transfer_time,identify_name,society_tag from user where aid = #{aid} and type = 0 and share_type = 0 and status != 1)t0
- left join
- (select uid,aid,max(create_time) as last_follow_time from user_follow where aid = #{aid} group by uid)t1
- on t0.id = t1.uid left join
- (select aid,uid,max(lock_time) as last_sign_time from user_lock_release where aid = #{aid} group by uid)t2
- on t0.id = t2.uid
- left join user_identity b on t0.id = b.uid
- left join district_glossory dg1 on b.province = dg1.id
- left join district_glossory dg2 on b.city = dg2.id
- left join district_glossory dg3 on b.area = dg3.id
- left join industry_category c on b.industry = c.id
- left join admin d on t0.aid = d.id where 1=1
- <if test="name != null and name != ''">
- and t0.identify_name like concat('%',#{name},'%')
- </if>
- <if test="startDate != null and startDate != ''">
- and t0.transfer_time > #{startDate}
- </if>
- <if test="endDate != null and endDate != ''">
- and t0.transfer_time < #{endDate}
- </if>
- <if test="province != null">
- and b.province = #{province,jdbcType=INTEGER}
- </if>
- <if test="city != null">
- and b.city = #{city,jdbcType=INTEGER}
- </if>
- <if test="area != null">
- and b.area = #{area,jdbcType=INTEGER}
- </if>
- order by orderTime
- <if test="page_sql != null">
- ${page_sql}
- </if>
- </select>
- <select id="selectPrivatePersonalCustomerCount" resultType="java.lang.Integer">
- select count(0)
- from
- (select id,aid,type,share_type,transfer_time,identify_name,society_tag from user where aid = #{aid} and type = 0 and share_type = 0 and status != 1)t0
- left join user_identity b on t0.id = b.uid where 1=1
- <if test="name != null and name != ''">
- and t0.identify_name like concat('%',#{name},'%')
- </if>
- <if test="startDate != null and startDate != ''">
- and t0.transfer_time > #{startDate}
- </if>
- <if test="endDate != null and endDate != ''">
- and t0.transfer_time < #{endDate}
- </if>
- <if test="province != null">
- and b.province = #{province,jdbcType=INTEGER}
- </if>
- <if test="city != null">
- and b.city = #{city,jdbcType=INTEGER}
- </if>
- <if test="area != null">
- and b.area = #{area,jdbcType=INTEGER}
- </if>
- </select>
- <select id="selectPublicPersonalCustomerList" resultType="com.goafanti.customer.bo.CustomerListOut">
- select
- a.id as uid,
- a.aid,
- a.identify_name as name,
- a.create_time as createTime,
- a.transfer_time as transferTime,
- b.contacts,
- b.contact_mobile as contactMobile,
- dg1.name as province,
- dg2.name as city,
- dg3.name as area
- from
- user a inner join user_identity b on a.id = b.uid
- left join district_glossory dg1 on b.province = dg1.id
- left join district_glossory dg2 on b.city = dg2.id
- left join district_glossory dg3 on b.area = dg3.id
- where
- a.type = 0 and a.share_type = 1 and a.status != 1
- <if test="aid != null and aid !=''">
- and a.aid = #{aid,jdbcType=VARCHAR}
- </if>
- <if test="name != null and name != ''">
- and a.identify_name like concat('%',#{name},'%')
- </if>
- <if test="startDate != null and startDate != ''">
- and a.transfer_time > #{startDate}
- </if>
- <if test="endDate != null and endDate != ''">
- and a.transfer_time < #{endDate}
- </if>
- <if test="province != null">
- and b.province = #{province,jdbcType=INTEGER}
- </if>
- <if test="city != null">
- and b.city = #{city,jdbcType=INTEGER}
- </if>
- <if test="area != null">
- and b.area = #{area,jdbcType=INTEGER}
- </if>
- order by a.create_time
- <if test="page_sql != null">
- ${page_sql}
- </if>
- </select>
- <select id="selectPublicPersonalCustomerCount" resultType="java.lang.Integer">
- select
- count(0)
- from
- user a inner join user_identity b on a.id = b.uid
- left join district_glossory dg1 on b.province = dg1.id
- left join district_glossory dg2 on b.city = dg2.id
- left join district_glossory dg3 on b.area = dg3.id
- where
- a.type = 0 and a.share_type = 1 and a.status != 1
- <if test="aid != null and aid !=''">
- and a.aid = #{aid,jdbcType=VARCHAR}
- </if>
- <if test="name != null and name != ''">
- and a.identify_name like concat('%',#{name},'%')
- </if>
- <if test="startDate != null and startDate != ''">
- and a.transfer_time > #{startDate}
- </if>
- <if test="endDate != null and endDate != ''">
- and a.transfer_time < #{endDate}
- </if>
- <if test="province != null">
- and b.province = #{province,jdbcType=INTEGER}
- </if>
- <if test="city != null">
- and b.city = #{city,jdbcType=INTEGER}
- </if>
- <if test="area != null">
- and b.area = #{area,jdbcType=INTEGER}
- </if>
-
- </select>
- <select id="selectSignPersonalCustomerList" resultType="com.goafanti.customer.bo.CustomerListOut">
- select
- t0.uid as uid,
- date_format(t0.update_time,'%Y-%m-%d %H:%i:%S') as lastSignTime,
- date_format(t1.last_follow_time,'%Y-%m-%d %H:%i:%S') as lastFollowTime,
- t2.society_tag as societyTag,
- t2.identify_name as name,
- t2.share_type as shareType,
- date_format(t2.transfer_time,'%Y-%m-%d %H:%i:%S') as transferTime,
- dg1.name as province,
- dg2.name as city,
- dg3.name as area,
- b.contacts,
- b.contact_mobile as contactMobile,
- c.name as industry,
- d.name as adminName
- from
- (select uid,aid,max(lock_time) as update_time
- from user_lock_release
- where type=1 and aid= #{aid,jdbcType=VARCHAR}
- group by uid)t0
- left join
- (select uid,aid,max(create_time) as last_follow_time from user_follow where aid =#{aid,jdbcType=VARCHAR} group by uid)t1
- on t0.uid = t1.uid
- inner join
- (select id,aid,share_type,society_tag,identify_name,transfer_time from user where type = 0 and status != 1)t2
- on t0.uid = t2.id
- left join user_identity b on t0.uid = b.uid
- left join district_glossory dg1 on b.province = dg1.id
- left join district_glossory dg2 on b.city = dg2.id
- left join district_glossory dg3 on b.area = dg3.id
- left join industry_category c on b.industry = c.id
- left join admin d on t2.aid = d.id where 1 = 1
- <if test="name != null and name != ''">
- and t2.identify_name like concat('%',#{name},'%')
- </if>
- <if test="shareType != null">
- and t2.share_type = #{shareType,jdbcType=VARCHAR}
- </if>
- <if test="startDate != null and startDate != ''">
- and t2.transfer_time > #{startDate}
- </if>
- <if test="endDate != null and endDate != ''">
- and t2.transfer_time < #{endDate}
- </if>
- <if test="province != null">
- and b.province = #{province,jdbcType=INTEGER}
- </if>
- <if test="city != null">
- and b.city = #{city,jdbcType=INTEGER}
- </if>
- <if test="area != null">
- and b.area = #{area,jdbcType=INTEGER}
- </if>
- <if test="page_sql != null">
- ${page_sql}
- </if>
- </select>
- <select id="selectSignPersonalCustomerCount" resultType="java.lang.Integer">
- select
- count(0)
- from
- (select uid,aid,max(lock_time) as update_time
- from user_lock_release
- where type=1 and aid= #{aid,jdbcType=VARCHAR}
- group by uid)t0
- <!-- (select uid,max(lock_time) from user_lock_release where aid = #{aid} and type = 1 and status = 0 group by uid)t0 -->
- inner join
- (select id,aid,share_type,society_tag,identify_name,transfer_time from user where type = 0 and status != 1)t2
- on t0.uid = t2.id
- left join user_identity b on t0.uid = b.uid
- where 1 = 1
- <if test="name != null and name != ''">
- and t2.identify_name like concat('%',#{name},'%')
- </if>
- <if test="shareType != null">
- and t2.share_type = #{shareType,jdbcType=VARCHAR}
- </if>
- <if test="startDate != null and startDate != ''">
- and t2.transfer_time > #{startDate}
- </if>
- <if test="endDate != null and endDate != ''">
- and t2.transfer_time < #{endDate}
- </if>
- <if test="province != null">
- and b.province = #{province,jdbcType=INTEGER}
- </if>
- <if test="city != null">
- and b.city = #{city,jdbcType=INTEGER}
- </if>
- <if test="area != null">
- and b.area = #{area,jdbcType=INTEGER}
- </if>
- </select>
-
- <select id="selectOrganizationCustomerList" resultType="com.goafanti.customer.bo.CustomerListOut">
- select
- a.id as uid,
- a.identify_name as name,
- date_format(a.create_time,'%Y-%m-%d %H:%i:%S') as createTime,
- dg1.name as province,
- dg2.name as city,
- dg3.name as area,
- a.aid,
- a.share_type as shareType,
- a.information_maintainer as mid
- from user a
- left join organization_identity b on a.id = b.uid
- left join district_glossory dg1 on b.location_province = dg1.id
- left join district_glossory dg2 on b.location_city = dg2.id
- left join district_glossory dg3 on b.location_area = dg3.id
- left join admin d on a.aid = d.id
- where a.type = 1 and a.status != 1
- and a.identify_name = #{name}
- <if test="aid != null and aid !=''">
- and a.aid = #{aid,jdbcType=VARCHAR}
- </if>
- <if test="departmentId != null and departmentId !=''">
- and d.department_id=#{departmentId,jdbcType=VARCHAR}
- </if>
- <if test="startDate != null and startDate != ''">
- and a.transfer_time > #{startDate}
- </if>
- <if test="endDate != null and endDate != ''">
- and a.transfer_time < #{endDate}
- </if>
- <if test="province != null">
- and b.location_province = #{province,jdbcType=INTEGER}
- </if>
- <if test="city != null">
- and b.location_city = #{city,jdbcType=INTEGER}
- </if>
- <if test="area != null">
- and b.location_area = #{area,jdbcType=INTEGER}
- </if>
- <if test="page_sql != null">
- ${page_sql}
- </if>
- </select>
- <select id="selectOrganizationCustomerCount" resultType="java.lang.Integer">
- select
- count(0)
- from user a
- left join organization_identity b on a.id = b.uid
- <if test="departmentId != null and departmentId !=''">
- INNER join (select id
- from admin
- where department_id=#{departmentId,jdbcType=VARCHAR}) d on a.aid = d.id
- </if>
- where a.type = 1 and a.status != 1
- and a.identify_name = #{name}
- <if test="aid != null and aid !=''">
- and a.aid = #{aid,jdbcType=VARCHAR}
- </if>
- <if test="startDate != null and startDate != ''">
- and a.transfer_time > #{startDate}
- </if>
- <if test="endDate != null and endDate != ''">
- and a.transfer_time < #{endDate}
- </if>
- <if test="province != null">
- and b.location_province = #{province,jdbcType=INTEGER}
- </if>
- <if test="city != null">
- and b.location_city = #{city,jdbcType=INTEGER}
- </if>
- <if test="area != null">
- and b.location_area = #{area,jdbcType=INTEGER}
- </if>
- </select>
- <select id="selectPrivateOrganizationCustomerList" resultType="com.goafanti.customer.bo.CustomerListOut">
- select t0.id as uid,
- t0.aid,
- date_format(t0.transfer_time,'%Y-%m-%d %H:%i:%S') as transferTime,
- date_format(t0.create_time,'%Y-%m-%d %H:%i:%S') as createTime,
- t0.identify_name as name,
- t0.society_tag as societyTag,
- t0.level,
- date_format(t1.last_follow_time,'%Y-%m-%d %H:%i:%S') as lastFollowTime,
- date_format(t2.last_sign_time,'%Y-%m-%d %H:%i:%S') as lastSignTime,
- b.contacts,
- b.contact_mobile as contactMobile,
- dg1.name as province,
- dg2.name as city,
- dg3.name as area,
- c.name as industry,
- if(t0.transfer_time < t1.last_follow_time,t1.last_follow_time,t0.transfer_time) as orderTime,
- d.name as adminName
- from
- (select id,aid,type,share_type,transfer_time,create_time,identify_name,society_tag,level from user where aid = #{aid} and type = 1 and share_type = 0 and status != 1)t0
- left join
- (select uid,aid,max(create_time) as last_follow_time from user_follow where aid = #{aid} group by uid)t1
- on t0.id = t1.uid left join
- (select aid,uid,max(lock_time) as last_sign_time from user_lock_release where aid = #{aid} group by uid)t2
- on t0.id = t2.uid
- left join organization_identity b on t0.id = b.uid
- left join district_glossory dg1 on b.location_province = dg1.id
- left join district_glossory dg2 on b.location_city = dg2.id
- left join district_glossory dg3 on b.location_area = dg3.id
- left join industry_category c on b.industry = c.id
- left join admin d on t0.aid = d.id where 1=1
- <if test="aid != null and aid !=''">
- and t0.aid = #{aid,jdbcType=VARCHAR}
- </if>
- <if test="name != null and name != ''">
- and t0.identify_name like concat('%',#{name},'%')
- </if>
- <if test="startDate != null and startDate != ''">
- and t0.transfer_time > #{startDate}
- </if>
- <if test="endDate != null and endDate != ''">
- and t0.transfer_time < #{endDate}
- </if>
- <if test="province != null">
- and b.location_province = #{province,jdbcType=INTEGER}
- </if>
- <if test="city != null">
- and b.location_city = #{city,jdbcType=INTEGER}
- </if>
- <if test="area != null">
- and b.location_area = #{area,jdbcType=INTEGER}
- </if>
- <if test="level != null">
- and t0.level = #{level,jdbcType=INTEGER}
- </if>
- <if test="sort != 1">
- order by orderTime
- </if>
- <if test="sort == 1">
- order by t0.create_time
- </if>
- <if test="sortType == 1">
- desc
- </if>
- <if test="page_sql != null">
- ${page_sql}
- </if>
- </select>
- <select id="selectPrivateOrganizationCustomerCount" resultType="java.lang.Integer">
- select
- count(0)
- from
- (select id,aid,type,share_type,transfer_time,identify_name,society_tag,level from user where aid = #{aid} and type = 1 and share_type = 0 and status != 1)t0
- left join organization_identity b on t0.id = b.uid where 1=1
- <if test="aid != null and aid !=''">
- and t0.aid = #{aid,jdbcType=VARCHAR}
- </if>
- <if test="name != null and name != ''">
- and t0.identify_name like concat('%',#{name},'%')
- </if>
- <if test="startDate != null and startDate != ''">
- and t0.transfer_time > #{startDate}
- </if>
- <if test="endDate != null and endDate != ''">
- and t0.transfer_time < #{endDate}
- </if>
- <if test="province != null">
- and b.location_province = #{province,jdbcType=INTEGER}
- </if>
- <if test="city != null">
- and b.location_city = #{city,jdbcType=INTEGER}
- </if>
- <if test="area != null">
- and b.location_area = #{area,jdbcType=INTEGER}
- </if>
- <if test="level != null">
- and t0.level = #{level,jdbcType=INTEGER}
- </if>
- </select>
- <select id="selectPublicOrganizationCustomerList" resultType="com.goafanti.customer.bo.CustomerListOut">
- select
- a.id as uid,
- a.identify_name as name,
- a.create_time as createTime,
- a.transfer_time as transferTime,
- b.contacts,
- b.contact_mobile as contactMobile,
- dg1.name as province,
- dg2.name as city,
- dg3.name as area
- from
- user a
- inner join organization_identity b on a.id = b.uid
- left join district_glossory dg1 on b.location_province = dg1.id
- left join district_glossory dg2 on b.location_city = dg2.id
- left join district_glossory dg3 on b.location_area = dg3.id
- where
- a.type = 1
- and a.share_type = 1
- and a.status != 1
- and a.source != 0
- <if test="aid != null and aid !=''">
- and a.aid = #{aid,jdbcType=VARCHAR}
- </if>
- <if test="name != null and name != ''">
- and a.identify_name like concat('%',#{name},'%')
- </if>
- <if test="startDate != null and startDate != ''">
- and a.transfer_time > #{startDate}
- </if>
- <if test="endDate != null and endDate != ''">
- and a.transfer_time < #{endDate}
- </if>
- <if test="province != null">
- and b.location_province = #{province,jdbcType=INTEGER}
- </if>
- <if test="city != null">
- and b.location_city = #{city,jdbcType=INTEGER}
- </if>
- <if test="area != null">
- and b.location_area = #{area,jdbcType=INTEGER}
- </if>
- <if test="page_sql != null">
- ${page_sql}
- </if>
- </select>
- <select id="selectPublicOrganizationCustomerCount" resultType="java.lang.Integer">
- select
- count(0)
- from
- user a
- inner join organization_identity b on a.id = b.uid
- left join district_glossory dg1 on b.location_province = dg1.id
- left join district_glossory dg2 on b.location_city = dg2.id
- left join district_glossory dg3 on b.location_area = dg3.id
- where
- a.type = 1
- and a.share_type = 1
- and a.status != 1
- and a.source != 0
- <if test="aid != null and aid !=''">
- and a.aid = #{aid,jdbcType=VARCHAR}
- </if>
- <if test="name != null and name != ''">
- and a.identify_name like concat('%',#{name},'%')
- </if>
- <if test="startDate != null and startDate != ''">
- and a.transfer_time > #{startDate}
- </if>
- <if test="endDate != null and endDate != ''">
- and a.transfer_time < #{endDate}
- </if>
- <if test="province != null">
- and b.location_province = #{province,jdbcType=INTEGER}
- </if>
- <if test="city != null">
- and b.location_city = #{city,jdbcType=INTEGER}
- </if>
- <if test="area != null">
- and b.location_area = #{area,jdbcType=INTEGER}
- </if>
- </select>
- <select id="selectSignOrganizationCustomerList" resultType="com.goafanti.customer.bo.CustomerListOut">
- select
- t0.uid as uid,
- date_format(t3.last_sign_time,'%Y-%m-%d %H:%I:%S') as lastSignTime,
- t1.last_follow_time as lastFollowTime,
- t2.society_tag as societyTag,
- t2.identify_name as name,
- t2.share_type as shareType,
- t2.transfer_time as transferTime,
- dg1.name as province,
- dg2.name as city,
- dg3.name as area,
- b.contacts,
- b.contact_mobile as contactMobile,
- c.name as industry,
- d.name as adminName
- from
- (select uid,aid,max(lock_time) as update_time
- from user_lock_release
- where type=1 and status=0 and aid= #{aid,jdbcType=VARCHAR}
- group by uid)t0
- left join
- (select uid,aid,max(create_time) as last_follow_time from user_follow where aid = #{aid,jdbcType=VARCHAR} group by uid)t1
- on t0.uid = t1.uid
- inner join
- (select id,aid,share_type,society_tag,identify_name,transfer_time from user where type = 1)t2
- on t0.uid = t2.id
- left join (select aid,uid,max(lock_time) as last_sign_time from user_lock_release where aid = #{aid,jdbcType=VARCHAR} group by uid)t3
- on t0.uid = t3.uid
- left join organization_identity b on t0.uid = b.uid
- left join district_glossory dg1 on b.location_province = dg1.id
- left join district_glossory dg2 on b.location_city = dg2.id
- left join district_glossory dg3 on b.location_area = dg3.id
- left join industry_category c on b.industry = c.id
- left join admin d on t2.aid = d.id where 1 = 1
- <if test="name != null and name != ''">
- and t2.identify_name like concat('%',#{name},'%')
- </if>
- <if test="shareType != null">
- and t2.share_type = #{shareType,jdbcType=VARCHAR}
- </if>
- <if test="startDate != null and startDate != ''">
- and t2.transfer_time > #{startDate}
- </if>
- <if test="endDate != null and endDate != ''">
- and t2.transfer_time < #{endDate}
- </if>
- <if test="province != null">
- and b.location_province = #{province,jdbcType=INTEGER}
- </if>
- <if test="city != null">
- and b.location_city = #{city,jdbcType=INTEGER}
- </if>
- <if test="area != null">
- and b.location_area = #{area,jdbcType=INTEGER}
- </if>
- order by t1.last_follow_time desc
- <if test="page_sql != null">
- ${page_sql}
- </if>
- </select>
-
- <select id="selectSignOrganizationCustomerCount" resultType="java.lang.Integer">
- select
- count(0)
- from
- (select uid,aid,max(lock_time) as update_time
- from user_lock_release
- where type=1 and status=0 and aid= #{aid,jdbcType=VARCHAR}
- group by uid)t0
- inner join
- (select id,aid,share_type,society_tag,identify_name,transfer_time from user where type = 1)t2
- on t0.uid = t2.id
- left join organization_identity b on t0.uid = b.uid where 1 = 1
- <if test="name != null and name != ''">
- and t2.identify_name like concat('%',#{name},'%')
- </if>
- <if test="shareType != null">
- and t2.share_type = #{shareType,jdbcType=VARCHAR}
- </if>
- <if test="startDate != null and startDate != ''">
- and t2.transfer_time > #{startDate}
- </if>
- <if test="endDate != null and endDate != ''">
- and t2.transfer_time < #{endDate}
- </if>
- <if test="province != null">
- and b.location_province = #{province,jdbcType=INTEGER}
- </if>
- <if test="city != null">
- and b.location_city = #{city,jdbcType=INTEGER}
- </if>
- <if test="area != null">
- and b.location_area = #{area,jdbcType=INTEGER}
- </if>
- </select>
-
- <select id="findCustomerByName" parameterType="java.lang.String" resultType="com.goafanti.customer.bo.CustomerSimpleBo">
- select id,identify_name as name from user where identify_name like
- concat('%',#{identifyName},'%') and status <![CDATA[!= ]]> 1 and audit_status = 1
- </select>
-
- <select id="judgeCustomerByName" resultType="java.lang.Integer">
- select count(0) from user where identify_name = #{identifyName,jdbcType=VARCHAR}
- and status <![CDATA[!= ]]> 1
- </select>
-
- <select id="findOrganizationCustomerDetail" parameterType="java.lang.String" resultType="com.goafanti.customer.bo.CustomerOrganizationDetailBo">
- select
- a.id as uid,
- a.society_tag as societyTag,
- a.company_logo_url as companyLogoUrl,
- a.introduction,
- a.identify_name as identifyName,
- b.industry,
- b.location_province as locationProvince,
- b.location_city as locationCity,
- b.location_area as locationArea,
- b.postal_address as postalAddress,
- b.contacts_fixed_tel as contactsFixedTel,
- b.contacts_fax as contactsFax,
- b.registered_capital registeredCapital,
- b.enterprise_scale as enterpriseScale,
- b.legal_person as legalPerson,
- b.legal_person_id_card as legalPersonIdCard,
- b.legal_person_tel as legalPersonTel,
- b.legal_person_email as legalPersonEmail,
- b.org_code as orgCode,
- b.org_code_url as orgCodeUrl,
- b.business_scope as businessScope,
- b.id,
- b.contacts,
- b.contact_mobile as contactMobile,
- b.licence_number as licenceNumber,
- a.aid as aid,
- d.name as adminName,
- a.information_maintainer as informationMaintainer,
- c.name as informationMaintainerName,
- a.core_technology as coreTechnology,
- a. accomplish_situation as accomplishSituation,
- a.intellectual_property as intellectualProperty,
- b.year_sales_amount as yearSalesAmount,
- b.last_year_research_amount as lastYearResearchAmount,
- b.assets,
- b.qualification,
- b.cooperation_situation as cooperationSituation,
- a.credit_rating as creditRating,
- e.poject_application_url as pojectApplicationUrl
- from
- user a inner join organization_identity b on a.id = b.uid
- left join admin d on d.id = a.aid
- left join admin c on c.id = a.information_maintainer
- left join organization_application_info e on a.id=e.uid
- where
- a.id = #{uid,jdbcType=VARCHAR}
- </select>
-
- <select id="findPersonalCustomerDetail" parameterType="java.lang.String" resultType="com.goafanti.customer.bo.CustomerPersonalDetailBo">
- select
- a.id as uid,
- a.identify_name as identifyName,
- a.society_tag as societyTag,
- a.head_portrait_url as headPortraitUrl,
- a.introduction,
- b.id,
- b.industry,
- b.sex,
- b.date_of_birth_year as dateOfBirthYear,
- b.date_of_birth_month as dateOfBirthMonth,
- b.id_number as idNumber,
- b.province,
- b.city,
- b.area,
- b.positive_id_url as positiveIdUrl,
- b.opposite_id_url as oppositeIdUrl,
- b.postal_address as postalAddress,
- b.contact_mobile as contactMobile,
- b.fixed_tel as fixedTel,
- b.email,
- b.expert,
- b.international,
- b.contacts,
- b.contact_mobile as contactMobile,
- b.qq,
- b.professional_title as professionalTitle,
- b.work_unit as workUnit,
- b.education,
- b.major_category as majorCategory,
- b.qualification,
- b.audit_status as auditStatus,
- b.graduate_school as graduateSchool,
- b.consultation_price as consultationPrice,
- b.release_status as releaseStatus,
- a.aid as aid,d.name as adminName
- from
- user a inner join user_identity b on
- a.id = b.uid
- left join admin d on d.id = a.aid
- where
- a.id = #{uid,jdbcType=VARCHAR}
- </select>
-
- <select id="selectFollowHistoryList" resultType="com.goafanti.customer.bo.FollowListBo">
- select
- a.id as followId,
- a.aid,
- a.create_time as followTime,
- a.contact_type as contactType,
- a.result,
- b.identify_name as identifyName,
- c.name as contacts,
- c.mobile as contactMobile,
- d.name as adminName
- <if test="businessProjectId != null and businessProjectId != ''"><!-- 客户甲项目A所有的跟进记录 -->
- ,e.id as ufbId,e.follow_situation as followSituation,e.customer_status as customerStatus
- </if>
- from user_follow a
- left join user b on a.uid = b.id
- left join organization_contact_book c on a.ocb_id = c.id
- left join admin d on a.aid = d.id
- <if test="businessProjectId != null and businessProjectId != ''"><!-- 客户甲项目A所有的跟进记录 -->
- inner join user_follow_business e on a.id = e.follow_id
- </if>
- where a.effective = 0
- <if test="uid != null and uid != ''">
- and a.uid = #{uid,jdbcType=VARCHAR}
- </if>
- <if test="aid != null and aid != ''">
- and a.aid = #{aid,jdbcType=VARCHAR}
- </if>
- <if test="businessProjectId != null and businessProjectId != ''"><!-- 客户甲项目A所有的跟进记录 -->
- and e.business_project_id = #{businessProjectId,jdbcType=VARCHAR}
- </if>
- <if test="page_sql != null">
- ${page_sql}
- </if>
- </select>
- <select id="selectFollowHistoryCount" resultType="java.lang.Integer">
- select
- count(0)
- from user_follow a
- left join user b on a.uid = b.id
- left join organization_contact_book c on a.ocb_id = c.id
- left join admin d on a.aid = d.id
- <if test="businessProjectId != null and businessProjectId != ''"><!-- 客户甲项目A所有的跟进记录 -->
- inner join user_follow_business e on a.id = e.follow_id
- </if>
- where a.effective = 0
- <if test="uid != null and uid != ''">
- and a.uid = #{uid,jdbcType=VARCHAR}
- </if>
- <if test="aid != null and aid != ''">
- and a.aid = #{aid,jdbcType=VARCHAR}
- </if>
- <if test="businessProjectId != null and businessProjectId != ''"><!-- 客户甲项目A所有的跟进记录 -->
- and e.business_project_id = #{businessProjectId,jdbcType=VARCHAR}
- </if>
- </select>
-
- <select id="findUserAccountDetail" parameterType="java.lang.String" resultType="com.goafanti.common.model.User">
- select
- id,
- mobile,
- nickname,
- create_time as createTime,
- type,
- source,
- email,
- identify_name as identifyName,
- status
- from
- user
- where id = #{uid,jdbcType=VARCHAR}
- </select>
-
- <select id="findCustomerContacts" parameterType="java.lang.String" resultType="com.goafanti.common.model.OrganizationContactBook">
- select id,name,mobile,email,qq,wechat,department,position,major from organization_contact_book
- where uid = #{uid,jdbcType=VARCHAR} and aid = #{aid,jdbcType=VARCHAR}
- </select>
-
- <select id="findAllContacts" parameterType="java.lang.String" resultType="com.goafanti.common.model.OrganizationContactBook">
- select id,name,mobile,major,sex,department,position,wechat,qq from organization_contact_book
- where uid = #{uid,jdbcType=VARCHAR}
- </select>
-
- <select id="findFollowById" parameterType="java.lang.String" resultType="com.goafanti.customer.bo.FollowBusinessBo">
- select
- a.id as followId,
- a.uid,
- a.ocb_id as ocbId,
- a.contact_type as contactType,
- a.result,
- a.create_time as followTime,
- b.identify_name as identifyName,
- c.name as contacts,
- c.mobile as contactMobile,
- d.name as adminName
- from
- user_follow a
- left join user b on a.uid = b.id
- left join organization_contact_book c on a.ocb_id = c.id
- left join admin d on a.aid = d.id
- where a.id = #{followId,jdbcType=VARCHAR}
- </select>
- <select id="customerStatisticsList" resultType="com.goafanti.customer.bo.StatisticBo">
- select a.*,b.name as adminName,c.name as departmentName from (
- select
- aid,
- sum(case when customer_status = 0 then 1 else 0 end) as newNo, <!-- 新客户 -->
- sum(case when customer_status = 1 then 1 else 0 end) as intentionNo, <!-- 意向客户 -->
- sum(case when customer_status = 2 then 1 else 0 end) as pointNo, <!-- 重点客户 -->
- sum(case when customer_status = 3 then 1 else 0 end) as interviewNo, <!-- 面谈客户 -->
- sum(case when customer_status = 4 then 1 else 0 end) as signNo, <!-- 签单客户 -->
- sum(case when customer_status = 5 then 1 else 0 end) as refuseNo, <!-- 拒绝客户 -->
- sum(case when customer_status = 6 then 1 else 0 end) as stopNo <!-- 停止跟进 -->
- from user_business where 1=1
- <if test="sDate != null">
- and create_time > #{sDate,jdbcType=DATE}
- </if>
- <if test="eDate != null">
- and create_time < #{eDate,jdbcType=DATE}
- </if>
- <if test="businessGlossoryId != null">
- and business_glossory_id = #{businessGlossoryId,jdbcType=VARCHAR}
- </if>
- group by aid
- )a
- left join admin b on a.aid = b.id
- left join department c on b.department_id = c.id
- <if test="depNo != null">
- where c.dep_no like concat(#{depNo,jdbcType=VARCHAR},'%')
- </if>
- <if test="page_sql != null">
- ${page_sql}
- </if>
- </select>
- <select id="customerStatisticsCount" resultType="java.lang.Integer">
- select count(0) from (
- select
- aid
- from user_business where 1=1
- <if test="sDate != null">
- and create_time > #{sDate,jdbcType=DATE}
- </if>
- <if test="eDate != null">
- and create_time < #{eDate,jdbcType=DATE}
- </if>
- <if test="businessGlossoryId != null">
- and business_glossory_id = #{businessGlossoryId,jdbcType=VARCHAR}
- </if>
- group by aid
- )a
- left join admin b on a.aid = b.id
- left join department c on b.department_id = c.id
- <if test="depNo !=null">
- where c.dep_no like concat(#{depNo,jdbcType=VARCHAR},'%')
- </if>
- </select>
-
- <select id="businessStatisticList" resultType="com.goafanti.customer.bo.StatisticBo">
- select a.*,b.name as adminName,c.name as departmentName from (
- select
- aid,
- sum(case when follow_situation = 0 then 1 else 0 end) as sendMaterialNo, <!-- 已发项目介绍资料 -->
- sum(case when follow_situation = 1 then 1 else 0 end) as interviewNo, <!-- 已约面谈 -->
- sum(case when follow_situation = 2 then 1 else 0 end) as sendProspectusNo, <!-- 已发合同计划书 -->
- sum(case when follow_situation = 3 then 1 else 0 end) as quoteNo, <!-- 已报价 -->
- sum(case when follow_situation = 4 then 1 else 0 end) as sendContractNo, <!-- 已发合同 -->
- sum(case when follow_situation = 5 then 1 else 0 end) as signContractNo, <!-- 已签合同 -->
- sum(case when follow_situation = 6 then 1 else 0 end) as onVisaNo, <!-- 面谈中 -->
- sum(case when follow_situation = 7 then 1 else 0 end) as visaNo <!-- 已面签 -->
- from user_business where 1=1
- <if test="sDate != null">
- and create_time > #{sDate,jdbcType=DATE}
- </if>
- <if test="eDate != null">
- and create_time < #{eDate,jdbcType=DATE}
- </if>
- <if test="businessGlossoryId != null">
- and business_glossory_id = #{businessGlossoryId,jdbcType=VARCHAR}
- </if>
- group by aid
- )a
- left join admin b on a.aid = b.id
- left join department c on b.department_id = c.id
- <if test="depNo !=null">
- where c.dep_no like concat(#{depNo,jdbcType=VARCHAR},'%')
- </if>
- <if test="page_sql != null">
- ${page_sql}
- </if>
- </select>
-
- <select id="businessStatisticCount" resultType="java.lang.Integer">
- select count(0) from (
- select
- aid
- from user_business where 1=1
- <if test="sDate != null">
- and create_time > #{sDate,jdbcType=DATE}
- </if>
- <if test="eDate != null">
- and create_time < #{eDate,jdbcType=DATE}
- </if>
- <if test="businessGlossoryId != null">
- and business_glossory_id = #{businessGlossoryId,jdbcType=VARCHAR}
- </if>
- group by aid
- )a
- left join admin b on a.aid = b.id
- left join department c on b.department_id = c.id
- <if test="depNo !=null">
- where c.dep_no like concat(#{depNo,jdbcType=VARCHAR},'%')
- </if>
- </select>
-
- <select id="followStatisticList" resultType="com.goafanti.customer.bo.StatisticBo">
- select x.*,b.name as adminName,c.name as departmentName,y.* from (
- select
- count(0) as followNo,
- aid,
- sum(case when contact_type = 0 then 1 else 0 end) as visitNo, <!-- 外出 -->
- sum(case when contact_type = 1 then 1 else 0 end) as telNo, <!-- 电话 -->
- sum(case when contact_type = 2 then 1 else 0 end) as qqNo, <!-- QQ -->
- sum(case when contact_type = 3 then 1 else 0 end) as wxNo, <!-- 微信 -->
- sum(case when contact_type = 4 then 1 else 0 end) as emailNo, <!-- 邮件 -->
- sum(case when contact_type = 5 then 1 else 0 end) as letterNo <!-- 书信 -->
- from user_follow where 1=1
- <if test="sDate != null">
- and create_time > #{sDate,jdbcType=DATE}
- </if>
- <if test="eDate != null">
- and create_time < #{eDate,jdbcType=DATE}
- </if>
- group by aid
- )x
- left join admin b on x.aid = b.id
- left join department c on b.department_id = c.id
- left join
- (
- select
- count( 0 ) as customerNo,
- aid
- from
- (
- select
- aid,
- uid
- from
- user_follow
-
- group by
- aid,
- uid
- ) a
- group by
- aid
- )y on x.aid = y.aid
- <if test="depNo !=null">
- where c.dep_no like concat(#{depNo,jdbcType=VARCHAR},'%')
- </if>
- </select>
-
- <select id="followStatisticCount" resultType="java.lang.Integer">
- select count(0) from (
- select
- aid
- from user_follow where 1=1
- <if test="sDate != null">
- and create_time > #{sDate,jdbcType=DATE}
- </if>
- <if test="sDate != null">
- and create_time < #{eDate,jdbcType=DATE}
- </if>
- group by aid
- )x
- left join admin b on x.aid = b.id
- left join department c on b.department_id = c.id
- <if test="depNo !=null">
- where c.dep_no like concat(#{depNo,jdbcType=VARCHAR},'%')
- </if>
- </select>
-
- <select id="findBusinessByFollowId" parameterType="java.lang.String" resultType="com.goafanti.customer.bo.BusinessListBo">
- select
- a.id as ufbId,
- a.follow_situation as followSituation,
- a.customer_status as customerStatus,
- a.remarks,
- a.business_project_id as businessProjectId,
- b.bname as businessProjectName,
- c.cname as businessVarietiesName
- from
- user_follow_business a
- left join business_project b on a.business_project_id = b.id
- left join business_category c on b.cid = c.id
- where
- a.follow_id = #{followId,jdbcType=VARCHAR}
- </select>
-
- <select id="selectBusinessList" resultType="com.goafanti.customer.bo.BusinessListBo">
- select
- c.bname as businessName,
- b.identify_name as identifyName,
- a.id as businessId,
- a.business_project_id as businessProjectId,
- a.create_time as createTime,
- a.update_time as updateTime,
- a.follow_situation as followSituation,
- a.customer_status as customerStatus,
- d.name as adminName
- from
- user_business a inner join user b on
- a.uid = b.id left join business_project c on
- a.business_project_id = c.id left join admin d on
- a.aid = d.id
- where 1 = 1
- <if test="aid != null and aid != ''">
- and a.aid = #{aid,jdbcType=VARCHAR}
- </if>
- <if test="uid != null and uid !=''">
- and a.uid = #{uid,jdbcType=VARCHAR}
- </if>
- <if test="businessProjectId !=null and businessProjectId != ''">
- and a.business_project_id = #{businessProjectId,jdbcType=VARCHAR}
- </if>
- <if test="identifyName != null and identifyName != ''">
- and b.identify_name like concat('%', #{identifyName},'%')
- </if>
- <if test="followSituation != null">
- and a.follow_situation = #{followSituation,jdbcType=INTEGER}
- </if>
- <if test="customerStatus != null">
- and a.customer_status = #{customerStatus,jdbcType=INTEGER}
- </if>
- <if test="adminName != null and adminName != ''">
- and d.name = #{adminName,jdbcType=VARCHAR}
- </if>
- <if test="startDate != null and startDate != ''">
- and a.create_time > STR_TO_DATE(#{startDate},'%Y-%m-%d %H:%i:%s')
- </if>
- <if test="endDate != null and endDate != ''">
- and a.create_time < STR_TO_DATE(#{endDate},'%Y-%m-%d %H:%i:%s')
- </if>
- order by a.create_time desc
- <if test="page_sql != null">
- ${page_sql}
- </if>
- </select>
-
- <select id="selectBusinessCount" parameterType="com.goafanti.customer.bo.BusinessListBo" resultType="java.lang.Integer">
- select
- count(*)
- from
- user_business a inner join user b on
- a.uid = b.id left join business_project c on
- a.business_project_id = c.id left join admin d on
- a.aid = d.id
- where 1 = 1
- <if test="aid != null and aid != ''">
- and a.aid = #{aid,jdbcType=VARCHAR}
- </if>
- <if test="uid != null and uid !=''">
- and a.uid = #{uid,jdbcType=VARCHAR}
- </if>
- <if test="businessProjectId !=null and businessProjectId != ''">
- and a.business_project_id = #{businessProjectId,jdbcType=VARCHAR}
- </if>
- <if test="identifyName != null and identifyName != ''">
- and b.identify_name like concat('%', #{identifyName},'%')
- </if>
- <if test="followSituation != null">
- and a.follow_situation = #{followSituation,jdbcType=INTEGER}
- </if>
- <if test="customerStatus != null">
- and a.customer_status = #{customerStatus,jdbcType=INTEGER}
- </if>
- <if test="adminName != null and adminName != ''">
- and d.name = #{adminName,jdbcType=VARCHAR}
- </if>
- <if test="startDate != null and startDate != ''">
- and a.create_time > STR_TO_DATE(#{startDate},'%Y-%m-%d %H:%i:%s')
- </if>
- <if test="endDate != null and endDate != ''">
- and a.create_time < STR_TO_DATE(#{endDate},'%Y-%m-%d %H:%i:%s')
- </if>
- </select>
-
- <select id="selectBusinessManageList" resultType="com.goafanti.customer.bo.BusinessListBo">
- select
- c.name as businessName,
- b.identify_name as identifyName,
- a.id as businessId,
- a.create_time as createTime,
- a.update_time as updateTime,
- a.follow_situation as followSituation,
- a.customer_status as customerStatus,
- d.name as adminName
- from
- user_business a inner join user b on
- a.uid = b.id left join business_glossory c on
- a.business_project_id = c.id left join admin d on
- a.aid = d.id
- left join department dm on dm.id = d.department_id
- where 1 = 1
- <if test="aid != null and aid != ''">
- and (b.aid = #{aid,jdbcType=VARCHAR} or d.department_id=(select department_id from admin where id=#{aid,jdbcType=VARCHAR}))
- </if>
- <if test="uid != null and uid !=''">
- and a.uid = #{uid,jdbcType=VARCHAR}
- </if>
- <if test="businessProjectId !=null and businessProjectId != ''">
- and a.business_project_id = #{businessProjectId,jdbcType=VARCHAR}
- </if>
- <if test="identifyName != null and identifyName != ''">
- and b.identify_name like concat('%', #{identifyName},'%')
- </if>
- <if test="followSituation != null">
- and a.follow_situation = #{followSituation,jdbcType=INTEGER}
- </if>
- <if test="customerStatus != null">
- and a.customer_status = #{customerStatus,jdbcType=INTEGER}
- </if>
- <if test="adminName != null and adminName != ''">
- and d.name = #{adminName,jdbcType=VARCHAR}
- </if>
- <if test="startDate != null and startDate != ''">
- and a.create_time > STR_TO_DATE(#{startDate},'%Y-%m-%d %H:%i:%s')
- </if>
- <if test="endDate != null and endDate != ''">
- and a.create_time < STR_TO_DATE(#{endDate},'%Y-%m-%d %H:%i:%s')
- </if>
- order by a.create_time desc
- <if test="page_sql != null">
- ${page_sql}
- </if>
- </select>
-
- <select id="selectBusinessManageCount" parameterType="com.goafanti.customer.bo.BusinessListBo" resultType="java.lang.Integer">
- select
- count(0)
- from
- user_business a inner join user b on
- a.uid = b.id left join business_glossory c on
- a.business_project_id = c.id left join admin d on
- a.aid = d.id
- left join department dm on dm.id = d.department_id
- where 1 = 1
- <if test="aid != null and aid != ''">
- and (b.aid = #{aid,jdbcType=VARCHAR} or d.department_id=(select department_id from admin where id=#{aid,jdbcType=VARCHAR}))
- </if>
- <if test="uid != null and uid !=''">
- and a.uid = #{uid,jdbcType=VARCHAR}
- </if>
- <if test="businessProjectId !=null and businessProjectId != ''">
- and a.business_project_id = #{businessProjectId,jdbcType=VARCHAR}
- </if>
- <if test="identifyName != null and identifyName != ''">
- and b.identify_name like concat('%', #{identifyName},'%')
- </if>
- <if test="followSituation != null">
- and a.follow_situation = #{followSituation,jdbcType=INTEGER}
- </if>
- <if test="customerStatus != null">
- and a.customer_status = #{customerStatus,jdbcType=INTEGER}
- </if>
- <if test="adminName != null and adminName != ''">
- and d.name = #{adminName,jdbcType=VARCHAR}
- </if>
- <if test="startDate != null and startDate != ''">
- and a.create_time > STR_TO_DATE(#{startDate},'%Y-%m-%d %H:%i:%s')
- </if>
- <if test="endDate != null and endDate != ''">
- and a.create_time < STR_TO_DATE(#{endDate},'%Y-%m-%d %H:%i:%s')
- </if>
- </select>
-
- <select id="selectManagePersonalCustomerList" resultType="com.goafanti.customer.bo.CustomerListOut">
- select
- a.id as uid,
- a.type,
- a.status,
- date_format(a.create_time,'%Y-%m-%d %H:%i:%s') as createTime,
- a.business_audit as businessAudit,
- a.current_member_status as currentMemberStatus,
- a.identify_name as name,
- a.lvl,a.is_member as isMember,
- a.society_tag as societyTag,
- a.share_type as shareType,
- b.contacts,
- b.contact_mobile as contactMobile,
- b.international,
- b.expert,
- b.audit_status as auditStatus,
- dg1.name as province,
- dg2.name as city,
- dg3.name as area,
- c.name as industry,
- d.name as adminName,
- b.release_status as releaseStatus
- from user a inner join user_identity b on a.id = b.uid
- left join district_glossory dg1 on b.province = dg1.id
- left join district_glossory dg2 on b.city = dg2.id
- left join district_glossory dg3 on b.area = dg3.id
- left join industry_category c on b.industry = c.id
- left join admin d on a.aid = d.id
- LEFT JOIN department dm on dm.id = d.department_id
- where a.type = 0 and a.status != 1 and a.audit_status = 1
- and a.share_type =0
- <if test="aid != null and aid !=''">
- and (a.aid = #{aid,jdbcType=VARCHAR} or d.department_id=(select department_id from admin where id=#{aid,jdbcType=VARCHAR}))
- </if>
- <if test="name != null and name != ''">
- and a.identify_name like concat('%',#{name},'%')
- </if>
- <if test="shareType != null">
- and a.share_type = #{shareType,jdbcType=INTEGER}
- </if>
- <if test="status != null">
- and a.status = #{status,jdbcType=INTEGER}
- </if>
- <if test="businessAudit != null">
- and a.business_audit = #{businessAudit,jdbcType=INTEGER}
- </if>
- <if test="isMember != null">
- and a.is_member = #{isMember,jdbcType=INTEGER}
- </if>
- <if test="lvl != null">
- and a.lvl = #{lvl,jdbcType=INTEGER}
- </if>
- <if test="currentMemberStatus != null">
- and a.current_member_status = #{currentMemberStatus,jdbcType=INTEGER}
- </if>
- <if test="societyTag != null and societyTag != ''">
- and a.society_tag = #{societyTag,jdbcType=VARCHAR}
- </if>
- <if test="startDate != null and startDate != ''">
- and a.create_time > STR_TO_DATE(#{startDate},'%Y-%m-%d %H:%i:%s')
- </if>
- <if test="endDate != null and endDate != ''">
- and a.create_time < STR_TO_DATE(#{endDate},'%Y-%m-%d %H:%i:%s')
- </if>
- <if test="province != null">
- and b.province = #{province,jdbcType=INTEGER}
- </if>
- <if test="city != null">
- and b.city = #{city,jdbcType=INTEGER}
- </if>
- <if test="area != null">
- and b.area = #{area,jdbcType=INTEGER}
- </if>
- <if test="industry != null">
- and b.industry = #{industry,jdbcType=INTEGER}
- </if>
- <if test="expert != null">
- and b.expert = #{expert,jdbcType=INTEGER}
- </if>
- <if test="international != null">
- and b.international = #{international,jdbcType=INTEGER}
- </if>
- <if test="auditStatus != null">
- and b.audit_status = #{auditStatus,jdbcType=INTEGER}
- </if>
- <if test="page_sql != null">
- ${page_sql}
- </if>
- </select>
- <select id="selectManagePersonalCustomerCount" resultType="java.lang.Integer">
- select count(0)
- from user a inner join user_identity b on a.id = b.uid
- left join admin d on a.aid = d.id
- LEFT JOIN department dm on dm.id = d.department_id
- where a.type = 0 and a.status != 1 and a.audit_status = 1
- <if test="aid != null and aid !=''">
- and (a.aid = #{aid,jdbcType=VARCHAR} or d.department_id=(select department_id from admin where id=#{aid,jdbcType=VARCHAR}))
- </if>
- <if test="name != null and name != ''">
- and a.identify_name like concat('%',#{name},'%')
- </if>
- <if test="shareType != null">
- and a.share_type = #{shareType,jdbcType=VARCHAR}
- </if>
- <if test="status != null">
- and a.status = #{status,jdbcType=INTEGER}
- </if>
- <if test="businessAudit != null">
- and a.business_audit = #{businessAudit,jdbcType=INTEGER}
- </if>
- <if test="isMember != null">
- and a.is_member = #{isMember,jdbcType=INTEGER}
- </if>
- <if test="lvl != null">
- and a.lvl = #{lvl,jdbcType=INTEGER}
- </if>
- <if test="currentMemberStatus != null">
- and a.current_member_status = #{currentMemberStatus,jdbcType=INTEGER}
- </if>
- <if test="societyTag != null and societyTag != ''">
- and a.society_tag = #{societyTag,jdbcType=VARCHAR}
- </if>
- <if test="startDate != null and startDate != ''">
- and a.create_time > STR_TO_DATE(#{startDate},'%Y-%m-%d %H:%i:%s')
- </if>
- <if test="endDate != null and endDate != ''">
- and a.create_time < STR_TO_DATE(#{endDate},'%Y-%m-%d %H:%i:%s')
- </if>
- <if test="province != null">
- and b.province = #{province,jdbcType=INTEGER}
- </if>
- <if test="city != null">
- and b.city = #{city,jdbcType=INTEGER}
- </if>
- <if test="area != null">
- and b.area = #{area,jdbcType=INTEGER}
- </if>
- <if test="industry != null">
- and b.industry = #{industry,jdbcType=INTEGER}
- </if>
- <if test="expert != null">
- and b.expert = #{expert,jdbcType=INTEGER}
- </if>
- <if test="international != null">
- and b.international = #{international,jdbcType=INTEGER}
- </if>
- <if test="auditStatus != null">
- and b.audit_status = #{auditStatus,jdbcType=INTEGER}
- </if>
- </select>
-
- <select id="selectManageOrganizationCustomerList" resultType="com.goafanti.customer.bo.CustomerListOut">
- select
- a.id as uid,
- a.type,
- a.status,
- date_format(a.create_time,'%Y-%m-%d %H:%i:%s') as createTime,
- a.identify_name as name,
- a.society_tag as societyTag,
- share_type as shareType,
- b.contacts,
- b.contact_mobile as contactMobile,
- dg1.name as province,
- dg2.name as city,
- dg3.name as area,
- c.name as industry,
- d.name as adminName
- from user a inner join organization_identity b on a.id = b.uid
- left join district_glossory dg1 on b.location_province = dg1.id
- left join district_glossory dg2 on b.location_city = dg2.id
- left join district_glossory dg3 on b.location_area = dg3.id
- left join industry_category c on b.industry = c.id
- left join admin d on a.aid = d.id
- LEFT JOIN department dm on dm.id = d.department_id
- where a.type = 1 and a.status != 1 and a.audit_status = 1
- <if test="aid != null and aid !=''">
- and (a.aid = #{aid,jdbcType=VARCHAR} or d.department_id=(select department_id from admin where id=#{aid,jdbcType=VARCHAR}))
- </if>
- <if test="name != null and name != ''">
- and a.identify_name like concat('%',#{name},'%')
- </if>
- <if test="shareType != null">
- and a.share_type = #{shareType,jdbcType=VARCHAR}
- </if>
- <if test="status != null">
- and a.status = #{status,jdbcType=INTEGER}
- </if>
- <if test="societyTag != null and societyTag != ''">
- and a.society_tag = #{societyTag,jdbcType=VARCHAR}
- </if>
- <if test="startDate != null and startDate != ''">
- and a.create_time > STR_TO_DATE(#{startDate},'%Y-%m-%d %H:%i:%s')
- </if>
- <if test="endDate != null and endDate != ''">
- and a.create_time < STR_TO_DATE(#{endDate},'%Y-%m-%d %H:%i:%s')
- </if>
- <if test="province != null">
- and b.location_province = #{province,jdbcType=INTEGER}
- </if>
- <if test="city != null">
- and b.location_city = #{city,jdbcType=INTEGER}
- </if>
- <if test="area != null">
- and b.location_area = #{area,jdbcType=INTEGER}
- </if>
- <if test="page_sql != null">
- ${page_sql}
- </if>
- </select>
-
- <select id="selectManageOrganizationCustomerCount" resultType="java.lang.Integer">
- select
- count(0)
- from user a inner join organization_identity b on a.id = b.uid
- left join admin d on a.aid = d.id
- LEFT JOIN department dm on dm.id = d.department_id
- where a.type = 1 and a.status != 1 and a.audit_status = 1
- <if test="aid != null and aid !=''">
- and (a.aid = #{aid,jdbcType=VARCHAR} or d.department_id=(select department_id from admin where id=#{aid,jdbcType=VARCHAR}))
- </if>
- <if test="name != null and name != ''">
- and a.identify_name like concat('%',#{name},'%')
- </if>
- <if test="shareType != null">
- and a.share_type = #{shareType,jdbcType=VARCHAR}
- </if>
- <if test="status != null">
- and a.status = #{status,jdbcType=INTEGER}
- </if>
- <if test="societyTag != null and societyTag != ''">
- and a.society_tag = #{societyTag,jdbcType=VARCHAR}
- </if>
- <if test="startDate != null and startDate != ''">
- and a.create_time > STR_TO_DATE(#{startDate},'%Y-%m-%d %H:%i:%s')
- </if>
- <if test="endDate != null and endDate != ''">
- and a.create_time < STR_TO_DATE(#{endDate},'%Y-%m-%d %H:%i:%s')
- </if>
- <if test="province != null">
- and b.location_province = #{province,jdbcType=INTEGER}
- </if>
- <if test="city != null">
- and b.location_city = #{city,jdbcType=INTEGER}
- </if>
- <if test="area != null">
- and b.location_area = #{area,jdbcType=INTEGER}
- </if>
- </select>
-
- <select id="findAdminName" resultType="com.goafanti.customer.bo.CustomerListOut">
- select d.name as adminName,d.id as aid
- from admin d left join department dm on dm.id = d.department_id
- where d.department_id=(select department_id from admin where id=#{aid,jdbcType=INTEGER})
- </select>
-
- <select id="findEnteringAuditList" resultType="com.goafanti.customer.bo.CustomerListOut">
- select u.id as uid,u.nickname as name,u.mobile as contactMobile,a.name as adminName,u.create_time as createTime,u.audit_status as auditStatus
- from user u left join admin a on u.aid=a.id
- where u.audit_status=0 and u.status != 1 and u.share_type=0
- <if test="aid != null and aid !=''">
- and u.aid = #{aid,jdbcType=VARCHAR}
- </if>
- <if test="name != null and name != ''">
- and u.nickname = #{name,jdbcType=VARCHAR}
- </if>
- <if test="adminName != null and adminName != ''">
- and a.name = #{adminName,jdbcType=VARCHAR}
- </if>
- <if test="page_sql != null">
- ${page_sql}
- </if>
- </select>
-
- <select id="findEnteringAuditCount" resultType="java.lang.Integer">
- select
- count(0)
- from user u left join admin a on u.aid=a.id
- where u.audit_status=0 and u.status != 1 and u.share_type=0
- <if test="aid != null and aid !=''">
- and u.aid = #{aid,jdbcType=VARCHAR}
- </if>
- <if test="name != null and name != ''">
- and u.nickname = #{name,jdbcType=VARCHAR}
- </if>
- <if test="adminName != null and adminName != ''">
- and a.name = #{adminName,jdbcType=VARCHAR}
- </if>
- </select>
-
- <select id="findEnteringAuditIsNoList" resultType="com.goafanti.customer.bo.CustomerListOut">
- select u.id as uid,u.nickname as name,u.mobile as contactMobile,a.name as adminName,u.create_time as createTime,
- u.audit_status as auditStatus,u.audit_opinion as auditOpinion,u.society_tag as societyTag
- from user u left join admin a on u.aid=a.id
- where u.audit_status=2 and u.status != 1
- <if test="aid != null and aid !=''">
- and u.aid = #{aid,jdbcType=VARCHAR}
- </if>
- <if test="name != null and name != ''">
- and u.nickname = #{name,jdbcType=VARCHAR}
- </if>
- <if test="adminName != null and adminName != ''">
- and a.name = #{adminName,jdbcType=VARCHAR}
- </if>
- <if test="page_sql != null">
- ${page_sql}
- </if>
- </select>
-
- <select id="findEnteringAuditIsNoCount" resultType="java.lang.Integer">
- select
- count(0)
- from user u left join admin a on u.aid=a.id
- where u.audit_status=2 and u.status != 1
- <if test="aid != null and aid !=''">
- and u.aid = #{aid,jdbcType=VARCHAR}
- </if>
- <if test="name != null and name != ''">
- and u.nickname = #{name,jdbcType=VARCHAR}
- </if>
- <if test="adminName != null and adminName != ''">
- and a.name = #{adminName,jdbcType=VARCHAR}
- </if>
- </select>
-
- <update id="updateRefusedCustomer" parameterType="map">
- update user
- set
- nickname = #{nickname,jdbcType=VARCHAR},
- mobile = #{mobile,jdbcType=VARCHAR},
- society_tag = #{societyTag,jdbcType=VARCHAR},
- audit_status=1
- where id = #{id,jdbcType=VARCHAR}
- </update>
-
- <select id="selectLockedProject" resultType="com.goafanti.customer.bo.LockingReleaseBo">
- select
- a.id,
- a.uid,
- a.aid,
- date_format( a.lock_time, '%Y-%m-%d %H:%i:%S' ) as lockTime,
- a.business_project_id as businessProjectId,
- b.bname as businessProjectName,
- d.name as salesmanName
- from
- user_lock_release a left join business_project b on
- a.business_project_id = b.id left join business_category c on
- b.cid = c.id left join admin d on
- a.aid = d.id
- where 1 = 1
- <if test="uid != null and uid != ''">
- and a.uid = #{uid}
- </if>
- <if test="aid != null and aid != ''">
- and a.aid = #{aid}
- </if>
- <if test="businessProjectId != null and businessProjectId != ''">
- and a.business_project_id = #{businessProjectId}
- </if>
- <if test="type != null">
- and a.type = #{type}
- </if>
- <if test="status != null">
- and a.status = #{status}
- </if>
- </select>
-
- <select id="selectPrivateCustomerByName" parameterType="java.lang.String" resultType="com.goafanti.customer.bo.CustomerSimpleBo">
- select b.id,b.identify_name as name from
- (select uid from user_lock_release where type = 0 and status = 0 and aid = #{aid} group by uid) a
- inner join user b on a.uid = b.id
- where b.status != 1 and b.identify_name like concat('%',#{name},'%')
- </select>
-
- <select id="selectSignedCustomerByName" parameterType="java.lang.String" resultType="com.goafanti.customer.bo.CustomerSimpleBo">
- select b.id,b.identify_name as name from
- (select uid from user_lock_release where type = 1 and status = 0 and aid = #{aid} group by uid) a
- inner join user b on a.uid = b.id
- where b.status != 1 and b.identify_name like concat('%',#{name},'%')
- </select>
-
- <update id="updateReleaseLock" parameterType="java.lang.String">
- update user a,user_lock_release b set a.share_type = 1,a.transfer_time = #{time} where b.status=1 and b.`type`=0 and a.id=b.uid
- </update>
-
- <select id="marketingStatistics" parameterType="java.lang.String" resultType="com.goafanti.report.bo.marketingESBo">
- select
- aid,
- count(0) as yearFollowNo,
- ifnull(sum(case when contact_type = 0 then 1 else 0 end) ,0)as yearVisitNo,
- ifnull(sum(case when contact_type = 1 then 1 else 0 end) ,0)as yearTelNo
- from user_follow where 1=1
- and aid = #{id,jdbcType=VARCHAR}
- and create_time > #{dailyStart,jdbcType=VARCHAR}
- and create_time < #{dailyEnd,jdbcType=VARCHAR}
- GROUP BY aid
- </select>
- <select id="marketingDepStatistics" parameterType="java.lang.String" resultType="com.goafanti.report.bo.marketingESBo">
- select
- b.department_id,
- count( 0 ) as yearFollowNo,
- ifnull(
- sum( case when a.contact_type = 0 then 1 else 0 end ),
- 0
- ) as yearVisitNo,
- ifnull(
- sum( case when a.contact_type = 1 then 1 else 0 end ),
- 0
- ) as yearTelNo
- from user_follow a left join admin b on a.aid =b.id
- where
- 1 = 1
- <if test="depId !=null">
- and b.department_id = #{depId,jdbcType=VARCHAR}
- </if>
- and a.create_time > #{dailyStart,jdbcType=VARCHAR}
- and a.create_time < #{dailyEnd,jdbcType=VARCHAR}
- GROUP BY b.department_id
- </select>
-
- <select id="countmarketingDepStatistics" parameterType="java.lang.String" resultType="com.goafanti.report.bo.CountMarketingStatisticsBo">
- select
- count( 0 ) as yearFollowNo,
- ifnull(
- sum( case when a.contact_type = 0 then 1 else 0 end ),
- 0
- ) as yearVisitNo,
- ifnull(
- sum( case when a.contact_type = 1 then 1 else 0 end ),
- 0
- ) as yearTelNo
- from user_follow a left join admin b on a.aid =b.id
- where
- 1 = 1
- <if test="depId !=null">
- and b.department_id = #{depId,jdbcType=VARCHAR}
- </if>
- and a.create_time > #{dailyStart,jdbcType=VARCHAR}
- and a.create_time < #{dailyEnd,jdbcType=VARCHAR}
- </select>
-
- <select id="selectCustomerInformationList" resultType="com.goafanti.customer.bo.CustomerListIn">
- select a.id,a.nickname as name,c.name as province,c1.name as city,c2.name as area,b.contacts,b.contact_mobile as contactMobile,
- date_format(a.create_time,'%Y-%m-%d %H:%i:%S') as createTime,d.name as industry,a.credit_rating as creditRating,a.integrity as dataGrade
- from user a left join organization_identity b
- on a.id=b.uid left join district_glossory c
- on b.location_province=c.id left join district_glossory c1
- on b.location_city=c1.id left join district_glossory c2
- on b.location_area=c2.id left join industry_category d on b.industry = d.id
- <if test="follow !=null and follow!=''">
- left join (select aid,uid,contact_type from user_follow where aid= #{aid,jdbcType=VARCHAR} and contact_type=0 GROUP by uid) e on a.id=e.uid and a.aid=e.aid
- </if>
- where a.status=0
- and a.information_maintainer = #{aid,jdbcType=VARCHAR}
- <if test="type !=null and type!=''">
- and a.`type`=#{type,jdbcType=VARCHAR}
- </if>
- <if test="follow ==0">
- and (e.contact_type !=0 or e.contact_type is null)
- </if>
- <if test="follow ==1">
- and e.contact_type=0
- </if>
- <if test="name!=null and name!=''">
- and a.nickname like concat('%',#{name,jdbcType=VARCHAR},'%')
- </if>
- <if test="province!=null and province!=''">
- and b.location_province= #{province,jdbcType=VARCHAR}
- </if>
- <if test="city!=null and city!=''">
- and b.location_city=#{city,jdbcType=VARCHAR}
- </if>
- <if test="area !=null and area !=''">
- and b.location_area= #{area,jdbcType=VARCHAR}
- </if>
- <if test="startDate != null and startDate != ''">
- and a.create_time > #{startDate}
- </if>
- <if test="endDate != null and endDate != ''">
- and a.create_time < #{endDate}
- </if>
- <if test="dataGrade ==0">
- and a.integrity !=1
- </if>
- <if test="dataGrade ==1">
- and a.integrity =1
- </if>
- order by a.create_time desc,a.nickname desc
- <if test="page_sql != null">
- ${page_sql}
- </if>
- </select>
- <select id="selectCustomerInformationCount" resultType="java.lang.Integer">
- select count(0)
- from user a left join organization_identity b
- on a.id=b.uid
- <if test="follow !=null and follow!=''">
- left join (select aid,uid,contact_type from user_follow where aid= #{aid,jdbcType=VARCHAR} and contact_type=0 GROUP by uid) e on a.id=e.uid and a.aid=e.aid
- </if>
- where a.status=0 and a.information_maintainer = #{aid,jdbcType=VARCHAR}
- <if test="type !=null and type!=''">
- and a.`type`=#{type,jdbcType=VARCHAR}
- </if>
- <if test="follow ==0">
- and (e.contact_type !=0 or e.contact_type is null)
- </if>
- <if test="follow ==1">
- and e.contact_type=0
- </if>
- <if test="name!=null and name!=''">
- and a.nickname like concat('%',#{name,jdbcType=VARCHAR},'%')
- </if>
- <if test="province!=null and province!=''">
- and b.location_province= #{province,jdbcType=VARCHAR}
- </if>
- <if test="city!=null and city!=''">
- and b.location_city=#{city,jdbcType=VARCHAR}
- </if>
- <if test="area !=null and area !=''">
- and b.location_area= #{area,jdbcType=VARCHAR}
- </if>
- <if test="startDate != null and startDate != ''">
- and a.create_time > #{startDate}
- </if>
- <if test="endDate != null and endDate != ''">
- and a.create_time < #{endDate}
- </if>
- <if test="dataGrade ==0">
- and a.integrity !=1
- </if>
- <if test="dataGrade ==1">
- and a.integrity =1
- </if>
- </select>
-
-
- <select id="selectDepCustomerInformationList" resultType="com.goafanti.customer.bo.CustomerListIn">
- select x.id,
- x.name,
- x.province,
- x.city,
- x.area ,
- x.contacts,
- x.contact_mobile as contactMobile,
- date_format( x.create_time, '%Y-%m-%d %H:%i:%S' ) as createTime,
- x.industry as industry,
- y.name as iname,
- x.integrity as dataGrade,
- x.credit_rating as creditRating
- from(
- select
- a.id,
- a.nickname as name,
- c.name as province,
- c1.name as city,
- c2.name as area,
- b.contacts,
- b.contact_mobile,
- a.create_time,
- d.name as industry,
- a.credit_rating ,
- a.information_maintainer,
- a.integrity
- from
- user a left join organization_identity b on
- a.id = b.uid left join district_glossory c
- on b.location_province=c.id left join district_glossory c1
- on b.location_city=c1.id left join district_glossory c2
- on b.location_area=c2.id left join industry_category d
- on b.industry = d.id
- where a.status=0
- <if test="type !=null and type!=''">
- and a.`type`=#{type,jdbcType=VARCHAR}
- </if>
- <if test="name!=null and name!=''">
- and a.nickname like concat('%',#{name,jdbcType=VARCHAR},'%')
- </if>
- <if test="province!=null and province!=''">
- and b.location_province= #{province,jdbcType=VARCHAR}
- </if>
- <if test="city!=null and city!=''">
- and b.location_city=#{city,jdbcType=VARCHAR}
- </if>
- <if test="area !=null and area !=''">
- and b.location_area= #{area,jdbcType=VARCHAR}
- </if>
- <if test="startDate != null and startDate != ''">
- and a.create_time > #{startDate}
- </if>
- <if test="endDate != null and endDate != ''">
- and a.create_time < #{endDate}
- </if>
- <if test="dataGrade ==0">
- and a.integrity !=1
- </if>
- <if test="dataGrade ==1">
- and a.integrity =1
- </if>
- order by a.create_time,a.nickname desc
- )x
- inner join(
- select id ,name from admin a
- inner join (select department_id as depId from admin where id= #{aid,jdbcType=VARCHAR})b on a.department_id=b.depId
- ) y on y.id = x.information_maintainer
- <if test="page_sql != null">
- ${page_sql}
- </if>
- </select>
- <select id="selectDepCustomerInformationCount" resultType="java.lang.Integer">
- select count(0)
- from user a left join organization_identity b
- on a.id=b.uid inner join (select id from admin a
- inner join (select department_id as depId from admin where id= #{aid,jdbcType=VARCHAR} )b on a.department_id=b.depId) y
- on y.id=a.information_maintainer
- where 1=1 and a.status=0
- <if test="type !=null and type!=''">
- and a.`type`=#{type,jdbcType=VARCHAR}
- </if>
- <if test="name!=null and name!=''">
- and a.nickname like concat('%',#{name,jdbcType=VARCHAR},'%')
- </if>
- <if test="province!=null and province!=''">
- and b.location_province= #{province,jdbcType=VARCHAR}
- </if>
- <if test="city!=null and city!=''">
- and b.location_city=#{city,jdbcType=VARCHAR}
- </if>
- <if test="area !=null and area !=''">
- and b.location_area= #{area,jdbcType=VARCHAR}
- </if>
- <if test="startDate != null and startDate != ''">
- and a.create_time > #{startDate}
- </if>
- <if test="endDate != null and endDate != ''">
- and a.create_time < #{endDate}
- </if>
- <if test="dataGrade ==0">
- and a.integrity !=1
- </if>
- <if test="dataGrade ==1">
- and a.integrity =1
- </if>
- </select>
- <select id="checkCustomerInformation" resultType="java.lang.Integer">
- select count(a.id)
- from user a left join organization_identity b
- on a.id=b.uid
- where b.industry is not null
- and b.business_scope is not null
- and b.registered_capital is not null and b.registered_capital !=0
- and b.location_province is not null and b.location_province !=0
- and b.cooperation_situation is not null and b.cooperation_situation !=''
- and b.qualification is not null and b.qualification !=''
- and b.assets is not null and b.assets !=''
- and b.last_year_research_amount is not null and b.last_year_research_amount !=''
- and b.year_sales_amount is not null and b.year_sales_amount !=''
- and a.core_technology is not null and a.core_technology !=''
- and a.accomplish_situation is not null and a.accomplish_situation !=''
- and a.credit_rating is not null and a.credit_rating !=''
- and a.id=#{uid,jdbcType=VARCHAR}
- </select>
- <select id="userDataStatistics" resultType="com.goafanti.report.bo.userDataListBo">
- select a.name ,c.name as depName,ifnull(d.count,0) as signUser,ifnull(e.count,0) as fullUser,
- ifnull(f.count,0) as dayFullUser,ifnull(g.count,0) as dayNewUser,ifnull(h.count,0) as countUser,
- ifnull(i.count,0) as signFullUser
- from admin a inner join (select uid from user_role x
- inner join(select id from `role` where role_name in ('营销员','营销经理','营销管理员')) y
- on x.rid=y.id)b on a.id =b.uid left join department c on a.department_id=c.id
- left join (select x.aid,count(1)as count from (select aid,uid from user_lock_release
- where type=1 and status=0 group by aid,uid)x group by aid)d on a.id=d.aid
- left join (select aid,count(1) as count from user where integrity=1 and type=1 and status=0 and share_type=0 group by aid) e on a.id=e.aid
- left join (select aid,count(1) as count
- from user where integrity=1 and type=1 and status=0 and share_type=0 and to_days(update_time)=to_days(now()) group by aid) f on a.id=f.aid
- left join (select aid,count(1) as count
- from user where type=1 and status=0 and share_type=0 and to_days(create_time)=to_days(now()) group by aid) g on a.id=g.aid
- left join (select aid,count(1) as count
- from user where type=1 and status=0 and share_type=0 group by aid) h on a.id=h.aid
- left join (select x.aid,count(1)as count from (select x1.aid,x1.uid from user_lock_release x1
- left join user y on x1.uid=y.id where x1.type=1
- and x1.status=0 and y.integrity=1 group by aid,uid)x group by aid) i on a.id=i.aid
- where a.status='正常'
- <if test="depId!=null and depId!=''">
- and a.department_id= #{depId,jdbcType=VARCHAR}
- </if>
- </select>
- <select id="userDataStatisticsCount" resultType="com.goafanti.report.bo.userDataListBo">
- select sum(z.signUser) as signUser,sum(z.fullUser) as fullUser,sum(z.dayFullUser) as dayFullUser,
- sum(z.dayNewUser) as dayNewUser,sum(z.countUser) as countUser,sum(z.signFullUser) as signFullUser from (select a.name ,c.name as depName,ifnull(d.count,0) as signUser,ifnull(e.count,0) as fullUser,
- ifnull(f.count,0) as dayFullUser,ifnull(g.count,0) as dayNewUser,ifnull(h.count,0) as countUser,
- ifnull(i.count,0) as signFullUser
- from admin a inner join (select uid from user_role x
- inner join(select id from `role` where role_name in ('营销员','营销经理','营销管理员')) y
- on x.rid=y.id)b on a.id =b.uid left join department c on a.department_id=c.id
- left join (select x.aid,count(1)as count from (select aid,uid from user_lock_release
- where type=1 and status=0 group by aid,uid)x group by aid)d on a.id=d.aid
- left join (select aid,count(1) as count from user where integrity=1 and type=1 and status=0 and share_type=0 group by aid) e on a.id=e.aid
- left join (select aid,count(1) as count
- from user where integrity=1 and type=1 and status=0 and share_type=0 and to_days(update_time)=to_days(now()) group by aid) f on a.id=f.aid
- left join (select aid,count(1) as count
- from user where type=1 and status=0 and share_type=0 and to_days(create_time)=to_days(now()) group by aid) g on a.id=g.aid
- left join (select aid,count(1) as count
- from user where type=1 and status=0 and share_type=0 group by aid) h on a.id=h.aid
- left join (select x.aid,count(1)as count from (select x1.aid,x1.uid from user_lock_release x1
- left join user y on x1.uid=y.id where x1.type=1
- and x1.status=0 and y.integrity=1 group by aid,uid)x group by aid) i on a.id=i.aid
- where a.status='正常'
- <if test="depId!=null and depId!=''">
- and a.department_id= #{depId,jdbcType=VARCHAR}
- </if>
- )z
- </select>
- <select id="UserReceiveCount" parameterType="string" resultType="integer">
- select count(*) from `user`
- where aid= #{aid,jdbcType=VARCHAR}
- and source=2
- and share_type=0
- and to_days(transfer_time)=to_days(now())
- </select>
-
-
- <select id="privateUnitCustomerList" parameterType="Map" resultType="com.goafanti.customer.bo.CustomerListOut">
- select t0.id as uid,
- t0.aid,
- date_format(t0.transfer_time,'%Y-%m-%d %H:%i:%S') as transferTime,
- date_format(t0.create_time,'%Y-%m-%d %H:%i:%S') as createTime,
- t0.identify_name as name,
- t0.society_tag as societyTag,
- t0.level,
- date_format(t1.last_follow_time,'%Y-%m-%d %H:%i:%S') as lastFollowTime,
- date_format(t2.last_sign_time,'%Y-%m-%d %H:%i:%S') as lastSignTime,
- b.contacts,
- b.contact_mobile as contactMobile,
- dg1.name as province,
- dg2.name as city,
- dg3.name as area,
- c.name as industry,
- if(t0.transfer_time < t1.last_follow_time,t1.last_follow_time,t0.transfer_time) as orderTime,
- d.name as adminName
- from
- (select id,aid,type,share_type,transfer_time,create_time,identify_name,society_tag,level from user where aid = #{params.aid} and type = 1 and share_type = 0 and status != 1)t0
- left join
- (select uid,aid,max(create_time) as last_follow_time from user_follow where aid = #{params.aid} group by uid)t1
- on t0.id = t1.uid left join
- (select aid,uid,max(lock_time) as last_sign_time from user_lock_release where aid = #{params.aid} group by uid)t2
- on t0.id = t2.uid
- left join organization_identity b on t0.id = b.uid
- left join district_glossory dg1 on b.location_province = dg1.id
- left join district_glossory dg2 on b.location_city = dg2.id
- left join district_glossory dg3 on b.location_area = dg3.id
- left join industry_category c on b.industry = c.id
- left join admin d on t0.aid = d.id where 1=1
- <if test="params != null">
- <if test="params.aid != null and params.aid !=''">
- and t0.aid = #{params.aid,jdbcType=VARCHAR}
- </if>
- <if test="params.name != null and params.name != ''">
- and t0.identify_name like concat('%',#{params.name},'%')
- </if>
- <if test="params.startDate != null and params.startDate != ''">
- and t0.transfer_time > #{params.startDate}
- </if>
- <if test="params.endDate != null and params.endDate != ''">
- and t0.transfer_time < #{params.endDate}
- </if>
- <if test="params.province != null">
- and b.location_province = #{params.province,jdbcType=INTEGER}
- </if>
- <if test="params.city != null">
- and b.location_city = #{params.city,jdbcType=INTEGER}
- </if>
- <if test="params.area != null">
- and b.location_area = #{params.area,jdbcType=INTEGER}
- </if>
- <if test="params.level != null">
- and t0.level = #{params.level,jdbcType=INTEGER}
- </if>
-
- </if>
- order by orderTime
-
- <if test="params!=null and params.sort == 1">
- order by t0.create_time
- </if>
- <if test="params != null and params.sortType == 1">
- desc
- </if>
- </select>
- </mapper>
|