feat : coupon
This commit is contained in:
@@ -42,6 +42,9 @@ class ConfirmationOrderService extends BaseOrderService
|
|||||||
return $this->return->success('success',$this->orderRes);
|
return $this->return->success('success',$this->orderRes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
private function autoSelectCoupon(): void
|
private function autoSelectCoupon(): void
|
||||||
{
|
{
|
||||||
if ($this->couponId != 0) return;
|
if ($this->couponId != 0) return;
|
||||||
@@ -56,7 +59,7 @@ class ConfirmationOrderService extends BaseOrderService
|
|||||||
$maxValidityEndTimeDate = max(array_column($noUseCoupon,'validity_end_time'));
|
$maxValidityEndTimeDate = max(array_column($noUseCoupon,'validity_end_time'));
|
||||||
|
|
||||||
$filtered = array_filter($noUseCoupon, function($item) use($maxValidityEndTimeDate) {
|
$filtered = array_filter($noUseCoupon, function($item) use($maxValidityEndTimeDate) {
|
||||||
return $item['validity_end_time'] === $maxValidityEndTimeDate;
|
return $item['validity_end_time'] == $maxValidityEndTimeDate;
|
||||||
});
|
});
|
||||||
|
|
||||||
$selectMaxPrice = 0;
|
$selectMaxPrice = 0;
|
||||||
@@ -64,7 +67,7 @@ class ConfirmationOrderService extends BaseOrderService
|
|||||||
foreach ($filtered as &$value) {
|
foreach ($filtered as &$value) {
|
||||||
$value['amount'] = match ($value['coupon_type']) {
|
$value['amount'] = match ($value['coupon_type']) {
|
||||||
CouponCode::COUPON_TYPE_INSTANT_REDUCTION => $value['amount'],
|
CouponCode::COUPON_TYPE_INSTANT_REDUCTION => $value['amount'],
|
||||||
CouponCode::COUPON_TYPE_DISCOUNT => $value['amount'] * $orderMaxPrice,
|
CouponCode::COUPON_TYPE_DISCOUNT => $value['ratio'] * $orderMaxPrice,
|
||||||
default => 0
|
default => 0
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user