<?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.CourseMoneyMapper">
    <resultMap type="com.ssm.manage.entity.CourseMoney" id="baseMap">
        <result property="id" column="id" jdbcType="BIGINT"/>
        <result property="storeId" column="store_id" jdbcType="BIGINT"/>
        <result property="date" column="date" jdbcType="TIMESTAMP"/>
        <result property="openning" column="openning" jdbcType="DECIMAL"/>
        <result property="courseMoney" column="course_money" jdbcType="DECIMAL"/>
        <result property="courseRepay" column="course_repay" jdbcType="DECIMAL"/>
        <result property="cashRefund" column="cash_refund" jdbcType="DECIMAL"/>
        <result property="coursePromotion" column="course_promotion" jdbcType="DECIMAL"/>
        <result property="init" column="init" jdbcType="DECIMAL"/>
        <result property="courseTurnStore" column="course_turn_store" jdbcType="DECIMAL"/>
        <result property="cardChange" column="card_change" jdbcType="DECIMAL"/>
        <result property="cashMoney" column="cash_money" jdbcType="DECIMAL"/>
        <result property="courseRefundMoney" column="course_refund_money" jdbcType="DECIMAL"/>
        <result property="courseTurnCharge" column="course_turn_charge" jdbcType="DECIMAL"/>
        <result property="courseTurnStoreMoney" column="course_turn_store_money" jdbcType="DECIMAL"/>
        <result property="balance" column="balance" jdbcType="DECIMAL"/>
        <result property="courseRepayMoney" column="course_repay_money" jdbcType="DECIMAL"/>
        <result property="coursePromotionRepay" column="course_promotion_repay" jdbcType="DECIMAL"/>
    </resultMap>
    <select id="selectByDate" resultMap="baseMap">
        select * from course_money where substring(date,1,10) = #{rechargeDate}
    </select>


    <insert id="saveList">
        insert into course_money
            (
             id,
             store_id,
             date,
             openning,
             course_money,
             course_repay,
             cash_refund,
             course_promotion,
             init,
             course_turn_store,
             card_change,
             cash_money,
             course_refund_money,
             course_turn_charge,
             course_turn_store_money,
             balance,
             course_repay_money,
             course_promotion_repay
        )
        values <foreach collection="courseInsert"  separator="," item="item">
        (
         #{item.id,jdbcType=BIGINT},
         #{item.storeId,jdbcType=BIGINT},
         #{item.date,jdbcType=TIMESTAMP},
         #{item.openning,jdbcType=DECIMAL},
         #{item.courseMoney,jdbcType=DECIMAL},
         #{item.courseRepay,jdbcType=DECIMAL},
         #{item.cashRefund,jdbcType=DECIMAL},
         #{item.coursePromotion,jdbcType=DECIMAL},
         #{item.init,jdbcType=DECIMAL},
         #{item.courseTurnStore,jdbcType=DECIMAL},
         #{item.cardChange,jdbcType=DECIMAL},
         #{item.cashMoney,jdbcType=DECIMAL},
         #{item.courseRefundMoney,jdbcType=DECIMAL},
         #{item.courseTurnCharge,jdbcType=DECIMAL},
         #{item.courseTurnStoreMoney,jdbcType=DECIMAL},
         #{item.balance,jdbcType=DECIMAL},
         #{item.courseRepayMoney,jdbcType=DECIMAL},
         #{item.coursePromotionRepay,jdbcType=DECIMAL}

        )
    </foreach>
    </insert>

    <select id="fixedNegativeCardByRecharge" resultMap="baseMap" parameterType="com.ssm.manage.extendEntity.NegativeDayStatistic">
        select * from course_money where substring(date,1,7) = #{selectDate} and store_id in
        <foreach collection="storeIdl" item="item" separator="," open="(" close=")">
            #{item}
        </foreach>
    </select>
</mapper>

