<?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.workorder.RpMaterialMaper">


    <select id="list" resultType="com.gree.mall.manager.bean.engin.RpMaterialOrderVO">
        SELECT
        ${ex.selected}
        FROM rp_material_order a
        ${ex.query}
        and a.pay_type != 'LINE'
        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="workerSettlementPageV2" resultType="com.gree.mall.manager.bean.engin.WorkerMaterialSettlementVO">
        SELECT
        ${ex.selected}
        FROM worker_settlement a
        ${ex.query}
        and a.type = 'PROJECT'
        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="listLine" resultType="com.gree.mall.manager.bean.engin.RpMaterialOrderLineVO">
        SELECT
        ${ex.selected}
        FROM rp_material_order a
        ${ex.query}
        and 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="listWechat" resultType="com.gree.mall.manager.bean.engin.RpMaterialOrderWechatVO">
        SELECT
        ${ex.selected}
        FROM rp_material_order a
        ${ex.query}
        and 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="listAll" resultType="com.gree.mall.manager.bean.engin.RpMaterialOrderAllListVO">
        SELECT
        ${ex.selected}
        FROM rp_material_order a
        ${ex.query}
        and a.pay_type != 'LINE'
        and a.pay_type != 'WECHAT'
        and a.is_all_fee = 'YES'
        <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="listSalesManager" resultType="com.gree.mall.manager.bean.engin.WebsitSalesManagerVO">
        SELECT
        a.websit_sales_manager_id,
        a.company_wechat_id,
        a.company_wechat_name,
        a.order_engin_base_id,
        a.goods_type,
        a.sales_num,
        a.status,
        a.sales_price,
        a.ret_num,
        a.ret_price,
        a.price,
        a.give_price,
        a.wait_price,
        a.create_by,
        a.create_time,
        a.update_by,
        a.update_time,
        b.project_name,
        b.project_no,
        b.manger,
        b.mobile,
        b.start_time,
        b.end_time,
        b.province,
        b.province_id,
        b.city,
        b.city_id,
        b.area,
        b.area_id,
        b.street,
        b.street_id,
        b.address,
        b.remark,
        b.lng,
        b.lat
        FROM websit_sales_manager a
        join order_engin_base b on a.order_engin_base_id = b.id
        ${ex.query}
        <if test="ex.orderBy == null or ex.orderBy ==''">
            ORDER BY a.create_time DESC
        </if>
        ${ex.orderBy}
    </select>
    <select id="listManual" resultType="com.gree.mall.manager.bean.workorder.WorkerSettlementManualVO">
        SELECT
        ${ex.selected}
        FROM worker_settlement_manual a
        ${ex.query}
        <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="listSettlement" resultType="com.gree.mall.manager.bean.workorder.SettlementOrderManualVO">
        SELECT
        ${ex.selected}
        FROM settlement_order_manual a
        ${ex.query}
        <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>