diff --git a/app/Console/Commands/OrderTimeout.php b/app/Console/Commands/OrderTimeout.php index 765f7c6..be90efe 100644 --- a/app/Console/Commands/OrderTimeout.php +++ b/app/Console/Commands/OrderTimeout.php @@ -79,12 +79,26 @@ class OrderTimeout extends Command $item = $v->orderProductItem->toArray(); //供应商产品规格加库存 - $ids = array_column($item, 'product_spec_id'); - ProductSpec::whereIn('id', $ids)->increment('stock', $v->num); + foreach ($item as $v2) { + if ($v2['product_spec_id']) { + if (is_array($v2['product_spec_id'])) { + ProductSpec::whereIn('id', $v2['product_spec_id'])->increment('stock', $v->num); + } else { + ProductSpec::where('id', $v2['product_spec_id'])->increment('stock', $v->num); + } + } + } //代理商产品规格加库存 - $ids = array_column($item, 'agent_product_spec_id'); - AgentProductSpec::whereIn('id', $ids)->increment('stock', $v->num); + foreach ($item as $v2) { + if ($v2['agent_product_spec_id']) { + if (is_array($v2['agent_product_spec_id'])) { + AgentProductSpec::whereIn('id', $v2['agent_product_spec_id'])->increment('stock', $v->num); + } else { + AgentProductSpec::where('id', $v2['agent_product_spec_id'])->increment('stock', $v->num); + } + } + } } DB::commit();