feat: add mobile number change functionality for doctors and clinics
- Implemented PATCH endpoints for changing the login mobile number of doctors and clinics. - Added ChangeLoginMobileModal component for handling mobile number updates in the UI. - Updated ClinicsPage and DoctorsPage to include buttons for changing mobile numbers. - Enhanced AdminApiController to manage mobile number changes with validation. - Created tests to ensure proper functionality and validation for mobile number changes. - Updated API documentation to reflect new endpoints and their usage.
This commit is contained in:
@@ -7,6 +7,9 @@ use App\Appointment\Repository\AppointmentRepository;
|
||||
use App\Auth\Entity\User;
|
||||
use App\Patient\Entity\PatientSession;
|
||||
use App\Patient\Service\PatientService;
|
||||
use App\Payment\Repository\PaymentRepository;
|
||||
use App\Representation\Service\DomainContextResolver;
|
||||
use App\Settlement\Service\CommissionService;
|
||||
use App\Shared\Constant\ErrorCodes;
|
||||
use App\Shared\Exception\AppException;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
@@ -24,10 +27,34 @@ class AppointmentConfirmationService
|
||||
public function __construct(
|
||||
private readonly PatientService $patientService,
|
||||
private readonly AppointmentRepository $appointmentRepo,
|
||||
private readonly PaymentRepository $paymentRepo,
|
||||
private readonly CommissionService $commissionService,
|
||||
private readonly DomainContextResolver $domainResolver,
|
||||
private readonly EntityManagerInterface $em,
|
||||
private readonly LoggerInterface $logger,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* تقسیم مالیِ نوبت آنلاین در لحظهٔ **تأیید** انجام میشود، نه لحظهٔ پرداخت: تا وقتی
|
||||
* نوبت قطعی نشده، پورسانت نماینده و سهم منشی هم اعتبار نمیشوند. برای نوبتی که
|
||||
* پرداخت آنلاین ندارد (ثبتشده در پنل) کاری انجام نمیشود. ثبت idempotent است.
|
||||
*/
|
||||
private function splitPaymentShares(Appointment $appointment): void
|
||||
{
|
||||
$payment = $this->paymentRepo->findSuccessfulByAppointment($appointment);
|
||||
if ($payment === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
$doctor = $appointment->getDoctor();
|
||||
$this->commissionService->processAppointment(
|
||||
$payment,
|
||||
$doctor->getRepresentationId(),
|
||||
$this->domainResolver->resolve($payment->getFrontendAddress())->representationId(),
|
||||
$doctor->getId(),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* idempotent: فراخوانی دوباره برای همان نوبت چیزی نمیسازد.
|
||||
*
|
||||
@@ -42,6 +69,8 @@ class AppointmentConfirmationService
|
||||
return null;
|
||||
}
|
||||
|
||||
$this->splitPaymentShares($appointment);
|
||||
|
||||
try {
|
||||
return $this->patientService->autoCreateOnAppointmentConfirm($appointment);
|
||||
} catch (\Throwable $e) {
|
||||
@@ -74,6 +103,8 @@ class AppointmentConfirmationService
|
||||
$appointment->transitionTo(Appointment::STATUS_CONFIRMED);
|
||||
$this->appointmentRepo->saveWithLock($appointment, $expectedVersion);
|
||||
|
||||
$this->splitPaymentShares($appointment);
|
||||
|
||||
$session = $this->patientService->autoCreateOnAppointmentConfirm($appointment);
|
||||
|
||||
if ($session === null) {
|
||||
|
||||
Reference in New Issue
Block a user