6
0
Fork 0

Admin 会员卡-优惠券-可配置数量

base
panliang 2022-07-11 14:29:57 +08:00
parent cececff1e4
commit 9c46caee62
1 changed files with 6 additions and 5 deletions

View File

@ -105,12 +105,13 @@ class VipService
if (isset($gift['coupon']) && $gift['coupon']) {
$coupon_service = new CouponService();
$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 {
$couponItem = array_filter($gift['coupon'], fn($v) => $v['id'] == $item->id);
$amount = data_get($couponItem, 'amount', 1);
if ($amount > 0) {
$coupon_service->sendCoupon($user, $item, $amount);
$coupon = $couponList->firstWhere('id', $item['id']);
$amount = data_get($item, 'amount', 1);
if ($amount > 0 && $coupon) {
$coupon_service->sendCoupon($user, $coupon, $amount);
}
} catch (BizException $e) {
}