Files
zxjp-web/coolstore-partner-dao/src/main/resources/mapper/HyPartnerLineInfoMapper.xml
2023-11-13 10:41:15 +08:00

1006 lines
41 KiB
XML

<?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.cool.store.mapper.HyPartnerLineInfoMapper">
<resultMap id="BaseResultMap" type="com.cool.store.entity.HyPartnerLineInfoDO">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="partner_id" jdbcType="VARCHAR" property="partnerId" />
<result column="workflow_stage" jdbcType="VARCHAR" property="workflowStage" />
<result column="workflow_status" jdbcType="VARCHAR" property="workflowStatus" />
<result column="line_status" jdbcType="TINYINT" property="lineStatus" />
<result column="investment_manager" jdbcType="VARCHAR" property="investmentManager" />
<result column="development_director" jdbcType="VARCHAR" property="developmentDirector" />
<result column="development_manager" jdbcType="VARCHAR" property="developmentManager" />
<result column="deadline" jdbcType="TIMESTAMP" property="deadline" />
<result column="pass_reason" jdbcType="VARCHAR" property="passReason" />
<result column="reject_public_reason" jdbcType="VARCHAR" property="rejectPublicReason" />
<result column="reject_real_reason" jdbcType="VARCHAR" property="rejectRealReason" />
<result column="certify_file" jdbcType="VARCHAR" property="certifyFile" />
<result column="deleted" jdbcType="BIT" property="deleted" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
<result column="close_time" jdbcType="TIMESTAMP" property="closeTime" />
<result column="close_user_id" jdbcType="VARCHAR" property="closeUserId" />
<result column="create_user_id" jdbcType="VARCHAR" property="createUserId" />
<result column="create_user_mobile" jdbcType="VARCHAR" property="createUserMobile" />
<result column="operator_type" jdbcType="VARCHAR" property="operatorType" />
<result column="update_user_id" jdbcType="VARCHAR" property="updateUserId" />
</resultMap>
<sql id="Base_Column_List">
id, partner_id, workflow_stage, workflow_status, line_status, investment_manager,
development_director, development_manager, deadline, pass_reason, reject_public_reason,
reject_real_reason, certify_file, deleted, create_time, update_time, close_time,
close_user_id,create_user_id,create_user_mobile,operator_type,update_user_id
</sql>
<select id="selectByPrimaryKeySelective" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"></include>
from hy_partner_line_info
where id = #{id}
</select>
<insert id="batchInsert" keyColumn="id" keyProperty="recordList.id" useGeneratedKeys="true">
insert into
hy_partner_line_info
(
partner_id,
workflow_stage,
workflow_status,
line_status,
investment_manager
)
values
<foreach collection="recordList" item="record" separator=",">
(#{record.partnerId},
#{record.workflowStage},
#{record.workflowStatus},
#{record.lineStatus},
#{record.investmentManager})
</foreach>
</insert>
<update id="batchDeleted">
update hy_partner_line_info
set deleted = 1
<where>
<if test="lineIdList!=null and lineIdList.size>0">
<foreach collection="lineIdList" open="and id in (" close=")" separator="," item="lineId">
#{lineId}
</foreach>
</if>
</where>
</update>
<insert id="insertSelective" keyColumn="id" keyProperty="record.id" useGeneratedKeys="true">
insert into hy_partner_line_info
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="record.partnerId != null">
partner_id,
</if>
<if test="record.workflowStage != null">
workflow_stage,
</if>
<if test="record.workflowStatus != null">
workflow_status,
</if>
<if test="record.lineStatus != null">
line_status,
</if>
<if test="record.investmentManager != null">
investment_manager,
</if>
<if test="record.developmentDirector != null">
development_director,
</if>
<if test="record.developmentManager != null">
development_manager,
</if>
<if test="record.deadline != null">
deadline,
</if>
<if test="record.passReason != null">
pass_reason,
</if>
<if test="record.rejectPublicReason != null">
reject_public_reason,
</if>
<if test="record.rejectRealReason != null">
reject_real_reason,
</if>
<if test="record.certifyFile != null">
certify_file,
</if>
<if test="record.deleted != null">
deleted,
</if>
<if test="record.createTime != null">
create_time,
</if>
<if test="record.updateTime != null">
update_time,
</if>
<if test="record.closeTime != null">
close_time,
</if>
<if test="record.closeUserId != null">
close_user_id,
</if>
<if test="record.createUserId != null">
create_user_id,
</if>
<if test="record.createUserMobile != null">
create_user_mobile,
</if>
<if test="record.operatorType != null">
operator_type,
</if>
<if test="record.updateUserId != null">
update_user_id,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="record.partnerId != null">
#{record.partnerId},
</if>
<if test="record.workflowStage != null">
#{record.workflowStage},
</if>
<if test="record.workflowStatus != null">
#{record.workflowStatus},
</if>
<if test="record.lineStatus != null">
#{record.lineStatus},
</if>
<if test="record.investmentManager != null">
#{record.investmentManager},
</if>
<if test="record.developmentDirector != null">
#{record.developmentDirector},
</if>
<if test="record.developmentManager != null">
#{record.developmentManager},
</if>
<if test="record.deadline != null">
#{record.deadline},
</if>
<if test="record.passReason != null">
#{record.passReason},
</if>
<if test="record.rejectPublicReason != null">
#{record.rejectPublicReason},
</if>
<if test="record.rejectRealReason != null">
#{record.rejectRealReason},
</if>
<if test="record.certifyFile != null">
#{record.certifyFile},
</if>
<if test="record.deleted != null">
#{record.deleted},
</if>
<if test="record.createTime != null">
#{record.createTime},
</if>
<if test="record.updateTime != null">
#{record.updateTime},
</if>
<if test="record.closeTime != null">
#{record.closeTime},
</if>
<if test="record.closeUserId != null">
#{record.closeUserId},
</if>
<if test="record.createUserId != null">
#{record.createUserId},
</if>
<if test="record.createUserMobile != null">
#{record.createUserMobile},
</if>
<if test="record.operatorType != null">
#{record.operatorType},
</if>
<if test="record.updateUserId != null">
#{record.updateUserId},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective">
update hy_partner_line_info
<set>
<if test="record.partnerId != null">
partner_id = #{record.partnerId},
</if>
<if test="record.workflowStage != null">
workflow_stage = #{record.workflowStage},
</if>
<if test="record.workflowStatus != null">
workflow_status = #{record.workflowStatus},
</if>
<if test="record.lineStatus != null">
line_status = #{record.lineStatus},
</if>
<if test="record.investmentManager != null">
investment_manager = #{record.investmentManager},
</if>
<if test="record.developmentDirector != null">
development_director = #{record.developmentDirector},
</if>
<if test="record.developmentManager != null">
development_manager = #{record.developmentManager},
</if>
<if test="record.deadline != null">
deadline = #{record.deadline},
</if>
<if test="record.passReason != null">
pass_reason = #{record.passReason},
</if>
<if test="record.rejectPublicReason != null">
reject_public_reason = #{record.rejectPublicReason},
</if>
<if test="record.rejectRealReason != null">
reject_real_reason = #{record.rejectRealReason},
</if>
<if test="record.certifyFile != null">
certify_file = #{record.certifyFile},
</if>
<if test="record.deleted != null">
deleted = #{record.deleted},
</if>
<if test="record.createTime != null">
create_time = #{record.createTime},
</if>
<if test="record.updateTime != null">
update_time = #{record.updateTime},
</if>
<if test="record.closeTime != null">
close_time = #{record.closeTime},
</if>
<if test="record.closeUserId != null">
close_user_id = #{record.closeUserId},
</if>
<if test="record.joinBlackReason != null">
join_black_reason = #{record.joinBlackReason},
</if>
<if test="record.removeBlackReason != null">
remove_black_reason = #{record.removeBlackReason},
</if>
</set>
where id = #{record.id}
</update>
<update id="updateByPrimaryKey">
update hy_partner_line_info
set
partner_id = #{record.partnerId},
workflow_stage = #{record.workflowStage},
workflow_status = #{record.workflowStatus},
line_status = #{record.lineStatus},
investment_manager = #{record.investmentManager},
development_director = #{record.developmentDirector},
development_manager = #{record.developmentManager},
deadline = #{record.deadline},
pass_reason = #{record.passReason},
reject_public_reason = #{record.rejectPublicReason},
reject_real_reason = #{record.rejectRealReason},
certify_file = #{record.certifyFile},
close_time = #{record.closeTime},
close_user_id = #{record.closeUserId},
join_black_reason = #{record.joinBlackReason},
remove_black_reason = #{record.removeBlackReason}
where id = #{record.id}
</update>
<select id="getAdventLineCount" resultType="com.cool.store.dto.partner.AdvanceLineDTO">
select DATE(deadline) as date ,count(1) as count from hy_partner_line_info
<where>
<if test="userId!=null and userId!=''">
and investment_manager = #{userId}
</if>
<if test="currentDate!=null and currentDate!=''">
and DATE(deadline) BETWEEN #{currentDate} and #{endDate}
</if>
and (workflow_stage = 2 and workflow_status = 0)
</where>
group by DATE(deadline)
</select>
<select id="selectStagePendingCount" resultType="com.cool.store.dto.partner.StageCountDTO">
select
IFNULL(sum(if(workflow_stage=1 and workflow_status = 1,1,0)),0) as intentApplyApproveCount,
IFNULL(sum(if(workflow_stage=2 and workflow_status = 1,1,0)),0) as reservationInterviewCount,
IFNULL(sum(if(workflow_stage=3 and workflow_status = 4,1,0)),0) as qualifiedInterviewCount
from hy_partner_line_info
where deleted = 0 and line_status!=3
<if test="userId!=null and userId!=''">
and investment_manager = #{userId}
</if>
</select>
<select id="selectStageFollowCount" resultType="com.cool.store.dto.partner.StageCountDTO">
select
IFNULL(sum(if(workflow_stage=1 and workflow_status = 0,1,0)),0) as intentApplyApproveCount,
IFNULL(sum(if(workflow_stage=2 and workflow_status = 0,1,0)),0) as reservationInterviewCount,
IFNULL(sum(if(workflow_stage=3 and workflow_status = 5,1,0)),0) as qualifiedInterviewCount
from hy_partner_line_info
where deleted = 0 and line_status!=3
<if test="userId!=null and userId!=''">
and investment_manager = #{userId}
</if>
</select>
<select id="selectPartnerLineInfoAndBaseInfo" resultType="com.cool.store.dto.partner.PartnerLineInfoAndBaseInfoDTO">
select
a.id as id,
a.development_director as developmentDirector,
a.partner_id as partnerId,
a.workflow_stage as workflowStage,
a.line_status as lineStatus,
a.workflow_status as workflowStatus,
a.partner_id as partnerUserId,
a.investment_manager as investmentManager,
b.user_portrait as user_portrait,
b.id as partnerBaseInfoId,
b.pass_reason as passCause,
b.id_card as idCard,
b.certify_file as certifyFile,
b.pass_time as passTime,
b.pass_user_id as passUserId,
hpuinfo.live_area as liveArea,
hpuinfo.want_shop_area as wantShopArea,
hpuinfo.accept_adjust_type as acceptAdjustType,
hpuinfo.mobile as partnerUserPhone,
hpuinfo.username as partnerUserName,
hpuinfo.ec_want_shop_area as ecWantShopArea,
hpuc.channel_name as channelName,
hpii.education as education,
hpii.detailed_address as detailedAddress,
hpii.email as email,
hpl.phone_address as phoneAddress
from hy_partner_line_info a
left join hy_partner_base_info b on a.id = b.partner_line_id
LEFT JOIN hy_partner_intent_info hpii ON a.id = hpii.partner_line_id
LEFT JOIN hy_partner_user_info hpuinfo ON a.partner_id = hpuinfo.partner_id
LEFT JOIN hy_partner_user_channel hpuc ON hpuinfo.user_channel_id = hpuc.channel_id
LEFT JOIN hy_phone_location hpl ON hpl.phone_number = hpuinfo.mobile
<where>
<if test="lineId!=null">
and a.id = #{lineId}
</if>
</where>
</select>
<select id="lastMonthCloseLine" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"></include>
from hy_partner_line_info
where deleted = 0 and line_status = 0 and close_time is not null
<if test="userId != null">
and investment_manager = #{userId}
</if>
<if test="lastMonthTodayDate!=null">
and close_time > #{lastMonthTodayDate} and close_time <![CDATA[<]]> now()
</if>
</select>
<update id="updateInvestmentManager">
update hy_partner_line_info
set investment_manager = #{userId}, line_status= '1'
<if test="lineIdList!=null and lineIdList.size>0">
<foreach collection="lineIdList" open="where id in (" close=")" separator="," item="lineId">
#{lineId}
</foreach>
</if>
</update>
<select id="getLineListByLineIds" resultMap="BaseResultMap" >
select
<include refid="Base_Column_List"></include>
from hy_partner_line_info
where deleted = 0
<if test="lineIdList!=null and lineIdList.size>0">
<foreach collection="lineIdList" open="and id in (" close=")" separator="," item="lineId">
#{lineId}
</foreach>
</if>
</select>
<select id="getBlackList" resultType="com.cool.store.dto.partner.PartnerBlackListDTO" >
select
b.partner_id as partnerId,
b.mobile as mobile,
b.username as partnerUserName,
a.id as lineId,
a.create_time as createTime,
a.close_user_id as closeUserId,
a.close_time as closeTime,
a.join_black_reason as joinBlackReason,
hpl.phone_address as phoneAddress
from hy_partner_line_info a
inner join hy_partner_user_info b on a.partner_id = b.partner_id
LEFT JOIN hy_open_area_info hoai ON hoai.id = b.want_shop_area
LEFT JOIN hy_phone_location hpl ON hpl.phone_number = b.mobile
where a.deleted = 0
and a.line_status = 3
<if test="userNameKeyword!=null and userNameKeyword !=''">
and b.username like concat('%', #{userNameKeyword}, '%')
</if>
<if test="phoneKeyword!=null and phoneKeyword !=''">
and b.mobile like concat('%', #{phoneKeyword}, '%')
</if>
<if test="intentAreaName!=null and intentAreaName!=''">
and hoai.area_path like concat('%/',#{intentAreaName},'/%')
</if>
<if test="acceptAdjustType!=null">
and b.accept_adjust_type =#{acceptAdjustType}
</if>
order by a.close_time desc
</select>
<update id="joinAndRemoveBlack">
update hy_partner_line_info
<set>
<if test="line_status != null">
line_status = #{status},
</if>
<if test="joinCause != null and joinCause!=''">
join_black_reason = #{joinCause},
</if>
<if test="removeReason != null and removeReason!=''">
remove_black_reason = #{removeReason},
</if>
</set>
where id = #{lineId}
</update>
<select id="getByPartnerId" resultMap="BaseResultMap" >
select
<include refid="Base_Column_List"></include>
from hy_partner_line_info
where partner_id = #{partnerId} and deleted = 0
</select>
<select id="getPublicSeaLineList" resultType="com.cool.store.dto.partner.PublicSeaLineDTO">
select
a.id as lineId,
a.create_time as createTime,
a.update_time as updateTime,
b.partner_id as partner_id,
b.mobile as mobile,
b.user_channel_id as userChannelId,
b.username as userName,
b.want_shop_area as wantShopArea,
b.ec_want_shop_area as EcWantShopArea,
b.accept_adjust_type as acceptAdjustType,
bi.user_portrait as userPortrait,
hpl.phone_address as phoneAddress
FROM hy_partner_line_info a
inner JOIN hy_partner_user_info b on a.partner_id = b.partner_id
left join hy_partner_base_info bi on a.id = bi.partner_line_id
LEFT JOIN hy_open_area_info hoai ON hoai.id = b.want_shop_area
LEFT JOIN hy_phone_location hpl ON hpl.phone_number = b.mobile
where a.line_status = 0 and a.deleted = 0
<if test="userNameKeyword!=null and userNameKeyword!=''">
and b.username like concat('%',#{userNameKeyword},'%')
</if>
<if test="phoneKeyword!=null and phoneKeyword!=''">
and b.mobile like concat('%',#{phoneKeyword},'%')
</if>
<if test="intentAreaName!=null and intentAreaName!=''">
and hoai.area_path like concat('%/',#{intentAreaName},'/%')
</if>
<if test="acceptAdjustType!=null">
and b.accept_adjust_type = #{acceptAdjustType}
</if>
<if test="updateStartTime!=null and updateEndTime!=''">
and a.update_time BETWEEN #{updateStartTime} and #{updateEndTime}
</if>
<if test="createStartTime!=null and createEndTime!=''">
and a.create_time BETWEEN #{createStartTime} and #{createEndTime}
</if>
<if test="userIdList!=null and userIdList.size>0">
<foreach collection="userIdList" item="userId" open="and a.investment_manager in (" close=")" separator=",">
#{userId}
</foreach>
</if>
order by a.create_time desc
</select>
<select id="getPrivateSeaLineList" resultType="com.cool.store.dto.partner.PrivateSeaLineDTO">
SELECT
hpli.id as lineId,
hpli.partner_id as partnerId,
hpli.workflow_stage as workflowStage,
hpli.workflow_status as workflowStatus,
hpli.deadline as deadline,
hpli.investment_manager as investmentManager,
hpli.development_manager as developmentManager,
hpli.line_status as lineStatus,
hpli.update_time as updateTime,
hpuinfo.user_channel_id as userChannelId,
hpuinfo.want_shop_area as wantShopArea,
hpuinfo.ec_want_shop_area as ecWantShopArea,
hpuinfo.accept_adjust_type as acceptAdjustType,
hpuinfo.username as partnerUserName,
hpuinfo.mobile as partnerUserPhone,
hpuinfo.shop_code as storeCode,
hpuinfo.shop_name as storeName,
hpuinfo.recommend_partner_name as recommendPartnerName,
hpuinfo.recommend_partner_mobile as recommendPartnerMobile,
bi.user_portrait as userPortrait,
eu.name as investmentManagerName,
eu.mobile as investmentManagerMobile,
hptil.create_time AS allotTime
FROM
hy_partner_line_info hpli
LEFT JOIN hy_partner_intent_info hpii ON hpli.id = hpii.partner_line_id
left join hy_partner_base_info bi on hpli.id = bi.partner_line_id
LEFT JOIN hy_partner_user_info hpuinfo ON hpli.partner_id = hpuinfo.partner_id
LEFT JOIN enterprise_user eu ON hpli.investment_manager = eu.user_id
LEFT JOIN hy_open_area_info hoai ON hoai.id = hpuinfo.want_shop_area
LEFT JOIN ( SELECT max(create_time) as create_time, partner_id,id FROM hy_partner_task_info_log WHERE operate_type
IN ( 'allocation_investment_manager', 'transfer_investment_manager','ec_sync_add_line' ) and deleted=0 GROUP BY partner_id ) hptil ON hpli.partner_id = hptil.partner_id
WHERE hpli.line_status in (1,2)
AND ( hpli.deleted IS NULL OR hpli.deleted = 0 )
<if test="keyword!=null and keyword!='' and keywordType!=null and keywordType=='name'">
AND (eu.name like concat('%',#{keyword},'%') or hpuinfo.username like concat('%',#{keyword},'%'))
</if>
<if test="keyword!=null and keyword!='' and keywordType!=null and keywordType=='mobile'">
AND ( eu.mobile like concat('%',#{keyword},'%') or hpuinfo.mobile like concat('%',#{keyword},'%'))
</if>
<if test="workflowStage!=null and workflowStage!=''">
AND hpli.workflow_stage = #{workflowStage}
</if>
<if test="workflowStatus!=null and workflowStatus!=''">
AND hpli.workflow_status = #{workflowStatus}
</if>
<if test="deadlineStart!=null and deadlineEnd!=null">
AND hpli.deadline BETWEEN #{deadlineStart} and #{deadlineEnd}
</if>
<if test="updateStartTime!=null and updateEndTime!=null">
AND hpli.update_time BETWEEN #{updateStartTime} and #{updateEndTime}
</if>
<if test="lineStartTime != null and lineEndTime != null">
AND hpli.create_time BETWEEN #{lineStartTime} and #{lineEndTime}
</if>
<if test="intentAreaName!=null and intentAreaName!='' and intentAreaQueryType!=null and intentAreaQueryType == 'contains'">
and hoai.area_path like concat('%/',#{intentAreaName},'/%')
</if>
<if test="intentAreaName!=null and intentAreaName!='' and intentAreaQueryType!=null and intentAreaQueryType == 'notContains'">
and hoai.area_path not like concat('%/',#{intentAreaName},'/%')
</if>
<if test="intentAreaQueryType !=null and intentAreaQueryType == 'blank'">
AND hpuinfo.want_shop_area is null
</if>
<if test="acceptAdjustType!=null">
AND hpuinfo.accept_adjust_type = #{acceptAdjustType}
</if>
<if test="partnerName !=null and partnerName!=''">
AND hpuinfo.username like concat('%',#{partnerName},'%')
</if>
<if test="partnerMobile !=null and partnerMobile!=''">
AND hpuinfo.mobile like concat('%',#{partnerMobile},'%')
</if>
<if test="investmentManagerId !=null and investmentManagerId!=''">
AND hpli.investment_manager = #{investmentManagerId}
</if>
<if test="storeKeyword!=null and storeKeyword!='' and storeKeywordType!=null and storeKeywordType=='storeCode'">
AND hpuinfo.shop_code like concat('%',#{storeKeyword},'%')
</if>
<if test="storeKeyword!=null and storeKeyword!='' and storeKeywordType!=null and storeKeywordType=='storeName'">
AND hpuinfo.shop_name like concat('%',#{storeKeyword},'%')
</if>
<if test="storeKeyword!=null and storeKeyword!='' and storeKeywordType!=null and storeKeywordType=='partnerName'">
AND hpuinfo.recommend_partner_name like concat('%',#{storeKeyword},'%')
</if>
<if test="storeKeyword!=null and storeKeyword!='' and storeKeywordType!=null and storeKeywordType=='partnerMobile'">
AND hpuinfo.recommend_partner_mobile like concat('%',#{storeKeyword},'%')
</if>
<if test="userIdList!=null and userIdList.size>0 and developmentManagerList!=null and developmentManagerList.size==0">
<foreach collection="userIdList" item="userId" open="and hpli.investment_manager in (" close=")" separator=",">
#{userId}
</foreach>
</if>
<if test="userPortraitIdList!=null and userPortraitIdList.size>0 and userPortraitQueryType!=null and userPortraitQueryType=='contains'">
<foreach collection="userPortraitIdList" separator="or" open="and (" close=")" item="userPortraitId">
bi.user_portrait like concat("%,", #{userPortraitId}, ",%")
</foreach>
</if>
<if test="userPortraitIdList!=null and userPortraitIdList.size>0 and userPortraitQueryType!=null and userPortraitQueryType=='notContains'">
<foreach collection="userPortraitIdList" separator="or" open="and (" close=")" item="userPortraitId">
bi.user_portrait not like concat("%,", #{userPortraitId}, ",%")
</foreach>
</if>
<if test="userPortraitQueryType!=null and userPortraitQueryType=='blank'">
AND bi.user_portrait is null
</if>
<if test="userChannelIdList!=null and userChannelIdList.size>0 and userChannelQueryType!=null and userChannelQueryType == 'contains' ">
<foreach collection="userChannelIdList" open="and hpuinfo.user_channel_id in (" close=")" separator="," item="userChannelId">
#{userChannelId}
</foreach>
</if>
<if test="userChannelIdList!=null and userChannelIdList.size>0 and userChannelQueryType!=null and userChannelQueryType == 'notContains' ">
<foreach collection="userChannelIdList" open="and hpuinfo.user_channel_id not in (" close=")" separator="," item="userChannelId">
#{userChannelId}
</foreach>
</if>
<if test="userChannelQueryType!=null and userChannelQueryType == 'blank' ">
AND hpuinfo.user_channel_id is null
</if>
<if test="userIdList!=null and userIdList.size==0 and developmentManagerList!=null and developmentManagerList.size>0">
<foreach collection="developmentManagerList" item="developmentManager" open="and hpli.development_manager in (" close=")" separator=",">
#{developmentManager}
</foreach>
</if>
<if test="userIdList!=null and userIdList.size>0 and developmentManagerList!=null and developmentManagerList.size>0">
<foreach collection="userIdList" item="userId" open="and (hpli.investment_manager in (" close=")" separator=",">
#{userId}
</foreach>
<foreach collection="developmentManagerList" item="developmentManager" open="or hpli.development_manager in (" close="))" separator=",">
#{developmentManager}
</foreach>
</if>
<if test="sortField!=null and sortField != '' and sortField=='updateTime' ">
order by hpli.update_time
<if test="sortOrder!=null and sortOrder != '' and sortOrder=='descend' ">
desc
</if>
<if test="sortOrder!=null and sortOrder != '' and sortOrder=='ascend' ">
asc
</if>
</if>
<if test="sortField!=null and sortField != '' and sortField=='deadline' ">
order by hpli.deadline
<if test="sortOrder!=null and sortOrder != '' and sortOrder=='descend' ">
desc
</if>
<if test="sortOrder!=null and sortOrder != '' and sortOrder=='ascend' ">
asc
</if>
</if>
<if test="sortField!=null and sortField != '' and sortField=='allotTime' ">
order by hptil.create_time
<if test="sortOrder!=null and sortOrder != '' and sortOrder=='descend' ">
desc
</if>
<if test="sortOrder!=null and sortOrder != '' and sortOrder=='ascend' ">
asc
</if>
</if>
</select>
<select id="getPartnerLastLine" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List"></include>
FROM hy_partner_line_info h1
WHERE h1.create_time = (
SELECT MAX(h2.create_time)
FROM hy_partner_line_info h2
WHERE h1.partner_id = h2.partner_id
and (h2.deleted = 1 or (h2.deleted=0 and h2.line_status=0 and h2.close_time is not null))
<if test="partnerIdList!=null and partnerIdList.size>0">
<foreach collection="partnerIdList" item="partnerId" open="and h1.partner_id in (" close=")" separator=",">
#{partnerId}
</foreach>
</if>
)
</select>
<select id="getFollowCountList" resultType="com.cool.store.dto.partner.LineCountDTO">
SELECT partner_id, IFNULL(COUNT(1), 0) AS followCount
FROM hy_partner_line_info
where (deleted = 1 or (deleted=0 and line_status in (0,3) and close_time is not null )) and investment_manager is not null
<if test="partnerIdList!=null and partnerIdList.size>0">
<foreach collection="partnerIdList" item="partnerId" open="and partner_id in (" close=")" separator=",">
#{partnerId}
</foreach>
</if>
GROUP BY partner_id;
</select>
<select id="getHyPartnerLineInfoListByIds" resultMap="BaseResultMap">
SELECT <include refid="Base_Column_List"></include>
FROM hy_partner_line_info
<where>
<if test="lineIds!=null and lineIds.size>0">
<foreach collection="lineIds" item="lineId" open="and id in (" close=")" separator=",">
#{lineId}
</foreach>
</if>
</where>
</select>
<select id="getLineFollowHistoryList" resultMap="BaseResultMap">
SELECT <include refid="Base_Column_List"></include>
FROM hy_partner_line_info
where (deleted = 1 or (deleted=0 and line_status in (0,3) and close_time is not null )) and investment_manager is not null
and partner_id = #{partner_id}
order by id desc
</select>
<!-- 根据面试计划 id 查询战区 id -->
<select id="getAffiliationZoneIdByInterviewPlanId" resultType="java.lang.String">
SELECT want_shop_area
FROM hy_partner_user_info
WHERE partner_id = (
SELECT partner_id
FROM hy_partner_interview_plan
WHERE id = #{interviewPlanId}
)
</select>
<select id="getWaitForOpenInterviewLineList" resultType="com.cool.store.entity.HyPartnerLineInfoDO">
SELECT <include refid="Base_Column_List"></include>
FROM hy_partner_line_info hpli
WHERE line_status = 1
AND workflow_stage = 3
AND workflow_status = 2
AND hpli.deleted = 0
AND id IN (
SELECT partner_line_id
FROM hy_partner_interview_plan
WHERE start_time &gt;= #{startTime}
AND start_time &lt;= #{endTime}
AND room_status = 0
AND deleted = 0
)
</select>
<select id="getOverTimeReserveLineList" resultType="com.cool.store.entity.HyPartnerLineInfoDO">
SELECT <include refid="Base_Column_List"></include>
FROM hy_partner_line_info hpli
WHERE line_status = 1
AND workflow_stage = #{workflowStage}
AND workflow_status = #{workflowStatus}
AND hpli.deleted = 0
AND deadline &lt;= #{deadlineEnd}
</select>
<update id="updateWorkflowStatus">
UPDATE hy_partner_line_info
SET workflow_status = #{status}
WHERE id = #{lineId}
</update>
<update id="batchUpdateStatusByLineIds">
UPDATE hy_partner_line_info
SET workflow_status = #{status}
WHERE id IN
<foreach collection="lineIds" item="lineId" open="(" close=")" separator=",">
#{lineId}
</foreach>
</update>
<select id="getPartnerSimpleInfoByLineIds" resultType="com.cool.store.dto.partner.PartnerSimpleInfoDTO">
select
a.id as partnerLineId,
a.partner_id as partnerId,
a.workflow_stage as workflowStage,
a.line_status as lineStatus,
b.username as username,
b.mobile as mobile
from
hy_partner_line_info a inner join hy_partner_user_info b on a.partner_id = b.partner_id and a.deleted = '0'
where
a.id in <foreach collection="partnerLineIds" open="(" close=")" separator="," item="lineId">#{lineId}</foreach>
</select>
<select id="getHyPartnerLineInfoList" resultMap="BaseResultMap">
SELECT <include refid="Base_Column_List"></include>
FROM hy_partner_line_info
<where>
<if test="lineIds!=null and lineIds.size>0">
<foreach collection="lineIds" item="lineId" open="and id in (" close=")" separator=",">
#{lineId}
</foreach>
</if>
<if test="investmentManager!=null and investmentManager!=''">
and investment_manager = #{investmentManager}
</if>
</where>
</select>
<!-- 获取线索转让次数 -->
<select id="getTransferTimes" resultType="java.lang.Integer">
select count(*)
from hy_partner_task_info_log
where operate_type = 'entrust_others'
and partner_line_id = #{lineId}
-- and deleted = 0
</select>
<select id="getPrivateSeaPageInfoNext" resultType="com.cool.store.vo.LinePageInfoVo">
SELECT
hpli.id as lineId,
hpli.partner_id as partnerId
FROM
hy_partner_line_info hpli
LEFT JOIN hy_partner_intent_info hpii ON hpli.id = hpii.partner_line_id
left join hy_partner_base_info bi on hpli.id = bi.partner_line_id
LEFT JOIN hy_partner_user_info hpuinfo ON hpli.partner_id = hpuinfo.partner_id
LEFT JOIN enterprise_user eu ON hpli.investment_manager = eu.user_id
LEFT JOIN hy_open_area_info hoai ON hoai.id = hpuinfo.want_shop_area
LEFT JOIN ( SELECT max(create_time) as create_time, partner_id,id FROM hy_partner_task_info_log WHERE operate_type
IN ( 'allocation_investment_manager', 'transfer_investment_manager','ec_sync_add_line' ) and deleted=0 GROUP BY partner_id ) hptil ON hpli.partner_id = hptil.partner_id
WHERE hpli.line_status in (1,2)
AND ( hpli.deleted IS NULL OR hpli.deleted = 0 )
<if test="keyword!=null and keyword!='' and keywordType!=null and keywordType=='name'">
AND (eu.name like concat('%',#{keyword},'%') or hpuinfo.username like concat('%',#{keyword},'%'))
</if>
<if test="keyword!=null and keyword!='' and keywordType!=null and keywordType=='mobile'">
AND ( eu.mobile like concat('%',#{keyword},'%') or hpuinfo.mobile like concat('%',#{keyword},'%'))
</if>
<if test="workflowStage!=null and workflowStage!=''">
AND hpli.workflow_stage = #{workflowStage}
</if>
<if test="workflowStatus!=null and workflowStatus!=''">
AND hpli.workflow_status = #{workflowStatus}
</if>
<if test="deadlineStart!=null and deadlineEnd!=null">
AND hpli.deadline BETWEEN #{deadlineStart} and #{deadlineEnd}
</if>
<if test="updateStartTime!=null and updateEndTime!=null">
AND hpli.update_time BETWEEN #{updateStartTime} and #{updateEndTime}
</if>
<if test="lineStartTime != null and lineEndTime != null">
AND hpli.create_time BETWEEN #{lineStartTime} and #{lineEndTime}
</if>
<if test="intentAreaName!=null and intentAreaName!='' and intentAreaQueryType!=null and intentAreaQueryType == 'contains'">
and hoai.area_path like concat('%/',#{intentAreaName},'/%')
</if>
<if test="intentAreaName!=null and intentAreaName!='' and intentAreaQueryType!=null and intentAreaQueryType == 'notContains'">
and hoai.area_path not like concat('%/',#{intentAreaName},'/%')
</if>
<if test="intentAreaQueryType !=null and intentAreaQueryType == 'blank'">
AND hpuinfo.want_shop_area is null
</if>
<if test="acceptAdjustType!=null">
AND hpuinfo.accept_adjust_type = #{acceptAdjustType}
</if>
<if test="partnerName !=null and partnerName!=''">
AND hpuinfo.username like concat('%',#{partnerName},'%')
</if>
<if test="partnerMobile !=null and partnerMobile!=''">
AND hpuinfo.mobile like concat('%',#{partnerMobile},'%')
</if>
<if test="investmentManagerId !=null and investmentManagerId!=''">
AND hpli.investment_manager = #{investmentManagerId}
</if>
<if test="storeKeyword!=null and storeKeyword!='' and storeKeywordType!=null and storeKeywordType=='storeCode'">
AND hpuinfo.shop_code like concat('%',#{storeKeyword},'%')
</if>
<if test="storeKeyword!=null and storeKeyword!='' and storeKeywordType!=null and storeKeywordType=='storeName'">
AND hpuinfo.shop_name like concat('%',#{storeKeyword},'%')
</if>
<if test="storeKeyword!=null and storeKeyword!='' and storeKeywordType!=null and storeKeywordType=='partnerName'">
AND hpuinfo.recommend_partner_name like concat('%',#{storeKeyword},'%')
</if>
<if test="storeKeyword!=null and storeKeyword!='' and storeKeywordType!=null and storeKeywordType=='partnerMobile'">
AND hpuinfo.recommend_partner_mobile like concat('%',#{storeKeyword},'%')
</if>
<if test="userIdList!=null and userIdList.size>0 and developmentManagerList!=null and developmentManagerList.size==0">
<foreach collection="userIdList" item="userId" open="and hpli.investment_manager in (" close=")" separator=",">
#{userId}
</foreach>
</if>
<if test="userPortraitIdList!=null and userPortraitIdList.size>0 and userPortraitQueryType!=null and userPortraitQueryType=='contains'">
<foreach collection="userPortraitIdList" separator="or" open="and (" close=")" item="userPortraitId">
bi.user_portrait like concat("%,", #{userPortraitId}, ",%")
</foreach>
</if>
<if test="userPortraitIdList!=null and userPortraitIdList.size>0 and userPortraitQueryType!=null and userPortraitQueryType=='notContains'">
<foreach collection="userPortraitIdList" separator="or" open="and (" close=")" item="userPortraitId">
bi.user_portrait not like concat("%,", #{userPortraitId}, ",%")
</foreach>
</if>
<if test="userPortraitQueryType!=null and userPortraitQueryType=='blank'">
AND bi.user_portrait is null
</if>
<if test="userChannelIdList!=null and userChannelIdList.size>0 and userChannelQueryType!=null and userChannelQueryType == 'contains' ">
<foreach collection="userChannelIdList" open="and hpuinfo.user_channel_id in (" close=")" separator="," item="userChannelId">
#{userChannelId}
</foreach>
</if>
<if test="userChannelIdList!=null and userChannelIdList.size>0 and userChannelQueryType!=null and userChannelQueryType == 'notContains' ">
<foreach collection="userChannelIdList" open="and hpuinfo.user_channel_id not in (" close=")" separator="," item="userChannelId">
#{userChannelId}
</foreach>
</if>
<if test="userChannelQueryType!=null and userChannelQueryType == 'blank' ">
AND hpuinfo.user_channel_id is null
</if>
<if test="userIdList!=null and userIdList.size==0 and developmentManagerList!=null and developmentManagerList.size>0">
<foreach collection="developmentManagerList" item="developmentManager" open="and hpli.development_manager in (" close=")" separator=",">
#{developmentManager}
</foreach>
</if>
<if test="userIdList!=null and userIdList.size>0 and developmentManagerList!=null and developmentManagerList.size>0">
<foreach collection="userIdList" item="userId" open="and (hpli.investment_manager in (" close=")" separator=",">
#{userId}
</foreach>
<foreach collection="developmentManagerList" item="developmentManager" open="or hpli.development_manager in (" close="))" separator=",">
#{developmentManager}
</foreach>
</if>
<if test="sortField!=null and sortField != '' and sortField=='updateTime' ">
order by hpli.update_time
<if test="sortOrder!=null and sortOrder != '' and sortOrder=='descend' ">
desc
</if>
<if test="sortOrder!=null and sortOrder != '' and sortOrder=='ascend' ">
asc
</if>
</if>
<if test="sortField!=null and sortField != '' and sortField=='deadline' ">
order by hpli.deadline
<if test="sortOrder!=null and sortOrder != '' and sortOrder=='descend' ">
desc
</if>
<if test="sortOrder!=null and sortOrder != '' and sortOrder=='ascend' ">
asc
</if>
</if>
<if test="sortField!=null and sortField != '' and sortField=='allotTime' ">
order by hptil.create_time
<if test="sortOrder!=null and sortOrder != '' and sortOrder=='descend' ">
desc
</if>
<if test="sortOrder!=null and sortOrder != '' and sortOrder=='ascend' ">
asc
</if>
</if>
limit #{limit1},#{limit2}
</select>
<select id="getPublicSeaPageInfoNext" resultType="com.cool.store.vo.LinePageInfoVo">
select
a.id as lineId,
a.partner_id as partnerId
FROM hy_partner_line_info a
inner JOIN hy_partner_user_info b on a.partner_id = b.partner_id
left join hy_partner_base_info bi on a.id = bi.partner_line_id
LEFT JOIN hy_open_area_info hoai ON hoai.id = b.want_shop_area
LEFT JOIN hy_phone_location hpl ON hpl.phone_number = b.mobile
where a.line_status = 0 and a.deleted = 0
<if test="lineId!=null and lineId!='' and pageTurn=='next'">
AND a.id <![CDATA[ < ]]> #{lineId}
</if>
<if test="lineId!=null and lineId!='' and pageTurn=='previous'">
AND a.id <![CDATA[ > ]]> #{lineId}
</if>
<if test="userNameKeyword!=null and userNameKeyword!=''">
and b.username like concat('%',#{userNameKeyword},'%')
</if>
<if test="phoneKeyword!=null and phoneKeyword!=''">
and b.mobile like concat('%',#{phoneKeyword},'%')
</if>
<if test="intentAreaName!=null and intentAreaName!=''">
and hoai.area_path like concat('%/',#{intentAreaName},'/%')
</if>
<if test="acceptAdjustType!=null">
and b.accept_adjust_type = #{acceptAdjustType}
</if>
<if test="updateStartTime!=null and updateEndTime!=''">
and a.update_time BETWEEN #{updateStartTime} and #{updateEndTime}
</if>
<if test="createStartTime!=null and createEndTime!=''">
and a.create_time BETWEEN #{createStartTime} and #{createEndTime}
</if>
<if test="userIdList!=null and userIdList.size>0">
<foreach collection="userIdList" item="userId" open="and a.investment_manager in (" close=")" separator=",">
#{userId}
</foreach>
</if>
order by a.create_time desc limit 1
</select>
</mapper>