mainId ?? 0; $sjId = $shop->sjId ?? 0; $chainShopList = ShopClass::getAllByCondition(['sjId' => $sjId, 'join' => 0], null, '*', null, true); $default = $shop->default ?? 0; $productList = ProductClass::getAllByCondition(['mainId' => $mainId], null, '*', 'id', true); if (!empty($productList)) { foreach ($productList as $product) { $price = $product->price ?? 0; $skPrice = bcadd(floatval($price), 3, 0); $product->skPrice = $skPrice; $product->save(); $ptItemId = $product->itemId ?? 0; if ($default == 1) { foreach ($chainShopList as $chain) { if ($chain->id == $shop->id) { continue; } $chainMainId = $chain->mainId ?? 0; $chainProduct = ProductClass::getByCondition(['mainId' => $chainMainId, 'itemId' => $ptItemId], true); if (!empty($chainProduct)) { $chainProduct->skPrice = $skPrice; $chainProduct->save(); } } } } } } //修改散客比批发价格贵 ssh 20220609 public function actionSkMore() { $query = new \yii\db\Query(); $query->from(Item::tableName()); $query->where(['>', 'id', 0]); foreach ($query->batch() as $batchItem) { foreach ($batchItem as $item) { $addPrice = $item['addPrice'] ?? 0; $id = $item['id'] ?? 0; $skAddPrice = $item['skAddPrice'] ?? 0; if ($skAddPrice > $addPrice) { $add = bcsub($skAddPrice, $addPrice, 2); ItemClass::updateById($id, ['skMore' => $add]); } else { echo "零售加价小于批发加价 {$id}\n"; } } } } //更新纯彩花艺的价格 ./yii product/update-price ssh 20211020 public function actionUpdatePrice() { $list = ProductClass::getAllByCondition(['shopId' => 10], null, '*', null, true); if (!empty($list)) { foreach ($list as $key => $item) { $price = $item->price ?? 0; $addPrice = $item->addPrice ?? 0; $skAddPrice = $item->skAddPrice ?? 0; $hjAddPrice = $item->hjAddPrice ?? 0; $zsAddPrice = $item->zsAddPrice ?? 0; $skDiff = bcsub($addPrice, $skAddPrice, 2); $skPrice = bcsub($price, $skDiff, 2); $hjDiff = bcsub($addPrice, $hjAddPrice, 2); $hkPrice = bcsub($price, $hjDiff, 2); $zsDiff = bcsub($addPrice, $zsAddPrice, 2); $zsPrice = bcsub($price, $zsDiff, 2); $item->skPrice = $skPrice; $item->hjPrice = $hkPrice; $item->zsPrice = $zsPrice; $item->save(); } } } // ./yii product/reset-cover public function actionResetCover() { $sql = "SELECT * FROM `" . Product::tableName() . "` WHERE cover not like '%.%'"; $command = Yii::$app->db->createCommand($sql); $data = $command->queryAll(); if (empty($data)) { return false; } foreach ($data as $item) { $id = $item['id'] ?? 0; $ptItemId = $item['itemId'] ?? 0; $preCover = $item['cover'] ?? ''; $ptItem = PtItemClass::getById($ptItemId, true); $cover = $ptItem->cover ?? ''; if (!empty($cover)) { ProductClass::updateById($id, ['cover' => $cover]); echo "productId:" . $id . "原图:{$preCover}, 恢复图片:" . $cover . "\n"; } else { echo "productId:" . $id . " 恢复图片没有成功-----------------\n"; } } } // ./yii product/sk-price public function actionSkPrice() { ini_set('memory_limit', '2045M'); set_time_limit(0); $list = ProductClass::getAllByCondition([], null, '*', null, true); if (empty($list)) { return false; } foreach ($list as $key => $item) { $price = $item->price ?? 0; $skAddPrice = $item->skAddPrice ?? 0; $addPrice = $item->addPrice ?? 0; $diff = bcsub($skAddPrice, $addPrice, 2); $currentPrice = $price; if ($diff > 0) { $currentPrice = bcadd($price, $diff, 2); } $item->skPrice = $currentPrice; $item->save(); } } //二个空间问题 public function actionSame() { ini_set('memory_limit', '5045M'); set_time_limit(0); if (getenv('YII_ENV') == 'production') { $mainId = 8164; } else { $mainId = 644; } $list = ProductClass::getAllByCondition(['mainId' => $mainId], null, '*', null); if (!empty($list)) { $ids = array_column($list, 'itemId'); $ptInfo = PtItemClass::getByIds($ids, null, 'id'); foreach ($list as $item) { $id = $item['id'] ?? 0; $name = $item['name'] ?? ''; $ptItemId = $item['itemId'] ?? 0; $pt = $ptInfo[$ptItemId]; $ptName = $pt['name'] ?? ''; if ($name != $ptName) { echo $id . ' ' . $name . ' ' . $ptName . "\n"; } } } } //二个空间问题 public function actionEmpty() { ini_set('memory_limit', '5045M'); set_time_limit(0); $list = PtItemClass::getAllByCondition(['delStatus' => 0], null, '*', null, true); if (!empty($list)) { foreach ($list as $item) { $name = $item->name ?? ''; $name = trim($name); $name = str_replace(" ", " ", $name); $name = str_replace(" ", " ", $name); $item->name = $name; $item->save(); } } } public function actionRecover() { ini_set('memory_limit', '5045M'); set_time_limit(0); if (getenv('YII_ENV') == 'production') { $mainId = 8164; } else { $mainId = 644; } $list = ProductClass::getAllByCondition(['mainId' => $mainId], null, '*', null); if (!empty($list)) { $ids = array_column($list, 'itemId'); $ptInfo = PtItemClass::getByIds($ids, null, 'id'); foreach ($list as $item) { $id = $item['id'] ?? 0; $name = $item['name'] ?? ''; $ptItemId = $item['itemId'] ?? 0; $pt = $ptInfo[$ptItemId]; $ptName = $pt['name'] ?? ''; if (!empty($ptName)) { $ptPy = stringUtil::py($ptName); ProductClass::updateById($id, ['name' => $ptName, 'py' => $ptPy]); } } } } }