<?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.ssm.manage.mapper.SsmStoreTurnTreatmentMapper">

    <resultMap type="com.ssm.manage.entity.StoreTurnTreatment" id="StoreTurnTreatmentMap">
        <result property="id" column="id" jdbcType="INTEGER"/>
        <result property="courseAccountId" column="course_account_id" jdbcType="INTEGER"/>
        <result property="memberId" column="member_id" jdbcType="INTEGER"/>
        <result property="memberName" column="member_name" jdbcType="VARCHAR"/>
        <result property="card" column="card" jdbcType="VARCHAR"/>
        <result property="storeId" column="store_id" jdbcType="INTEGER"/>
        <result property="storeName" column="store_name" jdbcType="VARCHAR"/>
        <result property="courseProjectId" column="course_project_id" jdbcType="INTEGER"/>
        <result property="courseProjectName" column="course_project_name" jdbcType="VARCHAR"/>
        <result property="courseProjectMoney" column="course_project_money" jdbcType="NUMERIC"/>
        <result property="courseCount" column="course_count" jdbcType="INTEGER"/>
        <result property="courseRestCount" column="course_rest_count" jdbcType="INTEGER"/>
        <result property="courseConsumeCount" column="course_consume_count" jdbcType="INTEGER"/>
        <result property="courseRestPrice" column="course_rest_price" jdbcType="NUMERIC"/>
        <result property="courseConsumePrice" column="course_consume_price" jdbcType="NUMERIC"/>
        <result property="courseProjectNum" column="course_project_num" jdbcType="VARCHAR"/>
        <result property="statu" column="statu" jdbcType="INTEGER"/>
        <result property="updateId" column="update_id" jdbcType="INTEGER"/>
        <result property="updateName" column="update_name" jdbcType="VARCHAR"/>
        <result property="updateDate" column="update_date" jdbcType="TIMESTAMP"/>
        <result property="proposerDate" column="proposer_date" jdbcType="TIMESTAMP"/>
        <result property="proposerId" column="proposer_id" jdbcType="INTEGER"/>
        <result property="proposerName" column="proposer_name" jdbcType="VARCHAR"/>
        <result property="orderCode" column="order_code" jdbcType="VARCHAR"/>
        <result property="courseStoreNum" column="course_store_num" jdbcType="VARCHAR"/>
    </resultMap>


    <resultMap type="com.ssm.manage.entity.StoreTurnTreatment" id="StoreTurnTreatmentMap1">
        <result property="id" column="id" jdbcType="INTEGER"/>
        <result property="courseAccountId" column="course_account_id" jdbcType="INTEGER"/>
        <result property="memberId" column="member_id" jdbcType="INTEGER"/>
        <result property="memberName" column="member_name" jdbcType="VARCHAR"/>
        <result property="card" column="card" jdbcType="VARCHAR"/>
        <result property="storeId" column="store_id" jdbcType="INTEGER"/>
        <result property="storeName" column="store_name" jdbcType="VARCHAR"/>
        <result property="storeNum" column="store_num" jdbcType="VARCHAR"/>
        <result property="courseProjectId" column="course_project_id" jdbcType="INTEGER"/>
        <result property="courseProjectName" column="course_project_name" jdbcType="VARCHAR"/>
        <result property="courseProjectMoney" column="course_project_money" jdbcType="NUMERIC"/>
        <result property="courseCount" column="course_count" jdbcType="INTEGER"/>
        <result property="courseRestCount" column="course_rest_count" jdbcType="INTEGER"/>
        <result property="courseConsumeCount" column="course_consume_count" jdbcType="INTEGER"/>
        <result property="courseRestPrice" column="course_rest_price" jdbcType="NUMERIC"/>
        <result property="courseConsumePrice" column="course_consume_price" jdbcType="NUMERIC"/>
        <result property="courseProjectNum" column="course_project_num" jdbcType="VARCHAR"/>
        <result property="statu" column="statu" jdbcType="INTEGER"/>
        <result property="updateId" column="update_id" jdbcType="INTEGER"/>
        <result property="updateName" column="update_name" jdbcType="VARCHAR"/>
        <result property="updateDate" column="update_date" jdbcType="TIMESTAMP"/>
        <result property="proposerDate" column="proposer_date" jdbcType="TIMESTAMP"/>
        <result property="proposerId" column="proposer_id" jdbcType="INTEGER"/>
        <result property="proposerName" column="proposer_name" jdbcType="VARCHAR"/>
        <result property="orderCode" column="order_code" jdbcType="VARCHAR"/>

        <result property="storesId" column="stores_id" jdbcType="INTEGER"/>
        <result property="storesName" column="stores_name" jdbcType="VARCHAR"/>
        <result property="storesNum" column="stores_num" jdbcType="VARCHAR"/>
    </resultMap>


    <select id="selectFKJ" resultMap="StoreTurnTreatmentMap" parameterType="com.ssm.manage.entity.StoreTurnTreatment">
        select * from store_turn_treatment
        <where>
            stores_id = #{storeId, jdbcType = BIGINT} and statu=2
            and DATE_FORMAT(proposer_date, '%Y-%m-%d' ) = DATE_FORMAT(#{proposerDate} , '%Y-%m-%d');
        </where>
    </select>

    <select id="selectFKJOut" resultMap="StoreTurnTreatmentMap" parameterType="com.ssm.manage.entity.StoreTurnTreatment">
        select * from store_turn_treatment
        <where>
            store_id = #{storeId, jdbcType = BIGINT} and statu=2
            and DATE_FORMAT(proposer_date, '%Y-%m-%d' ) = DATE_FORMAT(#{proposerDate} , '%Y-%m-%d');
        </where>
    </select>

    <select id="selectPhon" resultMap="StoreTurnTreatmentMap1" parameterType="com.ssm.manage.query.StoreTurnTreatmentQuery">
        select * from store_turn_treatment
        <where>
            <if test="mids != null">
            member_id in
            <foreach collection="mids" item="mids" index="index" open="(" close=")" separator=",">
                #{mids}
            </foreach>
            </if>
            <if test="dateone != null">
                and proposer_date like concat( #{dateone, jdbcType = VARCHAR}, '%')
            </if>
            <if test="dateEnd != null ">
                and proposer_date between #{dateStart, jdbcType = TIMESTAMP} and #{dateEnd, jdbcType = TIMESTAMP}
            </if>
            <if test="courseStoreNum!=null">
                and course_store_num like concat('%',#{courseStoreNum,jdbcType=VARCHAR},'%')
            </if>
        </where>
        LIMIT #{pageNum},#{pageSize}
    </select>

    <select id="exportachis" resultMap="StoreTurnTreatmentMap1" parameterType="com.ssm.manage.query.StoreTurnTreatmentQuery">
        select * from store_turn_treatment
        <where>
            <if test="mids != null">
                member_id in
                <foreach collection="mids" item="mids" index="index" open="(" close=")" separator=",">
                    #{mids}
                </foreach>
            </if>
            <if test="dateone != null">
                and proposer_date like concat( #{dateone, jdbcType = VARCHAR}, '%')
            </if>
            <if test="dateEnd != null ">
                and proposer_date between #{dateStart, jdbcType = TIMESTAMP} and #{dateEnd, jdbcType = TIMESTAMP}
            </if>
            <if test="courseStoreNum!=null">
                and course_store_num like concat('%',#{courseStoreNum,jdbcType=VARCHAR},'%')
            </if>
        </where>
    </select>

    <select id="selectPhonCount" resultType="java.lang.Integer" parameterType="com.ssm.manage.query.StoreTurnTreatmentQuery">
        select count(0) from store_turn_treatment
        <where>
            <if test="mids != null">
                member_id in
                <foreach collection="mids" item="mids" index="index" open="(" close=")" separator=",">
                    #{mids}
                </foreach>
            </if>
            <if test="dateone != null">
                and proposer_date like concat( #{dateone, jdbcType = VARCHAR}, '%')
            </if>
            <if test="dateEnd != null ">
                and proposer_date between #{dateStart, jdbcType = TIMESTAMP} and #{dateEnd, jdbcType = TIMESTAMP}
            </if>
        </where>

    </select>
    <select id="getDocNum" parameterType="com.ssm.manage.entity.StoreTurnTreatment"  resultMap="StoreTurnTreatmentMap">
        select * from store_turn_treatment
        where course_store_num like concat(#{courseStoreNum,jdbcType = VARCHAR},'%')
        order by course_store_num desc
    </select>
    <select id="selectFKJByDate" resultMap="StoreTurnTreatmentMap" parameterType="com.ssm.manage.entity.StoreTurnTreatment">
        select * from store_turn_treatment
        <where>
            stores_id = #{storeId, jdbcType = BIGINT} and statu=2
            and proposer_date between #{startTime} and #{endTime}
        </where>
    </select>
    <select id="selectFKJOutByDate" resultMap="StoreTurnTreatmentMap" parameterType="com.ssm.manage.entity.StoreTurnTreatment">
        select * from store_turn_treatment
        <where>
            store_id = #{storeId, jdbcType = BIGINT} and statu=2
            and proposer_date between #{startTime} and #{endTime}
        </where>
    </select>
</mapper>

