' => 0], null, '*', null, true); if (!empty($goodsList)) { foreach ($goodsList as $goods) { $goods->stock = 0; $goods->save(); } } $workList = WorkClass::getAllByCondition(['status' => 0], null, '*', null, true); if (!empty($workList)) { foreach ($workList as $work) { $num = $work->num ?? 0; $goodsId = $work->goodsId ?? 0; if (!empty($goodsId)) { GoodsClass::updateById($goodsId, ['stock' => -$num]); } } } } }