Skip to content

Commit a21c0b8

Browse files
authored
Feature: Add affiliate tracking (#640)
1 parent 03e9627 commit a21c0b8

File tree

70 files changed

+2598
-102
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+2598
-102
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,8 @@ frontend/.env
77
backend/.env
88
todo.md
99
CLAUDE.md
10+
/prompts/**
11+
/prompts
1012

11-
.vercel
13+
.vercel
14+
prompts/
Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,45 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace HiEvents\DomainObjects;
46

5-
class AffiliateDomainObject extends Generated\AffiliateDomainObjectAbstract
7+
use HiEvents\DomainObjects\Interfaces\IsSortable;
8+
use HiEvents\DomainObjects\SortingAndFiltering\AllowedSorts;
9+
10+
class AffiliateDomainObject extends Generated\AffiliateDomainObjectAbstract implements IsSortable
611
{
12+
public static function getAllowedSorts(): AllowedSorts
13+
{
14+
return new AllowedSorts(
15+
[
16+
self::CREATED_AT => [
17+
'asc' => __('Oldest First'),
18+
'desc' => __('Newest First'),
19+
],
20+
self::NAME => [
21+
'asc' => __('Name A-Z'),
22+
'desc' => __('Name Z-A'),
23+
],
24+
self::TOTAL_SALES => [
25+
'asc' => __('Sales Ascending'),
26+
'desc' => __('Sales Descending'),
27+
],
28+
self::TOTAL_SALES_GROSS => [
29+
'asc' => __('Revenue Ascending'),
30+
'desc' => __('Revenue Descending'),
31+
],
32+
],
33+
);
34+
}
35+
36+
public static function getDefaultSort(): string
37+
{
38+
return self::CREATED_AT;
39+
}
40+
41+
public static function getDefaultSortDirection(): string
42+
{
43+
return 'desc';
44+
}
745
}

backend/app/DomainObjects/EventDomainObject.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ class EventDomainObject extends Generated\EventDomainObjectAbstract implements I
3030

3131
private ?Collection $capacityAssignments = null;
3232

33+
private ?Collection $affiliates = null;
34+
3335
private ?EventSettingDomainObject $settings = null;
3436

3537
private ?OrganizerDomainObject $organizer = null;
@@ -298,4 +300,15 @@ public function setWebhooks(?Collection $webhooks): EventDomainObject
298300
$this->webhooks = $webhooks;
299301
return $this;
300302
}
303+
304+
public function getAffiliates(): ?Collection
305+
{
306+
return $this->affiliates;
307+
}
308+
309+
public function setAffiliates(?Collection $affiliates): EventDomainObject
310+
{
311+
$this->affiliates = $affiliates;
312+
return $this;
313+
}
301314
}

backend/app/DomainObjects/Generated/AffiliateDomainObjectAbstract.php

Lines changed: 75 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -12,33 +12,42 @@ abstract class AffiliateDomainObjectAbstract extends \HiEvents\DomainObjects\Abs
1212
final public const PLURAL_NAME = 'affiliates';
1313
final public const ID = 'id';
1414
final public const EVENT_ID = 'event_id';
15+
final public const ACCOUNT_ID = 'account_id';
16+
final public const NAME = 'name';
1517
final public const CODE = 'code';
16-
final public const SALES_VOLUME = 'sales_volume';
17-
final public const UNIQUE_VISITORS = 'unique_visitors';
18+
final public const EMAIL = 'email';
19+
final public const TOTAL_SALES = 'total_sales';
20+
final public const TOTAL_SALES_GROSS = 'total_sales_gross';
21+
final public const STATUS = 'status';
1822
final public const CREATED_AT = 'created_at';
1923
final public const UPDATED_AT = 'updated_at';
20-
final public const DELETED_AT = 'deleted_at';
2124

2225
protected int $id;
23-
protected ?int $event_id = null;
26+
protected int $event_id;
27+
protected int $account_id;
28+
protected string $name;
2429
protected string $code;
25-
protected ?float $sales_volume = null;
26-
protected int $unique_visitors = 0;
27-
protected string $created_at;
30+
protected ?string $email = null;
31+
protected int $total_sales = 0;
32+
protected float $total_sales_gross = 0.0;
33+
protected string $status = 'active';
34+
protected ?string $created_at = null;
2835
protected ?string $updated_at = null;
29-
protected ?string $deleted_at = null;
3036

3137
public function toArray(): array
3238
{
3339
return [
3440
'id' => $this->id ?? null,
3541
'event_id' => $this->event_id ?? null,
42+
'account_id' => $this->account_id ?? null,
43+
'name' => $this->name ?? null,
3644
'code' => $this->code ?? null,
37-
'sales_volume' => $this->sales_volume ?? null,
38-
'unique_visitors' => $this->unique_visitors ?? null,
45+
'email' => $this->email ?? null,
46+
'total_sales' => $this->total_sales ?? null,
47+
'total_sales_gross' => $this->total_sales_gross ?? null,
48+
'status' => $this->status ?? null,
3949
'created_at' => $this->created_at ?? null,
4050
'updated_at' => $this->updated_at ?? null,
41-
'deleted_at' => $this->deleted_at ?? null,
4251
];
4352
}
4453

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

56-
public function setEventId(?int $event_id): self
65+
public function setEventId(int $event_id): self
5766
{
5867
$this->event_id = $event_id;
5968
return $this;
6069
}
6170

62-
public function getEventId(): ?int
71+
public function getEventId(): int
6372
{
6473
return $this->event_id;
6574
}
6675

76+
public function setAccountId(int $account_id): self
77+
{
78+
$this->account_id = $account_id;
79+
return $this;
80+
}
81+
82+
public function getAccountId(): int
83+
{
84+
return $this->account_id;
85+
}
86+
87+
public function setName(string $name): self
88+
{
89+
$this->name = $name;
90+
return $this;
91+
}
92+
93+
public function getName(): string
94+
{
95+
return $this->name;
96+
}
97+
6798
public function setCode(string $code): self
6899
{
69100
$this->code = $code;
@@ -75,58 +106,69 @@ public function getCode(): string
75106
return $this->code;
76107
}
77108

78-
public function setSalesVolume(?float $sales_volume): self
109+
public function setEmail(?string $email): self
79110
{
80-
$this->sales_volume = $sales_volume;
111+
$this->email = $email;
81112
return $this;
82113
}
83114

84-
public function getSalesVolume(): ?float
115+
public function getEmail(): ?string
85116
{
86-
return $this->sales_volume;
117+
return $this->email;
87118
}
88119

89-
public function setUniqueVisitors(int $unique_visitors): self
120+
public function setTotalSales(int $total_sales): self
90121
{
91-
$this->unique_visitors = $unique_visitors;
122+
$this->total_sales = $total_sales;
92123
return $this;
93124
}
94125

95-
public function getUniqueVisitors(): int
126+
public function getTotalSales(): int
96127
{
97-
return $this->unique_visitors;
128+
return $this->total_sales;
98129
}
99130

100-
public function setCreatedAt(string $created_at): self
131+
public function setTotalSalesGross(float $total_sales_gross): self
101132
{
102-
$this->created_at = $created_at;
133+
$this->total_sales_gross = $total_sales_gross;
103134
return $this;
104135
}
105136

106-
public function getCreatedAt(): string
137+
public function getTotalSalesGross(): float
107138
{
108-
return $this->created_at;
139+
return $this->total_sales_gross;
109140
}
110141

111-
public function setUpdatedAt(?string $updated_at): self
142+
public function setStatus(string $status): self
112143
{
113-
$this->updated_at = $updated_at;
144+
$this->status = $status;
114145
return $this;
115146
}
116147

117-
public function getUpdatedAt(): ?string
148+
public function getStatus(): string
118149
{
119-
return $this->updated_at;
150+
return $this->status;
151+
}
152+
153+
public function setCreatedAt(?string $created_at): self
154+
{
155+
$this->created_at = $created_at;
156+
return $this;
120157
}
121158

122-
public function setDeletedAt(?string $deleted_at): self
159+
public function getCreatedAt(): ?string
123160
{
124-
$this->deleted_at = $deleted_at;
161+
return $this->created_at;
162+
}
163+
164+
public function setUpdatedAt(?string $updated_at): self
165+
{
166+
$this->updated_at = $updated_at;
125167
return $this;
126168
}
127169

128-
public function getDeletedAt(): ?string
170+
public function getUpdatedAt(): ?string
129171
{
130-
return $this->deleted_at;
172+
return $this->updated_at;
131173
}
132174
}

backend/app/DomainObjects/Generated/OrderDomainObjectAbstract.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ abstract class OrderDomainObjectAbstract extends \HiEvents\DomainObjects\Abstrac
1313
final public const ID = 'id';
1414
final public const EVENT_ID = 'event_id';
1515
final public const PROMO_CODE_ID = 'promo_code_id';
16+
final public const AFFILIATE_ID = 'affiliate_id';
1617
final public const SHORT_ID = 'short_id';
1718
final public const TOTAL_BEFORE_ADDITIONS = 'total_before_additions';
1819
final public const TOTAL_REFUNDED = 'total_refunded';
@@ -45,6 +46,7 @@ abstract class OrderDomainObjectAbstract extends \HiEvents\DomainObjects\Abstrac
4546
protected int $id;
4647
protected int $event_id;
4748
protected ?int $promo_code_id = null;
49+
protected ?int $affiliate_id = null;
4850
protected string $short_id;
4951
protected float $total_before_additions = 0.0;
5052
protected float $total_refunded = 0.0;
@@ -80,6 +82,7 @@ public function toArray(): array
8082
'id' => $this->id ?? null,
8183
'event_id' => $this->event_id ?? null,
8284
'promo_code_id' => $this->promo_code_id ?? null,
85+
'affiliate_id' => $this->affiliate_id ?? null,
8386
'short_id' => $this->short_id ?? null,
8487
'total_before_additions' => $this->total_before_additions ?? null,
8588
'total_refunded' => $this->total_refunded ?? null,
@@ -144,6 +147,17 @@ public function getPromoCodeId(): ?int
144147
return $this->promo_code_id;
145148
}
146149

150+
public function setAffiliateId(?int $affiliate_id): self
151+
{
152+
$this->affiliate_id = $affiliate_id;
153+
return $this;
154+
}
155+
156+
public function getAffiliateId(): ?int
157+
{
158+
return $this->affiliate_id;
159+
}
160+
147161
public function setShortId(string $short_id): self
148162
{
149163
$this->short_id = $short_id;
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace HiEvents\DomainObjects\Status;
6+
7+
use HiEvents\DomainObjects\Enums\BaseEnum;
8+
9+
enum AffiliateStatus: string
10+
{
11+
use BaseEnum;
12+
13+
case ACTIVE = 'ACTIVE';
14+
case INACTIVE = 'INACTIVE';
15+
}

backend/app/Exceptions/ResourceConflictException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class ResourceConflictException extends Exception
99
public function __construct(
1010
string $message = 'Resource conflict',
1111
int $code = 409,
12-
Exception $previous = null
12+
?Exception $previous = null
1313
) {
1414
parent::__construct($message, $code, $previous);
1515
}

0 commit comments

Comments
 (0)