100], [['background_url', 'member_limit','child_upgrade_links'], 'string', 'max' => 255], ]; } /** * {@inheritdoc} */ public function attributeLabels() { return [ 'id' => 'ID', 'mall_id' => 'Mall ID', 'name' => 'Name', 'is_enable' => 'Is Enable', 'discount' => 'Discount', 'status' => 'Status', 'created_at' => 'Created At', 'updated_at' => 'Updated At', 'child_discount' => 'Child Discount', 'child_num' => 'Child Num', 'child_expired_days' => 'Child Expired Days', 'background_url' => 'Background Url', 'member_limit' => 'Member Limit', 'child_upgrade_links' => 'Child Upgrade Links', 'is_enable_virtual' => 'Is Enable Virtual', ]; } public static function setData(array $params) { try { if (!empty($params['id'])) { $model = self::findOne(['mall_id' => $params['mall_id'], 'id' => $params['id'], 'status' => [StatusEnum::ENABLED, StatusEnum::DISABLED]]); if (empty($model)) throw new \Exception('数据不存在或已删除'); } else { $model = new self(); $model->loadDefaultValues(); } if (!$model->load($params, '')) throw new \Exception($model->getErrorMessage()); if (!$model->save()) throw new \Exception($model->getErrorMessage()); return $model; } catch (\Exception $e) { self::$static_error = $e->getMessage(); return false; } } public static function search($params) { $query = self::find() ->where(['status' => StatusEnum::ENABLED, 'mall_id' => $params['mall_id'],'is_enable'=>1]); if (isset($params['keyword']) && !empty($params['keyword'])) { $query->andWhere(['or', ['like', 'name', $params['keyword']]]); } $list = $query->limit(20)->select('id,name')->asArray()->all(); return $list; } }