陶杰
2024-08-22 ee9032d9baf5f33e376d2d2699136e0a7b26bec7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?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.mzl.flower.mapper.flower.FlowerMarkupSpMapper">
    <select id="selectMarkupSpList" resultType="com.mzl.flower.dto.response.flower.FlowerMarkupSpListDTO">
        SELECT f.*, sp.flower_id, sp.fee, s.name supplierName, c.name categoryStr, c.parent_name parentCategoryStr
            , (CASE f.level
                WHEN 'A' THEN c.weight_a
                WHEN 'B' THEN c.weight_b
                WHEN 'C' THEN c.weight_c
                WHEN 'D' THEN c.weight_d
                WHEN 'E' THEN c.weight_e
                WHEN 'O' THEN c.weight_o
                END
            ) weight
        FROM t_flower f
        join t_flower_markup_sp sp on sp.flower_id = f.id and sp.partner_id = #{partnerId}
        left join t_supplier_info s on s.id = f.supplier_id
        left join t_flower_category c on f.category = c.id
        WHERE f.deleted = 0
        <if test="condition.name != null and condition.name != ''">
            AND f.name LIKE concat('%', #{condition.name},'%')
        </if>
        <if test="condition.level != null and condition.level != ''">
            AND f.level = #{condition.level}
        </if>
        <if test="condition.tags != null and condition.tags != ''">
            AND f.tags LIKE concat('%', #{condition.tags},'%')
        </if>
        <if test="condition.category != null">
            AND (f.category = #{condition.category}
                or exists (
                    select 1 from t_flower_category fc where fc.id = f.category and fc.parent_id = #{condition.category}
                )
            )
        </if>
        ORDER BY f.id
    </select>
 
 
</mapper>