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;