<?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="org.springblade.modules.shopping.mapper.ConsignConfigMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="consignConfigResultMap" type="org.springblade.modules.shopping.entity.ConsignConfig">
        <id column="id" property="id"/>
        <result column="start_time" property="startTime"/>
        <result column="end_time" property="endTime"/>
        <result column="is_enabled" property="isEnabled"/>
    </resultMap>


    <select id="selectConsignConfigPage" resultMap="consignConfigResultMap">
        select * from t_consign_config where is_deleted = 0
    </select>

    <!--批量更新时间 -->
    <update id="updateConsignTime" parameterType="org.springblade.modules.shopping.entity.ConsignConfig">
        UPDATE t_consign t
        SET t.start_time = concat(date_format(t.start_time, '%Y-%m-%d'),CONCAT(' ',date_format(#{consignConfig.startTime}, '%H:%i:%s'))),
        t.end_time = concat(date_format(t.end_time, '%Y-%m-%d'),CONCAT(' ',date_format(#{consignConfig.endTime}, '%H:%i:%s')))
        WHERE t.now_stock > 0 AND t.consign_config_id = #{consignConfig.id};
    </update>

</mapper>
