Admin 会员卡-优惠券-可配置数量
parent
cececff1e4
commit
9c46caee62
|
|
@ -105,12 +105,13 @@ class VipService
|
||||||
if (isset($gift['coupon']) && $gift['coupon']) {
|
if (isset($gift['coupon']) && $gift['coupon']) {
|
||||||
$coupon_service = new CouponService();
|
$coupon_service = new CouponService();
|
||||||
$couponId = array_column($gift['coupon'], 'id');
|
$couponId = array_column($gift['coupon'], 'id');
|
||||||
foreach(Coupon::whereIn('id', $couponId)->get() as $item) {
|
$couponList = Coupon::whereIn('id', $couponId)->get();
|
||||||
|
foreach($gift['coupon'] as $item) {
|
||||||
try {
|
try {
|
||||||
$couponItem = array_filter($gift['coupon'], fn($v) => $v['id'] == $item->id);
|
$coupon = $couponList->firstWhere('id', $item['id']);
|
||||||
$amount = data_get($couponItem, 'amount', 1);
|
$amount = data_get($item, 'amount', 1);
|
||||||
if ($amount > 0) {
|
if ($amount > 0 && $coupon) {
|
||||||
$coupon_service->sendCoupon($user, $item, $amount);
|
$coupon_service->sendCoupon($user, $coupon, $amount);
|
||||||
}
|
}
|
||||||
} catch (BizException $e) {
|
} catch (BizException $e) {
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue