<?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.OperationsConsultantAssignMapper">
  <resultMap id="BaseResultMap" type="com.cool.store.entity.OperationsConsultantAssignDO">
    <!--
      WARNING - @mbg.generated
    -->
    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="shop_id" jdbcType="BIGINT" property="shopId" />
    <result column="region_id" jdbcType="BIGINT" property="regionId" />
    <result column="assign_status" jdbcType="TINYINT" property="assignStatus" />
    <result column="created_time" jdbcType="TIMESTAMP" property="createdTime" />
    <result column="updated_time" jdbcType="TIMESTAMP" property="updatedTime" />
  </resultMap>

  <select id="selectByShopId" resultMap="BaseResultMap">
    select * from zxjp_operations_consultant_assign
    <where>
      <if test="shopId!=null">
        and shop_id = #{shopId}
      </if>
    </where>
  </select>

  <select id="getNoAssign" resultMap="BaseResultMap">
    select * from zxjp_operations_consultant_assign zoca
    left join xfsg_shop_info xsi on zoca.shop_id = xsi.id
    <where>
      and zoca.assign_status = 0
      <if test="keyword!=null and keyword!=''">
        and (xsi.shop_name like concat('%', #{keyword}, '%') or xsi.shop_code like concat('%', #{keyword}, '%'))
      </if>
      <if test="regionIds!=null and regionIds.size>0">
        <foreach collection="regionIds" item="regionId" open="and xsi.region_id in (" close=")" separator=",">
          #{regionId}
        </foreach>
      </if>
    </where>
    order by zoca.id desc
  </select>

</mapper>