fix : auto coupon

This commit is contained in:
2025-08-06 21:37:30 +08:00
parent fdb5d99214
commit ea08aa94a6

View File

@@ -72,7 +72,20 @@ 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 => bcmul(bcsub("1", (string)$value['ratio'],2),(string)$orderMaxPrice,2),
// CouponCode::COUPON_TYPE_DISCOUNT => bcmul(bcsub("100", (string)$value['ratio'],2),(string)$orderMaxPrice,2),
CouponCode::COUPON_TYPE_DISCOUNT => bcmul(
bcdiv(
bcsub(
"100",
(string)$value['ratio'],
2
),
"100",
2
),
bcadd((string)max(array_column($this->orderRes['good'],'price')),(string)$this->orderRes['sundry_price'],2),
2
),
default => 0
};