- Add SendSmsMessage class for encapsulating SMS message data. - Create KavehNegarProvider and RanginehProvider classes implementing SmsProviderInterface for sending SMS. - Implement SmsLogRepository and SmsTemplateRepository for managing SMS logs and templates. - Develop SendSmsHandler for handling SMS sending messages. - Create SmsService to manage SMS dispatching and logging. - Add UserProfileController for managing user profiles with CRUD operations. - Implement UserProfile entity and repository for user profile data management. - Update symfony.lock and bootstrap.php for project dependencies and environment setup.
113 lines
3.6 KiB
PHP
113 lines
3.6 KiB
PHP
<?php
|
|
|
|
namespace App\Settlement\Entity;
|
|
|
|
use App\Auth\Entity\User;
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
use Symfony\Component\Uid\Uuid;
|
|
|
|
#[ORM\Entity]
|
|
#[ORM\Table(name: 'settlements')]
|
|
#[ORM\Index(columns: ['user_id', 'status'], name: 'idx_settlements_user_status')]
|
|
class Settlement
|
|
{
|
|
public const STATUS_PENDING = 'pending';
|
|
public const STATUS_APPROVED = 'approved';
|
|
public const STATUS_REJECTED = 'rejected';
|
|
public const STATUS_PAID = 'paid';
|
|
|
|
#[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: User::class)]
|
|
#[ORM\JoinColumn(name: 'user_id', referencedColumnName: 'id', nullable: false, onDelete: 'RESTRICT')]
|
|
private User $user;
|
|
|
|
#[ORM\Column(name: 'amount_rials', type: 'integer')]
|
|
private int $amountRials;
|
|
|
|
#[ORM\Column(type: 'string', length: 20)]
|
|
private string $status = self::STATUS_PENDING;
|
|
|
|
#[ORM\Column(name: 'bank_account', type: 'json', nullable: true)]
|
|
private ?array $bankAccount = null;
|
|
|
|
#[ORM\Column(name: 'admin_note', type: 'string', length: 500, nullable: true)]
|
|
private ?string $adminNote = null;
|
|
|
|
#[ORM\Column(name: 'reviewed_by', type: 'integer', nullable: true)]
|
|
private ?int $reviewedBy = null;
|
|
|
|
#[ORM\Column(name: 'reviewed_at', type: 'integer', nullable: true)]
|
|
private ?int $reviewedAt = null;
|
|
|
|
#[ORM\Column(name: 'created_at', type: 'integer')]
|
|
private int $createdAt;
|
|
|
|
#[ORM\Column(name: 'updated_at', type: 'integer')]
|
|
private int $updatedAt;
|
|
|
|
public function __construct(User $user, int $amountRials, ?array $bankAccount = null)
|
|
{
|
|
$this->uuid = Uuid::v4()->toRfc4122();
|
|
$this->user = $user;
|
|
$this->amountRials = $amountRials;
|
|
$this->bankAccount = $bankAccount;
|
|
$this->createdAt = time();
|
|
$this->updatedAt = time();
|
|
}
|
|
|
|
public function getId(): ?int { return $this->id; }
|
|
public function getUuid(): string { return $this->uuid; }
|
|
public function getUser(): User { return $this->user; }
|
|
public function getAmountRials(): int { return $this->amountRials; }
|
|
public function getStatus(): string { return $this->status; }
|
|
public function getBankAccount(): ?array { return $this->bankAccount; }
|
|
public function getAdminNote(): ?string { return $this->adminNote; }
|
|
|
|
public function approve(int $adminUserId, ?string $note = null): self
|
|
{
|
|
$this->status = self::STATUS_APPROVED;
|
|
$this->reviewedBy = $adminUserId;
|
|
$this->reviewedAt = time();
|
|
$this->adminNote = $note;
|
|
$this->updatedAt = time();
|
|
return $this;
|
|
}
|
|
|
|
public function reject(int $adminUserId, string $note): self
|
|
{
|
|
$this->status = self::STATUS_REJECTED;
|
|
$this->reviewedBy = $adminUserId;
|
|
$this->reviewedAt = time();
|
|
$this->adminNote = $note;
|
|
$this->updatedAt = time();
|
|
return $this;
|
|
}
|
|
|
|
public function markPaid(): self
|
|
{
|
|
$this->status = self::STATUS_PAID;
|
|
$this->updatedAt = time();
|
|
return $this;
|
|
}
|
|
|
|
public function toArray(): array
|
|
{
|
|
return [
|
|
'uuid' => $this->uuid,
|
|
'amount_rials' => $this->amountRials,
|
|
'status' => $this->status,
|
|
'bank_account' => $this->bankAccount,
|
|
'admin_note' => $this->adminNote,
|
|
'reviewed_at' => $this->reviewedAt,
|
|
'created_at' => $this->createdAt,
|
|
];
|
|
}
|
|
}
|