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