'ID', 'mall_id' => 'Mall ID', 'user_id' => 'User ID', 'follow_id' => 'Follow ID', 'status' => 'Status', 'created_at' => 'Created At', 'updated_at' => 'Updated At', ]; } public static function getList(int $mall_id, int $user_id, string $type, int $page = 1, int $limit = 10) { $wheres[] = ['mall_id' => $mall_id, 'status' => StatusEnum::ENABLED]; if ('follow' == $type) { $wheres[] = ['user_id' => $user_id]; $field = 'follow_id'; } if ('fans' == $type) { $wheres[] = ['follow_id' => $user_id]; $field = 'user_id'; }; $params = [ 'select' => 'id,user_id,follow_id', 'where' => $wheres, 'order' => 'created_at desc,id desc', 'page' => $page, 'limit' => $limit, ]; $follow_list = ShortVideoFollow::listPage($params); if (empty($follow_list['list'])) return $follow_list['list']; $user_ids = array_column($follow_list['list'], $field); $user_params = [ 'select' => 'id,nickname,mobile,username,avatar_url,signature_title,signature_content', 'where' => [['mall_id' => $mall_id, 'status' => StatusEnum::ENABLED, 'id' => $user_ids]], 'order' => 'created_at desc,id desc', ]; $users = User::lists($user_params); return $users; } public static function setData(int $mall_id, array $data) { $model = self::findOne(['mall_id' => $mall_id, 'user_id' => $data['user_id'], 'follow_id' => $data['follow_id']]); if (empty($model)) { $model = new self(); $model->loadDefaultValues(); $model->mall_id = $mall_id; } foreach ($data as $key => $val) { $model->$key = $val; } // dd($model); if (!$model->save()) { self::$static_error = '保存数据失败:' . $model->getErrorMessage(); return false; } return $model; } }