| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333 |
- <?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.AdminMapper">
- <resultMap type="com.goafanti.common.model.Admin" id="AdminMap">
- <result property="id" column="id" jdbcType="VARCHAR"/>
- <result property="mobile" column="mobile" jdbcType="VARCHAR"/>
- <result property="name" column="name" jdbcType="VARCHAR"/>
- <result property="password" column="password" jdbcType="VARCHAR"/>
- <result property="email" column="email" jdbcType="VARCHAR"/>
- <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
- <result property="number" column="number" jdbcType="INTEGER"/>
- <result property="province" column="province" jdbcType="VARCHAR"/>
- <result property="position" column="position" jdbcType="VARCHAR"/>
- <result property="superiorId" column="superior_id" jdbcType="VARCHAR"/>
- <result property="city" column="city" jdbcType="VARCHAR"/>
- <result property="departmentId" column="department_id" jdbcType="VARCHAR"/>
- <result property="status" column="status" jdbcType="VARCHAR"/>
- <result property="userNo" column="user_no" jdbcType="VARCHAR"/>
- <result property="duty" column="duty" jdbcType="VARCHAR"/>
- <result property="district" column="district" jdbcType="VARCHAR"/>
- <result property="headPortraitUrl" column="head_portrait_url" jdbcType="VARCHAR"/>
- <result property="contactMobile" column="contact_mobile" jdbcType="VARCHAR"/>
- <result property="lastLoginTime" column="last_login_time" jdbcType="TIMESTAMP"/>
- <result property="openId" column="open_id" jdbcType="VARCHAR"/>
- <result property="type" column="type" jdbcType="INTEGER"/>
- <result property="reviewer" column="reviewer" jdbcType="VARCHAR"/>
- <result property="ambId" column="amb_id" jdbcType="VARCHAR"/>
- <result property="ambRole" column="amb_role" jdbcType="VARCHAR"/>
- <result property="ambManage" column="amb_manage" jdbcType="INTEGER"/>
- <result property="managerId" column="manager_id" jdbcType="VARCHAR"/>
- <result property="seniorStaff" column="senior_staff" jdbcType="INTEGER"/>
- <result property="publicPurview" column="public_purview" jdbcType="INTEGER"/>
- <result property="expenseOpenId" column="expense_open_id" jdbcType="VARCHAR"/>
- <result property="expenseSuperExamine" column="expense_super_examine" jdbcType="INTEGER"/>
- <result property="publicCarbonCopy" column="public_carbon_copy" jdbcType="VARCHAR"/>
- <result property="callNo" column="call_no" jdbcType="VARCHAR"/>
- <result property="teamId" column="team_id" jdbcType="INTEGER"/>
- </resultMap>
- <sql id="AdminAllSql">
- id, mobile, name, password, email, create_time, number, province, position, superior_id, city, department_id, status, user_no, duty, district, head_portrait_url, contact_mobile, last_login_time, open_id, type, reviewer, amb_id, amb_role, amb_manage, manager_id, senior_staff, public_purview, expense_open_id, expense_super_examine, public_carbon_copy, call_no, team_id
- </sql>
- <!--查询单个-->
- <select id="queryById" resultMap="AdminMap">
- select
- <include refid="AdminAllSql"/>
- from admin
- where id = #{id}
- </select>
- <!--新增所有列-->
- <insert id="insert" keyProperty="id" useGeneratedKeys="true">
- insert into admin(id,mobile, name, password, email, create_time, number, province, position, superior_id, city,
- department_id, status, user_no, duty, district, head_portrait_url, contact_mobile,
- last_login_time, open_id, type, reviewer, amb_id, amb_role, amb_manage, manager_id,
- senior_staff, public_purview, expense_open_id, expense_super_examine, public_carbon_copy,
- call_no, team_id)
- values (#{id},#{mobile}, #{name}, #{password}, #{email}, #{createTime}, #{number}, #{province}, #{position},
- #{superiorId}, #{city}, #{departmentId}, #{status}, #{userNo}, #{duty}, #{district}, #{headPortraitUrl},
- #{contactMobile}, #{lastLoginTime}, #{openId}, #{type}, #{reviewer}, #{ambId}, #{ambRole}, #{ambManage},
- #{managerId}, #{seniorStaff}, #{publicPurview}, #{expenseOpenId}, #{expenseSuperExamine},
- #{publicCarbonCopy}, #{callNo}, #{teamId})
- </insert>
- <insert id="insertBatch">
- insert into admin(mobile, name, password, email, create_time, number, province, position, superior_id, city,
- department_id, status, user_no, duty, district, head_portrait_url, contact_mobile, last_login_time, open_id,
- type, reviewer, amb_id, amb_role, amb_manage, manager_id, senior_staff, public_purview, expense_open_id,
- expense_super_examine, public_carbon_copy, call_no, team_id)
- values
- <foreach collection="entities" item="entity" separator=",">
- (#{entity.mobile}, #{entity.name}, #{entity.password}, #{entity.email}, #{entity.createTime},
- #{entity.number}, #{entity.province}, #{entity.position}, #{entity.superiorId}, #{entity.city},
- #{entity.departmentId}, #{entity.status}, #{entity.userNo}, #{entity.duty}, #{entity.district},
- #{entity.headPortraitUrl}, #{entity.contactMobile}, #{entity.lastLoginTime}, #{entity.openId},
- #{entity.type}, #{entity.reviewer}, #{entity.ambId}, #{entity.ambRole}, #{entity.ambManage},
- #{entity.managerId}, #{entity.seniorStaff}, #{entity.publicPurview}, #{entity.expenseOpenId},
- #{entity.expenseSuperExamine}, #{entity.publicCarbonCopy}, #{entity.callNo}, #{entity.teamId})
- </foreach>
- </insert>
- <insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
- insert into admin(mobile, name, password, email, create_time, number, province, position, superior_id, city,
- department_id, status, user_no, duty, district, head_portrait_url, contact_mobile, last_login_time, open_id,
- type, reviewer, amb_id, amb_role, amb_manage, manager_id, senior_staff, public_purview, expense_open_id,
- expense_super_examine, public_carbon_copy, call_no, team_id)
- values
- <foreach collection="entities" item="entity" separator=",">
- (#{entity.mobile}, #{entity.name}, #{entity.password}, #{entity.email}, #{entity.createTime},
- #{entity.number}, #{entity.province}, #{entity.position}, #{entity.superiorId}, #{entity.city},
- #{entity.departmentId}, #{entity.status}, #{entity.userNo}, #{entity.duty}, #{entity.district},
- #{entity.headPortraitUrl}, #{entity.contactMobile}, #{entity.lastLoginTime}, #{entity.openId},
- #{entity.type}, #{entity.reviewer}, #{entity.ambId}, #{entity.ambRole}, #{entity.ambManage},
- #{entity.managerId}, #{entity.seniorStaff}, #{entity.publicPurview}, #{entity.expenseOpenId},
- #{entity.expenseSuperExamine}, #{entity.publicCarbonCopy}, #{entity.callNo})
- </foreach>
- on duplicate key update
- mobile = values(mobile),
- name = values(name),
- password = values(password),
- email = values(email),
- create_time = values(create_time),
- number = values(number),
- province = values(province),
- position = values(position),
- superior_id = values(superior_id),
- city = values(city),
- department_id = values(department_id),
- status = values(status),
- user_no = values(user_no),
- duty = values(duty),
- district = values(district),
- head_portrait_url = values(head_portrait_url),
- contact_mobile = values(contact_mobile),
- last_login_time = values(last_login_time),
- open_id = values(open_id),
- type = values(type),
- reviewer = values(reviewer),
- amb_id = values(amb_id),
- amb_role = values(amb_role),
- amb_manage = values(amb_manage),
- manager_id = values(manager_id),
- senior_staff = values(senior_staff),
- public_purview = values(public_purview),
- expense_open_id = values(expense_open_id),
- expense_super_examine = values(expense_super_examine),
- public_carbon_copy = values(public_carbon_copy),
- call_no = values(call_no),
- team_id = values(team_id)
- </insert>
- <!--通过主键修改数据-->
- <update id="update">
- update admin
- <set>
- <if test="mobile != null and mobile != ''">
- mobile = #{mobile},
- </if>
- <if test="name != null and name != ''">
- name = #{name},
- </if>
- <if test="password != null and password != ''">
- password = #{password},
- </if>
- <if test="email != null and email != ''">
- email = #{email},
- </if>
- <if test="createTime != null">
- create_time = #{createTime},
- </if>
- <if test="number != null">
- number = #{number},
- </if>
- <if test="province != null and province != ''">
- province = #{province},
- </if>
- <if test="position != null and position != ''">
- position = #{position},
- </if>
- <if test="superiorId != null and superiorId != ''">
- superior_id = #{superiorId},
- </if>
- <if test="city != null and city != ''">
- city = #{city},
- </if>
- <if test="departmentId != null and departmentId != ''">
- department_id = #{departmentId},
- </if>
- <if test="status != null and status != ''">
- status = #{status},
- </if>
- <if test="userNo != null and userNo != ''">
- user_no = #{userNo},
- </if>
- <if test="duty != null and duty != ''">
- duty = #{duty},
- </if>
- <if test="district != null and district != ''">
- district = #{district},
- </if>
- <if test="headPortraitUrl != null and headPortraitUrl != ''">
- head_portrait_url = #{headPortraitUrl},
- </if>
- <if test="contactMobile != null and contactMobile != ''">
- contact_mobile = #{contactMobile},
- </if>
- <if test="lastLoginTime != null">
- last_login_time = #{lastLoginTime},
- </if>
- <if test="openId != null and openId != ''">
- open_id = #{openId},
- </if>
- <if test="type != null">
- type = #{type},
- </if>
- <if test="reviewer != null and reviewer != ''">
- reviewer = #{reviewer},
- </if>
- <if test="ambId != null and ambId != ''">
- amb_id = #{ambId},
- </if>
- <if test="ambRole != null and ambRole != ''">
- amb_role = #{ambRole},
- </if>
- <if test="ambManage != null">
- amb_manage = #{ambManage},
- </if>
- <if test="managerId != null and managerId != ''">
- manager_id = #{managerId},
- </if>
- <if test="seniorStaff != null">
- senior_staff = #{seniorStaff},
- </if>
- <if test="publicPurview != null">
- public_purview = #{publicPurview},
- </if>
- <if test="expenseOpenId != null and expenseOpenId != ''">
- expense_open_id = #{expenseOpenId},
- </if>
- <if test="expenseSuperExamine != null">
- expense_super_examine = #{expenseSuperExamine},
- </if>
- <if test="publicCarbonCopy != null and publicCarbonCopy != ''">
- public_carbon_copy = #{publicCarbonCopy},
- </if>
- <if test="callNo != null and callNo != ''">
- call_no = #{callNo},
- </if>
- <if test="teamId != null">
- team_id = #{teamId},
- </if>
- </set>
- where id = #{id}
- </update>
- <!--通过主键删除-->
- <delete id="deleteById">
- delete
- from admin
- where id = #{id}
- </delete>
- <select id="selectAllAdmin" resultMap="AdminMap">
- select
- <include refid="AdminAllSql" />
- from admin
- where status ='0'
- <if test="depId != null">
- and department_id = #{depId,jdbcType=VARCHAR}
- </if>
- </select>
- <select id="selectByMobile" parameterType="java.lang.String" resultMap="AdminMap">
- select
- a.id,a.mobile,a.name,
- a.password,a.email,a.create_time,
- a.number,b.province ,a.position,
- a.superior_id,a.city,a.department_id,
- a.status,a.user_no,a.duty,
- a.district,a.head_portrait_url,a.contact_mobile,
- a.last_login_time,a.open_id,a.type,
- a.reviewer,a.amb_id,a.amb_role,
- a.amb_manage,a.manager_id,a.senior_staff,
- a.public_purview,a.expense_open_id,a.expense_super_examine,a.call_no
- from admin a left join department b on a.department_id=b.id
- left join district_glossory c on b.province=c.id
- where a.mobile = #{mobile,jdbcType=VARCHAR}
- </select>
- <select id="selectRolesByPrimaryKey" parameterType="java.lang.String" resultType="com.goafanti.common.model.Role">
- select r.role_name name, r.id, r.role_type type
- from role r
- left join user_role ur on ur.rid=r.id
- where ur.uid = #{uid,jdbcType=VARCHAR}
- </select>
- <select id="selectCognizanceConsultant" resultMap="AdminMap">
- select
- <include refid="AdminAllSql" />
- from admin
- where id <![CDATA[ <> ]]> '1'
- </select>
- <select id="selectCognizancePrincipal" resultMap="AdminMap">
- select a.id, a.name, a.position from admin a
- INNER JOIN user_role ur on a.id = ur.uid
- where ur.rid not in('1','2','3','4','5','6')
- group by a.id
- </select>
- <select id="selectPatentAuthor" resultMap="AdminMap">
- select a.id, a.name, a.position from admin a
- INNER JOIN user_role ur on a.id = ur.uid
- where ur.rid not in('1','2','3','4','5','6')
- group by a.id
- </select>
- <select id="selectPatentPrincipal" resultMap="AdminMap">
- select a.id, a.name, a.position from admin a
- INNER JOIN user_role ur on a.id = ur.uid
- where ur.rid not in('1','2','3','4','5','6')
- group by a.id
- </select>
- <select id="selectCopyrightConsultant" resultMap="AdminMap">
- select
- <include refid="AdminAllSql" />
- from admin
- where id <![CDATA[ <> ]]> '1'
- </select>
- <select id="selectCopyrightPrincipal" resultMap="AdminMap">
- select a.id, a.name, a.position from admin a
- INNER JOIN user_role ur on a.id = ur.uid
- where ur.rid not in('1','2','3','4','5','6')
- group by a.id
- </select>
- <select id="selectTechprojectConsultant" resultMap="AdminMap">
- select
- <include refid="AdminAllSql" />
- from admin
- where id <![CDATA[ <> ]]> '1'
- </select>
- <select id="selectTechprojectPrincipal" resultMap="AdminMap">
- select a.id, a.name, a.position from admin a
- INNER JOIN user_role ur on a.id = ur.uid
- where ur.rid not in('1','2','3','4','5','6')
- group by a.id
- </select>
- <select id="selectRoleByPrimaryKey" parameterType="java.lang.String" resultType="String">
- SELECT rid FROM user_role
- where uid = #{uid,jdbcType=VARCHAR}
- </select>
- <select id="selectAccoutManager" resultMap="AdminMap">
- select a.id, a.name, a.position from admin a
- INNER JOIN user_role ur on a.id = ur.uid
- where ur.rid = '4'
- </select>
- <select id="selectTechnician" resultMap="AdminMap">
- select a.id, a.name, a.position from admin a
- INNER JOIN user_role ur on a.id = ur.uid
- where ur.rid not in('1','2','3','4')
- group by a.id
- </select>
- <select id="selectSalesman" resultMap="AdminMap">
- select a.id, a.name, a.position from admin a
- INNER JOIN user_role ur on a.id = ur.uid
- where ur.rid in ('5', '6')
- </select>
- <select id="selectContractManager" resultMap="AdminMap">
- select a.id, a.name, a.position from admin a
- INNER JOIN user_role ur on a.id = ur.uid
- where ur.rid not in('1','2','3','4')
- group by a.id
- </select>
- <select id="selectTechBroder" resultMap="AdminMap">
- select
- u.rid as rolesId, a.name,a.id, a.position
- from user_role u
- left join admin a on a.id =u.uid
- left join role r on r.id =u.rid
- where
- r.role_name='技术经纪专员'
- </select>
- <select id="listAdminSelectBySuperAdmin" resultMap="AdminMap">
- select
- <include refid="AdminAllSql" />
- from admin
- where id <![CDATA[ <> ]]> '1'
- </select>
- <select id="listAdminSelectByAreaAdmin" resultMap="AdminMap">
- select
- a.id, a.name, a.mobile,
- a.create_time as createTime, a.number, aa.name as superior
- from admin a
- left join admin_location al on al.admin_id = a.id
- left join admin aa on aa.id = a.superior_id
- where 1 = 1
- <if test="provinceList != null and provinceList.size > 0">
- and al.province in
- <foreach close=")" collection="provinceList" item="plist" open="(" separator=",">
- #{plist}
- </foreach>
- </if>
- <if test="cityList != null and cityList.size > 0">
- and al.city in
- <foreach close=")" collection="cityList" item="clist" open="(" separator=",">
- #{clist}
- </foreach>
- </if>
- </select>
- <select id="findAdminListByPage" parameterType="java.lang.String" resultType="com.goafanti.admin.bo.AdminListBo">
- select
- a.number, a.mobile, a.name,
- a.position, a.email, a.id,
- a.province,
- a.city,
- a.create_time as createTime,
- aa.name as superior,
- a.superior_id as superiorId,
- a.department_id as departmentId,
- date_format(a.last_login_time,'%Y-%m-%d %H:%i:%S') as lastLoginTime,
- dm.name as departmentName
- from admin a
- left join admin_location al on a.id = al.admin_id
- left join admin aa on aa.id = a.superior_id
- left join department dm on a.department_id = dm.id
- left join user_role x on x.uid=a.id
- left join `role` y on x.rid=y.id
- where a.id <![CDATA[ <> ]]> '1'
- <if test="roleName != null">
- where y.role_name= #{roleName,jdbcType=VARCHAR}
- </if>
- <if test="mobile != null">
- and a.mobile = #{mobile,jdbcType=VARCHAR}
- </if>
- <if test="name != null">
- and a.name = #{name,jdbcType=VARCHAR}
- </if>
- <if test="number != null">
- and a.number = #{number,jdbcType=INTEGER}
- </if>
- <if test="seniorStaff != null">
- and a.senior_staff = #{seniorStaff}
- </if>
- <if test="province != null">
- and a.province = #{province,jdbcType=VARCHAR}
- </if>
- order by a.last_login_time ,a.number
- <if test="page_sql!=null">
- ${page_sql}
- </if>
- </select>
- <select id="findAdminCount" parameterType="java.lang.String" resultType="java.lang.Integer">
- select count(1) from admin
- where id <![CDATA[ <> ]]> '1'
- left join `role` y on x.rid=y.id
- where a.id <![CDATA[ <> ]]> '1'
- <if test="roleName != null">
- where y.role_name= #{roleName,jdbcType=VARCHAR}
- </if>
- <if test="mobile != null">
- and mobile = #{mobile,jdbcType=VARCHAR}
- </if>
- <if test="name != null">
- and name = #{name,jdbcType=VARCHAR}
- </if>
- <if test="number != null">
- and number = #{number,jdbcType=INTEGER}
- </if>
- <if test="seniorStaff != null">
- and a.senior_staff = #{seniorStaff}
- </if>
- <if test="province != null">
- and a.province = #{province,jdbcType=VARCHAR}
- </if>
- </select>
- <select id="listAdminByName" parameterType="java.lang.String" resultMap="AdminMap">
- select id,name from admin where name like concat('%',#{name},'%')
- <if test="status==0">
- and status= '0'
- </if>
- <if test="status==1">
- and status= '1'
- </if>
- </select>
- <!--*************************************************************************-->
- <select id="selectAdminListByPage" parameterType="java.lang.String" resultType="com.goafanti.admin.bo.AdminListBo">
- select a.id, a.mobile, a.name, a.position, a.email, a.province, a.city, a.create_time as createTime, aa.name as superior,dep.name departmentName,
- a.superior_id as superiorId, a.department_id as departmentId, a.last_login_time as lastLoginTime, a.contact_mobile as contactMobile,st.name teamName,a.team_id teamId,
- a.duty,a.status, a.type, ambs.id ambId,ambs.name ambName,ambs.ancestors_names ancestorsNames ,a.amb_role ambRole,a.senior_staff seniorStaff,a.public_purview publicPurview
- from admin a
- left join admin_location al on a.id = al.admin_id
- left join admin aa on aa.id = a.superior_id
- left join amb_system ambs on a.amb_id=ambs.id
- left join department dep on a.department_id = dep.id
- left join sales_team st on a.team_id=st.id
- <if test="rid != null">
- RIGHT join (select uid from user_role where rid=#{rid,jdbcType=VARCHAR}) ur on a.id=ur.uid
- </if>
- <if test="roleName != null">
- left join user_role ur on a.id=ur.uid
- RIGHT join (select id from role where role_name =#{roleName,jdbcType=VARCHAR}) y on ur.rid=y.id
- </if>
- where a.status in (0,1)
- <if test="name != null">
- and a.name like concat('%',#{name,jdbcType=VARCHAR},'%')
- </if>
- <if test="departmentId != null">
- and a.department_id = #{departmentId,jdbcType=VARCHAR}
- </if>
- <if test="duty != null">
- and a.duty = #{duty,jdbcType=VARCHAR}
- </if>
- <if test="position != null">
- and a.position = #{position,jdbcType=VARCHAR}
- </if>
- <if test="status != null">
- and a.status = #{status,jdbcType=VARCHAR}
- </if>
- <if test="mobile != null">
- and a.mobile = #{mobile,jdbcType=VARCHAR}
- </if>
- <if test="superiorId != null">
- and a.superior_id = #{superiorId,jdbcType=VARCHAR}
- </if>
- <if test="ambId != null">
- and a.amb_id = #{ambId}
- </if>
- <if test="seniorStaff != null">
- and a.senior_staff = #{seniorStaff}
- </if>
- <if test="publicPurview != null">
- and a.public_purview = #{publicPurview}
- </if>
- <if test="ancestors != null">
- and (ambs.id=#{ancestors} or find_in_set( #{ancestors} ,ambs.ancestors))
- </if>
- <if test="ambManage !=null">
- and a.amb_manage= #{ambManage}
- </if>
- order by a.last_login_time desc
- <if test="page_sql!=null">
- ${page_sql}
- </if>
- </select>
- <select id="selectAdminCount" parameterType="java.lang.String" resultType="java.lang.Integer">
- select count(*)
- from admin a
- left join admin_location al on a.id = al.admin_id
- left join admin aa on aa.id = a.superior_id
- left join amb_system ambs on a.amb_id=ambs.id
- left join department dep on a.department_id = dep.id
- <if test="rid != null">
- RIGHT join (select * from user_role where rid=#{rid,jdbcType=VARCHAR}) ur on a.id=ur.uid
- </if>
- <if test="roleName != null">
- left join user_role ur on a.id=ur.uid
- RIGHT join (select * from role where role_name =#{roleName,jdbcType=VARCHAR}) y on ur.rid=y.id
- </if>
- where a.status in (0,1)
- <if test="name != null">
- and a.name like concat('%',#{name,jdbcType=VARCHAR},'%')
- </if>
- <if test="departmentId != null">
- and a.department_id = #{departmentId,jdbcType=VARCHAR}
- </if>
- <if test="duty != null">
- and a.duty = #{duty,jdbcType=VARCHAR}
- </if>
- <if test="position != null">
- and a.position = #{position,jdbcType=VARCHAR}
- </if>
- <if test="status != null">
- and a.status = #{status,jdbcType=VARCHAR}
- </if>
- <if test="mobile != null">
- and a.mobile = #{mobile,jdbcType=VARCHAR}
- </if>
- <if test="superiorId != null">
- and a.superior_id = #{superiorId,jdbcType=VARCHAR}
- </if>
- <if test="ambId != null">
- and a.amb_id = #{ambId}
- </if>
- <if test="seniorStaff != null">
- and a.senior_staff = #{seniorStaff}
- </if>
- <if test="publicPurview != null">
- and a.public_purview = #{publicPurview}
- </if>
- <if test="ancestors != null">
- and (ambs.id=#{ancestors} or find_in_set( #{ancestors} ,ambs.ancestors))
- </if>
- <if test="ambManage !=null">
- and a.amb_manage= #{ambManage}
- </if>
- </select>
- <insert id="insertn" parameterType="com.goafanti.common.model.Admin">
- insert into admin (id, mobile, name,
- password, email, create_time,
- number, province, position, superior_id, city,department_id,status,user_no,duty,district,head_portrait_url,contact_mobile,type)
- values (#{id,jdbcType=VARCHAR}, #{mobile,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR},
- #{password,jdbcType=VARCHAR}, #{email,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP},
- #{number,jdbcType=INTEGER}, #{province,jdbcType=INTEGER}, #{position,jdbcType=VARCHAR},
- #{superiorId,jdbcType=VARCHAR}, #{city,jdbcType=INTEGER},#{departmentId,jdbcType=VARCHAR},
- #{status,jdbcType=VARCHAR},#{userNo,jdbcType=VARCHAR},#{duty,jdbcType=VARCHAR},#{district,jdbcType=VARCHAR},#{headPortraitUrl,jdbcType=VARCHAR},#{contactMobile,jdbcType=VARCHAR},
- #{type})
- </insert>
- <select id="selectUserNoBySuperiorId" parameterType="java.lang.String" resultType="java.lang.String">
- select
- user_no as userNo
- from admin
- where
- id=#{superiorId,jdbcType=VARCHAR}
- </select>
- <select id="selectCountBySuperiorId" parameterType="java.lang.String" resultType="java.lang.Integer">
- select
- count(1)
- from admin
- where
- superior_id=#{superiorId,jdbcType=VARCHAR}
- </select>
- <select id="selectIdByUserNo" parameterType="java.lang.String" resultType="java.lang.String">
- select
- id
- from admin
- where
- user_no=#{UserNo,jdbcType=VARCHAR}
- </select>
- <select id="selectAllByid" parameterType="java.lang.String" resultType="com.goafanti.common.model.Admin">
- select a.id, a.mobile, a.name, a.`password`, a.email, a.create_time as createTime,a.call_no callNo,
- a.province, a.`position`,a.reviewer , a.superior_id as superiorId,a.public_purview publicPurview,
- a.department_id as departmentId, a.status,a.user_no as userNo,a.duty,a.district,a.expense_super_examine expenseSuperExamine,
- a.head_portrait_url as headPortraitUrl, a.contact_mobile as contactMobile,a.senior_staff seniorStaff,
- b.name superior,c.name reviewerName,a.type,a.amb_id ambId,a.manager_id managerId ,d.name managerName,
- a.public_carbon_copy publicCarbonCopy,e.name publicCarbonCopyName,a.team_id teamId,st.name teamName
- from admin a left join admin b on a.superior_id =b.id left join admin c on a.reviewer =c.id
- left join admin d on a.manager_id=d.id left join admin e on a.public_carbon_copy=e.id
- left join sales_team st on a.team_id=st.id
- where a.id= #{id,jdbcType=VARCHAR}
- </select>
- <select id="selectNameByid" parameterType="java.lang.String" resultType="java.lang.String">
- select
- name
- from admin
- where
- id=#{id,jdbcType=VARCHAR}
- </select>
- <select id="selectRolesByUid" parameterType="com.goafanti.common.model.Role" resultType="com.goafanti.common.model.Role">
- select
- r.id,r.role_name as roleName
- from user_role ur
- left join role r on r.id = ur.rid
- where
- uid=#{id,jdbcType=VARCHAR}
- </select>
- <select id="selectStatusByMobile" parameterType="java.lang.String" resultType="java.lang.String">
- select
- status
- from admin
- where
- mobile= #{mobile,jdbcType=VARCHAR}
- </select>
- <select id="selectIDNBySuperiorId" parameterType="java.lang.String" resultType="com.goafanti.common.model.Admin">
- select id, mobile, name,
- password, email, create_time as createTime,
- province, position,
- superior_id as superiorId,department_id as departmentId,
- status,user_no as userNo,duty,district,head_portrait_url as headPortraitUrl
- from admin
- where
- superior_id=#{superiorId,jdbcType=VARCHAR}
- </select>
- <select id="selectUserNoById" resultType="java.lang.String">
- select user_no as userNo
- from admin
- where
- id=#{superiorId,jdbcType=VARCHAR}
- </select>
- <update id="updateByUserNo" parameterType="com.goafanti.common.model.Admin">
- update admin
- set user_no = #{userNo,jdbcType=VARCHAR}
- where
- id=#{id,jdbcType=VARCHAR}
- </update>
- <select id="selectIdBySuperiorId" parameterType="java.lang.String" resultType="java.lang.String">
- select id
- from admin
- where
- superior_id=#{superiorId,jdbcType=VARCHAR}
- </select>
- <select id="selectSubList" parameterType="java.lang.String" resultType="com.goafanti.admin.bo.AdminListBo">
- select
- a.id,
- a.user_no as userNo,
- a.mobile,
- a.name,
- a.position,
- b.name as departmentName
- from
- admin a left join department b on
- a.department_id = b.id
- where
- a.department_id =(
- select
- department_id
- from
- admin
- where
- id = #{adminId,jdbcType=VARCHAR}
- )
- and a.id <![CDATA[ <> ]]> #{adminId,jdbcType=VARCHAR}
- </select>
- <select id="selectAdminByRoleId" parameterType="java.lang.String" resultMap="AdminMap">
- select a.id,a.name from admin a left join user_role b on a.id = b.uid left join role c on b.rid = c.id where c.id = #{roleId,jdbcType=VARCHAR} limit 1
- </select>
- <select id="selectDepartmentStaff" parameterType="java.lang.String" resultType="com.goafanti.admin.bo.AdminListBo">
- select a.id ,a.name,a.password,a.department_id,b.name
- from admin a left join department b
- on a.department_id= b.id
- where 1=1
- <if test="departmentId != null and departmentId !='' ">
- and a.department_id = #{departmentId,jdbcType=VARCHAR}
- </if>
- <if test="name != null">
- and a.name like concat('%',#{name,jdbcType=VARCHAR},'%')
- </if>
- </select>
- <select id="selectAdminName" parameterType="java.lang.String" resultMap="AdminMap">
- select a.id, a.name from admin a left join user_role b on a.id=b.uid
- left join `role` c on b.rid=c.id
- where c.role_name = #{name,jdbcType=VARCHAR}
- </select>
- <update id="updateLockIds" parameterType="java.lang.String">
- update admin set status = '1' where id in (${lockIds})
- </update>
- <!-- 用户是为正常的 -->
- <select id="getCountById" parameterType="java.lang.String" resultType="java.lang.Integer">
- select count(a.id) from admin a
- inner join user_role ur on a.id=ur.uid
- where a.id= #{_parameter,jdbcType=VARCHAR} and ( a.status != '注销' or a.status is null)
- </select>
- <select id="getAdminRoleNameList" parameterType="java.lang.String" resultMap="AdminMap">
- select a.id, a.name from admin a left join user_role b on a.id=b.uid
- left join `role` c on b.rid=c.id
- where c.role_name = #{name,jdbcType=VARCHAR} and a.status= 0
- </select>
- <select id="getAdminRoleNamesList" parameterType="java.lang.String" resultMap="AdminMap">
- select a.id, a.name from admin a left join user_role b on a.id=b.uid
- left join `role` c on b.rid=c.id
- where a.status= 0
- and c.role_name in
- <foreach close=")" collection="list" item="name" open="(" separator=",">
- #{name}
- </foreach>
- </select>
- <select id="getAdminRoleTypeList" parameterType="java.lang.String" resultMap="AdminMap">
- select a.id, a.name from admin a left join user_role b on a.id=b.uid
- left join `role` c on b.rid=c.id
- where c.role_type = #{roleType} and a.status= 0
- </select>
- <select id="getAdminRoleTypesList" parameterType="java.lang.String" resultMap="AdminMap">
- select a.id, a.name from admin a left join user_role b on a.id=b.uid
- left join `role` c on b.rid=c.id
- where a.status= 0
- and c.role_type in
- <foreach close=")" collection="list" item="type" open="(" separator=",">
- #{type}
- </foreach>
- </select>
- <select id="getDeptNameByAid" parameterType="java.lang.String" resultType="com.goafanti.admin.bo.AdminListBo">
- select a.id,a.name, d.name as departmentName,a.department_id departmentId,a.email,a.superior_id superiorId,a.open_id openId,
- a.reviewer,d.manager_id depManager,d.finance_id depFinance,a.public_purview publicPurview,a.expense_super_examine expenseSuperExamine,
- a.public_carbon_copy publicCarbonCopy
- from admin a left join department d on a.department_id = d.id
- where a.id = #{_parameter,jdbcType=VARCHAR}
- </select>
- <insert id="addAdminContacts" parameterType="com.goafanti.admin.bo.AdminContacts">
- insert into admin_contacts (id,aid,contacts_id)values
- (#{id,jdbcType=VARCHAR},#{aid,jdbcType=VARCHAR},#{contactsId,jdbcType=VARCHAR})
- </insert>
- <select id="frequentContactsList" parameterType="java.lang.String" resultType="com.goafanti.admin.bo.AdminListBo">
- select a.id,b.id as contactId,b.name,b.position,b.contact_mobile as contactMobile,c.name as departmentName,y.role_name as roleName
- from admin_contacts a left join admin b
- on a.contacts_id=b.id left join department c
- on c.id=b.department_id left join user_role x on x.uid=b.id
- left join `role` y on x.rid=y.id
- where b.status ='0'
- <if test="roleName != null">
- and y.role_name= #{roleName,jdbcType=VARCHAR}
- </if>
- <if test="aid != null">
- and a.aid= #{aid,jdbcType=VARCHAR}
- </if>
- <if test="name != null">
- and b.name like CONCAT('%',#{name,jdbcType=VARCHAR},'%')
- </if>
- <if test="deps != null">
- and b.department_id in
- <foreach close=")" collection="deps" item="depId" open="(" separator=",">
- #{depId}
- </foreach>
- </if>
- <if test="page_sql!=null">
- ${page_sql}
- </if>
- </select>
- <select id="frequentContactsCount" parameterType="java.lang.String" resultType="java.lang.Integer">
- select count(*)
- from admin_contacts a left join admin b
- on a.contacts_id=b.id
- left join user_role x on x.uid=b.id
- left join `role` y on x.rid=y.id
- where b.status ='0'
- <if test="roleName != null">
- and y.role_name= #{roleName,jdbcType=VARCHAR}
- </if>
- <if test="aid != null">
- and a.aid= #{aid,jdbcType=VARCHAR}
- </if>
- <if test="name != null">
- and b.name like CONCAT('%',#{name,jdbcType=VARCHAR},'%')
- </if>
- <if test="deps != null">
- and b.department_id in
- <foreach close=")" collection="deps" item="depId" open="(" separator=",">
- #{depId}
- </foreach>
- </if>
- </select>
- <delete id="deleteFrequentContacts" parameterType="java.lang.String">
- delete from admin_contacts
- where id = #{id,jdbcType=VARCHAR}
- </delete>
- <select id="getaidFrequentContacts" resultType="java.lang.String">
- select b.id from admin_contacts a left join admin b on a.contacts_id = b.id
- where b.status = '0' and a.aid= #{id,jdbcType=VARCHAR}
- </select>
- <select id="selectAdminCustomerList" resultType="com.goafanti.admin.bo.AdminCustomerBo">
- select a.id as aid,a.name as aName,d.name as depName,ifnull(b.userCount,0) as userCount,ifnull(c.inputCount,0) as newCount,
- ifnull(c.receiveCount,0) as receiveCount,ifnull(b.signCount,0) as signCount,ifnull(c.transferCount,0) as transferCount
- from admin a
- left join (select aid, sum(if(share_type=0 and source in (1,2,3),1,0))userCount,
- sum(if(share_type=2,1,0))signCount from `user` where type=1 and new_channel=0
- group by aid) b on a.id=b.aid
- left join (select aid, sum(if(share_type=0 and source in (1),1,0))inputCount,
- sum(if(share_type=0 and source in (3),1,0))transferCount, sum(if(share_type=0 and source in (2),1,0))receiveCount
- from `user` where type=1 and new_channel=0
- <if test="startTime != null and endTime != null">
- and transfer_time between #{startTime,jdbcType=VARCHAR} and #{endTime,jdbcType=VARCHAR}
- </if>
- group by aid) c on a.id=c.aid
- left join department d on a.department_id=d.id
- left join user_role e on a.id=e.uid
- left join `role` f on e.rid=f.id
- where f.role_type in (96,996)
- and a.status= 0
- <if test="depId != null">
- and a.department_id = #{depId,jdbcType=VARCHAR}
- </if>
- <if test="page_sql!=null">
- ${page_sql}
- </if>
- </select>
- <select id="selectAdminCustomerCount" parameterType="java.lang.String" resultType="java.lang.Integer">
- select count(*) from admin a
- left join department d on a.department_id=d.id
- left join user_role e on a.id=e.uid
- left join `role` f on e.rid=f.id
- where f.role_type in (96,996)
- and a.status= 0
- <if test="depId != null">
- and a.department_id = #{depId,jdbcType=VARCHAR}
- </if>
- </select>
- <select id="selectAdminCustomerDetailList" resultType="com.goafanti.admin.bo.AdminCustomerDetailBo">
- select a.id,a.nickname as name,a.source,c.contacts contacts,c.contact_mobile as contactMobile,c.contacts_dep contactsDep,
- c.contacts_position contactsPosition, a.create_time as createTime,b.last_follow_time as followTime,c.location_province locationProvince,
- c.location_city locationCity,c.location_area locationArea,c.business_scope businessScope , c.intended_project intendedProject
- from user a left join (select uid,last_follow_time from user_mid where aid= #{aid}) b on a.id=b.uid
- left join organization_identity c on a.id=c.uid
- <if test="type==5 or type==6">
- left join (select aid,uid from public_release a left join public_release_details b on a.id=b.prid
- where b.clock_in =1
- and aid= #{aid,jdbcType=VARCHAR}
- <if test="startTime != null and endTime != null">
- and clock_in_time between #{startTime,jdbcType=VARCHAR} and #{endTime,jdbcType=VARCHAR}
- </if>
- )e on a.id=e.uid
- </if>
- where a.type=1 and a.new_channel=0
- <include refid="AdminCustomerDetailSql"/>
- <if test="page_sql!=null">
- ${page_sql}
- </if>
- </select>
- <sql id="AdminCustomerDetailSql">
- <if test="type != 5 and type !=6">
- and a.aid= #{aid,jdbcType=VARCHAR}
- </if>
- <if test="type == 5 or type ==6">
- and e.aid= #{aid,jdbcType=VARCHAR}
- </if>
- <if test="type == 0">
- and a.share_type = 0
- </if>
- <if test="type == 1">
- and a.share_type = 3
- </if>
- <if test="type ==0 or type==3 or type==5 or type==7 or type ==8">
- and a.channel=0
- </if>
- <if test="type == 1 or type==4 or type==6">
- and a.channel=1
- </if>
- <if test="type == 2">
- and a.share_type=2
- </if>
- <if test="type == 3 or type==4">
- and a.source=1
- and a.share_type = 0
- </if>
- <if test="type==7 ">
- and a.share_type = 0
- and a.source=2
- </if>
- <if test="type == 8">
- and a.share_type = 0
- and a.source=3
- </if>
- <if test="type!=5 and type!=6">
- <if test="startTime != null and endTime != null">
- and a.transfer_time between #{startTime,jdbcType=VARCHAR} and #{endTime,jdbcType=VARCHAR}
- </if>
- </if>
- </sql>
- <select id="selectAdminCustomerDetailCount" parameterType="java.lang.String" resultType="java.lang.Integer">
- select count(*)
- from user a
- <if test="type==5 or type==6">
- left join (select aid,uid from public_release a left join public_release_details b on a.id=b.prid
- where b.clock_in =1
- and aid= #{aid,jdbcType=VARCHAR}
- <if test="startTime != null and endTime != null">
- and clock_in_time between #{startTime,jdbcType=VARCHAR} and #{endTime,jdbcType=VARCHAR}
- </if>
- )e on a.id=e.uid
- </if>
- where a.type=1 and a.new_channel=0
- <include refid="AdminCustomerDetailSql"/>
- </select>
- <select id="listNameByDepAndName" resultType="java.lang.String">
- select a.id from admin a left join user_role b on a.id =b.uid
- left join `role` c on b.rid=c.id
- where department_id= #{depId}
- and c.role_type= #{roleType}
- </select>
- <select id="listAdminBydepIdAndRoleType" resultType="com.goafanti.common.model.Admin">
- select a.id,a.name,a.email ,a.open_id openId,a.expense_open_id expenseOpenId
- from admin a left join user_role b on a.id =b.uid left join `role` c on b.rid=c.id
- where a.status='0'
- and a.department_id= #{depId}
- and c.role_type= #{roleType}
- </select>
- <select id="selectBySuperId" resultType="java.lang.String">
- select id from admin where superior_id= #{aid}
- </select>
- <select id="selectMyAndSuperBySuperId" parameterType="java.lang.String" resultType="com.goafanti.common.bo.AdminNoticeBo">
- select
- a.id,a.name,a.email,a.open_id openId,a.expense_open_id expenseOpenId,a.expense_super_examine expenseSuperExamine,
- b.id superId,b.name superName,b.email superEmail,b.open_id superOpenId,b.expense_open_id superExpenseOpenId
- from admin a left join admin b on a.superior_id=b.id
- where a.id=#{id}
- </select>
- <select id="selectFinanceAdminByOrderDep" resultType="com.goafanti.common.model.Admin">
- select a.finance_id id,b.name from department a left join admin b on a.finance_id=b.id
- where a.id= #{orderDep}
- </select>
- <select id="getPermission" resultType="java.lang.String">
- select c.role_type from admin a left join user_role b on a.id=b.uid left join `role` c on b.rid=c.id
- where a.id= #{transferId}
- </select>
- <select id="selectDepIdWithSpuerId" resultType="java.lang.String">
- select b.id from admin a right join department b on a.id=b.finance_id
- where a.superior_id= #{superId}
- </select>
- <select id="getAdminRoleListByAid" resultType="java.lang.String">
- select c.role_type from admin a left join user_role b on a.id=b.uid
- left join role c on b.rid =c.id
- where a.id= #{id}
- </select>
- <select id="selectByOpeid" parameterType="java.lang.String" resultMap="AdminMap">
- select
- <include refid="AdminAllSql" />
- from admin
- where open_id= #{openid}
- </select>
- <select id="getFinanceDep" resultType="java.lang.String">
- select id from department where finance_id = #{aid}
- </select>
- <select id="getLowerFinanceDep" resultType="java.lang.String">
- select b.id from admin a left join department b on a.id=b.finance_id
- where a.superior_id = #{aid}
- </select>
- <select id="selectByAmbIdCount" resultType="java.lang.Integer">
- SELECT count(*) from admin where amb_id= #{ambId}
- </select>
- <select id="selectAdminByRoleType" parameterType="java.lang.String" resultType="com.goafanti.common.model.Admin">
- SELECT a.id,a.name ,a.mobile ,a.email,a.department_id departmentId,a.open_id openId,a.expense_open_id expenseOpenId
- FROM admin a left join user_role b on a.id=b.uid
- left join `role` c on b.rid =c.id
- where a.status='0'
- <if test="roleType =='99998'">
- and c.role_type in ('99998','99988')
- </if>
- <if test="roleType =='99999'">
- and c.role_type in ('99999','99989')
- </if>
- <if test="roleType =='99999888'">
- and c.role_type in ('99998','99988','99999','99989')
- </if>
- <if test="roleType !='99999' and roleType !='99998' and roleType !='99999888'">
- and c.role_type in (#{roleType})
- </if>
- </select>
- <select id="selectByDeps" resultType="com.goafanti.admin.bo.AdminCustomerBo">
- SELECT a.id aid,a.name aName,a.department_id depId,d.name depName
- from admin a left join department d on a.department_id = d.id
- where a.status =0 and a.`type` =1
- <if test="seniorStaff != null">
- and a.senior_staff=#{seniorStaff}
- </if>
- <if test="depIds!= null">
- and a.department_id in
- <foreach close=")" collection="depIds" item="deps" open="(" separator=",">
- #{deps.id}
- </foreach>
- </if>
- </select>
- <select id="getAdminByFinanceId" resultType="com.goafanti.common.model.Admin">
- select b.id ,b.name
- from department a left join admin b on a.finance_id=b.id
- where a.id= #{id}
- </select>
- <select id="selectRoleTypeByid" resultType="java.lang.Integer">
- select b.role_type
- from user_role a left join `role` b on a.rid =b.id
- where a.uid = #{aid}
- </select>
- <select id="selectFinanceAdminByAid" resultType="com.goafanti.common.model.Admin">
- select c.id,c.name,c.open_id openId,c.email
- from admin a left join department b on a.department_id=b.id
- left join admin c on b.finance_id=c.id
- where a.id= #{aid}
- </select>
- <select id="adminStatisticsInfo" resultType="com.goafanti.admin.bo.AdminStatisticsBo">
- select x.id aid,y.projectCheckSum,y.projectStopSum,g.orderSum,g.changeSum,
- z.rejectSum,t.receivables
- from admin x
- left join(select a.salesman_id aid , sum(if( b.project_status =29,1,0))projectStopSum ,
- sum(if(b.check_status=1,1,0))projectCheckSum from t_order_new a left join t_order_task b
- on a.order_no =b.order_no where a.salesman_id = #{aid})y on x.id=y.aid
- left join ( select salesman_id aid, sum(1)orderSum, sum(if(delete_sign=2,1,0))changeSum
- from t_order_new where delete_sign in (0,2,3) and process_status >0
- and salesman_id = #{aid})g on x.id=g.aid
- left join ( select salesman_id aid, sum(if(order_status=3 or order_status=5,1,0))rejectSum
- from t_order_new where delete_sign in (0,2,3)
- and salesman_id = #{aid})z on x.id=z.aid
- left join ( SELECT b.salesman_id aid ,sum(a.money) receivables
- from new_order_dun a left join t_order_new b on a.order_no =b.order_no
- where a.status =1 and b.delete_sign in (0,2,3)
- and b.salesman_id = #{aid})t on x.id=t.aid
- where x.id= #{aid}
- </select>
- <select id="adminStatisticsInfoByTime" resultType="com.goafanti.admin.bo.AdminStatisticsBo">
- select sum(follow_count) rangeFollowSum,sum(order_count) rangeOrdersum
- from admin_user_count a where aid=#{aid} and date_time BETWEEN #{startTime} and #{endTime}
- group by aid
- </select>
- <select id="thisMonthUser" resultType="com.goafanti.common.model.AdminUserCount">
- select id,aid,private_count privateCount,sign_count signCount,channel_count channelCount,public_release_count publicReleaseCount,
- follow_count followCount,order_count orderCount, DATE_FORMAT(date_time , '%Y-%m-%d') dateTime
- from admin_user_count
- where date_time BETWEEN #{firstDay} and #{endDay}
- and aid= #{aid}
- order by date_time
- </select>
- <select id="selectAdminPublicRelease" resultType="com.goafanti.common.model.AdminUserCount">
- select aid,count(*)publicReleaseCount, dates dateTime
- from (select aid,DATE_FORMAT(a.release_start , '%Y-%m-%d') dates
- from public_release a left join public_release_details b on a.id=b.prid
- where status =2 and aid= #{aid})x
- group by aid,dates
- </select>
- <select id="selectAdminUserFollow" resultType="com.goafanti.common.model.AdminUserCount">
- select aid ,count(*)followCount, dateTime
- from (select aid,DATE_FORMAT(create_time , '%Y-%m-%d') dateTime
- from user_follow where aid= #{aid} )a
- group by aid,dateTime
- </select>
- <select id="selectAdminOrder" resultType="com.goafanti.common.model.AdminUserCount">
- select salesman_id aid ,count(*)orderCount, dateTime
- from (select salesman_id, DATE_FORMAT(create_time , '%Y-%m-%d') dateTime
- from t_order_new
- where delete_sign in (0,2,3) and process_status >0
- and salesman_id= #{aid} )x
- group by salesman_id ,dateTime
- </select>
- <select id="adminStatisticsPublicReleaseByAidAndTime" resultType="java.lang.Integer">
- select sum(1) rangePublicReleaseSum
- from public_release a left join public_release_details b on a.id=b.prid
- where status =2 and a.aid = #{aid}
- and((a.release_start > #{startTime} and a.release_start < #{endTime})or
- (a.release_end > #{startTime} and a.release_end < #{endTime})or
- (a.release_start < #{startTime} and a.release_end > #{endTime}))
- </select>
- <select id="addAdminContactsRangeReceivables" resultType="java.math.BigDecimal">
- SELECT ifnull(sum(a.money),0) receivables
- from new_order_dun a left join t_order_new b on a.order_no =b.order_no
- where a.status =1 and b.delete_sign in (0,2,3)
- and b.salesman_id = #{aid}
- and a.start_time between #{startTime} and #{endTime}
- </select>
- <select id="consultantStatisticsInfo" resultType="com.goafanti.admin.bo.ConsultantStatisticsBo">
- SELECT x.aid,x.projectCount,x.inProgress,x.complete,x.notStarted,x.stop,y.countPublicRelease,y.countAssist,z.countChange,v.orderPayment
- from (select a.task_receiver aid,sum(commodity_quantity) projectCount, sum(if(a.project_status=1,commodity_quantity,0)) inProgress,
- sum(if(a.project_status in (19,27) ,commodity_quantity,0)) complete, sum(if(a.project_status=0,commodity_quantity,0)) notStarted,
- sum(if(a.project_status in (2,3,29),commodity_quantity,0)) stop
- from t_order_task a left join t_order_new b on a.order_no =b.order_no
- where b.delete_sign in (0,2,3) and a.split_status in (0,2) and a.task_receiver = #{aid} group by a.task_receiver)x
- left join (select aid,sum(if(a.`type` in (0,1,2),1,0)) countPublicRelease,sum(if(a.`type` in (3),1,0)) countAssist
- from public_release a left join public_release_details b on a.id=b.prid where aid= #{aid})y on x.aid=y.aid
- left join (SELECT b.aid,count(DISTINCT a.order_no) countChange from new_order_change a
- left join order_examine b on a.order_no =b.order_no where 1=1
- <if test="type==2">
- and a.process_state in (3,4)
- </if>
- <if test="type==0">
- and a.process_state in (3)
- </if>
- <if test="type==1">
- and a.process_state in (4)
- </if>
- and b.aid=#{aid} and b.status =0 group by b.aid)z on x.aid=z.aid
- LEFT join (select b.task_receiver aid, count(*) orderPayment from t_order_payment a
- left join t_order_task b on a.tid=b.id left join t_order_new c on b.order_no=c.order_no
- where b.task_receiver= #{aid} and a.status in(0,1,2) group by b.task_receiver )v on x.aid=v.aid
- </select>
- <select id="consultantStatisticsInfoByTime" resultType="com.goafanti.admin.bo.ConsultantStatisticsBo">
- select a.id,x.projectCount,x.inProgress,x.notStarted,y.complete,y.stop,z.countPublicRelease,z.countAssist
- from admin a left join (select a.task_receiver aid,sum(commodity_quantity) projectCount,
- sum(if(a.project_status=1,commodity_quantity,0)) inProgress,
- sum(if(a.project_status=0,commodity_quantity,0)) notStarted from t_order_task a where a.split_status in (0,2)
- and a.task_receiver = #{aid} and a.task_distribution_time BETWEEN #{startTime} and #{endTime} group by a.task_receiver )x on a.id=x.aid
- left join (SELECT a.task_receiver aid,sum(if(a.project_status in (19,27) ,commodity_quantity,0)) complete,
- sum(if(a.project_status in (2,3,29),commodity_quantity,0)) stop from t_order_task a left join task_time b on a.id=b.tid
- where a.split_status in (0,2) and b.project_status =a.project_status and a.task_receiver = #{aid}
- and b.date_time BETWEEN #{startTime} and #{endTime} group by a.task_receiver )y on a.id=y.aid
- left join (select aid,sum(if(a.`type` in (0,1,2),1,0)) countPublicRelease,sum(if(a.`type` in (3),1,0)) countAssist
- from public_release a left join public_release_details b on a.id=b.prid where aid= #{aid} and a.status =2
- and a.release_start BETWEEN #{startTime} and #{endTime} group by a.aid)z on a.id=z.aid
- where a.id=#{aid}
- </select>
- <select id="consultantthisMonthUser" resultType="com.goafanti.admin.bo.ConsultantUserCount">
- select x.dates,sum(projectCount)projectCount,sum(inProgress)inProgress,sum(notStarted)notStarted
- ,0 complete,0 stop,0 countPublicRelease,0 countAssist
- from (select commodity_quantity projectCount, if(a.project_status=1,commodity_quantity,0)inProgress,
- if(a.project_status=0,commodity_quantity,0)notStarted,DATE_FORMAT(a.task_distribution_time,'%Y-%m-%d') dates
- from t_order_task a where a.split_status in (0,2) and a.task_receiver = #{aid}
- and a.task_distribution_time BETWEEN #{firstDay} and #{endDay})x
- group by x.dates
- union
- select x.dates,0 projectCount,0 inProgress,0 notStarted,sum(complete)complete,sum(stop)stop,0,0
- from (SELECT if(a.project_status in (19,27) ,commodity_quantity,0) complete,
- if(a.project_status in (2,3,29),commodity_quantity,0) stop ,DATE_FORMAT(b.date_time ,'%Y-%m-%d') dates
- from t_order_task a left join task_time b on a.id=b.tid
- where a.split_status in (0,2) and b.project_status =a.project_status
- and a.task_receiver = #{aid} and b.date_time BETWEEN #{firstDay} and #{endDay})x
- group by x.dates
- union
- select x.dates,0,0,0,0,0,sum(countPublicRelease)countPublicRelease,sum(countAssist)countAssist
- from ( select if(a.`type` in (0,1,2),1,0) countPublicRelease,if(a.`type` in (3),1,0) countAssist,
- DATE_FORMAT(a.release_start ,'%Y-%m-%d') dates
- from public_release a left join public_release_details b on a.id=b.prid where aid= #{aid}
- and a.status =2
- and a.release_start BETWEEN #{firstDay} and #{endDay})x
- group by x.dates
- </select>
- <select id="selectOrderByFinanace" resultType="com.goafanti.common.model.Admin">
- select c.id,c.name
- from t_order_new a left join department b on a.order_dep=b.id
- left join admin c on b.finance_id=c.id
- where a.order_no =#{orderNo};
- </select>
- <select id="selectAdminByRoleTypes" resultType="com.goafanti.common.model.Admin">
- SELECT a.id,a.name ,a.mobile ,a.email,a.department_id departmentId,a.open_id openId,a.expense_open_id expenseOpenId
- FROM admin a left join user_role b on a.id=b.uid
- left join `role` c on b.rid =c.id
- where a.status='0'
- and c.role_type in
- <foreach collection="list" item="e" open="(" close=")" separator=",">
- #{e}
- </foreach>
- </select>
- <select id="financeInfo" resultType="com.goafanti.admin.bo.OutFinanceCount">
- select x.aid,x.orderCount,x.expenseCount,x.invoiceCount,x.memberCount,x.paymentCount,b.counts publicCount,y.orderUnauditedCount,
- c.counts receivables,y.expenseUnauditedCount,y.invoiceUnauditedCount,y.memberUnauditedCount,y.paymentUnauditedCount
- from ( select a.aid,sum(a.order_count)orderCount ,sum(a.expense_count)expenseCount ,SUM(a.invoice_count) invoiceCount,
- sum(a.member_count) memberCount ,sum(a.payment_count)paymentCount from finance_count a where a.aid= #{aid} )x
- left join(select aid,sum(if(a.`type` in (0,1,2),1,0)) counts from public_release a left join public_release_details b on a.id=b.prid
- where a.status=2 and a.aid= #{aid} )b on x.aid=b.aid
- left join (SELECT c.finance_id aid,sum(a.money) counts from new_order_dun a left join t_order_new b on a.order_no =b.order_no
- left join department c on b.order_dep =c.id where a.status =1 and b.delete_sign in (0,2,3) and c.finance_id = #{aid} )c on x.aid=c.aid
- left join (select a.aid,sum(a.order_unaudited_count)orderUnauditedCount , sum(a.expense_unaudited_count)expenseUnauditedCount ,
- SUM(a.invoice_unaudited_count) invoiceUnauditedCount, sum(a.member_unaudited_count) memberUnauditedCount ,
- sum(a.payment_unaudited_count)paymentUnauditedCount from finance_count a where a.aid= #{aid}
- and a.date_time BETWEEN #{startTime} and #{endTime} group by a.aid)y on x.aid=y.aid
- </select>
- <select id="financeCountRangeReceivables" resultType="java.math.BigDecimal">
- SELECT ifnull(sum(a.money),0) receivables
- from new_order_dun a left join t_order_new b on a.order_no =b.order_no
- left join department c on b.order_dep =c.id
- where a.status =1 and b.delete_sign in (0,2,3)
- and c.finance_id = #{aid}
- and a.start_time between #{startTime} and #{endTime}
- </select>
- <select id="selectFinanceChangeCount" resultType="com.goafanti.admin.bo.OutFinanceCount">
- select c.finance_id aid,sum(if(a.process_state=6,1,0))changeCount,
- sum(if(a.process_state>6 and a.status=2,1,0)) changeInvoiceCount
- from new_order_change a left join t_order_new b on a.order_no =b.order_no
- left join department c on b.order_dep =c.id
- where a.process_state in (6,8,9) and a.status in(1,2) and b.delete_sign in (0,2,3)
- and c.finance_id = #{aid}
- </select>
- <select id="selectFinanceReceivablesCount" resultType="java.math.BigDecimal">
- SELECT sum(a.money) receivables
- from new_order_dun a left join t_order_new b on a.order_no =b.order_no
- left join department c on b.order_dep =c.id
- where a.status =1 and b.delete_sign in (0,2,3)
- and c.finance_id = #{aid}
- and a.start_time between #{startTime} and #{endTime}
- </select>
- <select id="selectExpenseFinanceByAid" resultType="com.goafanti.common.model.Admin">
- select c.id,c.name,c.open_id openId,c.email
- from admin a left join department b on a.department_id=b.id
- left join admin c on b.finance_id=c.id
- where a.id= #{aid}
- </select>
- <update id="updateDepExpenseFinance">
- update expense_account a left join expense_account_examine b on a.id=b.eaid
- left join admin c on c.id= #{expenseFinanceId}
- set b.auditor =c.id ,b.auditorName =c.name
- where a.process_status in (0,1,2,3) and a.status =1 and b.process_status =3 and b.status =0
- and a.apply_dep = #{id}
- </update>
- <select id="agentList" resultMap="AdminMap">
- select
- <include refid="AdminAllSql"/>
- from admin
- where status='0' and call_no>0
- </select>
- <select id="selectByCallStaffNo" resultMap="AdminMap">
- select
- <include refid="AdminAllSql"/>
- from admin
- where call_no = #{callStaffNo}
- </select>
- <select id="queryByTeamId" resultMap="AdminMap">
- select
- <include refid="AdminAllSql"/>
- from admin
- where team_id = #{teamId}
- </select>
- <select id="selectUserCount" resultType="com.goafanti.admin.bo.AdminStatisticsBo">
- select aid,sum(if( share_type=0 and channel=0 and new_channel=0,1,0))privateSum,
- sum(if(share_type=0 and new_channel=1,1,0))channelSum,
- sum(if( share_type=2 ,1,0))signSum
- from `user` where `type` =1 and source in(1,2,3)
- AND aid = #{aid}
- group by aid
- </select>
- </mapper>
|