65], [['content'], 'string', 'max' => 255], ]; } /** * {@inheritdoc} */ public function attributeLabels() { return [ 'id' => 'ID', 'mall_id' => 'Mall ID', 'mch_id' => 'Mch ID', 'type' => '模板类型:1.好评|2.中评|3.差评', 'title' => '标题', 'content' => '内容', 'status' => '状态[-1:删除;0:禁用;1启用]', 'created_at' => '创建时间', 'updated_at' => '修改时间', ]; } /** * 保存数据 * @Author: hua * @DateTime: 2021/10/7 17:30 * @Copyright: copyright (c) 2021 广东七件事集团 * @param array $params * @return bool|OrderCommentsTemplates * @throws \yii\db\Exception */ public static function setData(array $params) { try { if (!empty($params['id'])) { $model = self::findOne(['id' => $params['id'], 'status' => [StatusEnum::ENABLED, StatusEnum::DISABLED]]); if (empty($model)) throw new Exception('服务不存在或已删除'); } else { $model = new self(); $model->loadDefaultValues(); } if(isset($params['pic_url'])) $params['pic_url'] = Json::encode($params['pic_url']); if(!empty($params['virtual_time'])) $params['virtual_time'] = strtotime($params['virtual_time']); if (!$model->load($params, '') || !$model->save()) throw new Exception($model->getErrorMessage()); return $model; } catch (Exception $e) { self::$static_error = $e->getMessage(); return false; } } }