<?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.gree.mall.miniapp.commonmapper.GoodsFlagUpdateMapper">
    <update id="updateSecFlag">
        update goods_spec gs
        set flag = 0
        WHERE gs.flag = 1
          and not EXISTS
            (select skas.goods_spec_id
             from sec_kill_activity ska
                      inner join sec_kill_stage sks on ska.sec_kill_id = sks.sec_kill_id
                      inner join sec_kill_activity_spec skas on skas.sec_kill_id = ska.sec_kill_id
             where gs.goods_spec_id = skas.goods_spec_id
               and (now() BETWEEN ska.start_time and ska.end_time)
               and ska.status = 1
               and ska.del = 0
            )
    </update>

</mapper>