<?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.gree.mall.manager.commonmapper.WebsitSalesRetCMapper">


    <select id="pageV2" resultType="com.gree.mall.manager.bean.websit.WebsitSalesRetVO">
        select
        ${ex.selected}
        from
        websit_sales_ret a LEFT JOIN storage b ON a.storage_id = b.storage_id
        ${ex.query}

        <if test="companyWechatIds != null and companyWechatIds.size > 0">
            AND a.company_wechat_id IN
            <foreach item="item" index="index" collection="companyWechatIds" open="(" separator="," close=")">
                #{item}
            </foreach>

        </if>
        <if test="ex.adminWebsitIds != null and ex.adminWebsitIds.size > 0">
            AND (
            a.websit_id IN
            <foreach item="item" index="index" collection="ex.adminWebsitIds" open="(" separator="," close=")">
                #{item}
            </foreach>
            )
        </if>

        <if test="ex.orderBy == null or ex.orderBy ==''">
            order by a.create_time desc
        </if>
        ${ex.orderBy}
    </select>
    <select id="pagePartsRetV2" resultType="com.gree.mall.manager.bean.websit.WebsitPartsRetVO">
        select
        ${ex.selected}
        from
        websit_parts_ret a LEFT JOIN storage b ON a.storage_id = b.storage_id
        ${ex.query}

        <if test="companyWechatIds != null and companyWechatIds.size > 0">
            AND a.company_wechat_id IN
            <foreach item="item" index="index" collection="companyWechatIds" open="(" separator="," close=")">
                #{item}
            </foreach>

        </if>
        <if test="ex.adminWebsitIds != null and ex.adminWebsitIds.size > 0">
            AND (
            a.websit_id IN
            <foreach item="item" index="index" collection="ex.adminWebsitIds" open="(" separator="," close=")">
                #{item}
            </foreach>
            )
        </if>

        <if test="ex.orderBy == null or ex.orderBy ==''">
            order by a.create_time desc
        </if>
        ${ex.orderBy}
    </select>
    <select id="pageSettletV2" resultType="com.gree.mall.manager.bean.websit.SettlementOrderLogicVO">
        select
        ${ex.selected}
        from
        settlement_order a
        ${ex.query}

        <if test="companyWechatIds != null and companyWechatIds.size > 0">
            AND a.company_wechat_id IN
            <foreach item="item" index="index" collection="companyWechatIds" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>
        <if test="ex.adminWebsitIds != null and ex.adminWebsitIds.size > 0">
            AND a.websit_id IN
            <foreach item="item" index="index" collection="ex.adminWebsitIds" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>
        <if test="ex.orderBy == null or ex.orderBy ==''">
            order by a.create_time desc
        </if>
        ${ex.orderBy}
    </select>
    <select id="pageWithdrawalV2" resultType="com.gree.mall.manager.bean.websit.WithdrawalOrderVO">
        select
        ${ex.selected}
        from
        withdrawal_order a
        ${ex.query}

        <if test="companyWechatIds != null and companyWechatIds.size > 0">
            AND a.company_wechat_id IN
            <foreach item="item" index="index" collection="companyWechatIds" open="(" separator="," close=")">
                #{item}
            </foreach>


        </if>
        <if test="ex.orderBy == null or ex.orderBy ==''">
            order by a.create_time desc
        </if>
        ${ex.orderBy}
    </select>
    <select id="workerSettlementPageV2" resultType="com.gree.mall.manager.bean.websit.WorkerSettlementVO">
        SELECT
        ${ex.selected}
        FROM worker_settlement a
        ${ex.query}
        and a.type = 'OTHER'
        and a.pay_type = 'WECHAT'
        <if test="ex.adminWebsitIds != null and ex.adminWebsitIds.size > 0">
            AND (
            a.websit_id IN
            <foreach item="item" index="index" collection="ex.adminWebsitIds" open="(" separator="," close=")">
                #{item}
            </foreach>
            )
        </if>
        <if test="ex.orderBy == null or ex.orderBy ==''">
            ORDER BY a.create_time DESC
        </if>
        ${ex.orderBy}
    </select>
    <select id="pageLineSettlementV2" resultType="com.gree.mall.manager.bean.websit.WorkerSettlementLineVO">
        SELECT
        ${ex.selected}
        FROM worker_settlement a
        ${ex.query}
        and a.type = 'OTHER'
        and a.pay_type = 'LINE'
        <if test="ex.adminWebsitIds != null and ex.adminWebsitIds.size > 0">
            AND (
            a.websit_id IN
            <foreach item="item" index="index" collection="ex.adminWebsitIds" open="(" separator="," close=")">
                #{item}
            </foreach>
            )
        </if>
        <if test="ex.orderBy == null or ex.orderBy ==''">
            ORDER BY a.create_time DESC
        </if>
        ${ex.orderBy}
    </select>
    <select id="pagePartsFactoryRetV2" resultType="com.gree.mall.manager.bean.websit.WebsitPartsFactoryRetVO">
        select
        ${ex.selected}
        from
        websit_parts_ret a LEFT JOIN storage b ON a.storage_id = b.storage_id
        ${ex.query}
        and a.type = 'FACTORY'
        <if test="companyWechatIds != null and companyWechatIds.size > 0">
            AND a.company_wechat_id IN
            <foreach item="item" index="index" collection="companyWechatIds" open="(" separator="," close=")">
                #{item}
            </foreach>


        </if>

        <if test="ex.adminWebsitIds != null and ex.adminWebsitIds.size > 0">
            AND a.websit_id IN
            <foreach item="item" index="index" collection="ex.adminWebsitIds" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>

        <if test="ex.orderBy == null or ex.orderBy ==''">
            order by a.create_time desc
        </if>
        ${ex.orderBy}
    </select>
</mapper>