BxBaseModPaymentOrders.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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. protected $_bIsApi;
  16. function __construct()
  17. {
  18. parent::__construct();
  19. $this->_oModule = BxDolModule::getInstance($this->MODULE);
  20. $this->_bIsApi = bx_is_api();
  21. }
  22. /**
  23. * @page service Service Calls
  24. * @section bx_base_payment Base Payment
  25. * @subsection bx_base_payment-integration Integration
  26. * @subsubsection bx_base_payment-get_orders_url get_orders_url
  27. *
  28. * @code bx_srv('bx_payment', 'get_orders_url', [...], 'Orders'); @endcode
  29. *
  30. * Get orders page URL.
  31. *
  32. * @return string with orders page URL.
  33. *
  34. * @see BxBaseModPaymentOrders::serviceGetOrdersUrl
  35. */
  36. /**
  37. * @ref bx_base_payment-get_orders_url "get_orders_url"
  38. */
  39. public function serviceGetOrdersUrl()
  40. {
  41. if(!$this->_oModule->isLogged())
  42. return '';
  43. return $this->_oModule->_oConfig->getUrl('URL_ORDERS');
  44. }
  45. /**
  46. * @page service Service Calls
  47. * @section bx_base_payment Base Payment
  48. * @subsection bx_base_payment-integration Integration
  49. * @subsubsection bx_base_payment-get_pending_orders_url get_pending_orders_url
  50. *
  51. * @code bx_srv('bx_payment', 'get_pending_orders_url', [...], 'Orders'); @endcode
  52. *
  53. * Get pending orders page URL.
  54. *
  55. * @return string with pending orders page URL.
  56. *
  57. * @see BxBaseModPaymentOrders::serviceGetPendingOrdersUrl
  58. */
  59. /**
  60. * @ref bx_base_payment-get_pending_orders_url "get_pending_orders_url"
  61. */
  62. public function serviceGetPendingOrdersUrl()
  63. {
  64. if(!$this->_oModule->isLogged())
  65. return '';
  66. return $this->_oModule->_oConfig->getUrl('URL_ORDERS', array('type' => 'pending'));
  67. }
  68. /**
  69. * @page service Service Calls
  70. * @section bx_base_payment Base Payment
  71. * @subsection bx_base_payment-integration Integration
  72. * @subsubsection bx_base_payment-get_orders_count get_orders_count
  73. *
  74. * @code bx_srv('bx_payment', 'get_orders_count', [...], 'Orders'); @endcode
  75. *
  76. * Get processed orders count by type.
  77. *
  78. * @param $sType string value with type. For now 'new' type is available only.
  79. * @param $iProfileId (optional) integer value with profile ID. If empty value is provided then currently logged in profile will be used.
  80. * @return integer value with orders count.
  81. *
  82. * @see BxBaseModPaymentOrders::serviceGetOrdersCount
  83. */
  84. /**
  85. * @ref bx_base_payment-get_orders_count "get_orders_count"
  86. */
  87. public function serviceGetOrdersCount($sType, $iProfileId = 0)
  88. {
  89. if(!in_array($sType, array('new')))
  90. return 0;
  91. $iProfileId = !empty($iProfileId) ? $iProfileId : $this->_oModule->getProfileId();
  92. if(empty($iProfileId))
  93. return 0;
  94. $aOrders = $this->_oModule->_oDb->getOrderProcessed(array('type' => $sType, 'seller_id' => $iProfileId));
  95. if(empty($aOrders) || !is_array($aOrders))
  96. return 0;
  97. return count($aOrders);
  98. }
  99. }
  100. /** @} */