SupplierQuotationProjectQuoteMapper.xml 2.74 KB
<?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.lframework.xingyun.sc.procurement.mappers.quotation.SupplierQuotationProjectQuoteMapper">

    <resultMap id="SupplierQuotationProjectQuote" type="com.lframework.xingyun.sc.procurement.entity.SupplierQuotationProjectQuote">
        <id column="id" property="id"/>
        <result column="project_id" property="projectId"/>
        <result column="supplier_id" property="supplierId"/>
        <result column="supplier_name" property="supplierName"/>
        <result column="quote_time" property="quoteTime"/>
        <result column="product_id" property="productId"/>
        <result column="product_name" property="productName"/>
        <result column="product_code" property="productCode"/>
        <result column="quantity" property="quantity"/>
        <result column="price" property="price"/>
        <result column="bid_status" property="bidStatus"/>
        <result column="create_by_id" property="createById"/>
        <result column="create_by" property="createBy"/>
        <result column="update_by_id" property="updateById"/>
        <result column="update_by" property="updateBy"/>
        <result column="create_time" property="createTime"/>
        <result column="update_time" property="updateTime"/>
    </resultMap>

    <sql id="SupplierQuotationProjectQuoteSql">
        SELECT
            tb.id,
            tb.project_id,
            tb.supplier_id,
            tb.supplier_name,
            tb.quote_time,
            tb.product_id,
            br.product_name,
            br.code AS product_code,
            tb.quantity,
            tb.price,
            tb.bid_status,
            tb.create_by_id,
            tb.create_by,
            tb.update_by_id,
            tb.update_by,
            tb.create_time,
            tb.update_time
        FROM procurement_supplier_quotation_project_quote tb
        LEFT JOIN base_data_breed_relationship br ON br.id = tb.product_id
    </sql>

    <select id="findByProjectAndSupplier" resultMap="SupplierQuotationProjectQuote">
        <include refid="SupplierQuotationProjectQuoteSql"/>
        WHERE tb.project_id = #{projectId}
          AND tb.supplier_id = #{supplierId}
    </select>

    <select id="listByProject" resultMap="SupplierQuotationProjectQuote">
        <include refid="SupplierQuotationProjectQuoteSql"/>
        WHERE tb.project_id = #{projectId}
        <choose>
            <when test="orderBy == 'PRICE_ASC'">
                ORDER BY tb.price ASC, tb.quote_time DESC, tb.id DESC
            </when>
            <otherwise>
                ORDER BY tb.create_time DESC, tb.id DESC
            </otherwise>
        </choose>
    </select>
</mapper>