From 4c18a48247ff70375f8ee308b855211625416385 Mon Sep 17 00:00:00 2001 From: linyaostalker <602604991@qq.com> Date: Tue, 17 Dec 2019 17:19:39 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E4=BF=AE=E6=94=B9=E5=95=86=E5=93=81?= =?UTF-8?q?=E5=88=86=E7=B1=BB=E9=94=99=E8=AF=AF=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...olumn_is_manual_in_table_atg_goods_sku.php | 41 +++++++++++++++++++ backend/modules/goods/models/ars/Category.php | 10 ++++- 2 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 backend/modules/goods/migrations/m191217_091658_update_column_is_manual_in_table_atg_goods_sku.php diff --git a/backend/modules/goods/migrations/m191217_091658_update_column_is_manual_in_table_atg_goods_sku.php b/backend/modules/goods/migrations/m191217_091658_update_column_is_manual_in_table_atg_goods_sku.php new file mode 100644 index 0000000..fc5b910 --- /dev/null +++ b/backend/modules/goods/migrations/m191217_091658_update_column_is_manual_in_table_atg_goods_sku.php @@ -0,0 +1,41 @@ +dropColumn('atg_goods_sku', 'is_manaul'); + $this->addColumn('atg_goods_sku', 'is_manual', $this->tinyInteger(1)->notNull()->defaultValue(0)->comment('是否手动')); + } + + /** + * {@inheritdoc} + */ + public function safeDown() + { + return true; + } + + /* + // Use up()/down() to run migration code without a transaction. + public function up() + { + + } + + public function down() + { + echo "m191217_091658_update_column_is_manual_in_table_atg_goods_sku cannot be reverted.\n"; + + return false; + } + */ +} diff --git a/backend/modules/goods/models/ars/Category.php b/backend/modules/goods/models/ars/Category.php index e32fd7c..66c431c 100755 --- a/backend/modules/goods/models/ars/Category.php +++ b/backend/modules/goods/models/ars/Category.php @@ -5,6 +5,7 @@ namespace backend\modules\goods\models\ars; use Yii; use yii\behaviors\TimestampBehavior; use backend\modules\file\models\ars\File; +use backend\modules\goods\logic\goods\GoodsManager; /** * This is the model class for table "atg_category". @@ -105,7 +106,14 @@ class Category extends \yii\db\ActiveRecord */ public static function modelColumn($ownId = 0) { - return $column = self::find()->select(['name'])->where(['is_delete' => self::IS_DELETE_NO])->andWhere(['!=', 'id', $ownId])->indexBy('id')->column(); + $query = self::find()->where(['is_delete' => self::IS_DELETE_NO]); + if ($ownId) { + $query->andWhere(['not in', 'id', GoodsManager::subCategoryId($ownId)]); + } + $data = $query->asArray()->all(); + $data = GoodsManager::btree($data); + $data = GoodsManager::constructDropList($data); + return $data; } public function getIconFile()