<?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.xhpc.activity.mapper.XhpcRechargeOrderMapper">


    <resultMap type="com.xhpc.activity.domain.XhpcRechargeOrderDomain" id="XhpcRechargeOrderResult">
        <result column="recharge_order_id" property="rechargeOrderId" />
        <result column="user_id" property="userId" />
        <result column="recharge_order_number" property="rechargeOrderNumber"/>
        <result column="prepay_id" property="prepayId" />
        <result column="alipay_number" property="alipayNumber" />
        <result column="amount" property="amount" />
        <result column="type" property="type" />
        <result column="status" property="status" />
        <result column="del_flag" property="delFlag" />
        <result column="create_time" property="createTime" />
        <result column="create_by" property="createBy" />
        <result column="update_time" property="updateTime" />
        <result column="update_by" property="updateBy" />
        <result column="source" property="source" />
    </resultMap>


    <select id="findOneByOrderNumber" resultType="com.xhpc.activity.domain.XhpcRechargeOrderDomain">
        select
        *
        from xhpc_recharge_order
        where recharge_order_number=#{orderNumber}
    </select>


    <select id="findListByOrderNumbers" resultType="map">
        select
        recharge_order_id as 'id',
        recharge_order_number as 'orderNumber',
        user_id as 'userId',
        amount as 'amount',
        create_time as 'createTime',
        update_time as 'updateTime'
        from xhpc_recharge_order
        where recharge_order_number in
        <foreach collection="orderNumbers" item="orderNumber" separator="," open="(" close=")">
            #{orderNumber}
        </foreach>
    </select>


    <select id="findListByTimeBetween" resultType="map">
        select
        recharge_order_id as 'id',
        recharge_order_number as 'orderNumber',
        user_id as 'userId',
        amount as 'amount',
        create_time as 'createTime',
        update_time as 'updateTime'
        from xhpc_recharge_order
        where tenant_id=#{tenantId}
          <if test="startTime!=null and startTime != ''">
              and create_time <![CDATA[ >= ]]> #{startTime}
          </if>
          <if test="endTime != null and endTime !=''">
              and create_time <![CDATA[ <= ]]> #{endTime}
          </if>
        <if test="type != null">
            and type=#{type}
        </if>
    </select>

</mapper>