<?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="org.springblade.modules.guosen.billRecord.mapper.BillRecordMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="billRecordResultMap" type="org.springblade.modules.guosen.billRecord.entity.BillRecord">
        <result column="id" property="id"/>
        <result column="create_user" property="createUser"/>
        <result column="create_dept" property="createDept"/>
        <result column="create_time" property="createTime"/>
        <result column="update_user" property="updateUser"/>
        <result column="update_time" property="updateTime"/>
        <result column="status" property="status"/>
        <result column="is_deleted" property="isDeleted"/>
        <result column="user_id" property="userId"/>
        <result column="open_id" property="openId"/>
        <result column="activity_id" property="activityId"/>
        <result column="pay_path" property="payPath"/>
        <result column="price" property="price"/>
        <result column="present_id" property="presentId"/>
        <result column="present_count" property="presentCount"/>
        <result column="type" property="type"/>
        <result column="pay_status" property="payStatus"/>
        <result column="relation_id" property="relationId"/>
        <result column="unique_order_no" property="uniqueOrderNo"/>
        <result column="bank_order_id" property="bankOrderId"/>
        <result column="channel" property="channel"/>
        <result column="pay_way" property="payWay"/>
        <result column="order_id" property="orderId"/>
        <result column="channel_order_id" property="channelOrderId"/>
        <result column="pay_amount" property="payAmount"/>
        <result column="yee_pay_status" property="yeePayStatus"/>
        <result column="real_pay_amount" property="realPayAmount"/>
        <result column="parent_merchant_no" property="parentMerchantNo"/>
        <result column="merchant_no" property="merchantNo"/>
        <result column="pay_success_date" property="paySuccessDate"/>
        <result column="payer_info" property="payerInfo"/>
        <result column="bussiness_fee" property="bussinessFee"/>
        <result column="fail_reason" property="failReason"/>
        <result column="third_pay_log" property="thirdPayLog"/>
        <result column="third_order_no" property="thirdOrderNo"/>
        <result column="remit_comment" property="remitComment"/>
        <result column="parent_bussiness_id" property="parentBussinessId"/>

<!--        <result column="points_value" property="pointsValue"/>-->
    </resultMap>

    <resultMap id="billRecordVOResultMap" type="org.springblade.modules.guosen.billRecord.vo.BillRecordVO" extends="billRecordResultMap">
        <result column="user_name" property="userName"/>
        <result column="user_phone" property="userPhone"/>
    </resultMap>


    <select id="selectBillRecordPage" resultMap="billRecordVOResultMap">
        select cbr.*, clu.nick_name as user_name,clu.phone as user_phone from cyzh_bill_record cbr,cyzh_login_user clu where cbr.is_deleted = 0
        and clu.is_deleted =0 and cbr.user_id = clu.id
        <if test="billRecord!= null">
            <if test="billRecord.payStatus!=null">
                and cbr.pay_status = ${billRecord.payStatus}
            </if>

            <if test="billRecord.userName!=null">
                and clu.nick_name like "%${billRecord.userName}%"
            </if>

            <if test="billRecord.userPhone!=null">
                and clu.phone like "%${billRecord.userPhone}%"
            </if>
        </if>
        order by cbr.update_time desc
    </select>

</mapper>
