<?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.younike.system.mapper.MerchantMapper">

    <select id="selectMerchantByAdminId" parameterType="Long" resultMap="MerchantResult">
        <include refid="selectMerchantVo"/>
        where admin_id = #{adminId}
    </select>

    <update id="updateMerchants">
        <foreach collection="list" item="item" index="index" separator=";">
            update merchant set score = #{item.score} , rate = #{item.rate} , sales = #{item.sales}
            where merchant_id = #{item.merchantId}
        </foreach>
    </update>

    <select id="getMerchantCountByMerchantType" parameterType="String" resultType="java.lang.Integer">
        SELECT
        count(*)
        FROM merchant
        WHERE del_flag = '0'
        AND merchant_type = #{merchantType}
    </select>
    <select id="getMerchantCountBy" parameterType="com.younike.system.domain.Merchant" resultType="java.lang.Integer">
        SELECT
        count(*)
        FROM merchant
        WHERE del_flag = '0'
        <if test="merchantType != null ">
             AND merchant_type = #{merchantType}
        </if>
        <if test="shopState != null and shopState != ''">
            AND shop_state in (${shopState})
        </if>

    </select>
</mapper>
