|
|
@@ -2,14 +2,70 @@
|
|
|
|
|
|
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()
|
|
|
{
|