<?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.style24.batch.biz.dao.TsbOrderDao">

	<!-- 무통장입금 입금기한 만료 주문 조회 -->
	<select id="getOrderDepositExpirationList" parameterType="Order" resultType="Order">
		/* TsbOrder.getOrderDepositExpirationList : 무통장입금 입금기한 만료 주문 조회 */
		SELECT OD.ORD_NO
		FROM   TB_ORDER_DETAIL OD
		INNER  JOIN TB_PAYMENT PAY
		ON     OD.ORD_NO = PAY.ORD_NO
		WHERE  OD.ORD_DTL_STAT = 'G013_10'
		AND    PAY.PAY_STAT = 'G016_10'
		AND    PAY.PG_GB = 'KCP'
		AND    PAY.PAY_MEANS = 'G014_20'
		AND    PAY.VA_DEADLINE <![CDATA[ < ]]> NOW()
		GROUP BY OD.ORD_NO
	</select>

	<!-- 선물하기 배송지 등록 기간 만료 주문 취소 -->
	<select id="getOrderGiftExpirationList" parameterType="Order" resultType="Order">
		/* TsbOrder.getOrderGiftExpirationList : 선물하기 배송지 등록 기간 만료 주문 취소 */
		SELECT O.ORD_NO
		FROM   TB_ORDER O
		INNER  JOIN TB_ORDER_DETAIL OD
		ON     OD.ORD_NO = O.ORD_NO
		WHERE  1=1
		AND    OD.GIFT_PACK_YN = 'Y'
		AND    OD.GIFT_ADDR_INP_YN = 'N'
		AND    OD.ORD_DTL_STAT = 'G013_20'
		AND    O.ORD_DT <![CDATA[ < ]]> ADDDATE(NOW(), INTERVAL -3 DAY)
		GROUP  BY O.ORD_NO
	</select>
</mapper>