<?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.thinkgem.jeesite.modules.pay.dao.OrderApiDao">

    <select id="getOrderList" resultType="com.thinkgem.jeesite.modules.pay.entity.OrderEntity">
        SELECT
            o.pay_code,
            o.pay_no,
            o.pay_status,
            o.pay_type,
            o.pay_channel,
            o.amount,
            o.create_date,
            o.`subject`,
            sd.label AS "payChannelName"
        FROM
            `youka_orders` o
        LEFT JOIN sys_dict sd ON sd.value = o.pay_channel
        WHERE o.del_flag = 0
        AND o.user_code = #{subMerchantCode}
        <if test="payChannel != null and payChannel != ''">
            AND o.pay_channel = #{payChannel}
        </if>
        <if test="payStatus != null and payStatus != ''">
            AND o.pay_status = #{payStatus}
        </if>
        <if test="startTime != null and startTime != ''">
            AND o.create_date &gt;= #{startTime}
        </if>
        <if test="endTime != null and endTime != ''">
            AND o.create_date &lt;= #{endTime}
        </if>

    </select>
    <select id="getBenefitList" resultType="com.thinkgem.jeesite.modules.pay.entity.BenefitEntity">
        SELECT
        o.pay_code AS "orderEntity.payCode",
        o.pay_no AS "orderEntity.payNo",
        o.pay_status AS "orderEntity.payStatus",
        o.pay_type AS "orderEntity.payType",
        o.pay_channel AS "orderEntity.payChannel",
        o.`subject` AS "orderEntity.subject",
        o.amount AS "orderEntity.amount",
        sd.label AS "orderEntity.payChannelName",
        yb.amount AS "amount",
        yb.create_date AS "createDate"
        FROM
        youka_benefit yb
        LEFT JOIN `youka_orders` o ON yb.order_code = o.`code`
        LEFT JOIN sys_dict sd ON sd.`VALUE` = o.pay_channel
        WHERE o.del_flag = 0
        AND o.user_code = #{subMerchantCode}
        <if test="payChannel != null and payChannel != ''">
            AND o.pay_channel = #{payChannel}
        </if>
        <if test="payStatus != null and payStatus != ''">
            AND o.pay_status = #{payStatus}
        </if>
        <if test="startTime != null and startTime != ''">
            AND o.create_date &gt;= #{startTime}
        </if>
        <if test="endTime != null and endTime != ''">
            AND o.create_date &lt;= #{endTime}
        </if>
        AND yb.del_flag = 0
    </select>
</mapper>