<?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.yc.ship.module.trade.dal.mysql.order.TradeOrderPayMapper">

    <select id="selectHadPayAmount" resultType="java.math.BigDecimal">

        select IFNULL(sum(pay_amount) ,0) hasPayAmount
        from trade_order_pay p
        where p.order_id = #{orderId} and p.pay_status = 1 and p.deleted = 0

    </select>

    <select id="selectPayOrderBySupplierOrderNo" resultType="com.yc.ship.module.trade.dal.dataobject.order.TradeOrderPayDO">

        select p.*
        from trade_order_pay p
        inner join trade_supplier_order o on p.order_id = o.order_id
        where o.supplier_order_no = #{supplierOrderNo} and p.pay_status = 1 and p.deleted = 0

    </select>

    <select id="getOrderPayType" resultType="com.yc.ship.module.trade.dal.dataobject.order.TradeOrderPayDO">
        select *
        from trade_order_pay p
        where p.order_id = #{orderId} and p.pay_status = 1 and p.deleted = 0
        LIMIT 1
    </select>
</mapper>