'ID', 'mall_id' => 'Mall ID', 'user_id' => 'User ID', 'duration' => '观看时长', 'register_time' => '注册时间', 'status' => '活动状态,1:启用,0:禁用,-1删除', 'created_at' => 'Created At', 'updated_at' => 'Updated At', ]; } public static function setData(array $params) { try { $model = self::findOne(['mall_id' => $params['mall_id'], 'user_id' => $params['user_id'],'status' => [StatusEnum::ENABLED]]); if (empty($model)) { $model = new self(); $model->loadDefaultValues(); } $params['duration'] += $model['duration']; 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; } } }