<?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.yami.shop.delivery.comment.dao.FetchMapper">

  <resultMap id="fetchMap" type="com.yami.shop.delivery.comment.model.Fetch">
    <id column="fetch_id" property="fetchId" />
    <result column="shop_id" property="shopId"/>
    <result column="fetch_name" property="fetchName"/>
    <result column="images" property="images"/>
    <result column="phone_prefix" property="phonePrefix"/>
    <result column="phone" property="phone"/>
    <result column="status" property="status"/>
    <result column="create_time" property="createTime"/>
    <result column="update_time" property="updateTime"/>
    <result column="province_id" property="provinceId"/>
    <result column="province" property="province"/>
    <result column="city_id" property="cityId"/>
    <result column="city" property="city"/>
    <result column="area_id" property="areaId"/>
    <result column="area" property="area"/>
    <result column="addr" property="addr"/>
    <result column="lng" property="lng"/>
    <result column="lat" property="lat"/>
  </resultMap>
  <update id="updateStatus">
    UPDATE
      tz_fetch
    SET
      `status` = #{status}
    WHERE `fetch_id` = #{handleId}
  </update>
  <select id="getPage" resultType="com.yami.shop.delivery.comment.model.Fetch">
    SELECT f.*,s.shop_name FROM tz_fetch f
    JOIN tz_shop_detail s  ON s.shop_id = f.shop_id
    <where>
      <if test="fetch.shopName != null and fetch.shopName !=''">
        AND s.shop_name LIKE CONCAT("%",#{fetch.shopName},"%")
      </if>
      <if test="fetch.fetchName != null and fetch.fetchName != ''">
        AND f.fetch_name LIKE CONCAT("%",#{fetch.fetchName},"%")
      </if>
      <if test="fetch.status != null">
        AND f.status  = #{fetch.status}
      </if>
    </where>
  </select>
</mapper>
