<?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.RechargeMoneyMapper">
    <resultMap type="com.ssm.manage.entity.RechargeMoney" 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="cashRefund" column="cash_refund" jdbcType="DECIMAL"/>
        <result property="cashMoney" column="cash_money" jdbcType="DECIMAL"/>
        <result property="cashRechargeGifMoney" column="cash_recharge_gif_money" jdbcType="DECIMAL"/>
        <result property="refundCashGifMoney" column="refund_cash_gif_money" jdbcType="DECIMAL"/>
        <result property="courseMoney" column="course_money" jdbcType="DECIMAL"/>
        <result property="coursePromotion" column="course_promotion" jdbcType="DECIMAL"/>
        <result property="courseTurnRecharge" column="course_turn_recharge" jdbcType="DECIMAL"/>
        <result property="groupPurchase" column="group_purchase" jdbcType="DECIMAL"/>
        <result property="init" column="init" jdbcType="DECIMAL"/>
        <result property="rechargeMoney" column="recharge_money" jdbcType="DECIMAL"/>
        <result property="rechargeGifMoney" column="recharge_gif_money" jdbcType="DECIMAL"/>
        <result property="rechargeRefundMoney" column="recharge_refund_money" jdbcType="DECIMAL"/>
        <result property="refundGifMoney" column="refund_gif_money" jdbcType="DECIMAL"/>
        <result property="rechargeRepay" column="recharge_repay" jdbcType="DECIMAL"/>
        <result property="repayRechargeGifMoney" column="repay_recharge_gif_money" jdbcType="DECIMAL"/>
        <result property="turnInStoreGifMoney" column="turn_in_store_gif_money" jdbcType="DECIMAL"/>
        <result property="turnOutStoreGifMoney" column="turn_out_store_gif_money" jdbcType="DECIMAL"/>
        <result property="openning" column="openning" jdbcType="DECIMAL"/>
        <result property="balance" column="balance" jdbcType="DECIMAL"/>
        <result property="rechargeRepayMoney" column="recharge_repay_money" jdbcType="DECIMAL"/>
        <result property="openningGift" column="openning_gift" jdbcType="DECIMAL"/>
        <result property="balanceGift" column="balance_gift" jdbcType="DECIMAL"/>
        <result property="zengka" column="zengka" jdbcType="DECIMAL"/>
    </resultMap>
    <select id="selectByDate" resultMap="baseMap" parameterType="string">
        select * from recharge_money where substring(date,1,10) = #{rechargeDate}
    </select>


    <insert id="saveList">
        insert into recharge_money (
                                    id,
                                    cash_money,
                                    cash_recharge_gif_money,
                                    cash_refund,
                                    refund_cash_gif_money,
                                    course_money,
                                    course_promotion,
                                    course_turn_recharge,
                                    group_purchase,
                                    init,
                                    recharge_money,
                                    recharge_gif_money,
                                    recharge_refund_money,
                                    refund_gif_money,
                                    recharge_repay,
                                    repay_recharge_gif_money,
                                    turn_in_store_gif_money,
                                    turn_out_store_gif_money,
                                    store_id,
                                    date,
                                    openning,
                                    balance,
                                    recharge_repay_money,
                                    openning_gift,
                                    balance_gift,
                                    zengka
                                    ) values
        <foreach collection="rechargeInsert" item="item" separator="," >
            (
            #{item.id,jdbcType=BIGINT},
            #{item.cashMoney,jdbcType=DECIMAL},
            #{item.cashRechargeGifMoney,jdbcType=DECIMAL},
            #{item.cashRefund,jdbcType=DECIMAL},
            #{item.refundCashGifMoney,jdbcType=DECIMAL},
            #{item.courseMoney,jdbcType=DECIMAL},
            #{item.coursePromotion,jdbcType=DECIMAL},
            #{item.courseTurnRecharge,jdbcType=DECIMAL},
            #{item.groupPurchase,jdbcType=DECIMAL},
            #{item.init,jdbcType=DECIMAL},
            #{item.rechargeMoney,jdbcType=DECIMAL},
            #{item.rechargeGifMoney,jdbcType=DECIMAL},
            #{item.rechargeRefundMoney,jdbcType=DECIMAL},
            #{item.refundGifMoney,jdbcType=DECIMAL},
            #{item.rechargeRepay,jdbcType=DECIMAL},
            #{item.repayRechargeGifMoney,jdbcType=DECIMAL},
            #{item.turnInStoreGifMoney,jdbcType=DECIMAL},
            #{item.turnOutStoreGifMoney,jdbcType=DECIMAL},
            #{item.storeId,jdbcType=BIGINT},
            #{item.date,jdbcType=TIMESTAMP},
            #{item.openning,jdbcType=DECIMAL},
            #{item.balance,jdbcType=DECIMAL},
            #{item.rechargeRepayMoney,jdbcType=DECIMAL},
            #{item.openningGift,jdbcType=DECIMAL},
            #{item.balanceGift,jdbcType=DECIMAL},
            #{item.zengka,jdbcType=DECIMAL}
            )
        </foreach>
    </insert>


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

