update: fix coupon multi generate

This commit is contained in:
tokumeikoi 2022-03-13 01:16:13 +08:00
parent d184225b2b
commit 82730acdac

View File

@ -88,7 +88,12 @@ class CouponController extends Controller
array_push($coupons, $coupon);
}
DB::beginTransaction();
if (!Coupon::insert($coupons)) {
if (!Coupon::insert(array_map(function ($item) use ($coupon) {
// format data
$item['limit_plan_ids'] = json_encode($coupon['limit_plan_ids']);
$item['limit_period'] = json_encode($coupon['limit_period']);
return $item;
}, $coupons))) {
DB::rollBack();
abort(500, '生成失败');
}