<?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.m2pool.lease.mapper.LeaseShopMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.m2pool.lease.entity.LeaseShop">
        <id column="id" property="id" />
        <result column="user_email" property="userEmail" />
        <result column="name" property="name" />
        <result column="image" property="image" />
        <result column="description" property="description" />
        <result column="create_time" property="createTime" />
        <result column="update_time" property="updateTime" />
        <result column="del" property="del" />
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id, user_email, name, image, description, create_time, update_time, del
    </sql>
    <select id="getPayAddressAndPayCoin" resultType="com.m2pool.lease.entity.LeaseShopConfig">
        SELECT
        `shop_id` as shopId,
        `pay_address` as payAddress,
        `pay_coin` as payCoin,
        `qrcode`,
        `chain`
        FROM
        lease_shop_config
        WHERE
        del = false AND
        <foreach collection="chainAndCoinSet" item="item" separator="OR">
            (pay_coin = #{item.coin} AND chain = #{item.chain} AND shop_id = #{item.shopId})
        </foreach>
    </select>
    <select id="getShopWalletInfo" resultType="com.m2pool.lease.dto.PayConfigDto">
        SELECT
        pay_coin as payCoin,
        pay_coin_image as payCoinImage,
        chain as payChain
        FROM
        lease_shop_config
        WHERE
        shop_id = #{shopId} and del = 0
    </select>
    <select id="getShopWalletInfoList" resultType="com.m2pool.lease.dto.PayConfigDto">
        SELECT
        pay_coin as payCoin,
        pay_coin_image as payCoinImage,
        chain as payChain,
        shop_id as shopId
        FROM
        lease_shop_config
        WHERE
        shop_id IN
        <foreach collection="shopIds" item="shopId" open="(" separator="," close=")">
            #{shopId}
        </foreach>
        and del = 0
    </select>
    <select id="getShopIdsByMachineIds" resultType="java.lang.Long">
        SELECT
        DISTINCT shop_id as shopId
        FROM
        lease_product_machine
        WHERE
        id IN
        <foreach collection="machineIds" item="machineId" open="(" separator="," close=")">
            #{machineId}
        </foreach>

    </select>
    <select id="getShopNameMapByIds" resultType="com.m2pool.lease.entity.LeaseShop">
        SELECT
        id ,
        name
        FROM
        lease_shop
        WHERE
        id IN
        <foreach collection="shopIds" item="shopId" open="(" separator="," close=")">
            #{shopId}
        </foreach>
        and del = 0
    </select>


</mapper>
