| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- <?php
- namespace console\controllers;
- use bizHd\goods\classes\GoodsClass;
- use bizHd\goods\classes\KindClass;
- use bizHd\shop\classes\ShopClass;
- use bizHd\work\classes\WorkClass;
- use yii\console\Controller;
- use Yii;
- class KindController extends Controller
- {
- //品类更新 ssh 20230320
- public function actionUpdate()
- {
- 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;
- $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]);
- GoodsClass::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();
- }
- }
- }
- }
- }
- }
- //种类初始化 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);
- }
- }
- }
- }
|