| 123456789101112131415161718192021222324252627282930313233343536 |
- <?php
- namespace console\controllers;
- use biz\goods\classes\GoodsClass;
- use bizHd\work\classes\WorkClass;
- use yii\console\Controller;
- use Yii;
- class WorkController extends Controller
- {
- public function actionInit()
- {
- 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)) {
- GoodsClass::updateById($goodsId, ['stock' => -$num]);
- }
- }
- }
- }
- }
|