<?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="cn.pluss.platform.mapper.JftReceiptOrderMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="cn.pluss.platform.entity.JftReceiptOrder">
        <id column="id" property="id" />
        <result column="rid" property="rid" />
        <result column="amount" property="amount" />
        <result column="status" property="status" />
        <result column="payType" property="payType" />
        <result column="orderNumber" property="orderNumber" />
        <result column="userId" property="userId" />
        <result column="merchantCode" property="merchantCode" />
        <result column="merchantName" property="merchantName" />
        <result column="payUserId" property="payUserId" />
        <result column="name" property="name" />
        <result column="phone" property="phone" />
        <result column="goods" property="goods" />
        <result column="address" property="address" />
        <result column="transNo" property="transNo" />
        <result column="channelTransNo" property="channelTransNo" />
        <result column="transTime" property="transTime" />
        <result column="rate" property="rate" />
        <result column="createTime" property="createTime" />
        <result column="channelFee" property="channelFee" />
        <result column="mercFee" property="mercFee" />
        <result column="cashFee" property="cashFee" />
        <result column="payData" property="payData" />
        <result column="remark" property="remark" />
        <result column="createDate" property="createDate" />
    </resultMap>

    <select id="pageData" parameterType="cn.pluss.platform.dto.jft.JftReceiptOrderDTO" resultType="cn.pluss.platform.vo.JftReceiptOrderVO">
        select
            ri.projectName as projectName,
            ri.amount as orderAmt,
            IF(ro.`status` = '01','待付款','已付款') as payStatusDesc,
            ro.orderNumber as orderNumber,
            ro.createTime
        from tb_pluss_jft_receipt_order ro left join tb_pluss_jft_receipt_info ri on ro.rid = ri.id
        <where>
            <if test="entity.userId != null">
                and ro.userId = #{entity.userId}
            </if>
            <if test="entity.status != null and entity.status != ''">
                and ro.status = #{entity.status}
            </if>
            <if test="entity.startDate != null and entity.startDate != ''">
                and ro.createDate >= #{entity.startDate}
            </if>
            <if test="entity.endDate != null and entity.endDate != ''">
                and ro.createDate <![CDATA[ <= ]]> #{entity.endDate}
            </if>
        </where>
        order by ro.id desc
    </select>
</mapper>
