left join ( select bop05.order_id, SUM(IF(sp05.activity_price < sp05.price, sp05.activity_price, sp05.price)) course05Sum from buy_order_product bop05 inner join shop_product sp05 on sp05.product_id = bop05.product_id and sp05.goods_type = '05' group by bop05.order_id ) c05 on c05.order_id = t.order_id left join ( select bop07.order_id, IFNULL(SUM(spc_sum.s), 0) cs, IFNULL(SUM(spb_sum.s), 0) bs from buy_order_product bop07 inner join shop_product sp07 on sp07.product_id = bop07.product_id and sp07.goods_type = '07' left join ( select product_id, SUM(IFNULL(product_price, 0)) s from shop_product_course where del_flag = 0 group by product_id ) spc_sum on spc_sum.product_id = sp07.product_id left join ( select product_id, SUM(IFNULL(product_price, 0)) s from shop_product_book where del_flag = 0 group by product_id ) spb_sum on spb_sum.product_id = sp07.product_id group by bop07.order_id ) c07 on c07.order_id = t.order_id ${baseAmount} - IFNULL(c05.course05Sum, 0) - IFNULL(ROUND(${baseAmount} * IFNULL(c07.cs, 0) / NULLIF(IFNULL(c07.cs, 0) + IFNULL(c07.bs, 0), 0), 2), 0) GROUP_CONCAT( IF(sp.goods_type = '07', IFNULL(( select GROUP_CONCAT(bk.name SEPARATOR '/') from shop_product_book spb inner join book bk on bk.id = spb.book_id where spb.product_id = sp.product_id and spb.del_flag = 0 ), sp.product_name), sp.product_name ) SEPARATOR ', ' )