1], null, '*', null, true); if (!empty($shopList)) { foreach ($shopList as $shop) { $mainId = $shop->mainId ?? 0; $kindList = KindClass::getAllByCondition(['mainId' => $mainId], null, '*'); $lzKindId = 0; $lzName = ''; $hsKindId = 0; $hsName = ''; if (!empty($kindList)) { foreach ($kindList as $kindInfo) { $name = $kindInfo['name'] ?? ''; $kId = $kindInfo['id'] ?? 0; if ($name == '绿植') { $lzKindId = $kId; $lzName = $name; } if ($name == '花束') { $hsKindId = $kId; $hsName = $name; } } } if (empty($lzKindId) || empty($hsKindId)) { echo '有品类id没有 ' . $shop->merchantName . ' ' . $shop->shopName; Yii::$app->end(); } GoodsClass::updateByCondition(['mainId' => $mainId, 'flower' => 1], ['kindId' => $hsKindId, 'kindName' => $hsName]); GoodsCategoryClass::updateByCondition(['mainId' => $mainId, 'flower' => 1], ['kindId' => $hsKindId, 'kindName' => $hsName]); GoodsClass::updateByCondition(['mainId' => $mainId, 'flower' => 0], ['kindId' => $lzKindId, 'kindName' => $lzName]); GoodsCategoryClass::updateByCondition(['mainId' => $mainId, 'flower' => 0], ['kindId' => $lzKindId, 'kindName' => $lzName]); $workList = WorkClass::getAllByCondition(['mainId' => $mainId], null, '*', null, true); if (!empty($workList)) { foreach ($workList as $work) { $goodsId = $work->goodsId ?? 0; $goodsInfo = GoodsClass::getById($goodsId, true); if (!empty($goodsInfo)) { $thisKindId = $goodsInfo->kindId ?? 0; $thisKindName = $goodsInfo->kindName ?? ''; $work->kindId = $thisKindId; $work->kindName = $thisKindName; $work->save(); } } } $arr = OrderGoodsClass::getAllByCondition(['id>' => 0], null, '*', null, true); if (!empty($arr)) { foreach ($arr as $in) { $goodsId = $in->goodsId ?? 0; $goodsInfo = GoodsClass::getById($goodsId, true); if (!empty($goodsInfo)) { $thisKindId = $goodsInfo->kindId ?? 0; $thisKindName = $goodsInfo->kindName ?? ''; $in->kindId = $thisKindId; $in->kindName = $thisKindName; $in->save(); } } } } } } //种类初始化 ssh 20230301 public function actionInit() { ini_set('memory_limit', '2045M'); set_time_limit(0); $shopList = ShopClass::getAllByCondition(['ptStyle' => 1], null, '*', null, true); if (!empty($shopList)) { foreach ($shopList as $shop) { $mainId = $shop->mainId ?? 0; $sjId = $shop->sjId ?? 0; $has = KindClass::getByCondition(['mainId' => $mainId], true); if (!empty($has)) { continue; } $data = [ 'mainId' => $mainId, 'sjId' => $sjId, ]; KindClass::initKind($data); } } } }