From 0f6b6a1f32bac03bab2883697ea87d03d455a7e7 Mon Sep 17 00:00:00 2001 From: Lemon <15040771@qq.com> Date: Tue, 27 Oct 2020 10:19:37 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E6=83=A0=E5=88=B8=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Controller/v3/OrderOnlineController.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/Controller/v3/OrderOnlineController.php b/app/Controller/v3/OrderOnlineController.php index c085e13..2839970 100644 --- a/app/Controller/v3/OrderOnlineController.php +++ b/app/Controller/v3/OrderOnlineController.php @@ -179,7 +179,16 @@ class OrderOnlineController extends BaseController $total = bcadd($total,$res['value_added_service']['price'],2); $total = bcadd($total,$res['location']['distribution_price'],2); $res['total'] = $total; - + //优惠券排序 + $collection = collect($res['coupon']['available']); + $sorted = $collection->sortBy(function ($product, $key) use ($total){ + if($product['coupon']['discount_type'] == 2){ + return bcmul($total,bcdiv($product['coupon']['discounts'],10,2),2); + }elseif($product['coupon']['discount_type'] == 1){ + return bcsub($total,$product['coupon']['discounts'],2); + } + }); + $res['coupon']['available'] = $sorted->values()->all(); // 新增返回市场信息 $res['market'] = $market;