Bill.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | WeChatDeveloper
  4. // +----------------------------------------------------------------------
  5. // | 版权所有 2014~2022 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
  6. // +----------------------------------------------------------------------
  7. // | 官方网站: https://thinkadmin.top
  8. // +----------------------------------------------------------------------
  9. // | 开源协议 ( https://mit-license.org )
  10. // +----------------------------------------------------------------------
  11. // | github开源项目:https://github.com/zoujingli/WeChatDeveloper
  12. // +----------------------------------------------------------------------
  13. namespace WePay;
  14. use WeChat\Contracts\BasicWePay;
  15. use WeChat\Contracts\Tools;
  16. use WeChat\Exceptions\InvalidResponseException;
  17. /**
  18. * 微信商户账单及评论
  19. * Class Bill
  20. * @package WePay
  21. */
  22. class Bill extends BasicWePay
  23. {
  24. /**
  25. * 下载对账单
  26. * @param array $options 静音参数
  27. * @param null|string $outType 输出类型
  28. * @return bool|string
  29. * @throws \WeChat\Exceptions\InvalidResponseException
  30. * @throws \WeChat\Exceptions\LocalCacheException
  31. */
  32. public function download(array $options, $outType = null)
  33. {
  34. $this->params->set('sign_type', 'MD5');
  35. $params = $this->params->merge($options);
  36. $params['sign'] = $this->getPaySign($params, 'MD5');
  37. $result = Tools::post('https://api.mch.weixin.qq.com/pay/downloadbill', Tools::arr2xml($params));
  38. if (is_array($jsonData = Tools::xml3arr($result))) {
  39. if ($jsonData['return_code'] !== 'SUCCESS') {
  40. throw new InvalidResponseException($jsonData['return_msg'], '0');
  41. }
  42. }
  43. return is_null($outType) ? $result : $outType($result);
  44. }
  45. /**
  46. * 拉取订单评价数据
  47. * @param array $options
  48. * @return array
  49. * @throws \WeChat\Exceptions\InvalidResponseException
  50. * @throws \WeChat\Exceptions\LocalCacheException
  51. */
  52. public function comment(array $options)
  53. {
  54. $url = 'https://api.mch.weixin.qq.com/billcommentsp/batchquerycomment';
  55. return $this->callPostApi($url, $options, true);
  56. }
  57. }