<?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.dayou.mapper.BrokerageMarketerSettledMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.dayou.entity.BrokerageMarketerSettled">
        <result column="id" property="id" />
        <result column="deleted" property="deleted" />
        <result column="created" property="created" />
        <result column="modified" property="modified" />
        <result column="payment_id" property="paymentId" />
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id,
        deleted,
        created,
        modified,
        payment_id
    </sql>

    <select id="getNotSettledPayment" parameterType="java.lang.Long" resultType="com.dayou.entity.PaymentCollection">
        SELECT
            pc.*
        FROM
            `payment_collection` pc
                LEFT JOIN item i ON i.id = pc.item_id
        WHERE
            i.id = #{itemId}
          AND NOT EXISTS(select * from brokerage_marketer_settled where payment_id= pc.id and deleted = 0)
          AND pc.deleted = 0
          AND i.deleted = 0
    </select>
</mapper>
