update: fix coupon use

This commit is contained in:
tokumeikoi
2021-11-01 02:31:27 +08:00
parent 6f67096fe3
commit d0947d1aaa
2 changed files with 19 additions and 1 deletions

View File

@ -30,6 +30,9 @@ class CouponService
$order->discount_amount = $order->total_amount * ($this->coupon->value / 100);
break;
}
if ($order->discount_amount > $order->total_amount) {
$order->discount_amount = $order->total_amount;
}
if ($this->coupon->limit_use !== NULL) {
$this->coupon->limit_use = $this->coupon->limit_use - 1;
if (!$this->coupon->save()) {