WechatService.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646
  1. <?php
  2. namespace crmeb\services;
  3. use app\admin\model\wechat\WechatMessage;
  4. use app\admin\model\wechat\WechatReply;
  5. use app\models\user\User;
  6. use app\models\user\WechatUser;
  7. use crmeb\repositories\MessageRepositories;
  8. use crmeb\repositories\PaymentRepositories;
  9. use EasyWeChat\Foundation\Application;
  10. use EasyWeChat\Message\Article;
  11. use EasyWeChat\Message\Image;
  12. use EasyWeChat\Message\Material;
  13. use EasyWeChat\Message\News;
  14. use EasyWeChat\Message\Text;
  15. use EasyWeChat\Message\Video;
  16. use EasyWeChat\Message\Voice;
  17. use EasyWeChat\Payment\Order;
  18. use EasyWeChat\Server\Guard;
  19. use think\Response;
  20. use crmeb\utils\Hook;
  21. class WechatService
  22. {
  23. private static $instance = null;
  24. public static function options()
  25. {
  26. $wechat = SystemConfigService::more([
  27. 'wechat_appid',
  28. 'wechat_appsecret',
  29. 'wechat_token',
  30. 'wechat_encodingaeskey',
  31. 'wechat_encode',
  32. ]);
  33. $payment = SystemConfigService::more([
  34. 'pay_weixin_appid',
  35. 'pay_weixin_appsecret',
  36. 'pay_weixin_mchid',
  37. 'pay_weixin_client_cert',
  38. 'pay_weixin_client_key',
  39. 'pay_weixin_key',
  40. 'pay_weixin_open',
  41. ]);
  42. $config = [
  43. 'app_id' => isset($wechat['wechat_appid']) ? trim($wechat['wechat_appid']) : '',
  44. 'secret' => isset($wechat['wechat_appsecret']) ? trim($wechat['wechat_appsecret']) : '',
  45. 'token' => isset($wechat['wechat_token']) ? trim($wechat['wechat_token']) : '',
  46. 'guzzle' => [
  47. 'timeout' => 10.0, // 超时时间(秒)
  48. 'verify' => false
  49. ],
  50. ];
  51. if (
  52. isset($wechat['wechat_encode']) &&
  53. (int)$wechat['wechat_encode'] > 0 &&
  54. isset($wechat['wechat_encodingaeskey']) &&
  55. !empty($wechat['wechat_encodingaeskey'])
  56. ) {
  57. $config['aes_key'] = $wechat['wechat_encodingaeskey'];
  58. }
  59. if (isset($payment['pay_weixin_open']) && $payment['pay_weixin_open'] == 1) {
  60. $config['payment'] = [
  61. 'app_id' => trim($payment['pay_weixin_appid']),
  62. 'merchant_id' => trim($payment['pay_weixin_mchid']),
  63. 'key' => trim($payment['pay_weixin_key']),
  64. 'cert_path' => realpath('.' . $payment['pay_weixin_client_cert']),
  65. 'key_path' => realpath('.' . $payment['pay_weixin_client_key']),
  66. 'notify_url' => sys_config('site_url') . '/api/wechat/notify'
  67. ];
  68. }
  69. return $config;
  70. }
  71. public static function application($cache = false)
  72. {
  73. (self::$instance === null || $cache === true) && (self::$instance = new Application(self::options()));
  74. return self::$instance;
  75. }
  76. public static function serve(): Response
  77. {
  78. $wechat = self::application(true);
  79. $server = $wechat->server;
  80. self::hook($server);
  81. $response = $server->serve();
  82. return response($response->getContent());
  83. }
  84. /**
  85. * 监听行为
  86. * @param Guard $server
  87. */
  88. private static function hook($server)
  89. {
  90. $server->setMessageHandler(function ($message) {
  91. event('WechatMessageBefore', [$message]);
  92. switch ($message->MsgType) {
  93. case 'event':
  94. switch (strtolower($message->Event)) {
  95. case 'subscribe':
  96. $response = WechatReply::reply('subscribe');
  97. if (isset($message->EventKey)) {
  98. if ($message->EventKey && ($qrInfo = QrcodeService::getQrcode($message->Ticket, 'ticket'))) {
  99. QrcodeService::scanQrcode($message->Ticket, 'ticket');
  100. if (strtolower($qrInfo['third_type']) == 'spread') {
  101. try {
  102. $spreadUid = $qrInfo['third_id'];
  103. $uid = WechatUser::openidToUid($message->FromUserName, 'openid');
  104. if ($spreadUid == $uid) return '自己不能推荐自己';
  105. $userInfo = User::getUserInfo($uid);
  106. if ($userInfo['spread_uid']) return '已有推荐人!';
  107. if (!User::setSpreadUid($userInfo['uid'], $spreadUid)) {
  108. $response = '绑定推荐人失败!';
  109. }
  110. } catch (\Exception $e) {
  111. $response = $e->getMessage();
  112. }
  113. }
  114. }
  115. }
  116. break;
  117. case 'unsubscribe':
  118. event('WechatEventUnsubscribeBefore', [$message]);
  119. break;
  120. case 'scan':
  121. $response = WechatReply::reply('subscribe');
  122. if ($message->EventKey && ($qrInfo = QrcodeService::getQrcode($message->Ticket, 'ticket'))) {
  123. QrcodeService::scanQrcode($message->Ticket, 'ticket');
  124. if (strtolower($qrInfo['third_type']) == 'spread') {
  125. try {
  126. $spreadUid = $qrInfo['third_id'];
  127. $uid = WechatUser::openidToUid($message->FromUserName, 'openid');
  128. if ($spreadUid == $uid) return '自己不能推荐自己';
  129. $userInfo = User::getUserInfo($uid);
  130. if ($userInfo['spread_uid']) return '已有推荐人!';
  131. if (User::setSpreadUid($userInfo['uid'], $spreadUid)) {
  132. $response = '绑定推荐人失败!';
  133. }
  134. } catch (\Exception $e) {
  135. $response = $e->getMessage();
  136. }
  137. }
  138. }
  139. break;
  140. case 'location':
  141. $response = MessageRepositories::wechatEventLocation($message);
  142. break;
  143. case 'click':
  144. $response = WechatReply::reply($message->EventKey);
  145. break;
  146. case 'view':
  147. $response = MessageRepositories::wechatEventView($message);
  148. break;
  149. }
  150. break;
  151. case 'text':
  152. $response = WechatReply::reply($message->Content);
  153. break;
  154. case 'image':
  155. $response = MessageRepositories::wechatMessageImage($message);
  156. break;
  157. case 'voice':
  158. $response = MessageRepositories::wechatMessageVoice($message);
  159. break;
  160. case 'video':
  161. $response = MessageRepositories::wechatMessageVideo($message);
  162. break;
  163. case 'location':
  164. $response = MessageRepositories::wechatMessageLocation($message);
  165. break;
  166. case 'link':
  167. $response = MessageRepositories::wechatMessageLink($message);
  168. break;
  169. // ... 其它消息
  170. default:
  171. $response = MessageRepositories::wechatMessageOther($message);
  172. break;
  173. }
  174. return $response ?? false;
  175. });
  176. }
  177. /**
  178. * 多客服消息转发
  179. * @param string $account
  180. * @return \EasyWeChat\Message\Transfer
  181. */
  182. public static function transfer($account = '')
  183. {
  184. $transfer = new \EasyWeChat\Message\Transfer();
  185. return empty($account) ? $transfer : $transfer->to($account);
  186. }
  187. /**
  188. * 上传永久素材接口
  189. * @return \EasyWeChat\Material\Material
  190. */
  191. public static function materialService()
  192. {
  193. return self::application()->material;
  194. }
  195. /**
  196. * 上传临时素材接口
  197. * @return \EasyWeChat\Material\Temporary
  198. */
  199. public static function materialTemporaryService()
  200. {
  201. return self::application()->material_temporary;
  202. }
  203. /**
  204. * 用户接口
  205. * @return \EasyWeChat\User\User
  206. */
  207. public static function userService()
  208. {
  209. return self::application()->user;
  210. }
  211. /**
  212. * 客服消息接口
  213. * @param null $to
  214. * @param null $message
  215. */
  216. public static function staffService()
  217. {
  218. return self::application()->staff;
  219. }
  220. /**
  221. * 微信公众号菜单接口
  222. * @return \EasyWeChat\Menu\Menu
  223. */
  224. public static function menuService()
  225. {
  226. return self::application()->menu;
  227. }
  228. /**
  229. * 微信二维码生成接口
  230. * @return \EasyWeChat\QRCode\QRCode
  231. */
  232. public static function qrcodeService()
  233. {
  234. return self::application()->qrcode;
  235. }
  236. /**
  237. * 微信永久二维码生成接口 小于10万个
  238. * @return \EasyWeChat\QRCode\QRCode
  239. */
  240. public static function qrcodeForeverService($sceneValue)
  241. {
  242. return self::application()->qrcode->forever($sceneValue);
  243. }
  244. /**
  245. * 微信临时二维码生成接口 30天有效期
  246. * @return \EasyWeChat\QRCode\QRCode
  247. */
  248. public static function qrcodeTempService($sceneValue, $expireSeconds = 2592000)
  249. {
  250. return self::application()->qrcode->temporary($sceneValue, $expireSeconds);
  251. }
  252. /**
  253. * 短链接生成接口
  254. * @return \EasyWeChat\Url\Url
  255. */
  256. public static function urlService()
  257. {
  258. return self::application()->url;
  259. }
  260. /**
  261. * 用户授权
  262. * @return \Overtrue\Socialite\Providers\WeChatProvider
  263. */
  264. public static function oauthService()
  265. {
  266. return self::application()->oauth;
  267. }
  268. /**
  269. * 模板消息接口
  270. * @return \EasyWeChat\Notice\Notice
  271. */
  272. public static function noticeService()
  273. {
  274. return self::application()->notice;
  275. }
  276. public static function sendTemplate($openid, $templateId, array $data, $url = null, $defaultColor = null)
  277. {
  278. $notice = self::noticeService()->to($openid)->template($templateId)->andData($data);
  279. if ($url !== null) $notice->url($url);
  280. if ($defaultColor !== null) $notice->defaultColor($defaultColor);
  281. return $notice->send();
  282. }
  283. /**
  284. * 支付
  285. * @return \EasyWeChat\Payment\Payment
  286. */
  287. public static function paymentService()
  288. {
  289. return self::application()->payment;
  290. }
  291. public static function downloadBill($day, $type = 'ALL')
  292. {
  293. // $payment = self::paymentService();
  294. // $merchant = $payment->getMerchant();
  295. // $params = [
  296. // 'appid' => $merchant->app_id,
  297. // 'bill_date'=>$day,
  298. // 'bill_type'=>strtoupper($type),
  299. // 'mch_id'=> $merchant->merchant_id,
  300. // 'nonce_str' => uniqid()
  301. // ];
  302. // $params['sign'] = \EasyWeChat\Payment\generate_sign($params, $merchant->key, 'md5');
  303. // $xml = XML::build($params);
  304. // dump(self::paymentService()->downloadBill($day)->getContents());
  305. // dump($payment->getHttp()->request('https://api.mch.weixin.qq.com/pay/downloadbill','POST',[
  306. // 'body' => $xml,
  307. // 'stream'=>true
  308. // ])->getBody()->getContents());
  309. }
  310. public static function userTagService()
  311. {
  312. return self::application()->user_tag;
  313. }
  314. public static function userGroupService()
  315. {
  316. return self::application()->user_group;
  317. }
  318. /**
  319. * 生成支付订单对象
  320. * @param $openid
  321. * @param $out_trade_no
  322. * @param $total_fee
  323. * @param $attach
  324. * @param $body
  325. * @param string $detail
  326. * @param string $trade_type
  327. * @param array $options
  328. * @return Order
  329. */
  330. protected static function paymentOrder($openid, $out_trade_no, $total_fee, $attach, $body, $detail = '', $trade_type = 'JSAPI', $options = [])
  331. {
  332. $total_fee = bcmul($total_fee, 100, 0);
  333. $order = array_merge(compact('out_trade_no', 'total_fee', 'attach', 'body', 'detail', 'trade_type'), $options);
  334. if (!is_null($openid)) $order['openid'] = $openid;
  335. if ($order['detail'] == '') unset($order['detail']);
  336. return new Order($order);
  337. }
  338. /**
  339. * 获得下单ID
  340. * @param $openid
  341. * @param $out_trade_no
  342. * @param $total_fee
  343. * @param $attach
  344. * @param $body
  345. * @param string $detail
  346. * @param string $trade_type
  347. * @param array $options
  348. * @return mixed
  349. */
  350. public static function paymentPrepare($openid, $out_trade_no, $total_fee, $attach, $body, $detail = '', $trade_type = 'JSAPI', $options = [])
  351. {
  352. $order = self::paymentOrder($openid, $out_trade_no, $total_fee, $attach, $body, $detail, $trade_type, $options);
  353. $result = self::paymentService()->prepare($order);
  354. if ($result->return_code == 'SUCCESS' && $result->result_code == 'SUCCESS') {
  355. try {
  356. PaymentRepositories::wechatPaymentPrepare($order, $result->prepay_id);
  357. } catch (\Exception $e) {
  358. }
  359. return $result;
  360. } else {
  361. if ($result->return_code == 'FAIL') {
  362. exception('微信支付错误返回:' . $result->return_msg);
  363. } else if (isset($result->err_code)) {
  364. exception('微信支付错误返回:' . $result->err_code_des);
  365. } else {
  366. exception('没有获取微信支付的预支付ID,请重新发起支付!');
  367. }
  368. exit;
  369. }
  370. }
  371. /**
  372. * 获得jsSdk支付参数
  373. * @param $openid
  374. * @param $out_trade_no
  375. * @param $total_fee
  376. * @param $attach
  377. * @param $body
  378. * @param string $detail
  379. * @param string $trade_type
  380. * @param array $options
  381. * @return array|string
  382. */
  383. public static function jsPay($openid, $out_trade_no, $total_fee, $attach, $body, $detail = '', $trade_type = 'JSAPI', $options = [])
  384. {
  385. $paymentPrepare = self::paymentPrepare($openid, $out_trade_no, $total_fee, $attach, $body, $detail, $trade_type, $options);
  386. return self::paymentService()->configForJSSDKPayment($paymentPrepare->prepay_id);
  387. }
  388. /**
  389. * 获得AppSdk支付参数
  390. * @param $openid
  391. * @param $out_trade_no
  392. * @param $total_fee
  393. * @param $attach
  394. * @param $body
  395. * @param string $detail
  396. * @param string $trade_type
  397. * @param array $options
  398. * @return array|string
  399. */
  400. public static function appPay($openid, $out_trade_no, $total_fee, $attach, $body, $detail = '', $trade_type = 'APP', $options = [])
  401. {
  402. $paymentPrepare = self::paymentPrepare($openid, $out_trade_no, $total_fee, $attach, $body, $detail, $trade_type, $options);
  403. return self::paymentService()->configForAppPayment($paymentPrepare->prepay_id);
  404. }
  405. /**
  406. * 使用商户订单号退款
  407. * @param $orderNo
  408. * @param $refundNo
  409. * @param $totalFee
  410. * @param null $refundFee
  411. * @param null $opUserId
  412. * @param string $refundReason
  413. * @param string $type
  414. * @param string $refundAccount
  415. */
  416. public static function refund($orderNo, $refundNo, $totalFee, $refundFee = null, $opUserId = null, $refundReason = '', $type = 'out_trade_no', $refundAccount = 'REFUND_SOURCE_UNSETTLED_FUNDS')
  417. {
  418. $totalFee = floatval($totalFee);
  419. $refundFee = floatval($refundFee);
  420. return self::paymentService()->refund($orderNo, $refundNo, $totalFee, $refundFee, $opUserId, $type, $refundAccount, $refundReason);
  421. }
  422. public static function payOrderRefund($orderNo, array $opt)
  423. {
  424. if (!isset($opt['pay_price'])) exception('缺少pay_price');
  425. $totalFee = floatval(bcmul($opt['pay_price'], 100, 0));
  426. $refundFee = isset($opt['refund_price']) ? floatval(bcmul($opt['refund_price'], 100, 0)) : null;
  427. $refundReason = isset($opt['desc']) ? $opt['desc'] : '';
  428. $refundNo = isset($opt['refund_id']) ? $opt['refund_id'] : $orderNo;
  429. $opUserId = isset($opt['op_user_id']) ? $opt['op_user_id'] : null;
  430. $type = isset($opt['type']) ? $opt['type'] : 'out_trade_no';
  431. /*仅针对老资金流商户使用
  432. REFUND_SOURCE_UNSETTLED_FUNDS---未结算资金退款(默认使用未结算资金退款)
  433. REFUND_SOURCE_RECHARGE_FUNDS---可用余额退款*/
  434. $refundAccount = isset($opt['refund_account']) ? $opt['refund_account'] : 'REFUND_SOURCE_UNSETTLED_FUNDS';
  435. try {
  436. $res = (self::refund($orderNo, $refundNo, $totalFee, $refundFee, $opUserId, $refundReason, $type, $refundAccount));
  437. if ($res->return_code == 'FAIL') exception('退款失败:' . $res->return_msg);
  438. if (isset($res->err_code)) exception('退款失败:' . $res->err_code_des);
  439. } catch (\Exception $e) {
  440. exception($e->getMessage());
  441. }
  442. return true;
  443. }
  444. /**
  445. * 微信支付成功回调接口
  446. */
  447. public static function handleNotify()
  448. {
  449. self::paymentService()->handleNotify(function ($notify, $successful) {
  450. if ($successful && isset($notify->out_trade_no)) {
  451. if (isset($notify->attach) && $notify->attach) {
  452. if (($count = strpos($notify->out_trade_no, '_')) !== false) {
  453. $notify->out_trade_no = substr($notify->out_trade_no, $count + 1);
  454. }
  455. return (new Hook(PaymentRepositories::class, 'wechat'))->listen($notify->attach, $notify->out_trade_no);
  456. }
  457. WechatMessage::setOnceMessage($notify, $notify->openid, 'payment_success', $notify->out_trade_no);
  458. return false;
  459. }
  460. });
  461. }
  462. /**
  463. * jsSdk
  464. * @return \EasyWeChat\Js\Js
  465. */
  466. public static function jsService()
  467. {
  468. return self::application()->js;
  469. }
  470. public static function jsSdk($url = '')
  471. {
  472. $apiList = ['editAddress', 'openAddress', 'updateTimelineShareData', 'updateAppMessageShareData', 'onMenuShareTimeline', 'onMenuShareAppMessage', 'onMenuShareQQ', 'onMenuShareWeibo', 'onMenuShareQZone', 'startRecord', 'stopRecord', 'onVoiceRecordEnd', 'playVoice', 'pauseVoice', 'stopVoice', 'onVoicePlayEnd', 'uploadVoice', 'downloadVoice', 'chooseImage', 'previewImage', 'uploadImage', 'downloadImage', 'translateVoice', 'getNetworkType', 'openLocation', 'getLocation', 'hideOptionMenu', 'showOptionMenu', 'hideMenuItems', 'showMenuItems', 'hideAllNonBaseMenuItem', 'showAllNonBaseMenuItem', 'closeWindow', 'scanQRCode', 'chooseWXPay', 'openProductSpecificView', 'addCard', 'chooseCard', 'openCard'];
  473. $jsService = self::jsService();
  474. if ($url) $jsService->setUrl($url);
  475. try {
  476. return $jsService->config($apiList);
  477. } catch (\Exception $e) {
  478. return '{}';
  479. }
  480. }
  481. /**
  482. * 回复文本消息
  483. * @param string $content 文本内容
  484. * @return Text
  485. */
  486. public static function textMessage($content)
  487. {
  488. return new Text(compact('content'));
  489. }
  490. /**
  491. * 回复图片消息
  492. * @param string $media_id 媒体资源 ID
  493. * @return Image
  494. */
  495. public static function imageMessage($media_id)
  496. {
  497. return new Image(compact('media_id'));
  498. }
  499. /**
  500. * 回复视频消息
  501. * @param string $media_id 媒体资源 ID
  502. * @param string $title 标题
  503. * @param string $description 描述
  504. * @param null $thumb_media_id 封面资源 ID
  505. * @return Video
  506. */
  507. public static function videoMessage($media_id, $title = '', $description = '...', $thumb_media_id = null)
  508. {
  509. return new Video(compact('media_id', 'title', 'description', 'thumb_media_id'));
  510. }
  511. /**
  512. * 回复声音消息
  513. * @param string $media_id 媒体资源 ID
  514. * @return Voice
  515. */
  516. public static function voiceMessage($media_id)
  517. {
  518. return new Voice(compact('media_id'));
  519. }
  520. /**
  521. * 回复图文消息
  522. * @param string|array $title 标题
  523. * @param string $description 描述
  524. * @param string $url URL
  525. * @param string $image 图片链接
  526. */
  527. public static function newsMessage($title, $description = '...', $url = '', $image = '')
  528. {
  529. if (is_array($title)) {
  530. if (isset($title[0]) && is_array($title[0])) {
  531. $newsList = [];
  532. foreach ($title as $news) {
  533. $newsList[] = self::newsMessage($news);
  534. }
  535. return $newsList;
  536. } else {
  537. $data = $title;
  538. }
  539. } else {
  540. $data = compact('title', 'description', 'url', 'image');
  541. }
  542. return new News($data);
  543. }
  544. /**
  545. * 回复文章消息
  546. * @param string|array $title 标题
  547. * @param string $thumb_media_id 图文消息的封面图片素材id(必须是永久 media_ID)
  548. * @param string $source_url 图文消息的原文地址,即点击“阅读原文”后的URL
  549. * @param string $content 图文消息的具体内容,支持HTML标签,必须少于2万字符,小于1M,且此处会去除JS
  550. * @param string $author 作者
  551. * @param string $digest 图文消息的摘要,仅有单图文消息才有摘要,多图文此处为空
  552. * @param int $show_cover_pic 是否显示封面,0为false,即不显示,1为true,即显示
  553. * @param int $need_open_comment 是否打开评论,0不打开,1打开
  554. * @param int $only_fans_can_comment 是否粉丝才可评论,0所有人可评论,1粉丝才可评论
  555. * @return Article
  556. */
  557. public static function articleMessage($title, $thumb_media_id, $source_url, $content = '', $author = '', $digest = '', $show_cover_pic = 0, $need_open_comment = 0, $only_fans_can_comment = 1)
  558. {
  559. $data = is_array($title) ? $title : compact('title', 'thumb_media_id', 'source_url', 'content', 'author', 'digest', 'show_cover_pic', 'need_open_comment', 'only_fans_can_comment');
  560. return new Article($data);
  561. }
  562. /**
  563. * 回复素材消息
  564. * @param string $type [mpnews、 mpvideo、voice、image]
  565. * @param string $media_id 素材 ID
  566. * @return Material
  567. */
  568. public static function materialMessage($type, $media_id)
  569. {
  570. return new Material($type, $media_id);
  571. }
  572. /**
  573. * 作为客服消息发送
  574. * @param $to
  575. * @param $message
  576. * @return bool
  577. */
  578. public static function staffTo($to, $message)
  579. {
  580. $staff = self::staffService();
  581. $staff = is_callable($message) ? $staff->message($message()) : $staff->message($message);
  582. $res = $staff->to($to)->send();
  583. return $res;
  584. }
  585. /**
  586. * 获得用户信息
  587. * @param array|string $openid
  588. * @return \EasyWeChat\Support\Collection
  589. */
  590. public static function getUserInfo($openid)
  591. {
  592. $userService = self::userService();
  593. $userInfo = is_array($openid) ? $userService->batchGet($openid) : $userService->get($openid);
  594. return $userInfo;
  595. }
  596. }