<?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.pay_method,
            o.amount,
            o.create_date,
            o.`subject`,
            sd.label AS "payMethodName"
        FROM
            `youka_orders` o
        LEFT JOIN sys_dict sd ON sd.value = o.pay_method
        WHERE o.del_flag = 0
        AND o.user_code = #{subMerchantCode}
        <if test="payChannel != null and payChannel != ''">
            AND o.pay_channel = #{payChannel}
        </if>
        <if test="payMethod != null and payMethod != ''">
            AND o.pay_channel = #{payMethod}
        </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.pay_method AS "orderEntity.payMethod",
        o.`subject` AS "orderEntity.subject",
        o.amount AS "orderEntity.amount",
        sd.label AS "orderEntity.payChannelName",
        sdm.label AS "orderEntity.payMethodName",
        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
        LEFT JOIN sys_dict sdm ON sdm.`VALUE` = o.pay_method
        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>