feat: implement staff management and subscription system

- Added StaffController for managing clinic staff, including listing, creating, updating, and toggling staff status.
- Created ClinicStaff entity and repository for staff data handling.
- Developed SubscriptionController to manage subscription plans and periods, including trial subscriptions.
- Introduced SubscriptionPlan, SubscriptionPeriod, and ClinicSubscription entities for subscription management.
- Implemented SubscriptionService for handling subscription logic, including trial activation and subscription creation from payments.
- Added necessary repositories for subscription entities to facilitate data access and manipulation.
This commit is contained in:
hamed
2026-06-14 22:10:28 +03:30
parent dcd631f503
commit b0244f28f5
53 changed files with 4434 additions and 40 deletions
+71
View File
@@ -0,0 +1,71 @@
<?php
namespace App\Sms\Entity;
use App\Sms\Repository\SmsSettingsRepository;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: SmsSettingsRepository::class)]
#[ORM\Table(name: 'sms_settings')]
#[ORM\UniqueConstraint(name: 'uniq_sms_settings_entity', columns: ['entity_type', 'entity_id'])]
class SmsSettings
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private ?int $id = null;
#[ORM\Column(name: 'entity_type', type: 'string', length: 10)]
private string $entityType;
#[ORM\Column(name: 'entity_id', type: 'integer')]
private int $entityId;
#[ORM\Column(name: 'reminder_enabled', type: 'boolean')]
private bool $reminderEnabled = false;
#[ORM\Column(name: 'reminder_hours_before', type: 'smallint')]
private int $reminderHoursBefore = 2;
#[ORM\Column(name: 'post_visit_enabled', type: 'boolean')]
private bool $postVisitEnabled = false;
#[ORM\Column(name: 'post_visit_text', type: 'text', nullable: true)]
private ?string $postVisitText = null;
#[ORM\Column(name: 'updated_at', type: 'integer')]
private int $updatedAt;
public function __construct(string $entityType, int $entityId)
{
$this->entityType = $entityType;
$this->entityId = $entityId;
$this->updatedAt = time();
}
public function getId(): ?int { return $this->id; }
public function getEntityType(): string { return $this->entityType; }
public function getEntityId(): int { return $this->entityId; }
public function isReminderEnabled(): bool { return $this->reminderEnabled; }
public function getReminderHoursBefore(): int { return $this->reminderHoursBefore; }
public function isPostVisitEnabled(): bool { return $this->postVisitEnabled; }
public function getPostVisitText(): ?string { return $this->postVisitText; }
public function setReminderEnabled(bool $v): self { $this->reminderEnabled = $v; $this->updatedAt = time(); return $this; }
public function setReminderHoursBefore(int $v): self { $this->reminderHoursBefore = $v; $this->updatedAt = time(); return $this; }
public function setPostVisitEnabled(bool $v): self { $this->postVisitEnabled = $v; $this->updatedAt = time(); return $this; }
public function setPostVisitText(?string $v): self { $this->postVisitText = $v; $this->updatedAt = time(); return $this; }
public function toArray(): array
{
return [
'entity_type' => $this->entityType,
'entity_id' => $this->entityId,
'reminder_enabled' => $this->reminderEnabled,
'reminder_hours_before' => $this->reminderHoursBefore,
'post_visit_enabled' => $this->postVisitEnabled,
'post_visit_text' => $this->postVisitText,
'updated_at' => $this->updatedAt,
];
}
}
+61
View File
@@ -0,0 +1,61 @@
<?php
namespace App\Sms\Entity;
use App\Sms\Repository\SmsWalletRepository;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: SmsWalletRepository::class)]
#[ORM\Table(name: 'sms_wallets')]
#[ORM\UniqueConstraint(name: 'uniq_sms_wallet_entity', columns: ['entity_type', 'entity_id'])]
class SmsWallet
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private ?int $id = null;
#[ORM\Column(name: 'entity_type', type: 'string', length: 10)]
private string $entityType;
#[ORM\Column(name: 'entity_id', type: 'integer')]
private int $entityId;
#[ORM\Column(name: 'balance_rials', type: 'integer')]
private int $balanceRials = 0;
#[ORM\Column(name: 'created_at', type: 'integer')]
private int $createdAt;
#[ORM\Column(name: 'updated_at', type: 'integer')]
private int $updatedAt;
public function __construct(string $entityType, int $entityId)
{
$this->entityType = $entityType;
$this->entityId = $entityId;
$this->createdAt = time();
$this->updatedAt = time();
}
public function getId(): ?int { return $this->id; }
public function getEntityType(): string { return $this->entityType; }
public function getEntityId(): int { return $this->entityId; }
public function getBalanceRials(): int { return $this->balanceRials; }
public function credit(int $amount): void
{
$this->balanceRials += $amount;
$this->updatedAt = time();
}
public function debit(int $amount): bool
{
if ($this->balanceRials < $amount) {
return false;
}
$this->balanceRials -= $amount;
$this->updatedAt = time();
return true;
}
}
+73
View File
@@ -0,0 +1,73 @@
<?php
namespace App\Sms\Entity;
use App\Payment\Entity\Payment;
use App\Sms\Repository\SmsWalletTransactionRepository;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Uid\Uuid;
#[ORM\Entity(repositoryClass: SmsWalletTransactionRepository::class)]
#[ORM\Table(name: 'sms_wallet_transactions')]
class SmsWalletTransaction
{
public const TYPE_CREDIT = 'credit';
public const TYPE_DEBIT = 'debit';
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private ?int $id = null;
#[ORM\Column(type: 'string', length: 36, unique: true)]
private string $uuid;
#[ORM\ManyToOne(targetEntity: SmsWallet::class)]
#[ORM\JoinColumn(nullable: false, onDelete: 'CASCADE')]
private SmsWallet $wallet;
#[ORM\Column(type: 'string', length: 10)]
private string $type;
#[ORM\Column(name: 'amount_rials', type: 'integer')]
private int $amountRials;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private ?string $description = null;
#[ORM\ManyToOne(targetEntity: Payment::class)]
#[ORM\JoinColumn(nullable: true, onDelete: 'SET NULL')]
private ?Payment $payment = null;
#[ORM\Column(name: 'created_at', type: 'integer')]
private int $createdAt;
public function __construct(SmsWallet $wallet, string $type, int $amountRials, ?string $description = null, ?Payment $payment = null)
{
$this->uuid = Uuid::v4()->toRfc4122();
$this->wallet = $wallet;
$this->type = $type;
$this->amountRials = $amountRials;
$this->description = $description;
$this->payment = $payment;
$this->createdAt = time();
}
public function getId(): ?int { return $this->id; }
public function getUuid(): string { return $this->uuid; }
public function getType(): string { return $this->type; }
public function getAmountRials(): int { return $this->amountRials; }
public function getDescription(): ?string { return $this->description; }
public function getCreatedAt(): int { return $this->createdAt; }
public function toArray(): array
{
return [
'uuid' => $this->uuid,
'type' => $this->type,
'amount_rials' => $this->amountRials,
'description' => $this->description,
'created_at' => $this->createdAt,
];
}
}