<?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.chinacreator.video.mapper.ColorSealDao">

    <select id="getNo" resultType="String">
       SELECT TO_CHAR(SYSDATE,'yyyyMMddhh24miss')||SEQ_COMMON6.nextval SENO FROM DUAL       
    </select>

    <insert id="addColorSealRec" parameterType="Map">
       INSERT INTO TD_COLORSEAL_ORDER_REC(
			ID,USERID,ORDERID,CPID,SPID,ORDERTYPE,interface,isreverse,channel)
 		VALUES(#{id},#{userid},
 		#{orderid},#{cpid},#{spid},#{ordertype},#{interface},#{isreverse},#{channel})
    </insert>

    <update id="upColorSealRec" parameterType="Map">
		UPDATE TD_COLORSEAL_ORDER_REC SET resultcode = #{resultcode},resultinfo = #{resultinfo},retry = #{retry}
		WHERE ID = #{id}
	</update>

    <update id="upColorSealRecResult" parameterType="Map">
		UPDATE TD_COLORSEAL_ORDER_REC SET resultcode = #{resultcode},resultinfo = #{resultinfo}
		WHERE ID = #{id}
	</update>

    <select id="isSuccess" resultType="Map">
		select * from
        (SELECT resultcode,resultinfo from TD_COLORSEAL_ORDER_REC where interface = 'colorsealset' and userid = #{userid} order by inserttime desc )
         where rownum = 1
	</select>

    <select id="hasOrder" resultType="Map">
	 select * from (select * from TD_COLORSEAL_ORDER_REC where ordertype = '1' and userid not in
		 (select distinct userid from TD_COLORSEAL_ORDER_REC where interface = 'colorsealset')
         and userid = #{userid} and interface = 'colorsealnotify' order by inserttime desc) where rownum =1
	</select>

</mapper>