update: fix generate coupon

This commit is contained in:
tokumeikoi 2022-04-15 01:02:06 +08:00
parent 7faa56a4fd
commit e2597b4ac3

View File

@ -90,8 +90,12 @@ class CouponController extends Controller
DB::beginTransaction(); DB::beginTransaction();
if (!Coupon::insert(array_map(function ($item) use ($coupon) { if (!Coupon::insert(array_map(function ($item) use ($coupon) {
// format data // format data
if (is_array($item['limit_plan_ids'])) $item['limit_plan_ids'] = json_encode($coupon['limit_plan_ids']); if (isset($item['limit_plan_ids']) && is_array($item['limit_plan_ids'])) {
if (is_array($item['limit_period'])) $item['limit_period'] = json_encode($coupon['limit_period']); $item['limit_plan_ids'] = json_encode($coupon['limit_plan_ids']);
}
if (isset($item['limit_period']) && is_array($item['limit_period'])) {
$item['limit_period'] = json_encode($coupon['limit_period']);
}
return $item; return $item;
}, $coupons))) { }, $coupons))) {
DB::rollBack(); DB::rollBack();