<?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.zfire.mall.manager.commonmapper.rece.ReceMapper">

    <select id="list" resultType="com.zfire.mall.manager.bean.rece.ReceivableItemBean">
        SELECT
            a.*,
            b.id 'itemId',
            project_code,
            project_name,
            department_id,
            customer_wallet_id,
            customer_wallet_name,
            wallet_id,
            invoice_type,
            after_tax_amount,
            b.total_amount 'itemAmount',
            tax,
            tax_rate,
            b.remark 'itemRemark'
        FROM
	        receivable_order a
        JOIN receivable_order_item b ON a.id = b.receivable_order_id
        <where>
            <if test="source != null and source != ''">
                and a.soucre =#{source}
            </if>

            <if test="customerNumber != null and customerNumber != ''">
                and a.customer_number = #{customerNumber}
            </if>

            <if test="code != null and code != ''">
                and a.code like concat('%',#{code},'%')
            </if>

            <if test="userName != null and userName != ''">
                and a.user_name like concat('%',#{userName},'%')
            </if>
            <if test="examineBy != null and examineBy !=''">
                and a.examine_by like concat('%',#{examineBy},'%')
            </if>

            <if test="examineStatus != null and examineStatus != ''">
                and a.examine_status = #{examineStatus}
            </if>

            <if test="startTime != null and startTime != '' and endTime != '' and endTime != null ">
                and a.the_time BETWEEN #{startTime} and #{endTime}
            </if>
        </where>

        ORDER BY a.create_time DESC
    </select>
    <select id="walletV2" resultType="com.zfire.mall.manager.bean.k3.KingDeeWalletVO">
        SELECT
            a.*
        FROM
        king_dee_wallet a
        ${ex.query}
        <if test="ex.orderBy == null or ex.orderBy ==''">
            ORDER BY a.create_time DESC
        </if>
        ${ex.orderBy}
    </select>


</mapper>