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()