'ID', 'mall_id' => 'Mall ID', 'user_id' => 'User ID', 'comment_id' => 'Comment ID', 'status' => 'Status', 'created_at' => 'Created At', 'updated_at' => 'Updated At', ]; } public static function setData(int $mall_id, array $data) { if (!empty($data['id'])) { $model = self::findOne(['mall_id' => $mall_id, 'status' => StatusEnum::ENABLED, 'id' => $data['id']]); if (empty($model)) { self::$static_error = '评论点赞记录不存在'; return false; } } else { $model = self::findOne(['mall_id' => $mall_id, 'user_id' => $data['user_id'], 'comment_id' => $data['comment_id']]); if (empty($model)) { $model = new self(); $model->loadDefaultValues(); $model->mall_id = $mall_id; } } foreach ($data as $key => $val) { $model->$key = $val; } if (!$model->save()) { self::$static_error = '保存数据失败:' . $model->getErrorMessage(); return false; } return $model; } }