| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274 |
- <?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 DISTINCT
- a.id as uid,
- a.nickname 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.sign_bills signBills,
- a.share_type as shareType,
- a.channel ,
- a.information_maintainer as mid
- from `user` a
- left join user_names un on a.id=un.uid
- 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 =0
- <if test="role == 0">
- and un.name = #{name}
- </if>
- <if test="role == 1 and name != null">
- and un.name like concat('%', #{name},'%')
- </if>
- <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(select a.id from `user` a
- <if test="name != null">
- left join user_names un on a.id=un.uid
- </if>
- 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 =0
- <if test="role == 0 and name !=null">
- and un.name = #{name}
- </if>
- <if test="role == 1 and name != null">
- and un.name like concat('%', #{name},'%')
- </if>
- <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>
- group by a.id)x
- </select>
- <select id="selectPublicOrganizationCustomerList" resultType="com.goafanti.customer.bo.CustomerListOut">
- select
- a.id as uid,
- a.nickname as name,
- a.create_time as createTime,
- a.transfer_time as transferTime,
- 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 = 0 and a.source in(1,2,3)
- <if test="aid != null and aid !=''">
- and a.aid = #{aid,jdbcType=VARCHAR}
- </if>
- <if test="name != null and name != ''">
- and a.nickname 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="sort == 1">
- order by a.transfer_time desc
- </if>
- <if test="sort == 2">
- order by a.transfer_time
- </if>
- <if test="page_sql != null">
- ${page_sql}
- </if>
- </select>
- <select id="selectPublicOrganizationCustomerCount" resultType="java.lang.Integer">
- select
- count(0)
- from user a
- <if test="province != null or city != null or area != null">
- inner join organization_identity b on a.id = b.uid
- </if>
- where a.type = 1 and a.share_type = 1 and a.status = 0 and a.source in(1,2,3)
- <if test="aid != null and aid !=''">
- and a.aid = #{aid,jdbcType=VARCHAR}
- </if>
- <if test="name != null and name != ''">
- and a.nickname 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
- a.id as uid,
- a.society_tag as societyTag,
- a.nickname as name,
- a.share_type as shareType,
- date_format(a.transfer_time,'%Y-%m-%d %H:%i:%S') as transferTime,
- dg1.name as province,
- dg2.name as city,
- dg3.name as area,
- c.name as industry,
- a.channel,
- b.intended_project intendedProject,
- b.business_scope businessScope,
- d.name as adminName
- 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 industry_category c on b.industry = c.id
- left join admin d on a.aid = d.id where a.share_type =2
- <if test="aid != null and aid != ''">
- and a.aid = #{aid}
- </if>
- <if test="channel !=null">
- and a.channel= #{channel}
- </if>
- <if test="name != null and name != ''">
- and a.nickname like concat('%',#{name},'%')
- </if>
- <if test="shareType != null">
- and a.share_type = #{shareType,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>
- order by a.transfer_time desc,a.`number`
- <if test="page_sql != null">
- ${page_sql}
- </if>
- </select>
- <select id="selectSignOrganizationCustomerCount" resultType="java.lang.Integer">
- select count(0) from user a
- left join organization_identity b on a.id = b.uid
- where a.share_type =2
- <if test="aid != null and aid != ''">
- and a.aid = #{aid}
- </if>
- <if test="channel !=null">
- and a.channel= #{channel}
- </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="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="findCustomerByName" parameterType="java.lang.String" resultType="com.goafanti.customer.bo.CustomerSimpleBo">
- select id,nickname 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,
- a.nickname, 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.sales_target salesTarget, 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,date_format( a.create_time,'%Y-%m-%d %H:%i:%S') as followTime, a.contact_type as contactType,
- a.result,a.guidance, b.nickname,b.identify_name as identifyName, c.name as contacts, c.mobile as contactMobile,pr.supplement ,pr.id prid,
- d.name as adminName,date_format(a.guidance_time,'%Y-%m-%d %H:%i:%S') as guidanceTime,a.guidance_name guidanceName,
- pr.plan ,pr.next_plan nextPlan ,pr.expected_effect expectedEffect
- <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 left join public_release pr on a.id =pr.ufid
- <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>
- order by a.create_time desc
- <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,
- guidance
- from
- user
- where id = #{uid,jdbcType=VARCHAR}
- </select>
- <select id="findCustomerContacts" parameterType="java.lang.String" resultType="com.goafanti.common.model.OrganizationContactBook">
- select a.id,a.name,a.mobile,a.email,a.qq,a.wechat,a.department,a.position,a.major,a.fixed_tel fixedTel,ad.name aname,b.location_province,
- d1.name provinceName,d2.name cityName,d3.name areaName,date_format(a.create_time,'%Y-%m-%d')createTimes,a.aid
- from organization_contact_book a left join admin ad on a.aid=ad.id
- left join organization_identity b on a.uid=b.uid left join district_glossory d1 on b.location_province=d1.id
- left join district_glossory d2 on b.location_city=d2.id left join district_glossory d3 on b.location_area=d3.id
- where a.uid = #{uid,jdbcType=VARCHAR}
- <if test="aid !=null">
- and a.aid= #{aid,jdbcType=VARCHAR}
- </if>
- order by a.create_time desc
- </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,
- a.remarks,
- 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.nickname 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 and a.share_type in (0,2,3)
- <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.nickname like concat('%',#{name},'%')
- </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 and a.share_type in (0,2,3)
- <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.nickname like concat('%',#{name},'%')
- </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.nickname 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.channel =0 and b.nickname like concat('%',#{name},'%')
- </select>
- <select id="selectSignedCustomerByName" resultType="com.goafanti.customer.bo.CustomerSimpleBo">
- select b.id,b.nickname as name from user b
- where b.status != 1
- <if test="type==2">
- and b.channel=1
- </if>
- <if test="type==1">
- and b.share_type=2
- </if>
- and b.aid = #{aid} and b.nickname 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}
- ,b.status=2,b.release_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,
- b.business_scope businessScope,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.`type` =1 and a.new_channel=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="businessScope != null">
- and b.business_scope like concat('%',#{businessScope},'%')
- </if>
- <if test="shareType!=null">
- and a.share_type= #{shareType}
- </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(*)
- 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.`type` =1 and a.new_channel=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="businessScope != null">
- and b.business_scope like concat('%',#{businessScope},'%')
- </if>
- <if test="shareType!=null">
- and a.share_type= #{shareType}
- </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>
- <select id="checkUserMax" parameterType="string" resultType="integer">
- select count(*) from `user`
- where aid= #{aid,jdbcType=VARCHAR}
- and source in(1,2,3) and share_type=0 and channel =0
- </select>
- <select id="checkRoleMax" parameterType="string" resultType="string">
- select role_type from user_role ur left join `role` r on ur.rid =r.id
- where ur.uid = #{aid,jdbcType=VARCHAR} order by role_type desc limit 1
- </select>
- <select id="checkLock" parameterType="string" resultType="integer">
- select count(*) from `user`
- where id= #{uid,jdbcType=VARCHAR}
- and share_type=2
- </select>
- <update id="updateShareType">
- update user set share_type =2,sign_bills =1,aid = #{aid}
- where id= #{uid}
- </update>
- <insert id="insertBatch" parameterType="com.goafanti.user.bo.InputUserChannel">
- INSERT INTO `user` (id, mobile, password,
- nickname,identify_name,username,
- share_type,type,society_tag,channel,source,status)VALUES
- <foreach item="item" index="index" collection="list"
- separator=",">
- (#{item.uid,jdbcType=VARCHAR}, #{item.contactMobile,jdbcType=VARCHAR},#{item.password,jdbcType=VARCHAR},
- #{item.userName},#{item.userName},#{item.userName},
- #{item.shareType,jdbcType=TIMESTAMP}, 1,#{item.societyTag},1,1 ,#{item.userStatus})
- </foreach>
- </insert>
- <select id="selectChannelCustomerList" resultType="com.goafanti.user.bo.OutUserChannel">
- select a.id,a.uid,b.nickname userName,a.aid,a.status,date_format(a.distribution_time,'%Y-%m-%d %H:%i:%S')distributionTimes,
- a.distribution_time distributionTime,date_format(a.create_time,'%Y-%m-%d %H:%i:%S')createTimes ,c.contacts ,
- c.contact_mobile contactMobile,e.name channelName,b.society_tag societyTag ,d1.name province,d2.name city,
- f.name adminName ,b.guidance,a.recovery,a.remarks,c.intended_project intendedProject,c.business_scope businessScope
- from user_channel a
- left join user b on a.uid=b.id left join organization_identity c on a.uid =c.uid
- left join district_glossory d1 on c.location_province =d1.id
- left join district_glossory d2 on c.location_city =d2.id
- left join admin e on a.aid =e.id
- left join admin f on b.aid=f.id
- where 1=1
- <if test="status !=null">
- and a.status = #{status}
- </if>
- <!-- 0营销员 1渠道专员 2营销总监 3营销经理 4释放 5未分配 6已分配 7已签单 -->
- <if test="type==0">
- and a.status in(1,2,7)
- and b.aid= #{sid}
- <if test="aid!=null">
- and a.aid= #{aid}
- </if>
- </if>
- <if test="type==1">
- and a.status in (0,1,2,6,7)
- and a.aid= #{aid}
- </if>
- <if test="type==2">
- and a.status in (0,1,2,6,7)
- <if test="aid != null">
- and a.aid= #{aid}
- </if>
- </if>
- <if test="type==3">
- and a.status in (0,1,2,6,7)
- and a.maid= #{maid}
- <if test="aid != null">
- and a.aid= #{aid}
- </if>
- </if>
- <if test="type==4">
- and a.status =8
- and a.aid= #{aid}
- </if>
- <if test="type==5">
- and a.status in(0,6)
- and a.aid= #{aid}
- </if>
- <if test="type==6">
- and a.status in(1,2)
- and a.aid= #{aid}
- </if>
- <if test="type==7">
- and a.status =7
- and a.aid= #{aid}
- </if>
- <if test="province !=null">
- and c.location_province= #{province}
- </if>
- <if test="city!=null">
- and c.location_city= #{city}
- </if>
- <if test="name!=null">
- and b.nickname like concat('%',#{name},'%')
- </if>
- <if test="startTime!=null and endTime !=null">
- and a.create_time between #{startTime} and #{endTime}
- </if>
- order by a.status ,a.create_time desc,a.id
- <if test="page_sql != null">
- ${page_sql}
- </if>
- </select>
- <select id="selectChannelCustomerCount" resultType="java.lang.Integer">
- select count(*) from user_channel a
- left join user b on a.uid=b.id left join organization_identity c on a.uid =c.uid
- where 1=1
- <if test="status !=null">
- and a.status = #{status}
- </if>
- <!-- 0营销员 1渠道专员 2营销总监 3营销经理 4释放 5未分配 6已分配 7已签单 -->
- <if test="type==0">
- and a.status in(1,2,7)
- and b.aid= #{sid}
- <if test="aid!=null">
- and a.aid= #{aid}
- </if>
- </if>
- <if test="type==1">
- and a.status in (0,1,2,6,7)
- and a.aid= #{aid}
- </if>
- <if test="type==2">
- and a.status in (0,1,2,6,7)
- <if test="aid != null">
- and a.aid= #{aid}
- </if>
- </if>
- <if test="type==3">
- and a.status in (0,1,2,6,7)
- and a.maid= #{maid}
- <if test="aid != null">
- and a.aid= #{aid}
- </if>
- </if>
- <if test="type==4">
- and a.status =8
- and a.aid= #{aid}
- </if>
- <if test="type==5">
- and a.status in(0,6)
- and a.aid= #{aid}
- </if>
- <if test="type==6">
- and a.status in(1,2)
- and a.aid= #{aid}
- </if>
- <if test="type==7">
- and a.status =7
- and a.aid= #{aid}
- </if>
- <if test="province !=null">
- and c.location_province= #{province}
- </if>
- <if test="city!=null">
- and c.location_city= #{city}
- </if>
- <if test="name!=null">
- and b.nickname like concat('%',#{name},'%')
- </if>
- <if test="startTime!=null and endTime !=null">
- and a.create_time between #{startTime} and #{endTime}
- </if>
- </select>
- <update id="updatechannelCustomerDeliver">
- update user set aid = #{aid},information_maintainer= #{aid},transfer_time=now()
- where id in(
- <foreach item="item" collection="list" separator="," index="">
- #{item}
- </foreach>
- )
- </update>
- <update id="updateReleaseUserChannel">
- update user a ,user_channel b,user_lock_release c
- set
- <if test="type==0">
- b.status = 6,b.recovery=1,
- </if>
- <if test="type==1">
- a.share_type = 1,b.status = 8,
- </if>
- a.transfer_time = now(), c.release_time = now(),
- c.status = 2
- where a.id=b.uid and a.id=c.uid and a.aid=c.aid and c.status =0 and c.`type` =0
- and b.status in (0,1,2) and a.id in(
- <foreach item="item" collection="list" separator="," index="">
- #{item.uid}
- </foreach>
- )
- </update>
- <select id="checkBeforeChannel" resultType="java.lang.String">
- select b.aid from user_channel a
- left join user b on a.uid =b.id
- where a.status=8 and a.uid = #{uid}
- </select>
- <select id="selectChannelCountsList" resultType="com.goafanti.customer.bo.OutChannelCounts">
- select b.name,b.id aid,a.counts,a.wfp unallocated,a.yfp allocated,a.yqd sign,a.ysf common
- from admin b
- left join (select t1.aid,sum(tj)counts ,sum(t1.wfp)wfp,sum(t1.yfp)yfp,sum(t1.yqd)yqd,sum(t1.ysf)ysf from
- (select x.aid,x.uid,
- if(x.status=8,0,1) tj,
- case x.status when 0 then 1 when 6 then 1 else 0 end as wfp,
- case x.status when 1 then 1 when 2 then 1 else 0 end as yfp,
- case x.status when 7 then 1 else 0 end as yqd,
- case x.status when 8 then 1 else 0 end as ysf
- from user_channel x left join user y on x.uid =y.id
- where 1=1 and x.status in (0,1,2,6,7,8)
- <if test="type==0 and startTime !=null and endTime !=null">
- and x.create_time between #{startTime} and #{endTime}
- </if>
- <if test="type==1 and startTime !=null and endTime !=null">
- and x.distribution_time between #{startTime} and #{endTime}
- </if>
- <if test="type==2 and startTime !=null and endTime !=null">
- and x.sign_time between #{startTime} and #{endTime}
- </if>
- )t1 group by t1.aid)a on a.aid=b.id left join user_role ur on b.id=ur.uid
- left join `role` r on r.id=ur.rid where r.role_type=80
- <if test="page_sql != null">
- ${page_sql}
- </if>
- </select>
- <select id="selectChannelCountsCount" resultType="java.lang.Integer">
- select count(*) from admin b left join user_role ur on b.id=ur.uid
- left join `role` r on r.id=ur.rid
- where r.role_type=80
- </select>
- <select id="getUserByName" parameterType="java.lang.String" resultType="com.goafanti.customer.bo.CustomerSimpleBo">
- select id,nickname name from `user` where nickname like concat('%',#{name},'%')
- </select>
- <select id="getUserByNameList" parameterType="java.lang.String" resultType="com.goafanti.customer.bo.CustomerSimpleBo">
- select id,nickname name from `user` where nickname like concat('%',#{name},'%')
- <if test="page_sql != null">
- ${page_sql}
- </if>
- </select>
- <select id="getUserByNameCount" resultType="java.lang.Integer" >
- select count(*) from `user` where nickname like concat('%',#{name},'%')
- </select>
- <select id="getAllUser" resultType="com.goafanti.common.bo.OutUser">
- select id,name ,province ,name_mobile nameMobile from user_now
- </select>
- <select id="channelUserList" resultType="com.goafanti.customer.bo.OutChannelListBo">
- select
- a.id id,a.aid,a.nickname name,b.name aName,dg1.name as province,dg2.name as city,
- dg3.name as area,date_format(um.last_sign_time,'%Y-%m-%d %H:%i:%S') lastSignTime,
- date_format(a.transfer_time,'%Y-%m-%d %H:%i:%S') as transferTime,a.introduction ,
- date_format(a.create_time,'%Y-%m-%d %H:%i:%S') as createTime,
- date_format(um.last_follow_time,'%Y-%m-%d %H:%i:%S') lastFollowTime ,
- if(a.transfer_time < um.last_follow_time,um.last_follow_time,a.transfer_time) as orderTime,
- um.channel_type type
- from user a left join admin b on a.aid=b.id left join organization_identity d on a.id = d.uid
- left join district_glossory dg1 on d.location_province = dg1.id
- left join district_glossory dg2 on d.location_city = dg2.id
- left join district_glossory dg3 on d.location_area = dg3.id
- left join user_mid um on um.aid=a.aid and um.uid=a.id
- where a.type= 1 and a.source in(1,2,3) and a.new_channel=1
- <if test=" shareType !=null ">
- and a.share_type = #{shareType}
- </if>
- <if test=" newChannel !=null ">
- and a.new_channel = #{newChannel}
- </if>
- <if test=" name !=null ">
- and a.nickname like concat ('%',#{name},'%')
- </if>
- <if test=" aid !=null ">
- and a.aid= #{aid}
- </if>
- <if test=" province !=null ">
- and d.location_province= #{province}
- </if>
- <if test=" city !=null ">
- and d.location_city= #{city}
- </if>
- <if test=" area !=null ">
- and d.location_area= #{area}
- </if>
- <if test=" type !=null ">
- and um.channel_type= #{type}
- </if>
- <if test=" startDate !=null and endDate !=null ">
- and a.transfer_time between #{startDate} and #{endDate}
- </if>
- order by orderTime,a.transfer_time,a.create_time desc
- <if test="page_sql != null">
- ${page_sql}
- </if>
- </select>
- <select id="channelUserCout" resultType="integer">
- select
- count(*)
- from user a left join admin b on a.aid=b.id left join organization_identity d on a.id = d.uid
- left join user_mid um on um.aid=a.aid and um.uid=a.id
- where a.type= 1 and a.source in(1,2,3)
- <if test=" shareType !=null ">
- and a.share_type = #{shareType}
- </if>
- <if test=" newChannel !=null ">
- and a.new_channel = #{newChannel}
- </if>
- <if test=" name !=null ">
- and a.nickname like concat ('%',#{name},'%')
- </if>
- <if test=" aid !=null ">
- and a.aid= #{aid}
- </if>
- <if test=" province !=null ">
- and d.location_province= #{province}
- </if>
- <if test=" city !=null ">
- and d.location_city= #{city}
- </if>
- <if test=" area !=null ">
- and d.location_area= #{area}
- </if>
- <if test=" type !=null ">
- and um.channel_type= #{type}
- </if>
- <if test=" startDate !=null and endDate !=null ">
- and a.transfer_time between #{startDate} and #{endDate}
- </if>
- </select>
- </mapper>
|