ProfitSharing.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | WeChatDeveloper
  4. // +----------------------------------------------------------------------
  5. // | 版权所有 2014~2023 ThinkAdmin [ thinkadmin.top ]
  6. // +----------------------------------------------------------------------
  7. // | 官方网站: https://thinkadmin.top
  8. // +----------------------------------------------------------------------
  9. // | 开源协议 ( https://mit-license.org )
  10. // | 免责声明 ( https://thinkadmin.top/disclaimer )
  11. // +----------------------------------------------------------------------
  12. // | gitee 代码仓库:https://gitee.com/zoujingli/WeChatDeveloper
  13. // | github 代码仓库:https://github.com/zoujingli/WeChatDeveloper
  14. // +----------------------------------------------------------------------
  15. namespace WePayV3;
  16. use WePayV3\Contracts\BasicWePay;
  17. /**
  18. * 普通商户商家分账
  19. * Class Profitsharing
  20. * @package WePayV3
  21. */
  22. class ProfitSharing extends BasicWePay
  23. {
  24. /**
  25. * 请求分账
  26. * @param array $options
  27. * @return array
  28. * @throws \WeChat\Exceptions\InvalidResponseException
  29. */
  30. public function create($options)
  31. {
  32. $options['appid'] = $this->config['appid'];
  33. return $this->doRequest('POST', '/v3/profitsharing/orders', json_encode($options, JSON_UNESCAPED_UNICODE), true);
  34. }
  35. /**
  36. * 查询分账结果
  37. * @param string $outOrderNo 商户分账单号
  38. * @param string $transactionId 微信订单号
  39. * @return array
  40. * @throws \WeChat\Exceptions\InvalidResponseException
  41. */
  42. public function query($outOrderNo, $transactionId)
  43. {
  44. $pathinfo = "/v3/profitsharing/orders/{$outOrderNo}?&transaction_id={$transactionId}";
  45. return $this->doRequest('GET', $pathinfo, '', true);
  46. }
  47. /**
  48. * 解冻剩余资金
  49. * @param array $options
  50. * @return array
  51. * @throws \WeChat\Exceptions\InvalidResponseException
  52. */
  53. public function unfreeze($options)
  54. {
  55. return $this->doRequest('POST', '/v3/profitsharing/orders/unfreeze', json_encode($options, JSON_UNESCAPED_UNICODE), true);
  56. }
  57. /**
  58. * 查询剩余待分金额
  59. * @param string $transactionId 微信订单号
  60. * @return array
  61. * @throws \WeChat\Exceptions\InvalidResponseException
  62. */
  63. public function amounts($transactionId)
  64. {
  65. $pathinfo = "/v3/profitsharing/transactions/{$transactionId}/amounts";
  66. return $this->doRequest('GET', $pathinfo, '', true);
  67. }
  68. /**
  69. * 添加分账接收方
  70. * @param array $options
  71. * @return array
  72. * @throws \WeChat\Exceptions\InvalidResponseException
  73. */
  74. public function addReceiver($options)
  75. {
  76. $options['appid'] = $this->config['appid'];
  77. return $this->doRequest('POST', "/v3/profitsharing/receivers/add", json_encode($options, JSON_UNESCAPED_UNICODE), true);
  78. }
  79. /**
  80. * 删除分账接收方
  81. * @param array $options
  82. * @return array
  83. * @throws \WeChat\Exceptions\InvalidResponseException
  84. */
  85. public function deleteReceiver($options)
  86. {
  87. $options['appid'] = $this->config['appid'];
  88. return $this->doRequest('POST', "/v3/profitsharing/receivers/delete", json_encode($options, JSON_UNESCAPED_UNICODE), true);
  89. }
  90. }