Bill.php 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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 WePay;
  16. use WeChat\Contracts\BasicWePay;
  17. use WeChat\Contracts\Tools;
  18. use WeChat\Exceptions\InvalidResponseException;
  19. /**
  20. * 微信商户账单及评论
  21. * Class Bill
  22. * @package WePay
  23. */
  24. class Bill extends BasicWePay
  25. {
  26. /**
  27. * 下载对账单
  28. * @param array $options 静音参数
  29. * @param null|string $outType 输出类型
  30. * @return bool|string
  31. * @throws \WeChat\Exceptions\InvalidResponseException
  32. * @throws \WeChat\Exceptions\LocalCacheException
  33. */
  34. public function download(array $options, $outType = null)
  35. {
  36. $this->params->set('sign_type', 'MD5');
  37. $params = $this->params->merge($options);
  38. $params['sign'] = $this->getPaySign($params, 'MD5');
  39. $result = Tools::post('https://api.mch.weixin.qq.com/pay/downloadbill', Tools::arr2xml($params));
  40. if (is_array($jsonData = Tools::xml3arr($result))) {
  41. if ($jsonData['return_code'] !== 'SUCCESS') {
  42. throw new InvalidResponseException($jsonData['return_msg'], '0');
  43. }
  44. }
  45. return is_null($outType) ? $result : $outType($result);
  46. }
  47. /**
  48. * 拉取订单评价数据
  49. * @param array $options
  50. * @return array
  51. * @throws \WeChat\Exceptions\InvalidResponseException
  52. * @throws \WeChat\Exceptions\LocalCacheException
  53. */
  54. public function comment(array $options)
  55. {
  56. $url = 'https://api.mch.weixin.qq.com/billcommentsp/batchquerycomment';
  57. return $this->callPostApi($url, $options, true);
  58. }
  59. }