bug fix in pay system
This commit is contained in:
parent
0884a777e1
commit
c59a28f259
|
@ -21,7 +21,7 @@ use OpenApi\Annotations as OA;
|
||||||
|
|
||||||
class PluginController extends AbstractController
|
class PluginController extends AbstractController
|
||||||
{
|
{
|
||||||
private const PRICE_MULTIPLIER = 10.1; // ضریب قیمت به صورت ثابت برای محاسبه
|
private const PRICE_MULTIPLIER = 10; // ضریب قیمت به صورت ثابت برای محاسبه تبدیل تومان به ریال
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* بررسی دسترسی کاربر با نقش مشخص
|
* بررسی دسترسی کاربر با نقش مشخص
|
||||||
|
@ -95,39 +95,50 @@ class PluginController extends AbstractController
|
||||||
* @OA\Response(response=404, description="افزونه یافت نشد")
|
* @OA\Response(response=404, description="افزونه یافت نشد")
|
||||||
* )
|
* )
|
||||||
*/
|
*/
|
||||||
#[Route('/api/plugin/insert/{id}', name: 'api_plugin_insert', methods: ["POST"])]
|
#[Route('/api/plugin/insert/{id}', name: 'api_plugin_insert')]
|
||||||
public function api_plugin_insert(string $id, Log $log, twigFunctions $twigFunctions, PayMGR $payMGR, Access $access, EntityManagerInterface $entityManager): Response
|
public function api_plugin_insert(string $id, Log $log, twigFunctions $twigFunctions, PayMGR $payMGR, Access $access, EntityManagerInterface $entityManager): Response
|
||||||
{
|
{
|
||||||
$acc = $this->checkAccess($access, 'join');
|
$acc = $this->checkAccess($access, 'join');
|
||||||
$pp = $entityManager->getRepository(PluginProdect::class)->find($id)
|
$pp = $entityManager->getRepository(PluginProdect::class)->find($id)
|
||||||
?? throw $this->createNotFoundException('افزونه یافت نشد');
|
?? throw $this->createNotFoundException('افزونه یافت نشد');
|
||||||
|
|
||||||
$plugin = new Plugin();
|
$entityManager->beginTransaction(); // شروع تراکنش
|
||||||
$plugin->setBid($acc['bid'])
|
try {
|
||||||
->setSubmitter($this->getUser())
|
$plugin = new Plugin();
|
||||||
->setDateSubmit(time())
|
$pluginPrice = (($pp->getPrice() * self::PRICE_MULTIPLIER) * 111) / 100;
|
||||||
->setStatus(0)
|
$plugin->setBid($acc['bid'])
|
||||||
->setDes($pp->getName())
|
->setSubmitter($this->getUser())
|
||||||
->setName($pp->getCode())
|
->setDateSubmit(time())
|
||||||
->setPrice($pp->getPrice() * self::PRICE_MULTIPLIER)
|
->setStatus(0)
|
||||||
->setDateExpire(time() + $pp->getTimestamp());
|
->setDes($pp->getName())
|
||||||
|
->setName($pp->getCode())
|
||||||
|
->setPrice($pluginPrice)
|
||||||
|
->setDateExpire(time() + $pp->getTimestamp());
|
||||||
|
|
||||||
$entityManager->persist($plugin);
|
$entityManager->persist($plugin);
|
||||||
|
$entityManager->flush(); // ذخیره اولیه برای تولید ID
|
||||||
|
|
||||||
$result = $payMGR->createRequest(
|
$result = $payMGR->createRequest(
|
||||||
$plugin->getPrice(),
|
$plugin->getPrice(),
|
||||||
$this->generateUrl('api_plugin_buy_verify', ['id' => $plugin->getId()], UrlGeneratorInterface::ABSOLUTE_URL),
|
$this->generateUrl('api_plugin_buy_verify', ['id' => $plugin->getId()], UrlGeneratorInterface::ABSOLUTE_URL),
|
||||||
'خرید ' . $pp->getName()
|
'خرید ' . $pp->getName()
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($result['Success'] ?? false) {
|
if ($result['Success'] ?? false) {
|
||||||
$plugin->setGatePay($result['gate'])
|
$plugin->setGatePay($result['gate'])
|
||||||
->setVerifyCode($result['authkey']);
|
->setVerifyCode($result['authkey']);
|
||||||
$log->insert('بازار افزونهها', 'صدور فاکتور افزونه ' . $pp->getName(), $this->getUser(), $acc['bid']);
|
$log->insert('بازار افزونهها', 'صدور فاکتور افزونه ' . $pp->getName(), $this->getUser(), $acc['bid']);
|
||||||
|
$entityManager->persist($plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
$entityManager->flush(); // ذخیره تغییرات نهایی
|
||||||
|
$entityManager->commit(); // تأیید تراکنش
|
||||||
|
|
||||||
|
return $this->json($result);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
$entityManager->rollback(); // در صورت خطا، تغییرات لغو میشوند
|
||||||
|
throw $e; // خطا را به بالا پرتاب کنید تا مدیریت شود
|
||||||
}
|
}
|
||||||
|
|
||||||
$entityManager->flush();
|
|
||||||
return $this->json($result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -149,7 +160,7 @@ class PluginController extends AbstractController
|
||||||
* @OA\Response(response=404, description="افزونه یافت نشد")
|
* @OA\Response(response=404, description="افزونه یافت نشد")
|
||||||
* )
|
* )
|
||||||
*/
|
*/
|
||||||
#[Route('/api/plugin/buy/verify/{id}', name: 'api_plugin_buy_verify',requirements: ['id' => '.+'], methods: ["POST"])]
|
#[Route('/api/plugin/buy/verify/{id}', name: 'api_plugin_buy_verify', requirements: ['id' => '.+'])]
|
||||||
public function api_plugin_buy_verify(string $id, twigFunctions $twigFunctions, PayMGR $payMGR, Request $request, EntityManagerInterface $entityManager, Log $log): Response
|
public function api_plugin_buy_verify(string $id, twigFunctions $twigFunctions, PayMGR $payMGR, Request $request, EntityManagerInterface $entityManager, Log $log): Response
|
||||||
{
|
{
|
||||||
$req = $entityManager->getRepository(Plugin::class)->find($id)
|
$req = $entityManager->getRepository(Plugin::class)->find($id)
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
404 خطا </p>
|
404 خطا </p>
|
||||||
<h1 class="fw-bold mb-2"> صفحه یافت نشد </h1>
|
<h1 class="fw-bold mb-2"> صفحه یافت نشد </h1>
|
||||||
<p class="fs-4 fw-medium text-muted mb-5"> متاسفیم اما صفحه مورد نظر شما یافت نشد. </p>
|
<p class="fs-4 fw-medium text-muted mb-5"> متاسفیم اما صفحه مورد نظر شما یافت نشد. </p>
|
||||||
<a class="btn btn-lg btn-alt-danger" href="/">
|
<a class="btn btn-lg btn-alt-danger" href="{{ twigFunctions.systemSettings().appSite }}">
|
||||||
<i class="fa fa-arrow-right opacity-50 me-1"></i> صفحه نخست </a>
|
<i class="fa fa-arrow-right opacity-50 me-1"></i> صفحه نخست </a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
<i class="bi bi-backward"></i>
|
<i class="bi bi-backward"></i>
|
||||||
بازگشت به فاکتور
|
بازگشت به فاکتور
|
||||||
</a>
|
</a>
|
||||||
<a class="btn btn-lg btn-primary mt-4" href="/">
|
<a class="btn btn-lg btn-primary mt-4" href="{{ twigFunctions.systemSettings().appSite }}">
|
||||||
<i class="bi bi-backward"></i>
|
<i class="bi bi-backward"></i>
|
||||||
صفحه نخست
|
صفحه نخست
|
||||||
</a>
|
</a>
|
||||||
|
|
Loading…
Reference in a new issue