feat : coupon

This commit is contained in:
2025-03-05 10:31:19 +08:00
parent 63f60bc92b
commit 75f649676d
5 changed files with 110 additions and 11 deletions

View File

@@ -35,10 +35,14 @@ class ConfirmationOrderService extends BaseOrderService
$this->check();
$this->getCouponInfo();
$this->compute();
$this->autoSelectCoupon();
$this->reloadCompute();
return $this->return->success('success',$this->orderRes);
}
@@ -67,7 +71,7 @@ class ConfirmationOrderService extends BaseOrderService
foreach ($filtered as &$value) {
$value['amount'] = match ($value['coupon_type']) {
CouponCode::COUPON_TYPE_INSTANT_REDUCTION => $value['amount'],
CouponCode::COUPON_TYPE_DISCOUNT => $value['ratio'] * $orderMaxPrice,
CouponCode::COUPON_TYPE_DISCOUNT => bcmul(bcsub("1", $value['ratio'],2),$orderMaxPrice,2),
default => 0
};
@@ -80,12 +84,7 @@ class ConfirmationOrderService extends BaseOrderService
$this->couponId = $selectCouponInfo['id'];
$this->orderRes['coupon'] = $selectCouponInfo;
$this->orderRes['coupon_id'] = $selectCouponInfo['id'];
$this->reloadCompute();
}
private function reloadCompute(): void
{
}
}