feat: Implement SMS sending functionality with KavehNegar and Rangineh providers
- 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.
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace App\Settlement\Repository;
|
||||
|
||||
use App\Auth\Entity\User;
|
||||
use App\Settlement\Entity\Settlement;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
class SettlementRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, Settlement::class);
|
||||
}
|
||||
|
||||
public function findByUuid(string $uuid): ?Settlement
|
||||
{
|
||||
return $this->findOneBy(['uuid' => $uuid]);
|
||||
}
|
||||
|
||||
/** @return Settlement[] */
|
||||
public function findByUser(User $user): array
|
||||
{
|
||||
return $this->findBy(['user' => $user], ['createdAt' => 'DESC']);
|
||||
}
|
||||
|
||||
/** Balance = sum of credits - sum of debits from wallet_transactions */
|
||||
public function getWalletBalance(User $user): int
|
||||
{
|
||||
$em = $this->getEntityManager();
|
||||
|
||||
$credit = (int) ($em->createQuery(
|
||||
'SELECT SUM(w.amountRials) FROM App\Settlement\Entity\WalletTransaction w
|
||||
WHERE w.user = :user AND w.type = :type'
|
||||
)->setParameters(['user' => $user, 'type' => 'credit'])->getSingleScalarResult() ?? 0);
|
||||
|
||||
$debit = (int) ($em->createQuery(
|
||||
'SELECT SUM(w.amountRials) FROM App\Settlement\Entity\WalletTransaction w
|
||||
WHERE w.user = :user AND w.type = :type'
|
||||
)->setParameters(['user' => $user, 'type' => 'debit'])->getSingleScalarResult() ?? 0);
|
||||
|
||||
return $credit - $debit;
|
||||
}
|
||||
|
||||
public function save(Settlement $entity, bool $flush = true): void
|
||||
{
|
||||
$this->getEntityManager()->persist($entity);
|
||||
if ($flush) $this->getEntityManager()->flush();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user