BxBaseModPaymentOrders.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <?php defined('BX_DOL') or die('hack attempt');
  2. /**
  3. * Copyright (c) UNA, Inc - https://una.io
  4. * MIT License - https://opensource.org/licenses/MIT
  5. *
  6. * @defgroup BasePayment Base classes for Payment like modules
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. class BxBaseModPaymentOrders extends BxDol
  12. {
  13. protected $MODULE;
  14. protected $_oModule;
  15. function __construct()
  16. {
  17. parent::__construct();
  18. $this->_oModule = BxDolModule::getInstance($this->MODULE);
  19. }
  20. /**
  21. * @page service Service Calls
  22. * @section bx_base_payment Base Payment
  23. * @subsection bx_base_payment-integration Integration
  24. * @subsubsection bx_base_payment-get_orders_url get_orders_url
  25. *
  26. * @code bx_srv('bx_payment', 'get_orders_url', [...], 'Orders'); @endcode
  27. *
  28. * Get orders page URL.
  29. *
  30. * @return string with orders page URL.
  31. *
  32. * @see BxBaseModPaymentOrders::serviceGetOrdersUrl
  33. */
  34. /**
  35. * @ref bx_base_payment-get_orders_url "get_orders_url"
  36. */
  37. public function serviceGetOrdersUrl()
  38. {
  39. if(!$this->_oModule->isLogged())
  40. return '';
  41. return $this->_oModule->_oConfig->getUrl('URL_ORDERS');
  42. }
  43. /**
  44. * @page service Service Calls
  45. * @section bx_base_payment Base Payment
  46. * @subsection bx_base_payment-integration Integration
  47. * @subsubsection bx_base_payment-get_pending_orders_url get_pending_orders_url
  48. *
  49. * @code bx_srv('bx_payment', 'get_pending_orders_url', [...], 'Orders'); @endcode
  50. *
  51. * Get pending orders page URL.
  52. *
  53. * @return string with pending orders page URL.
  54. *
  55. * @see BxBaseModPaymentOrders::serviceGetPendingOrdersUrl
  56. */
  57. /**
  58. * @ref bx_base_payment-get_pending_orders_url "get_pending_orders_url"
  59. */
  60. public function serviceGetPendingOrdersUrl()
  61. {
  62. if(!$this->_oModule->isLogged())
  63. return '';
  64. return $this->_oModule->_oConfig->getUrl('URL_ORDERS', array('type' => 'pending'));
  65. }
  66. /**
  67. * @page service Service Calls
  68. * @section bx_base_payment Base Payment
  69. * @subsection bx_base_payment-integration Integration
  70. * @subsubsection bx_base_payment-get_orders_count get_orders_count
  71. *
  72. * @code bx_srv('bx_payment', 'get_orders_count', [...], 'Orders'); @endcode
  73. *
  74. * Get processed orders count by type.
  75. *
  76. * @param $sType string value with type. For now 'new' type is available only.
  77. * @param $iProfileId (optional) integer value with profile ID. If empty value is provided then currently logged in profile will be used.
  78. * @return integer value with orders count.
  79. *
  80. * @see BxBaseModPaymentOrders::serviceGetOrdersCount
  81. */
  82. /**
  83. * @ref bx_base_payment-get_orders_count "get_orders_count"
  84. */
  85. public function serviceGetOrdersCount($sType, $iProfileId = 0)
  86. {
  87. if(!in_array($sType, array('new')))
  88. return 0;
  89. $iProfileId = !empty($iProfileId) ? $iProfileId : $this->_oModule->getProfileId();
  90. if(empty($iProfileId))
  91. return 0;
  92. $aOrders = $this->_oModule->_oDb->getOrderProcessed(array('type' => $sType, 'seller_id' => $iProfileId));
  93. if(empty($aOrders) || !is_array($aOrders))
  94. return 0;
  95. return count($aOrders);
  96. }
  97. }
  98. /** @} */