From 938550f13aa7b0c43ba614bad182bb8a5d4bcf06 Mon Sep 17 00:00:00 2001 From: linyaostalker <602604991@qq.com> Date: Wed, 18 Dec 2019 08:56:07 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=E4=BF=AE=E6=94=B9=E5=89=8D=E7=AB=AF?= =?UTF-8?q?=E5=95=86=E5=93=81=E5=88=86=E7=B1=BB=E8=8E=B7=E5=8F=96=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E9=94=AE=E5=80=BC=E5=AF=B9=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/goods/models/ars/ShopCategory.php | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/backend/modules/goods/models/ars/ShopCategory.php b/backend/modules/goods/models/ars/ShopCategory.php index 0a00e89..37ff7d9 100755 --- a/backend/modules/goods/models/ars/ShopCategory.php +++ b/backend/modules/goods/models/ars/ShopCategory.php @@ -2,9 +2,11 @@ namespace backend\modules\goods\models\ars; +use backend\modules\goods\logic\goods\GoodsManager; use Yii; use yii\behaviors\TimestampBehavior; use backend\modules\file\models\ars\File; +use yii\db\ActiveQuery; /** * This is the model class for table "atg_shop_category". @@ -108,12 +110,20 @@ class ShopCategory extends \yii\db\ActiveRecord /** * @param int $ownId - * @return array + * @param int $needDefault + * @return array 数据键值对 * 数据键值对 */ - public static function modelColumn($ownId = 0) + public static function modelColumn($ownId = 0, $needDefault = 1) { - 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::subShopCategoryId($ownId)]); + } + $data = $query->asArray()->all(); + $data = GoodsManager::btree($data); + $data = GoodsManager::constructDropList($data, $needDefault); + return $data; } public function getIconFile()