<?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" />
  </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
  </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>
    </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>
    </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,
    hpuc.channel_name as channelName,
    hpii.education as education,
    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.username as userName,
      b.want_shop_area as wantShopArea,
      b.accept_adjust_type as acceptAdjustType,
      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.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="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.want_shop_area as wantShopArea,
      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,
      eu.name as investmentManagerName,
      eu.mobile as investmentManagerMobile
    FROM
    hy_partner_line_info hpli
    LEFT JOIN hy_partner_intent_info hpii ON hpli.id = hpii.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
    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="intentAreaName!=null and intentAreaName!=''">
      and hoai.area_path like  concat('%/',#{intentAreaName},'/%')
    </if>
    <if test="acceptAdjustType!=null">
      AND hpuinfo.accept_adjust_type = #{acceptAdjustType}
    </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="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>
    order by hpli.update_time desc
  </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>

</mapper>