Skip to content

Feature: Add affiliate tracking #640

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,8 @@ frontend/.env
backend/.env
todo.md
CLAUDE.md
/prompts/**
/prompts

.vercel
.vercel
prompts/
40 changes: 39 additions & 1 deletion backend/app/DomainObjects/AffiliateDomainObject.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,45 @@
<?php

declare(strict_types=1);

namespace HiEvents\DomainObjects;

class AffiliateDomainObject extends Generated\AffiliateDomainObjectAbstract
use HiEvents\DomainObjects\Interfaces\IsSortable;
use HiEvents\DomainObjects\SortingAndFiltering\AllowedSorts;

class AffiliateDomainObject extends Generated\AffiliateDomainObjectAbstract implements IsSortable
{
public static function getAllowedSorts(): AllowedSorts
{
return new AllowedSorts(
[
self::CREATED_AT => [
'asc' => __('Oldest First'),
'desc' => __('Newest First'),
],
self::NAME => [
'asc' => __('Name A-Z'),
'desc' => __('Name Z-A'),
],
self::TOTAL_SALES => [
'asc' => __('Sales Ascending'),
'desc' => __('Sales Descending'),
],
self::TOTAL_SALES_GROSS => [
'asc' => __('Revenue Ascending'),
'desc' => __('Revenue Descending'),
],
],
);
}

public static function getDefaultSort(): string
{
return self::CREATED_AT;
}

public static function getDefaultSortDirection(): string
{
return 'desc';
}
}
13 changes: 13 additions & 0 deletions backend/app/DomainObjects/EventDomainObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ class EventDomainObject extends Generated\EventDomainObjectAbstract implements I

private ?Collection $capacityAssignments = null;

private ?Collection $affiliates = null;

private ?EventSettingDomainObject $settings = null;

private ?OrganizerDomainObject $organizer = null;
Expand Down Expand Up @@ -298,4 +300,15 @@ public function setWebhooks(?Collection $webhooks): EventDomainObject
$this->webhooks = $webhooks;
return $this;
}

public function getAffiliates(): ?Collection
{
return $this->affiliates;
}

public function setAffiliates(?Collection $affiliates): EventDomainObject
{
$this->affiliates = $affiliates;
return $this;
}
}
108 changes: 75 additions & 33 deletions backend/app/DomainObjects/Generated/AffiliateDomainObjectAbstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,33 +12,42 @@ abstract class AffiliateDomainObjectAbstract extends \HiEvents\DomainObjects\Abs
final public const PLURAL_NAME = 'affiliates';
final public const ID = 'id';
final public const EVENT_ID = 'event_id';
final public const ACCOUNT_ID = 'account_id';
final public const NAME = 'name';
final public const CODE = 'code';
final public const SALES_VOLUME = 'sales_volume';
final public const UNIQUE_VISITORS = 'unique_visitors';
final public const EMAIL = 'email';
final public const TOTAL_SALES = 'total_sales';
final public const TOTAL_SALES_GROSS = 'total_sales_gross';
final public const STATUS = 'status';
final public const CREATED_AT = 'created_at';
final public const UPDATED_AT = 'updated_at';
final public const DELETED_AT = 'deleted_at';

protected int $id;
protected ?int $event_id = null;
protected int $event_id;
protected int $account_id;
protected string $name;
protected string $code;
protected ?float $sales_volume = null;
protected int $unique_visitors = 0;
protected string $created_at;
protected ?string $email = null;
protected int $total_sales = 0;
protected float $total_sales_gross = 0.0;
protected string $status = 'active';
protected ?string $created_at = null;
protected ?string $updated_at = null;
protected ?string $deleted_at = null;

public function toArray(): array
{
return [
'id' => $this->id ?? null,
'event_id' => $this->event_id ?? null,
'account_id' => $this->account_id ?? null,
'name' => $this->name ?? null,
'code' => $this->code ?? null,
'sales_volume' => $this->sales_volume ?? null,
'unique_visitors' => $this->unique_visitors ?? null,
'email' => $this->email ?? null,
'total_sales' => $this->total_sales ?? null,
'total_sales_gross' => $this->total_sales_gross ?? null,
'status' => $this->status ?? null,
'created_at' => $this->created_at ?? null,
'updated_at' => $this->updated_at ?? null,
'deleted_at' => $this->deleted_at ?? null,
];
}

Expand All @@ -53,17 +62,39 @@ public function getId(): int
return $this->id;
}

public function setEventId(?int $event_id): self
public function setEventId(int $event_id): self
{
$this->event_id = $event_id;
return $this;
}

public function getEventId(): ?int
public function getEventId(): int
{
return $this->event_id;
}

public function setAccountId(int $account_id): self
{
$this->account_id = $account_id;
return $this;
}

public function getAccountId(): int
{
return $this->account_id;
}

public function setName(string $name): self
{
$this->name = $name;
return $this;
}

public function getName(): string
{
return $this->name;
}

public function setCode(string $code): self
{
$this->code = $code;
Expand All @@ -75,58 +106,69 @@ public function getCode(): string
return $this->code;
}

public function setSalesVolume(?float $sales_volume): self
public function setEmail(?string $email): self
{
$this->sales_volume = $sales_volume;
$this->email = $email;
return $this;
}

public function getSalesVolume(): ?float
public function getEmail(): ?string
{
return $this->sales_volume;
return $this->email;
}

public function setUniqueVisitors(int $unique_visitors): self
public function setTotalSales(int $total_sales): self
{
$this->unique_visitors = $unique_visitors;
$this->total_sales = $total_sales;
return $this;
}

public function getUniqueVisitors(): int
public function getTotalSales(): int
{
return $this->unique_visitors;
return $this->total_sales;
}

public function setCreatedAt(string $created_at): self
public function setTotalSalesGross(float $total_sales_gross): self
{
$this->created_at = $created_at;
$this->total_sales_gross = $total_sales_gross;
return $this;
}

public function getCreatedAt(): string
public function getTotalSalesGross(): float
{
return $this->created_at;
return $this->total_sales_gross;
}

public function setUpdatedAt(?string $updated_at): self
public function setStatus(string $status): self
{
$this->updated_at = $updated_at;
$this->status = $status;
return $this;
}

public function getUpdatedAt(): ?string
public function getStatus(): string
{
return $this->updated_at;
return $this->status;
}

public function setCreatedAt(?string $created_at): self
{
$this->created_at = $created_at;
return $this;
}

public function setDeletedAt(?string $deleted_at): self
public function getCreatedAt(): ?string
{
$this->deleted_at = $deleted_at;
return $this->created_at;
}

public function setUpdatedAt(?string $updated_at): self
{
$this->updated_at = $updated_at;
return $this;
}

public function getDeletedAt(): ?string
public function getUpdatedAt(): ?string
{
return $this->deleted_at;
return $this->updated_at;
}
}
14 changes: 14 additions & 0 deletions backend/app/DomainObjects/Generated/OrderDomainObjectAbstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ abstract class OrderDomainObjectAbstract extends \HiEvents\DomainObjects\Abstrac
final public const ID = 'id';
final public const EVENT_ID = 'event_id';
final public const PROMO_CODE_ID = 'promo_code_id';
final public const AFFILIATE_ID = 'affiliate_id';
final public const SHORT_ID = 'short_id';
final public const TOTAL_BEFORE_ADDITIONS = 'total_before_additions';
final public const TOTAL_REFUNDED = 'total_refunded';
Expand Down Expand Up @@ -45,6 +46,7 @@ abstract class OrderDomainObjectAbstract extends \HiEvents\DomainObjects\Abstrac
protected int $id;
protected int $event_id;
protected ?int $promo_code_id = null;
protected ?int $affiliate_id = null;
protected string $short_id;
protected float $total_before_additions = 0.0;
protected float $total_refunded = 0.0;
Expand Down Expand Up @@ -80,6 +82,7 @@ public function toArray(): array
'id' => $this->id ?? null,
'event_id' => $this->event_id ?? null,
'promo_code_id' => $this->promo_code_id ?? null,
'affiliate_id' => $this->affiliate_id ?? null,
'short_id' => $this->short_id ?? null,
'total_before_additions' => $this->total_before_additions ?? null,
'total_refunded' => $this->total_refunded ?? null,
Expand Down Expand Up @@ -144,6 +147,17 @@ public function getPromoCodeId(): ?int
return $this->promo_code_id;
}

public function setAffiliateId(?int $affiliate_id): self
{
$this->affiliate_id = $affiliate_id;
return $this;
}

public function getAffiliateId(): ?int
{
return $this->affiliate_id;
}

public function setShortId(string $short_id): self
{
$this->short_id = $short_id;
Expand Down
15 changes: 15 additions & 0 deletions backend/app/DomainObjects/Status/AffiliateStatus.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

declare(strict_types=1);

namespace HiEvents\DomainObjects\Status;

use HiEvents\DomainObjects\Enums\BaseEnum;

enum AffiliateStatus: string
{
use BaseEnum;

case ACTIVE = 'ACTIVE';
case INACTIVE = 'INACTIVE';
}
2 changes: 1 addition & 1 deletion backend/app/Exceptions/ResourceConflictException.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class ResourceConflictException extends Exception
public function __construct(
string $message = 'Resource conflict',
int $code = 409,
Exception $previous = null
?Exception $previous = null
) {
parent::__construct($message, $code, $previous);
}
Expand Down
Loading
Loading