'ID', 'user_id' => 'User ID', 'mall_id' => 'Mall ID', 'activity_id' => '活动id', 'performance' => '人数;业绩金额', 'performance_goal' => '业绩目标', 'created_at' => 'Created At', 'updated_at' => 'Updated At', 'performance_type' => '业绩类型;1拉新;2业绩', 'performance_rank' => '业绩排名', 'order_id' => '订单id', 'status' => '状态[-1:删除;0:禁用;1启用]', ]; } public function getUser() { return $this->hasOne(User::ClassName(), ['id' => 'user_id']); } public function getActivity() { return $this->hasOne(PkActivity::ClassName(), ['id' => 'activity_id']); } /** * 保存数据 * @Author: ltm * @DateTime: 2022/6/8 0015 9:26 * @Copyright: copyright (c) 2021 * @param $mall_id * @param array $params * @return Rebate|bool */ public static function setData(array $params) { try { $mall_id = $params['mall_id']; if (!empty($params['id'])) { $model = self::findOne(['and', ['id' => $params['id'], 'mall_id' => $mall_id], ['<>', 'status', StatusEnum::ENABLED]]); if (empty($model)) throw new \Exception('活动不存在或已删除'); } else { $model = new self(); $model->loadDefaultValues(); $model->mall_id = $mall_id; } if (!$model->load($params, '') || !$model->save()) throw new Exception($model->getErrorMessage()); return $model; } catch (\Exception $e) { self::setStaticError($e->getMessage()); return false; } } }