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
41
42
43
44
45
46
47
48
<?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.ruoyi.inspect.mapper.InsOrderRatesMapper">
    <!-- 查询费用列表 -->
    <select id="selectInsOrderRates" resultType="com.ruoyi.inspect.dto.SampleOrderDto">
        select *
        from (select io.*,
        case
        when
        io.type_source = 0
        then io.sample_view
        else io.sample end                            sampleStr,
        GROUP_CONCAT(DISTINCT isa.model SEPARATOR ' ') AS sample_model,
        COALESCE(sum(st.price), 0) total_price
        from ins_order io
        LEFT JOIN ins_sample isa ON isa.ins_order_id = io.id
        left join ins_order_standard_template iost on iost.ins_order_id = io.id
        left join standard_template st on st.id = iost.template_id
        where iost.id is not null
        and io.state != 5
        group by io.id) a
        <if test="ew.customSqlSegment != null and ew.customSqlSegment != ''">
            ${ew.customSqlSegment}
        </if>
        order by a.sample_date desc, a.id desc
    </select>
 
    <!-- 更新订单的费用优惠与备注 -->
    <update id="updateOrderFee">
        update ins_order
        set is_discount = #{isDiscount},
            discount_amount = #{discountAmount},
            fee_remark = #{feeRemark}
        where id = #{id}
    </update>
 
    <!-- 查询订单费用详情(模板价格) -->
    <select id="selectTemplateRatesDetail" resultType="com.ruoyi.inspect.dto.TemplateRateDto">
        select iost.number, iost.name, COALESCE(st.price, 0) as price
        from ins_order_standard_template iost
        join ins_order io on io.id = iost.ins_order_id
        left join standard_template st on st.id = iost.template_id
        where iost.ins_order_id = #{insOrderId}
        and io.state != 5
        order by iost.sort, iost.id
    </select>
 
</mapper>