|
|
@@ -10,21 +10,27 @@ use Yii;
|
|
|
class WorkController extends Controller
|
|
|
{
|
|
|
|
|
|
-
|
|
|
public function actionInit()
|
|
|
{
|
|
|
- GoodsClass::updateByCondition(['id>' => 0], ['stock' => 0]);
|
|
|
+ ini_set('memory_limit', '2045M');
|
|
|
+ set_time_limit(0);
|
|
|
+ $goodsList = GoodsClass::getAllByCondition(['id>' => 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)){
|
|
|
+ if (!empty($goodsId)) {
|
|
|
GoodsClass::updateById($goodsId, ['stock' => $num]);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
}
|