<?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.ruoyi.basic.mapper.YjStoreMapper">

    <select id="getOne" resultType="com.ruoyi.basic.domain.YjStore">
        SELECT a.*,a.dept_id as id,b.parent_id,b.tenant_id
        from yj_store a,sys_dept b
        WHERE a.dept_id=b.dept_id
          and a.dept_id=#{deptId}
          and b.status='0'
          and b.delete_flag='0'
          and b.activation_date <![CDATA[ <= ]]> NOW() <![CDATA[ <= ]]> b.expiry_date

    </select>

    <select id="getStoreListByTenantId" resultType="com.ruoyi.basic.domain.YjStore">
        SELECT b.dept_id as id,a.store_name,a.address,a.phone,a.founder,a.profile,a.banner,
               b.parent_id,
               b.tenant_id
        from yj_store a,
             sys_dept b,
             sys_tenant c
        WHERE a.dept_id=b.dept_id and b.tenant_id=c.tenant_id
          and a.display='1'
          and b.dept_type='2'
          and b.status='0'
          and b.delete_flag='0'
          and c.in_use='0'
          and c.delete_flag='0'
          and now() between c.begin_time and c.end_time
          and b.tenant_id=#{tenantId}
          and b.activation_date <![CDATA[ <= ]]> NOW() <![CDATA[ <= ]]> b.expiry_date

    </select>


    <select id="getStoreList" resultType="com.ruoyi.basic.domain.YjStore">
        SELECT b.dept_id as id,a.store_name,b.parent_id,a.address,a.phone
        from yj_store  a,sys_dept b,sys_tenant c
        WHERE  a.dept_id=b.dept_id and b.tenant_id=c.tenant_id
            and c.super_tenant != 1
            and b.parent_id='0'
            and b.status='0'
            and a.display=1
            and c.in_use='0'
            and c.delete_flag='0'
            and now() between c.begin_time and c.end_time
    </select>

    <select id="getChilds" resultType="com.ruoyi.basic.domain.YjStore">
        SELECT b.dept_id as id,a.store_name,b.parent_id,a.address,a.phone
        from yj_store  a,sys_dept b
        WHERE  a.dept_id=b.dept_id
            and b.parent_id=#{id} and a.display=1 and b.status='0'
           and b.activation_date <![CDATA[ <= ]]> NOW() <![CDATA[ <= ]]> b.expiry_date
    </select>

    <select id="getAppIndex" resultType="SysAppIndex">
        select * from sys_app_index order by sort
    </select>

</mapper>
