<?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.JxMapper">


    <select id="pageStock" resultType="com.gree.mall.manager.bean.goods.GoodsStockVO">
        SELECT
        ${ex.selected}
        FROM goods_material_storage a
        ${ex.query}
        and a.is_virtyual = 'NO'
        <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="pageCode" resultType="com.gree.mall.manager.bean.goods.GoodsCodeAccVO">
        SELECT
        ${ex.selected}
        FROM goods_code_acc a
        ${ex.query}

        <if test="ex.orderBy == null or ex.orderBy ==''">
            ORDER BY a.create_time DESC
        </if>
        ${ex.orderBy}
    </select>
    <select id="pageSale" resultType="com.gree.mall.manager.bean.goods.GoodsSaleLedgerVO">
        SELECT
        ${ex.selected}
        FROM goods_sale_ledger a
        ${ex.query}

        <if test="ex.orderBy == null or ex.orderBy ==''">
            ORDER BY a.create_time DESC
        </if>
        ${ex.orderBy}
    </select>
    <select id="pageV2" resultType="com.gree.mall.manager.bean.trade.GoodsCategoryItemVO">
        SELECT
        ${ex.selected}
        FROM goods_category_item 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="listOther" resultType="com.gree.mall.manager.bean.trade.GoodsCategoryOtherItemVO">
        SELECT
        ${ex.selected}
        FROM goods_category_item 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="pageManagerV2" resultType="com.gree.mall.manager.bean.trade.OldProductManagerVO">
        SELECT
        ${ex.selected}
        FROM old_product_manager a
        join old_product_manager_item b on a.id = b.old_product_manager_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.orderBy == null or ex.orderBy ==''">
            ORDER BY a.create_time DESC
        </if>
        ${ex.orderBy}
    </select>
</mapper>