<?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.yami.shop.seckill.comment.dao.SeckillOrderMapper">

  <resultMap id="seckillOrderMap" type="com.yami.shop.seckill.comment.model.SeckillOrder">
    <id column="seckill_order_id" property="seckillOrderId" />
    <result column="seckill_id" property="seckillId"/>
    <result column="user_id" property="userId"/>
    <result column="order_number" property="orderNumber"/>
    <result column="prod_count" property="prodCount"/>
    <result column="create_time" property="createTime"/>
    <result column="prod_id" property="prodId" />
    <result column="state" property="state" />
  </resultMap>
    <update id="updateStateByOrderNumber">
      update tz_seckill_order set state =#{state} where order_number = #{orderNumber}

    </update>
  <update id="cancelUnpayOrderByOrderNumber">
    UPDATE tz_seckill_order so
    set so.state = -1
    where order_number = #{orderNumber}
  </update>
  <insert id="cancelUnpayOrder">
    UPDATE tz_seckill_order so JOIN tz_seckill s ON s.seckill_id = so.seckill_id AND (UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(so.`create_time`))/60 &gt; s.`max_cancel_time` and so.`state` = 0
    SET so.`state` = -1
  </insert>


</mapper>
