Yihaotong.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. <?php
  2. namespace crmeb\services\invoice\storage;
  3. use crmeb\services\invoice\BaseInvoice;
  4. class Yihaotong extends BaseInvoice
  5. {
  6. /**
  7. * 获取发票开具页面iframe地址
  8. */
  9. const INVOICE_ISSUANCE_URL = 'v2/invoice/invoice_issuance_url';
  10. /**
  11. * 下载发票
  12. */
  13. const DOWNLOAD_INVOICE = 'v2/invoice/download_invoice';
  14. /**
  15. * 查看发票详情
  16. */
  17. const INVOICE_INFO = 'v2/invoice/invoice_info';
  18. /**
  19. * 获取商品类目
  20. */
  21. const CATEGORY = 'v2/invoice/category';
  22. /**
  23. * 发票开具
  24. */
  25. const INVOICE_ISSUANCE = 'v2/invoice/invoice_issuance';
  26. /**
  27. * 申请红字发票
  28. */
  29. const APPLY_RED_INVOICE = 'v2/invoice/apply_red_invoice';
  30. /**
  31. * 开具负数发票
  32. */
  33. const RED_INVOICE_ISSUANCE = 'v2/invoice/red_invoice_issuance';
  34. /**
  35. * @param array $config
  36. * @return mixed|void
  37. * @author wuhaotian
  38. * @email 442384644@qq.com
  39. * @date 2024/5/13
  40. */
  41. protected function initialize(array $config = [])
  42. {
  43. parent::initialize($config);
  44. }
  45. /**
  46. * 获取发票开具页面iframe地址
  47. * @param array $params
  48. * @return array|mixed
  49. * @author wuhaotian
  50. * @email 442384644@qq.com
  51. * @date 2024/5/13
  52. */
  53. public function invoiceIssuanceUrl(array $params = [])
  54. {
  55. return $this->accessToken->httpRequest(self::INVOICE_ISSUANCE_URL, $params);
  56. }
  57. /**
  58. * 下载发票
  59. * @param string $invoiceNum
  60. * @return array|mixed
  61. * @author wuhaotian
  62. * @email 442384644@qq.com
  63. * @date 2024/5/13
  64. */
  65. public function downloadInvoice(string $invoiceNum = '')
  66. {
  67. return $this->accessToken->httpRequest(self::DOWNLOAD_INVOICE . '/' . $invoiceNum, [], 'GET');
  68. }
  69. /**
  70. * 查看发票详情
  71. * @param string $invoiceNum
  72. * @return array|mixed
  73. * @author wuhaotian
  74. * @email 442384644@qq.com
  75. * @date 2024/5/14
  76. */
  77. public function invoiceInfo(string $invoiceNum = '')
  78. {
  79. return $this->accessToken->httpRequest(self::INVOICE_INFO . '/' . $invoiceNum, [], 'GET');
  80. }
  81. /**
  82. * 获取商品类目
  83. * @return array|mixed
  84. * @author wuhaotian
  85. * @email 442384644@qq.com
  86. * @date 2024/5/15
  87. */
  88. public function category(array $params = [])
  89. {
  90. return $this->accessToken->httpRequest(self::CATEGORY, $params, 'GET');
  91. }
  92. /**
  93. * 发票开具
  94. * @param string $unique
  95. * @param array $params
  96. * @return array|mixed
  97. * @author wuhaotian
  98. * @email 442384644@qq.com
  99. * @date 2024/5/15
  100. */
  101. public function invoiceIssuance(string $unique = '', array $params = [])
  102. {
  103. return $this->accessToken->httpRequest(self::INVOICE_ISSUANCE . '/' . $unique, $params);
  104. }
  105. /**
  106. * 申请红字发票
  107. * @param array $params
  108. * @return array|mixed
  109. * @author wuhaotian
  110. * @email 442384644@qq.com
  111. * @date 2024/5/16
  112. */
  113. public function applyRedInvoice(array $params = [])
  114. {
  115. return $this->accessToken->httpRequest(self::APPLY_RED_INVOICE, $params);
  116. }
  117. /**
  118. * 开具负数发票
  119. * @param array $params
  120. * @return array|mixed
  121. * @author wuhaotian
  122. * @email 442384644@qq.com
  123. * @date 2024/5/16
  124. */
  125. public function redInvoiceIssuance(array $params = [])
  126. {
  127. return $this->accessToken->httpRequest(self::RED_INVOICE_ISSUANCE, $params);
  128. }
  129. }