| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363 |
- <?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.management.platform.mapper.CustomMapper">
- <!-- 通用查询映射结果 -->
- <resultMap id="BaseResultMap" type="com.management.platform.entity.Custom">
- <id column="id" property="id" />
- <result column="company_id" property="companyId" />
- <result column="custom_name" property="customName" />
- <result column="custom_source_id" property="customSourceId" />
- <result column="customer_industry_id" property="customerIndustryId" />
- <result column="customer_level_id" property="customerLevelId" />
- <result column="email" property="email" />
- <result column="owner_id" property="ownerId" />
- <result column="custom_code" property="customCode" />
- <result column="tel_phone" property="telPhone" />
- <result column="fax" property="fax" />
- <result column="country_billing" property="countryBilling" />
- <result column="province_billing" property="provinceBilling" />
- <result column="city_billing" property="cityBilling" />
- <result column="street_billing" property="streetBilling" />
- <result column="country_delivery" property="countryDelivery" />
- <result column="province_delivery" property="provinceDelivery" />
- <result column="city_delivery" property="cityDelivery" />
- <result column="street_delivery" property="streetDelivery" />
- <result column="create_time" property="createTime" />
- <result column="plate1" property="plate1" />
- <result column="plate2" property="plate2" />
- <result column="plate3" property="plate3" />
- <result column="plate4" property="plate4" />
- <result column="plate5" property="plate5" />
- <result column="creator_id" property="creatorId" />
- <result column="custom_desc" property="customDesc" />
- <result column="is_delete" property="isDelete" />
- <result column="company_phone" property="companyPhone" />
- <result column="incharger_id" property="inchargerId" />
- <result column="address" property="address" />
- <result column="close_deal" property="closeDeal" />
- </resultMap>
- <!-- 通用查询结果列 -->
- <sql id="Base_Column_List">
- id, company_id, custom_name, custom_source_id, customer_industry_id, customer_level_id, email, owner_id, custom_code, tel_phone, fax, country_billing, province_billing, city_billing, street_billing, country_delivery, province_delivery, city_delivery, street_delivery, create_time, plate1, plate2, plate3, plate4, plate5, creator_id, custom_desc, is_delete, company_phone, incharger_id, address, close_deal
- </sql>
- <select id="getList" resultType="com.management.platform.entity.Custom">
- select
- c.id,
- c.contacts_name,
- c.custom_name,
- c.email,
- c.company_phone,
- c.create_time,
- c.customer_level_id,
- (select name from sys_dict where customer_level_id = id and code = 'CustomLevel') customerLevelValue,
- c.customer_industry_id,
- (select name from sys_dict where customer_industry_id = id and code = 'CustomIndustry') customerIndustryValue,
- c.custom_source_id,
- (select name from sys_dict where custom_source_id = id) customSourceValue,
- c.incharger_id,
- (select `name` from `user` where id = incharger_id) inchargerName,
- c.creator_id,
- (select `name` from `user` where id = creator_id) creatorName
- from custom c
- left join sys_dict sd on c.customer_level_id = sd.id
- where c.company_id = #{companyId}
- and c.is_delete =#{isDelete}
- <if test="inchargerId != null and inchargerId != '' ">
- and c.incharger_id =#{inchargerId}
- </if>
- <if test="startTime != null and endTime != null ">
- and c.create_time BETWEEN #{startTime} and #{endTime}
- </if>
- <if test="customName != null and customName != '' ">
- and c.custom_name LIKE CONCAT('%', #{customName}, '%')
- </if>
- <if test="email != null and email != '' ">
- and c.email LIKE CONCAT('%', #{email}, '%')
- </if>
- <if test="companyPhone != null ">
- and c.company_phone = #{companyPhone}
- </if>
- <if test="customerLevelId != null ">
- and c.customer_level_id = #{customerLevelId}
- </if>
- <if test="customSourceId != null ">
- and c.custom_source_id = #{customSourceId}
- </if>
- <if test="customerIndustryId != null ">
- and c.customer_industry_id = #{customerIndustryId}
- </if>
- ORDER BY
- <choose>
- <when test="isDesc == null ">
- c.id DESC
- </when>
- <when test="isDesc == 0">
- sd.seq ASC, c.id DESC
- </when>
- <when test="isDesc == 1">
- sd.seq DESC, c.id DESC
- </when>
- <otherwise>
- c.id DESC
- </otherwise>
- </choose>
- Limit #{pageIndex},#{pageFrom}
- </select>
- <select id="getTotal" resultType="java.lang.Integer">
- select count(id)
- from custom
- where company_id = #{companyId}
- and is_delete =#{isDelete}
- <if test="inchargerId != null and inchargerId != '' ">
- and incharger_id =#{inchargerId}
- </if>
- <if test="startTime != null and endTime != null ">
- and create_time BETWEEN #{startTime} and #{endTime}
- </if>
- <if test="customName != null and customName != '' ">
- and custom_name = #{customName}
- </if>
- <if test="email != null and email != '' ">
- and email = #{email}
- </if>
- <if test="companyPhone != null ">
- and company_phone = #{companyPhone}
- </if>
- <if test="customerLevelId != null ">
- and customer_level_id = #{customerLevelId}
- </if>
- <if test="customSourceId != null ">
- and custom_source_id = #{customSourceId}
- </if>
- <if test="customerIndustryId != null ">
- and customer_industry_id = #{customerIndustryId}
- </if>
- </select>
- <select id="getList1" resultType="com.management.platform.entity.Custom">
- select c.id,
- c.custom_name,
- c.email,
- c.company_phone,
- c.create_time,
- c.customer_level_id,
- (select name from sys_dict where customer_level_id = id and code = 'CustomLevel') customerLevelValue,
- c.customer_industry_id,
- (select name from sys_dict where customer_industry_id = id and code = 'CustomIndustry') customerIndustryValue,
- c.custom_source_id,
- (select name from sys_dict where custom_source_id = id ) customSourceValue,
- c.incharger_id,
- (select `name` from `user` where id = incharger_id) inchargerName,
- c.creator_id,
- (select `name` from `user` where id = creator_id) creatorName
- from custom c
- left join sys_dict sd on c.customer_level_id = sd.id
- where c.company_id = #{companyId}
- and c.is_delete =#{isDelete}
- and c.incharger_id in
- (SELECT id from `user` WHERE department_id = (SELECT department_id from `user` WHERE id = #{userId}))
- or c.incharger_id is null
- <if test="inchargerId != null and inchargerId != '' ">
- and c.incharger_id =#{inchargerId}
- </if>
- <if test="startTime != null and endTime != null ">
- and c.create_time BETWEEN #{startTime} and #{endTime}
- </if>
- <if test="customName != null and customName != '' ">
- and c.custom_name LIKE CONCAT('%', #{customName}, '%')
- </if>
- <if test="email != null and email != '' ">
- and c.email LIKE CONCAT('%', #{email}, '%')
- </if>
- <if test="companyPhone != null ">
- and c.company_phone = #{companyPhone}
- </if>
- <if test="customerLevelId != null ">
- and c.customer_level_id = #{customerLevelId}
- </if>
- <if test="customSourceId != null ">
- and c.custom_source_id = #{customSourceId}
- </if>
- <if test="customerIndustryId != null ">
- and c.customer_industry_id = #{customerIndustryId}
- </if>
- ORDER BY
- <choose>
- <when test="isDesc == null ">
- c.id DESC
- </when>
- <when test="isDesc == 0">
- sd.seq ASC, c.id DESC
- </when>
- <when test="isDesc == 1">
- sd.seq DESC, c.id DESC
- </when>
- <otherwise>
- c.id DESC
- </otherwise>
- </choose>
- Limit #{pageIndex},#{pageFrom}
- </select>
- <select id="getTotal1" resultType="java.lang.Integer">
- select count(id)
- from custom
- where company_id = #{companyId}
- and is_delete =#{isDelete}
- and incharger_id in
- (SELECT id from `user` WHERE department_id = (SELECT department_id from `user` WHERe id = #{userId}))
- or incharger_id is null
- <if test="inchargerId != null and inchargerId != '' ">
- and incharger_id =#{inchargerId}
- </if>
- <if test="startTime != null and endTime != null ">
- and create_time BETWEEN #{startTime} and #{endTime}
- </if>
- <if test="customName != null and customName != '' ">
- and custom_name = #{customName}
- </if>
- <if test="email != null and email != '' ">
- and email = #{email}
- </if>
- <if test="companyPhone != null ">
- and company_phone = #{companyPhone}
- </if>
- <if test="customerLevelId != null ">
- and customer_level_id = #{customerLevelId}
- </if>
- <if test="customSourceId != null ">
- and custom_source_id = #{customSourceId}
- </if>
- <if test="customerIndustryId != null ">
- and customer_industry_id = #{customerIndustryId}
- </if>
- </select>
- <select id="getList2" resultType="com.management.platform.entity.Custom">
- select id,
- custom_name,
- email,
- company_phone,
- create_time,
- customer_level_id,
- (select name from sys_dict where customer_level_id = id and code = 'CustomLevel') customerLevelValue,
- customer_industry_id,
- (select name from sys_dict where customer_industry_id = id and code = 'CustomIndustry') customerIndustryValue,
- custom_source_id,
- (select name from sys_dict where custom_source_id = id ) customSourceValue,
- incharger_id,
- (select `name` from `user` where id = incharger_id) inchargerName,
- creator_id,
- (select `name` from `user` where id = creator_id) creatorName
- from custom
- where company_id = #{companyId}
- and is_delete =#{isDelete}
- and incharger_id = #{inchargerId}
- or incharger_id is null
- <if test="inchargerId != null and inchargerId != '' ">
- and incharger_id =#{inchargerId}
- </if>
- <if test="startTime != null and endTime != null ">
- and create_time BETWEEN #{startTime} and #{endTime}
- </if>
- <if test="customName != null and customName != '' ">
- and custom_name LIKE CONCAT('%', #{customName}, '%')
- </if>
- <if test="email != null and email != '' ">
- and email LIKE CONCAT('%', #{email}, '%')
- </if>
- <if test="companyPhone != null ">
- and company_phone = #{companyPhone}
- </if>
- <if test="customerLevelId != null ">
- and customer_level_id = #{customerLevelId}
- </if>
- <if test="customSourceId != null ">
- and custom_source_id = #{customSourceId}
- </if>
- <if test="customerIndustryId != null ">
- and customer_industry_id = #{customerIndustryId}
- </if>
- ORDER BY id desc
- Limit #{pageIndex},#{pageFrom}
- </select>
- <select id="getTotal2" resultType="java.lang.Integer">
- select count(id)
- from custom
- where company_id = #{companyId}
- and is_delete = #{isDelete}
- and incharger_id = #{inchargerId}
- or incharger_id is null
- <if test="inchargerId != null and inchargerId != '' ">
- and incharger_id =#{inchargerId}
- </if>
- <if test="startTime != null and endTime != null ">
- and create_time BETWEEN #{startTime} and #{endTime}
- </if>
- <if test="customName != null and customName != '' ">
- and custom_name = #{customName}
- </if>
- <if test="email != null and email != '' ">
- and email = #{email}
- </if>
- <if test="companyPhone != null ">
- and company_phone = #{companyPhone}
- </if>
- <if test="customerLevelId != null ">
- and customer_level_id = #{customerLevelId}
- </if>
- <if test="customSourceId != null ">
- and custom_source_id = #{customSourceId}
- </if>
- <if test="customerIndustryId != null ">
- and customer_industry_id = #{customerIndustryId}
- </if>
- </select>
- <select id="getInfo" resultType="com.management.platform.entity.Custom">
- select id,
- custom_name,
- contacts_name,
- custom_source_id,
- customer_industry_id,
- customer_level_id,
- email,
- tel_phone,
- address,
- custom_code,
- tel_phone,
- fax,
- create_time,
- plate1,
- plate2,
- plate3,
- plate4,
- plate5,
- creator_id,
- custom_desc,
- is_delete,
- (select `name` from sys_dict where customer_level_id = id and code = 'CustomLevel') customerLevelValue,
- (select `name` from sys_dict where customer_industry_id = id and code = 'CustomIndustry') customerIndustryValue,
- (select `name` from sys_dict where custom_source_id = id ) customSourceValue,
- (select `name` from `user` where id = incharger_id) inchargerName,
- (select `name` from `user` where id = creator_id) creatorName
- from custom
- where id = #{id}
- </select>
- <select id="getDataSummary" resultType="java.util.Map">
- SELECT COUNT(*) newNum,SUM(close_deal=1) closeDealNum FROM custom
- WHERE company_id=#{companyId} and is_delete=0
- <if test="startDate!=null and startDate!='' and endDate!=null and endDate!=''">
- and DATE_FORMAT(create_time,'%Y-%m-%d') BETWEEN #{startDate} AND #{endDate}
- </if>
- <if test="userId!=null and userId!=''">
- and incharger_id=#{userId}
- </if>
- <if test="list!=null and list.size()>0">
- and incharger_id in
- <foreach collection="list" separator="," open="(" close=")" item="item">
- #{item}
- </foreach>
- </if>
- </select>
- </mapper>
|