255], ]; } /** * {@inheritdoc} */ public function attributeLabels() { return [ 'id' => 'ID', 'mall_id' => 'Mall ID', 'store_id' => '门店id', 'title' => '标题', 'content' => '内容', 'status' => '状态[0禁用 1启用 -1删除]', 'created_at' => '创建时间', 'updated_at' => '修改时间', ]; } public static function setData(array $params) { try { if (!empty($params['id'])) { $where = ['id' => $params['id'], ['status' => StatusEnum::ENABLED]]; if (isset($params['mall_id'])) $where[] = ['mall_id' => $params['mall_id']]; if (isset($params['store_id'])) $where[] = ['store_id' => $params['store_id']]; $model = self::findOne($where); if (empty($model)) throw new \Exception('服务不存在或已删除'); } else { $model = new self(); $model->loadDefaultValues(); } if (!$model->load($params, '') || !$model->save()) throw new \PHPUnit\Util\Exception($model->getErrorMessage()); return $model; } catch (\Exception $e) { self::$static_error = $e->getMessage(); return false; } } }