From 6fd67f403ca573b5fb04dddc5561cb1049791494 Mon Sep 17 00:00:00 2001 From: wanghongjun <1445693971@qq,com> Date: Tue, 24 Oct 2023 11:07:27 +0800 Subject: [PATCH] =?UTF-8?q?=E9=83=A8=E7=BD=B2=E5=88=B0git?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MiniProgram/ActivityMessage/Client.php | 85 ++++ .../ActivityMessage/ServiceProvider.php | 28 ++ .../wechat/src/MiniProgram/AppCode/Client.php | 92 ++++ .../MiniProgram/AppCode/ServiceProvider.php | 33 ++ .../wechat/src/MiniProgram/Application.php | 83 ++++ .../src/MiniProgram/Auth/AccessToken.php | 39 ++ .../wechat/src/MiniProgram/Auth/Client.php | 43 ++ .../src/MiniProgram/Auth/ServiceProvider.php | 32 ++ .../wechat/src/MiniProgram/Base/Client.php | 38 ++ .../src/MiniProgram/Base/ServiceProvider.php | 33 ++ .../CustomerService/ServiceProvider.php | 34 ++ .../src/MiniProgram/DataCube/Client.php | 174 +++++++ .../MiniProgram/DataCube/ServiceProvider.php | 28 ++ .../wechat/src/MiniProgram/Encryptor.php | 50 ++ .../wechat/src/MiniProgram/Express/Client.php | 133 ++++++ .../MiniProgram/Express/ServiceProvider.php | 33 ++ .../src/MiniProgram/Mall/CartClient.php | 88 ++++ .../src/MiniProgram/Mall/ForwardsMall.php | 48 ++ .../src/MiniProgram/Mall/MediaClient.php | 37 ++ .../src/MiniProgram/Mall/OrderClient.php | 75 +++ .../src/MiniProgram/Mall/ProductClient.php | 68 +++ .../src/MiniProgram/Mall/ServiceProvider.php | 44 ++ .../src/MiniProgram/NearbyPoi/Client.php | 123 +++++ .../MiniProgram/NearbyPoi/ServiceProvider.php | 33 ++ .../src/MiniProgram/OCR/ServiceProvider.php | 34 ++ .../src/MiniProgram/OpenData/Client.php | 96 ++++ .../MiniProgram/OpenData/ServiceProvider.php | 28 ++ .../wechat/src/MiniProgram/Plugin/Client.php | 67 +++ .../src/MiniProgram/Plugin/DevClient.php | 93 ++++ .../MiniProgram/Plugin/ServiceProvider.php | 42 ++ .../MiniProgram/Server/ServiceProvider.php | 42 ++ .../wechat/src/MiniProgram/Soter/Client.php | 41 ++ .../src/MiniProgram/Soter/ServiceProvider.php | 33 ++ .../MiniProgram/SubscribeMessage/Client.php | 208 +++++++++ .../SubscribeMessage/ServiceProvider.php | 28 ++ .../MiniProgram/TemplateMessage/Client.php | 114 +++++ .../TemplateMessage/ServiceProvider.php | 28 ++ .../src/MiniProgram/UniformMessage/Client.php | 146 ++++++ .../UniformMessage/ServiceProvider.php | 28 ++ .../src/OfficialAccount/Application.php | 88 ++++ .../src/OfficialAccount/Auth/AccessToken.php | 39 ++ .../OfficialAccount/Auth/ServiceProvider.php | 33 ++ .../src/OfficialAccount/AutoReply/Client.php | 34 ++ .../AutoReply/ServiceProvider.php | 33 ++ .../src/OfficialAccount/Base/Client.php | 84 ++++ .../OfficialAccount/Base/ServiceProvider.php | 33 ++ .../OfficialAccount/Broadcasting/Client.php | 383 ++++++++++++++++ .../Broadcasting/MessageBuilder.php | 162 +++++++ .../Broadcasting/ServiceProvider.php | 33 ++ .../Card/BoardingPassClient.php | 33 ++ .../wechat/src/OfficialAccount/Card/Card.php | 52 +++ .../src/OfficialAccount/Card/Client.php | 428 ++++++++++++++++++ .../src/OfficialAccount/Card/CodeClient.php | 193 ++++++++ .../src/OfficialAccount/Card/CoinClient.php | 119 +++++ .../Card/GeneralCardClient.php | 71 +++ .../OfficialAccount/Card/GiftCardClient.php | 74 +++ .../Card/GiftCardOrderClient.php | 78 ++++ .../Card/GiftCardPageClient.php | 102 +++++ .../OfficialAccount/Card/InvoiceClient.php | 113 +++++ .../src/OfficialAccount/Card/JssdkClient.php | 85 ++++ .../Card/MeetingTicketClient.php | 33 ++ .../OfficialAccount/Card/MemberCardClient.php | 123 +++++ .../Card/MovieTicketClient.php | 33 ++ .../OfficialAccount/Card/ServiceProvider.php | 89 ++++ .../Card/SubMerchantClient.php | 121 +++++ .../src/OfficialAccount/Comment/Client.php | 208 +++++++++ .../Comment/ServiceProvider.php | 44 ++ .../CustomerService/Client.php | 230 ++++++++++ .../CustomerService/Messenger.php | 165 +++++++ .../CustomerService/ServiceProvider.php | 37 ++ .../CustomerService/SessionClient.php | 104 +++++ .../src/OfficialAccount/DataCube/Client.php | 340 ++++++++++++++ .../DataCube/ServiceProvider.php | 33 ++ .../src/OfficialAccount/Device/Client.php | 251 ++++++++++ .../Device/ServiceProvider.php | 33 ++ .../src/OfficialAccount/Goods/Client.php | 113 +++++ .../OfficialAccount/Goods/ServiceProvider.php | 33 ++ .../src/OfficialAccount/Material/Client.php | 301 ++++++++++++ .../Material/ServiceProvider.php | 44 ++ .../src/OfficialAccount/Menu/Client.php | 103 +++++ .../OfficialAccount/Menu/ServiceProvider.php | 33 ++ .../OfficialAccount/OAuth/ServiceProvider.php | 66 +++ .../wechat/src/OfficialAccount/OCR/Client.php | 85 ++++ .../OfficialAccount/OCR/ServiceProvider.php | 33 ++ .../wechat/src/OfficialAccount/POI/Client.php | 145 ++++++ .../OfficialAccount/POI/ServiceProvider.php | 33 ++ .../src/OfficialAccount/Semantic/Client.php | 45 ++ .../Semantic/ServiceProvider.php | 31 ++ .../src/OfficialAccount/Server/Guard.php | 30 ++ .../Server/Handlers/EchoStrHandler.php | 51 +++ .../Server/ServiceProvider.php | 46 ++ .../OfficialAccount/ShakeAround/Client.php | 81 ++++ .../ShakeAround/DeviceClient.php | 190 ++++++++ .../ShakeAround/GroupClient.php | 167 +++++++ .../ShakeAround/MaterialClient.php | 44 ++ .../ShakeAround/PageClient.php | 110 +++++ .../ShakeAround/RelationClient.php | 87 ++++ .../ShakeAround/ServiceProvider.php | 57 +++ .../ShakeAround/ShakeAround.php | 44 ++ .../ShakeAround/StatsClient.php | 110 +++++ .../src/OfficialAccount/Store/Client.php | 209 +++++++++ .../OfficialAccount/Store/ServiceProvider.php | 33 ++ .../TemplateMessage/Client.php | 234 ++++++++++ .../TemplateMessage/ServiceProvider.php | 33 ++ .../OfficialAccount/User/ServiceProvider.php | 35 ++ .../src/OfficialAccount/User/TagClient.php | 175 +++++++ .../src/OfficialAccount/User/UserClient.php | 172 +++++++ .../src/OfficialAccount/WiFi/CardClient.php | 52 +++ .../src/OfficialAccount/WiFi/Client.php | 98 ++++ .../src/OfficialAccount/WiFi/DeviceClient.php | 127 ++++++ .../OfficialAccount/WiFi/ServiceProvider.php | 45 ++ .../src/OfficialAccount/WiFi/ShopClient.php | 100 ++++ .../wechat/src/OpenWork/Application.php | 85 ++++ .../wechat/src/OpenWork/Auth/AccessToken.php | 52 +++ .../src/OpenWork/Auth/ServiceProvider.php | 33 ++ .../wechat/src/OpenWork/Corp/Client.php | 217 +++++++++ .../src/OpenWork/Corp/ServiceProvider.php | 38 ++ .../src/OpenWork/MiniProgram/Client.php | 50 ++ .../OpenWork/MiniProgram/ServiceProvider.php | 31 ++ .../wechat/src/OpenWork/Provider/Client.php | 206 +++++++++ .../src/OpenWork/Provider/ServiceProvider.php | 36 ++ .../wechat/src/OpenWork/Server/Guard.php | 68 +++ .../Server/Handlers/EchoStrHandler.php | 62 +++ .../src/OpenWork/Server/ServiceProvider.php | 56 +++ .../src/OpenWork/SuiteAuth/AccessToken.php | 56 +++ .../OpenWork/SuiteAuth/ServiceProvider.php | 37 ++ .../src/OpenWork/SuiteAuth/SuiteTicket.php | 85 ++++ .../wechat/src/OpenWork/Work/Application.php | 41 ++ .../src/OpenWork/Work/Auth/AccessToken.php | 80 ++++ 129 files changed, 11244 insertions(+) create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/ActivityMessage/Client.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/ActivityMessage/ServiceProvider.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/AppCode/Client.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/AppCode/ServiceProvider.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/Application.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/Auth/AccessToken.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/Auth/Client.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/Auth/ServiceProvider.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/Base/Client.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/Base/ServiceProvider.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/CustomerService/ServiceProvider.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/DataCube/Client.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/DataCube/ServiceProvider.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/Encryptor.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/Express/Client.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/Express/ServiceProvider.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/Mall/CartClient.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/Mall/ForwardsMall.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/Mall/MediaClient.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/Mall/OrderClient.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/Mall/ProductClient.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/Mall/ServiceProvider.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/NearbyPoi/Client.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/NearbyPoi/ServiceProvider.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/OCR/ServiceProvider.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/OpenData/Client.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/OpenData/ServiceProvider.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/Plugin/Client.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/Plugin/DevClient.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/Plugin/ServiceProvider.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/Server/ServiceProvider.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/Soter/Client.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/Soter/ServiceProvider.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/SubscribeMessage/Client.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/SubscribeMessage/ServiceProvider.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/TemplateMessage/Client.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/TemplateMessage/ServiceProvider.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/UniformMessage/Client.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/UniformMessage/ServiceProvider.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Application.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Auth/AccessToken.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Auth/ServiceProvider.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/AutoReply/Client.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/AutoReply/ServiceProvider.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Base/Client.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Base/ServiceProvider.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Broadcasting/Client.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Broadcasting/MessageBuilder.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Broadcasting/ServiceProvider.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Card/BoardingPassClient.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Card/Card.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Card/Client.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Card/CodeClient.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Card/CoinClient.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Card/GeneralCardClient.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Card/GiftCardClient.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Card/GiftCardOrderClient.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Card/GiftCardPageClient.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Card/InvoiceClient.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Card/JssdkClient.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Card/MeetingTicketClient.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Card/MemberCardClient.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Card/MovieTicketClient.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Card/ServiceProvider.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Card/SubMerchantClient.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Comment/Client.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Comment/ServiceProvider.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/CustomerService/Client.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/CustomerService/Messenger.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/CustomerService/ServiceProvider.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/CustomerService/SessionClient.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/DataCube/Client.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/DataCube/ServiceProvider.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Device/Client.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Device/ServiceProvider.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Goods/Client.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Goods/ServiceProvider.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Material/Client.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Material/ServiceProvider.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Menu/Client.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Menu/ServiceProvider.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/OAuth/ServiceProvider.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/OCR/Client.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/OCR/ServiceProvider.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/POI/Client.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/POI/ServiceProvider.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Semantic/Client.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Semantic/ServiceProvider.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Server/Guard.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Server/Handlers/EchoStrHandler.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Server/ServiceProvider.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/ShakeAround/Client.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/ShakeAround/DeviceClient.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/ShakeAround/GroupClient.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/ShakeAround/MaterialClient.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/ShakeAround/PageClient.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/ShakeAround/RelationClient.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/ShakeAround/ServiceProvider.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/ShakeAround/ShakeAround.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/ShakeAround/StatsClient.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Store/Client.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Store/ServiceProvider.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/TemplateMessage/Client.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/TemplateMessage/ServiceProvider.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/User/ServiceProvider.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/User/TagClient.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/User/UserClient.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/WiFi/CardClient.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/WiFi/Client.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/WiFi/DeviceClient.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/WiFi/ServiceProvider.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/WiFi/ShopClient.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/OpenWork/Application.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/OpenWork/Auth/AccessToken.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/OpenWork/Auth/ServiceProvider.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/OpenWork/Corp/Client.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/OpenWork/Corp/ServiceProvider.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/OpenWork/MiniProgram/Client.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/OpenWork/MiniProgram/ServiceProvider.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/OpenWork/Provider/Client.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/OpenWork/Provider/ServiceProvider.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/OpenWork/Server/Guard.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/OpenWork/Server/Handlers/EchoStrHandler.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/OpenWork/Server/ServiceProvider.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/OpenWork/SuiteAuth/AccessToken.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/OpenWork/SuiteAuth/ServiceProvider.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/OpenWork/SuiteAuth/SuiteTicket.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/OpenWork/Work/Application.php create mode 100644 addons/weliam_smartcity/vendor/overtrue/wechat/src/OpenWork/Work/Auth/AccessToken.php diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/ActivityMessage/Client.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/ActivityMessage/Client.php new file mode 100644 index 0000000..16f273d --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/ActivityMessage/Client.php @@ -0,0 +1,85 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\MiniProgram\ActivityMessage; + +use EasyWeChat\Kernel\BaseClient; +use EasyWeChat\Kernel\Exceptions\InvalidArgumentException; + +class Client extends BaseClient +{ + /** + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + */ + public function createActivityId() + { + return $this->httpGet('cgi-bin/message/wxopen/activityid/create'); + } + + /** + * @param string $activityId + * @param int $state + * @param array $params + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function updateMessage(string $activityId, int $state = 0, array $params = []) + { + if (!in_array($state, [0, 1], true)) { + throw new InvalidArgumentException('"state" should be "0" or "1".'); + } + + $params = $this->formatParameters($params); + + $params = [ + 'activity_id' => $activityId, + 'target_state' => $state, + 'template_info' => ['parameter_list' => $params], + ]; + + return $this->httpPostJson('cgi-bin/message/wxopen/updatablemsg/send', $params); + } + + /** + * @param array $params + * + * @return array + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException + */ + protected function formatParameters(array $params) + { + $formatted = []; + + foreach ($params as $name => $value) { + if (!in_array($name, ['member_count', 'room_limit', 'path', 'version_type'], true)) { + continue; + } + + if ('version_type' === $name && !in_array($value, ['develop', 'trial', 'release'], true)) { + throw new InvalidArgumentException('Invalid value of attribute "version_type".'); + } + + $formatted[] = [ + 'name' => $name, + 'value' => strval($value), + ]; + } + + return $formatted; + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/ActivityMessage/ServiceProvider.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/ActivityMessage/ServiceProvider.php new file mode 100644 index 0000000..fa7d3cf --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/ActivityMessage/ServiceProvider.php @@ -0,0 +1,28 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\MiniProgram\ActivityMessage; + +use Pimple\Container; +use Pimple\ServiceProviderInterface; + +class ServiceProvider implements ServiceProviderInterface +{ + /** + * {@inheritdoc}. + */ + public function register(Container $app) + { + $app['activity_message'] = function ($app) { + return new Client($app); + }; + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/AppCode/Client.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/AppCode/Client.php new file mode 100644 index 0000000..82d2af2 --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/AppCode/Client.php @@ -0,0 +1,92 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\MiniProgram\AppCode; + +use EasyWeChat\Kernel\BaseClient; +use EasyWeChat\Kernel\Http\StreamResponse; + +/** + * Class Client. + * + * @author mingyoung + */ +class Client extends BaseClient +{ + /** + * Get AppCode. + * + * @param string $path + * @param array $optional + * + * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string + */ + public function get(string $path, array $optional = []) + { + $params = array_merge([ + 'path' => $path, + ], $optional); + + return $this->getStream('wxa/getwxacode', $params); + } + + /** + * Get AppCode unlimit. + * + * @param string $scene + * @param array $optional + * + * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string + */ + public function getUnlimit(string $scene, array $optional = []) + { + $params = array_merge([ + 'scene' => $scene, + ], $optional); + + return $this->getStream('wxa/getwxacodeunlimit', $params); + } + + /** + * Create QrCode. + * + * @param string $path + * @param int|null $width + * + * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string + */ + public function getQrCode(string $path, int $width = null) + { + return $this->getStream('cgi-bin/wxaapp/createwxaqrcode', compact('path', 'width')); + } + + /** + * Get stream. + * + * @param string $endpoint + * @param array $params + * + * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + protected function getStream(string $endpoint, array $params) + { + $response = $this->requestRaw($endpoint, 'POST', ['json' => $params]); + + if (false !== stripos($response->getHeaderLine('Content-disposition'), 'attachment')) { + return StreamResponse::buildFromPsrResponse($response); + } + + return $this->castResponseToType($response, $this->app['config']->get('response_type')); + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/AppCode/ServiceProvider.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/AppCode/ServiceProvider.php new file mode 100644 index 0000000..fefdc22 --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/AppCode/ServiceProvider.php @@ -0,0 +1,33 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\MiniProgram\AppCode; + +use Pimple\Container; +use Pimple\ServiceProviderInterface; + +/** + * Class ServiceProvider. + * + * @author mingyoung + */ +class ServiceProvider implements ServiceProviderInterface +{ + /** + * {@inheritdoc}. + */ + public function register(Container $app) + { + $app['app_code'] = function ($app) { + return new Client($app); + }; + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/Application.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/Application.php new file mode 100644 index 0000000..4f81ff7 --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/Application.php @@ -0,0 +1,83 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\MiniProgram; + +use EasyWeChat\BasicService; +use EasyWeChat\Kernel\ServiceContainer; + +/** + * Class Application. + * + * @author mingyoung + * + * @property \EasyWeChat\MiniProgram\Auth\AccessToken $access_token + * @property \EasyWeChat\MiniProgram\DataCube\Client $data_cube + * @property \EasyWeChat\MiniProgram\AppCode\Client $app_code + * @property \EasyWeChat\MiniProgram\Auth\Client $auth + * @property \EasyWeChat\OfficialAccount\Server\Guard $server + * @property \EasyWeChat\MiniProgram\Encryptor $encryptor + * @property \EasyWeChat\MiniProgram\TemplateMessage\Client $template_message + * @property \EasyWeChat\OfficialAccount\CustomerService\Client $customer_service + * @property \EasyWeChat\MiniProgram\Plugin\Client $plugin + * @property \EasyWeChat\MiniProgram\Plugin\DevClient $plugin_dev + * @property \EasyWeChat\MiniProgram\UniformMessage\Client $uniform_message + * @property \EasyWeChat\MiniProgram\ActivityMessage\Client $activity_message + * @property \EasyWeChat\MiniProgram\Express\Client $logistics + * @property \EasyWeChat\MiniProgram\NearbyPoi\Client $nearby_poi + * @property \EasyWeChat\MiniProgram\OCR\Client $ocr + * @property \EasyWeChat\MiniProgram\Soter\Client $soter + * @property \EasyWeChat\BasicService\Media\Client $media + * @property \EasyWeChat\BasicService\ContentSecurity\Client $content_security + * @property \EasyWeChat\MiniProgram\Mall\ForwardsMall $mall + * @property \EasyWeChat\MiniProgram\SubscribeMessage\Client $subscribe_message + */ +class Application extends ServiceContainer +{ + /** + * @var array + */ + protected $providers = [ + Auth\ServiceProvider::class, + DataCube\ServiceProvider::class, + AppCode\ServiceProvider::class, + Server\ServiceProvider::class, + TemplateMessage\ServiceProvider::class, + CustomerService\ServiceProvider::class, + UniformMessage\ServiceProvider::class, + ActivityMessage\ServiceProvider::class, + OpenData\ServiceProvider::class, + Plugin\ServiceProvider::class, + Base\ServiceProvider::class, + Express\ServiceProvider::class, + NearbyPoi\ServiceProvider::class, + OCR\ServiceProvider::class, + Soter\ServiceProvider::class, + Mall\ServiceProvider::class, + SubscribeMessage\ServiceProvider::class, + // Base services + BasicService\Media\ServiceProvider::class, + BasicService\ContentSecurity\ServiceProvider::class, + ]; + + /** + * Handle dynamic calls. + * + * @param string $method + * @param array $args + * + * @return mixed + */ + public function __call($method, $args) + { + return $this->base->$method(...$args); + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/Auth/AccessToken.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/Auth/AccessToken.php new file mode 100644 index 0000000..8147d25 --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/Auth/AccessToken.php @@ -0,0 +1,39 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\MiniProgram\Auth; + +use EasyWeChat\Kernel\AccessToken as BaseAccessToken; + +/** + * Class AccessToken. + * + * @author mingyoung + */ +class AccessToken extends BaseAccessToken +{ + /** + * @var string + */ + protected $endpointToGetToken = 'https://api.weixin.qq.com/cgi-bin/token'; + + /** + * {@inheritdoc} + */ + protected function getCredentials(): array + { + return [ + 'grant_type' => 'client_credential', + 'appid' => $this->app['config']['app_id'], + 'secret' => $this->app['config']['secret'], + ]; + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/Auth/Client.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/Auth/Client.php new file mode 100644 index 0000000..90d2c88 --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/Auth/Client.php @@ -0,0 +1,43 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\MiniProgram\Auth; + +use EasyWeChat\Kernel\BaseClient; + +/** + * Class Auth. + * + * @author mingyoung + */ +class Client extends BaseClient +{ + /** + * Get session info by code. + * + * @param string $code + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + */ + public function session(string $code) + { + $params = [ + 'appid' => $this->app['config']['app_id'], + 'secret' => $this->app['config']['secret'], + 'js_code' => $code, + 'grant_type' => 'authorization_code', + ]; + + return $this->httpGet('sns/jscode2session', $params); + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/Auth/ServiceProvider.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/Auth/ServiceProvider.php new file mode 100644 index 0000000..fcb687b --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/Auth/ServiceProvider.php @@ -0,0 +1,32 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\MiniProgram\Auth; + +use Pimple\Container; +use Pimple\ServiceProviderInterface; + +class ServiceProvider implements ServiceProviderInterface +{ + /** + * {@inheritdoc}. + */ + public function register(Container $app) + { + !isset($app['access_token']) && $app['access_token'] = function ($app) { + return new AccessToken($app); + }; + + !isset($app['auth']) && $app['auth'] = function ($app) { + return new Client($app); + }; + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/Base/Client.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/Base/Client.php new file mode 100644 index 0000000..84d6b81 --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/Base/Client.php @@ -0,0 +1,38 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\MiniProgram\Base; + +use EasyWeChat\Kernel\BaseClient; + +/** + * Class Client. + * + * @author mingyoung + */ +class Client extends BaseClient +{ + /** + * Get paid unionid. + * + * @param string $openid + * @param array $options + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function getPaidUnionid($openid, $options = []) + { + return $this->httpGet('wxa/getpaidunionid', compact('openid') + $options); + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/Base/ServiceProvider.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/Base/ServiceProvider.php new file mode 100644 index 0000000..d9aa41b --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/Base/ServiceProvider.php @@ -0,0 +1,33 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\MiniProgram\Base; + +use Pimple\Container; +use Pimple\ServiceProviderInterface; + +/** + * Class ServiceProvider. + * + * @author mingyoung + */ +class ServiceProvider implements ServiceProviderInterface +{ + /** + * {@inheritdoc}. + */ + public function register(Container $app) + { + $app['base'] = function ($app) { + return new Client($app); + }; + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/CustomerService/ServiceProvider.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/CustomerService/ServiceProvider.php new file mode 100644 index 0000000..cfd3039 --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/CustomerService/ServiceProvider.php @@ -0,0 +1,34 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\MiniProgram\CustomerService; + +use EasyWeChat\OfficialAccount\CustomerService\Client; +use Pimple\Container; +use Pimple\ServiceProviderInterface; + +/** + * Class ServiceProvider. + * + * @author overtrue + */ +class ServiceProvider implements ServiceProviderInterface +{ + /** + * {@inheritdoc}. + */ + public function register(Container $app) + { + $app['customer_service'] = function ($app) { + return new Client($app); + }; + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/DataCube/Client.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/DataCube/Client.php new file mode 100644 index 0000000..8a10b7e --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/DataCube/Client.php @@ -0,0 +1,174 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\MiniProgram\DataCube; + +use EasyWeChat\Kernel\BaseClient; + +/** + * Class Client. + * + * @author mingyoung + */ +class Client extends BaseClient +{ + /** + * Get summary trend. + * + * @param string $from + * @param string $to + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + */ + public function summaryTrend(string $from, string $to) + { + return $this->query('datacube/getweanalysisappiddailysummarytrend', $from, $to); + } + + /** + * Get daily visit trend. + * + * @param string $from + * @param string $to + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + */ + public function dailyVisitTrend(string $from, string $to) + { + return $this->query('datacube/getweanalysisappiddailyvisittrend', $from, $to); + } + + /** + * Get weekly visit trend. + * + * @param string $from + * @param string $to + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + */ + public function weeklyVisitTrend(string $from, string $to) + { + return $this->query('datacube/getweanalysisappidweeklyvisittrend', $from, $to); + } + + /** + * Get monthly visit trend. + * + * @param string $from + * @param string $to + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + */ + public function monthlyVisitTrend(string $from, string $to) + { + return $this->query('datacube/getweanalysisappidmonthlyvisittrend', $from, $to); + } + + /** + * Get visit distribution. + * + * @param string $from + * @param string $to + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + */ + public function visitDistribution(string $from, string $to) + { + return $this->query('datacube/getweanalysisappidvisitdistribution', $from, $to); + } + + /** + * Get daily retain info. + * + * @param string $from + * @param string $to + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + */ + public function dailyRetainInfo(string $from, string $to) + { + return $this->query('datacube/getweanalysisappiddailyretaininfo', $from, $to); + } + + /** + * Get weekly retain info. + * + * @param string $from + * @param string $to + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + */ + public function weeklyRetainInfo(string $from, string $to) + { + return $this->query('datacube/getweanalysisappidweeklyretaininfo', $from, $to); + } + + /** + * Get monthly retain info. + * + * @param string $from + * @param string $to + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + */ + public function monthlyRetainInfo(string $from, string $to) + { + return $this->query('datacube/getweanalysisappidmonthlyretaininfo', $from, $to); + } + + /** + * Get visit page. + * + * @param string $from + * @param string $to + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + */ + public function visitPage(string $from, string $to) + { + return $this->query('datacube/getweanalysisappidvisitpage', $from, $to); + } + + /** + * Get user portrait. + * + * @param string $from + * @param string $to + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + */ + public function userPortrait(string $from, string $to) + { + return $this->query('datacube/getweanalysisappiduserportrait', $from, $to); + } + + /** + * Unify query. + * + * @param string $api + * @param string $from + * @param string $to + * + * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + protected function query(string $api, string $from, string $to) + { + $params = [ + 'begin_date' => $from, + 'end_date' => $to, + ]; + + return $this->httpPostJson($api, $params); + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/DataCube/ServiceProvider.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/DataCube/ServiceProvider.php new file mode 100644 index 0000000..258d7c4 --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/DataCube/ServiceProvider.php @@ -0,0 +1,28 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\MiniProgram\DataCube; + +use Pimple\Container; +use Pimple\ServiceProviderInterface; + +class ServiceProvider implements ServiceProviderInterface +{ + /** + * {@inheritdoc}. + */ + public function register(Container $app) + { + $app['data_cube'] = function ($app) { + return new Client($app); + }; + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/Encryptor.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/Encryptor.php new file mode 100644 index 0000000..167a2a0 --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/Encryptor.php @@ -0,0 +1,50 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\MiniProgram; + +use EasyWeChat\Kernel\Encryptor as BaseEncryptor; +use EasyWeChat\Kernel\Exceptions\DecryptException; +use EasyWeChat\Kernel\Support\AES; + +/** + * Class Encryptor. + * + * @author mingyoung + */ +class Encryptor extends BaseEncryptor +{ + /** + * Decrypt data. + * + * @param string $sessionKey + * @param string $iv + * @param string $encrypted + * + * @return array + * + * @throws \EasyWeChat\Kernel\Exceptions\DecryptException + */ + public function decryptData(string $sessionKey, string $iv, string $encrypted): array + { + $decrypted = AES::decrypt( + base64_decode($encrypted, false), base64_decode($sessionKey, false), base64_decode($iv, false) + ); + + $decrypted = json_decode($this->pkcs7Unpad($decrypted), true); + + if (!$decrypted) { + throw new DecryptException('The given payload is invalid.'); + } + + return $decrypted; + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/Express/Client.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/Express/Client.php new file mode 100644 index 0000000..a0311c8 --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/Express/Client.php @@ -0,0 +1,133 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\MiniProgram\Express; + +use EasyWeChat\Kernel\BaseClient; + +/** + * Class Client. + * + * @author kehuanhuan <1152018701@qq.com> + */ +class Client extends BaseClient +{ + /** + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + */ + public function listProviders() + { + return $this->httpGet('cgi-bin/express/business/delivery/getall'); + } + + /** + * @param array $params + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function createWaybill(array $params = []) + { + return $this->httpPostJson('cgi-bin/express/business/order/add', $params); + } + + /** + * @param array $params + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function deleteWaybill(array $params = []) + { + return $this->httpPostJson('cgi-bin/express/business/order/cancel', $params); + } + + /** + * @param array $params + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function getWaybill(array $params = []) + { + return $this->httpPostJson('cgi-bin/express/business/order/get', $params); + } + + /** + * @param array $params + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function getWaybillTrack(array $params = []) + { + return $this->httpPostJson('cgi-bin/express/business/path/get', $params); + } + + /** + * @param string $deliveryId + * @param string $bizId + * + * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function getBalance(string $deliveryId, string $bizId) + { + return $this->httpPostJson('cgi-bin/express/business/quota/get', [ + 'delivery_id' => $deliveryId, + 'biz_id' => $bizId, + ]); + } + + /** + * @param string $openid + * + * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function bindPrinter(string $openid) + { + return $this->httpPostJson('cgi-bin/express/business/printer/update', [ + 'update_type' => 'bind', + 'openid' => $openid, + ]); + } + + /** + * @param string $openid + * + * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function unbindPrinter(string $openid) + { + return $this->httpPostJson('cgi-bin/express/business/printer/update', [ + 'update_type' => 'unbind', + 'openid' => $openid, + ]); + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/Express/ServiceProvider.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/Express/ServiceProvider.php new file mode 100644 index 0000000..4794094 --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/Express/ServiceProvider.php @@ -0,0 +1,33 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\MiniProgram\Express; + +use Pimple\Container; +use Pimple\ServiceProviderInterface; + +/** + * Class ServiceProvider. + * + * @author kehuanhuan <1152018701@qq.com> + */ +class ServiceProvider implements ServiceProviderInterface +{ + /** + * {@inheritdoc}. + */ + public function register(Container $app) + { + $app['express'] = function ($app) { + return new Client($app); + }; + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/Mall/CartClient.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/Mall/CartClient.php new file mode 100644 index 0000000..7a07e77 --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/Mall/CartClient.php @@ -0,0 +1,88 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\MiniProgram\Mall; + +use EasyWeChat\Kernel\BaseClient; + +/** + * Class Client. + * + * @author mingyoung + */ +class CartClient extends BaseClient +{ + /** + * 导入收藏. + * + * @param array $params + * @param bool $isTest + * + * @return mixed + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function add($params, $isTest = false) + { + return $this->httpPostJson('mall/addshoppinglist', $params, ['is_test' => (int) $isTest]); + } + + /** + * 查询用户收藏信息. + * + * @param array $params + * + * @return mixed + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function query($params) + { + return $this->httpPostJson('mall/queryshoppinglist', $params, ['type' => 'batchquery']); + } + + /** + * 查询用户收藏信息. + * + * @param array $params + * + * @return mixed + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function queryByPage($params) + { + return $this->httpPostJson('mall/queryshoppinglist', $params, ['type' => 'getbypage']); + } + + /** + * 删除收藏. + * + * @param string $openid + * @param array $products + * + * @return mixed + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function delete($openid, array $products = []) + { + if (empty($products)) { + return $this->httpPostJson('mall/deletebizallshoppinglist', ['user_open_id' => $openid]); + } + + return $this->httpPostJson('mall/deleteshoppinglist', ['user_open_id' => $openid, 'sku_product_list' => $products]); + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/Mall/ForwardsMall.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/Mall/ForwardsMall.php new file mode 100644 index 0000000..f727b17 --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/Mall/ForwardsMall.php @@ -0,0 +1,48 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\MiniProgram\Mall; + +/** + * Class Application. + * + * @author mingyoung + * + * @property \EasyWeChat\MiniProgram\Mall\OrderClient $order + * @property \EasyWeChat\MiniProgram\Mall\CartClient $cart + * @property \EasyWeChat\MiniProgram\Mall\ProductClient $product + * @property \EasyWeChat\MiniProgram\Mall\MediaClient $media + */ +class ForwardsMall +{ + /** + * @var \EasyWeChat\Kernel\ServiceContainer + */ + protected $app; + + /** + * @param \EasyWeChat\Kernel\ServiceContainer $app + */ + public function __construct($app) + { + $this->app = $app; + } + + /** + * @param string $property + * + * @return mixed + */ + public function __get($property) + { + return $this->app["mall.{$property}"]; + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/Mall/MediaClient.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/Mall/MediaClient.php new file mode 100644 index 0000000..a3827bc --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/Mall/MediaClient.php @@ -0,0 +1,37 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\MiniProgram\Mall; + +use EasyWeChat\Kernel\BaseClient; + +/** + * Class Client. + * + * @author mingyoung + */ +class MediaClient extends BaseClient +{ + /** + * 更新或导入媒体信息. + * + * @param array $params + * + * @return mixed + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function import($params) + { + return $this->httpPostJson('mall/importmedia', $params); + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/Mall/OrderClient.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/Mall/OrderClient.php new file mode 100644 index 0000000..9879695 --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/Mall/OrderClient.php @@ -0,0 +1,75 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\MiniProgram\Mall; + +use EasyWeChat\Kernel\BaseClient; + +/** + * Class Client. + * + * @author mingyoung + */ +class OrderClient extends BaseClient +{ + /** + * 导入订单. + * + * @param array $params + * @param bool $isHistory + * + * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function add($params, $isHistory = false) + { + return $this->httpPostJson('mall/importorder', $params, ['action' => 'add-order', 'is_history' => (int) $isHistory]); + } + + /** + * 导入订单. + * + * @param array $params + * @param bool $isHistory + * + * @return mixed + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function update($params, $isHistory = false) + { + return $this->httpPostJson('mall/importorder', $params, ['action' => 'update-order', 'is_history' => (int) $isHistory]); + } + + /** + * 删除订单. + * + * @param string $openid + * @param string $orderId + * + * @return mixed + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function delete($openid, $orderId) + { + $params = [ + 'user_open_id' => $openid, + 'order_id' => $orderId, + ]; + + return $this->httpPostJson('mall/deleteorder', $params); + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/Mall/ProductClient.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/Mall/ProductClient.php new file mode 100644 index 0000000..f7fbfd0 --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/Mall/ProductClient.php @@ -0,0 +1,68 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\MiniProgram\Mall; + +use EasyWeChat\Kernel\BaseClient; + +/** + * Class Client. + * + * @author mingyoung + */ +class ProductClient extends BaseClient +{ + /** + * 更新或导入物品信息. + * + * @param array $params + * @param bool $isTest + * + * @return mixed + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function import($params, $isTest = false) + { + return $this->httpPostJson('mall/importproduct', $params, ['is_test' => (int) $isTest]); + } + + /** + * 查询物品信息. + * + * @param array $params + * + * @return mixed + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function query($params) + { + return $this->httpPostJson('mall/queryproduct', $params, ['type' => 'batchquery']); + } + + /** + * 小程序的物品是否可被搜索. + * + * @param bool $value + * + * @return mixed + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function setSearchable($value) + { + return $this->httpPostJson('mall/brandmanage', ['can_be_search' => $value], ['action' => 'set_biz_can_be_search']); + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/Mall/ServiceProvider.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/Mall/ServiceProvider.php new file mode 100644 index 0000000..964395b --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/Mall/ServiceProvider.php @@ -0,0 +1,44 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\MiniProgram\Mall; + +use Pimple\Container; +use Pimple\ServiceProviderInterface; + +class ServiceProvider implements ServiceProviderInterface +{ + /** + * {@inheritdoc}. + */ + public function register(Container $app) + { + $app['mall'] = function ($app) { + return new ForwardsMall($app); + }; + + $app['mall.order'] = function ($app) { + return new OrderClient($app); + }; + + $app['mall.cart'] = function ($app) { + return new CartClient($app); + }; + + $app['mall.product'] = function ($app) { + return new ProductClient($app); + }; + + $app['mall.media'] = function ($app) { + return new MediaClient($app); + }; + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/NearbyPoi/Client.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/NearbyPoi/Client.php new file mode 100644 index 0000000..da9ee05 --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/NearbyPoi/Client.php @@ -0,0 +1,123 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\MiniProgram\NearbyPoi; + +use EasyWeChat\Kernel\BaseClient; +use EasyWeChat\Kernel\Exceptions\InvalidArgumentException; + +/** + * Class Client. + * + * @author joyeekk + */ +class Client extends BaseClient +{ + /** + * Add nearby poi. + * + * @param array $params + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function add(array $params) + { + $params = array_merge([ + 'is_comm_nearby' => '1', + 'poi_id' => '', + ], $params); + + return $this->httpPostJson('wxa/addnearbypoi', $params); + } + + /** + * Update nearby poi. + * + * @param string $poiId + * @param array $params + * + * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function update(string $poiId, array $params) + { + $params = array_merge([ + 'is_comm_nearby' => '1', + 'poi_id' => $poiId, + ], $params); + + return $this->httpPostJson('wxa/addnearbypoi', $params); + } + + /** + * Delete nearby poi. + * + * @param string $poiId + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function delete(string $poiId) + { + return $this->httpPostJson('wxa/delnearbypoi', [ + 'poi_id' => $poiId, + ]); + } + + /** + * Get nearby poi list. + * + * @param int $page + * @param int $pageRows + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + */ + public function list(int $page, int $pageRows) + { + return $this->httpGet('wxa/getnearbypoilist', [ + 'page' => $page, + 'page_rows' => $pageRows, + ]); + } + + /** + * Set nearby poi show status. + * + * @param string $poiId + * @param int $status + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function setVisibility(string $poiId, int $status) + { + if (!in_array($status, [0, 1], true)) { + throw new InvalidArgumentException('status should be 0 or 1.'); + } + + return $this->httpPostJson('wxa/setnearbypoishowstatus', [ + 'poi_id' => $poiId, + 'status' => $status, + ]); + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/NearbyPoi/ServiceProvider.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/NearbyPoi/ServiceProvider.php new file mode 100644 index 0000000..cb15bb3 --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/NearbyPoi/ServiceProvider.php @@ -0,0 +1,33 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\MiniProgram\NearbyPoi; + +use Pimple\Container; +use Pimple\ServiceProviderInterface; + +/** + * Class ServiceProvider. + * + * @author joyeekk + */ +class ServiceProvider implements ServiceProviderInterface +{ + /** + * {@inheritdoc}. + */ + public function register(Container $app) + { + $app['nearby_poi'] = function ($app) { + return new Client($app); + }; + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/OCR/ServiceProvider.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/OCR/ServiceProvider.php new file mode 100644 index 0000000..80e0001 --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/OCR/ServiceProvider.php @@ -0,0 +1,34 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\MiniProgram\OCR; + +use EasyWeChat\OfficialAccount\OCR\Client; +use Pimple\Container; +use Pimple\ServiceProviderInterface; + +/** + * Class ServiceProvider. + * + * @author joyeekk + */ +class ServiceProvider implements ServiceProviderInterface +{ + /** + * {@inheritdoc}. + */ + public function register(Container $app) + { + $app['ocr'] = function ($app) { + return new Client($app); + }; + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/OpenData/Client.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/OpenData/Client.php new file mode 100644 index 0000000..c9472c6 --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/OpenData/Client.php @@ -0,0 +1,96 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\MiniProgram\OpenData; + +use EasyWeChat\Kernel\BaseClient; + +/** + * Class Client. + * + * @author tianyong90 <412039588@qq.com> + */ +class Client extends BaseClient +{ + /** + * @var string + */ + protected $baseUri = 'https://api.weixin.qq.com/wxa/'; + + /** + * removeUserStorage. + * + * @param string $openid + * @param string $sessionKey + * @param array $key + * + * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function removeUserStorage(string $openid, string $sessionKey, array $key) + { + $data = ['key' => $key]; + $query = [ + 'openid' => $openid, + 'sig_method' => 'hmac_sha256', + 'signature' => hash_hmac('sha256', json_encode($data), $sessionKey), + ]; + + return $this->httpPostJson('remove_user_storage', $data, $query); + } + + /** + * setUserStorage. + * + * @param string $openid + * @param string $sessionKey + * @param array $kvList + * + * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function setUserStorage(string $openid, string $sessionKey, array $kvList) + { + $kvList = $this->formatKVLists($kvList); + + $data = ['kv_list' => $kvList]; + $query = [ + 'openid' => $openid, + 'sig_method' => 'hmac_sha256', + 'signature' => hash_hmac('sha256', json_encode($data), $sessionKey), + ]; + + return $this->httpPostJson('set_user_storage', $data, $query); + } + + /** + * @param array $params + * + * @return array + */ + protected function formatKVLists(array $params) + { + $formatted = []; + + foreach ($params as $name => $value) { + $formatted[] = [ + 'key' => $name, + 'value' => strval($value), + ]; + } + + return $formatted; + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/OpenData/ServiceProvider.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/OpenData/ServiceProvider.php new file mode 100644 index 0000000..3ea1287 --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/OpenData/ServiceProvider.php @@ -0,0 +1,28 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\MiniProgram\OpenData; + +use Pimple\Container; +use Pimple\ServiceProviderInterface; + +class ServiceProvider implements ServiceProviderInterface +{ + /** + * {@inheritdoc}. + */ + public function register(Container $app) + { + $app['open_data'] = function ($app) { + return new Client($app); + }; + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/Plugin/Client.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/Plugin/Client.php new file mode 100644 index 0000000..cd885cc --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/Plugin/Client.php @@ -0,0 +1,67 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\MiniProgram\Plugin; + +use EasyWeChat\Kernel\BaseClient; + +/** + * Class Client. + * + * @author mingyoung + */ +class Client extends BaseClient +{ + /** + * @param string $appId + * + * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function apply($appId) + { + return $this->httpPostJson('wxa/plugin', [ + 'action' => 'apply', + 'plugin_appid' => $appId, + ]); + } + + /** + * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function list() + { + return $this->httpPostJson('wxa/plugin', [ + 'action' => 'list', + ]); + } + + /** + * @param string $appId + * + * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function unbind($appId) + { + return $this->httpPostJson('wxa/plugin', [ + 'action' => 'unbind', + 'plugin_appid' => $appId, + ]); + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/Plugin/DevClient.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/Plugin/DevClient.php new file mode 100644 index 0000000..3f25edc --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/Plugin/DevClient.php @@ -0,0 +1,93 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\MiniProgram\Plugin; + +use EasyWeChat\Kernel\BaseClient; + +/** + * Class DevClient. + * + * @author her-cat + */ +class DevClient extends BaseClient +{ + /** + * Get users. + * + * @param int $page + * @param int $size + * + * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function getUsers(int $page = 1, int $size = 10) + { + return $this->httpPostJson('wxa/devplugin', [ + 'action' => 'dev_apply_list', + 'page' => $page, + 'num' => $size, + ]); + } + + /** + * Agree to use plugin. + * + * @param string $appId + * + * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function agree(string $appId) + { + return $this->httpPostJson('wxa/devplugin', [ + 'action' => 'dev_agree', + 'appid' => $appId, + ]); + } + + /** + * Refuse to use plugin. + * + * @param string $reason + * + * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function refuse(string $reason) + { + return $this->httpPostJson('wxa/devplugin', [ + 'action' => 'dev_refuse', + 'reason' => $reason, + ]); + } + + /** + * Delete rejected applications. + * + * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function delete() + { + return $this->httpPostJson('wxa/devplugin', [ + 'action' => 'dev_delete', + ]); + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/Plugin/ServiceProvider.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/Plugin/ServiceProvider.php new file mode 100644 index 0000000..097c77e --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/Plugin/ServiceProvider.php @@ -0,0 +1,42 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\MiniProgram\Plugin; + +use Pimple\Container; +use Pimple\ServiceProviderInterface; + +/** + * Class ServiceProvider. + * + * @author mingyoung + */ +class ServiceProvider implements ServiceProviderInterface +{ + /** + * Registers services on the given container. + * + * This method should only be used to configure services and parameters. + * It should not get services. + * + * @param \Pimple\Container $app + */ + public function register(Container $app) + { + $app['plugin'] = function ($app) { + return new Client($app); + }; + + $app['plugin_dev'] = function ($app) { + return new DevClient($app); + }; + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/Server/ServiceProvider.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/Server/ServiceProvider.php new file mode 100644 index 0000000..0586bb9 --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/Server/ServiceProvider.php @@ -0,0 +1,42 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\MiniProgram\Server; + +use EasyWeChat\MiniProgram\Encryptor; +use EasyWeChat\OfficialAccount\Server\Guard; +use EasyWeChat\OfficialAccount\Server\Handlers\EchoStrHandler; +use Pimple\Container; +use Pimple\ServiceProviderInterface; + +class ServiceProvider implements ServiceProviderInterface +{ + /** + * {@inheritdoc}. + */ + public function register(Container $app) + { + !isset($app['encryptor']) && $app['encryptor'] = function ($app) { + return new Encryptor( + $app['config']['app_id'], + $app['config']['token'], + $app['config']['aes_key'] + ); + }; + + !isset($app['server']) && $app['server'] = function ($app) { + $guard = new Guard($app); + $guard->push(new EchoStrHandler($app)); + + return $guard; + }; + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/Soter/Client.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/Soter/Client.php new file mode 100644 index 0000000..cdf66d7 --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/Soter/Client.php @@ -0,0 +1,41 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\MiniProgram\Soter; + +use EasyWeChat\Kernel\BaseClient; + +/** + * Class Client. + * + * @author her-cat + */ +class Client extends BaseClient +{ + /** + * @param string $openid + * @param string $json + * @param string $signature + * + * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function verifySignature(string $openid, string $json, string $signature) + { + return $this->httpPostJson('cgi-bin/soter/verify_signature', [ + 'openid' => $openid, + 'json_string' => $json, + 'json_signature' => $signature, + ]); + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/Soter/ServiceProvider.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/Soter/ServiceProvider.php new file mode 100644 index 0000000..c8520db --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/Soter/ServiceProvider.php @@ -0,0 +1,33 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\MiniProgram\Soter; + +use Pimple\Container; +use Pimple\ServiceProviderInterface; + +/** + * Class ServiceProvider. + * + * @author her-cat + */ +class ServiceProvider implements ServiceProviderInterface +{ + /** + * {@inheritdoc} + */ + public function register(Container $app) + { + $app['soter'] = function ($app) { + return new Client($app); + }; + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/SubscribeMessage/Client.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/SubscribeMessage/Client.php new file mode 100644 index 0000000..a9a7dfe --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/SubscribeMessage/Client.php @@ -0,0 +1,208 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\MiniProgram\SubscribeMessage; + +use EasyWeChat\Kernel\BaseClient; +use EasyWeChat\Kernel\Exceptions\InvalidArgumentException; +use ReflectionClass; + +/** + * Class Client. + * + * @author hugo + */ +class Client extends BaseClient +{ + /** + * {@inheritdoc}. + */ + protected $message = [ + 'touser' => '', + 'template_id' => '', + 'page' => '', + 'data' => [], + ]; + + /** + * {@inheritdoc}. + */ + protected $required = ['touser', 'template_id', 'data']; + + /** + * Send a template message. + * + * @param array $data + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function send(array $data = []) + { + $params = $this->formatMessage($data); + + $this->restoreMessage(); + + return $this->httpPostJson('cgi-bin/message/subscribe/send', $params); + } + + /** + * @param array $data + * + * @return array + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException + */ + protected function formatMessage(array $data = []) + { + $params = array_merge($this->message, $data); + + foreach ($params as $key => $value) { + if (in_array($key, $this->required, true) && empty($value) && empty($this->message[$key])) { + throw new InvalidArgumentException(sprintf('Attribute "%s" can not be empty!', $key)); + } + + $params[$key] = empty($value) ? $this->message[$key] : $value; + } + + foreach ($params['data'] as $key => $value) { + if (is_array($value)) { + if (isset($value['value'])) { + $params['data'][$key] = ['value' => $value['value']]; + + continue; + } + + if (count($value) >= 1) { + $value = [ + 'value' => $value[0], +// 'color' => $value[1],// color unsupported + ]; + } + } else { + $value = [ + 'value' => strval($value), + ]; + } + + $params['data'][$key] = $value; + } + + return $params; + } + + /** + * Restore message. + */ + protected function restoreMessage() + { + $this->message = (new ReflectionClass(static::class))->getDefaultProperties()['message']; + } + + /** + * Combine templates and add them to your personal template library under your account. + * + * @param string $tid + * @param array $kidList + * @param string|null $sceneDesc + * + * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function addTemplate(string $tid, array $kidList, string $sceneDesc = null) + { + $sceneDesc = $sceneDesc ?? ''; + $data = \compact('tid', 'kidList', 'sceneDesc'); + + return $this->httpPost('wxaapi/newtmpl/addtemplate', $data); + } + + /** + * Delete personal template under account. + * + * @param string $id + * + * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function deleteTemplate(string $id) + { + return $this->httpPost('wxaapi/newtmpl/deltemplate', ['priTmplId' => $id]); + } + + /** + * Get keyword list under template title. + * + * @param string $tid + * + * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function getTemplateKeywords(string $tid) + { + return $this->httpGet('wxaapi/newtmpl/getpubtemplatekeywords', compact('tid')); + } + + /** + * Get the title of the public template under the category to which the account belongs. + * + * @param array $ids + * @param int $start + * @param int $limit + * + * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function getTemplateTitles(array $ids, int $start = 0, int $limit = 30) + { + $ids = \implode(',', $ids); + $query = \compact('ids', 'start', 'limit'); + + return $this->httpGet('wxaapi/newtmpl/getpubtemplatetitles', $query); + } + + /** + * Get list of personal templates under the current account. + * + * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function getTemplates() + { + return $this->httpGet('wxaapi/newtmpl/gettemplate'); + } + + /** + * Get the category of the applet account. + * + * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function getCategory() + { + return $this->httpGet('wxaapi/newtmpl/getcategory'); + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/SubscribeMessage/ServiceProvider.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/SubscribeMessage/ServiceProvider.php new file mode 100644 index 0000000..726b3ed --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/SubscribeMessage/ServiceProvider.php @@ -0,0 +1,28 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\MiniProgram\SubscribeMessage; + +use Pimple\Container; +use Pimple\ServiceProviderInterface; + +class ServiceProvider implements ServiceProviderInterface +{ + /** + * {@inheritdoc}. + */ + public function register(Container $app) + { + $app['subscribe_message'] = function ($app) { + return new Client($app); + }; + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/TemplateMessage/Client.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/TemplateMessage/Client.php new file mode 100644 index 0000000..08f8a3b --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/TemplateMessage/Client.php @@ -0,0 +1,114 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\MiniProgram\TemplateMessage; + +use EasyWeChat\OfficialAccount\TemplateMessage\Client as BaseClient; + +/** + * Class Client. + * + * @author mingyoung + */ +class Client extends BaseClient +{ + const API_SEND = 'cgi-bin/message/wxopen/template/send'; + + /** + * {@inheritdoc}. + */ + protected $message = [ + 'touser' => '', + 'template_id' => '', + 'page' => '', + 'form_id' => '', + 'data' => [], + 'emphasis_keyword' => '', + ]; + + /** + * {@inheritdoc}. + */ + protected $required = ['touser', 'template_id', 'form_id']; + + /** + * @param int $offset + * @param int $count + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function list(int $offset, int $count) + { + return $this->httpPostJson('cgi-bin/wxopen/template/library/list', compact('offset', 'count')); + } + + /** + * @param string $id + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function get(string $id) + { + return $this->httpPostJson('cgi-bin/wxopen/template/library/get', compact('id')); + } + + /** + * @param string $id + * @param array $keyword + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function add(string $id, array $keyword) + { + return $this->httpPostJson('cgi-bin/wxopen/template/add', [ + 'id' => $id, + 'keyword_id_list' => $keyword, + ]); + } + + /** + * @param string $templateId + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function delete(string $templateId) + { + return $this->httpPostJson('cgi-bin/wxopen/template/del', [ + 'template_id' => $templateId, + ]); + } + + /** + * @param int $offset + * @param int $count + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function getTemplates(int $offset, int $count) + { + return $this->httpPostJson('cgi-bin/wxopen/template/list', compact('offset', 'count')); + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/TemplateMessage/ServiceProvider.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/TemplateMessage/ServiceProvider.php new file mode 100644 index 0000000..776a15e --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/TemplateMessage/ServiceProvider.php @@ -0,0 +1,28 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\MiniProgram\TemplateMessage; + +use Pimple\Container; +use Pimple\ServiceProviderInterface; + +class ServiceProvider implements ServiceProviderInterface +{ + /** + * {@inheritdoc}. + */ + public function register(Container $app) + { + $app['template_message'] = function ($app) { + return new Client($app); + }; + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/UniformMessage/Client.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/UniformMessage/Client.php new file mode 100644 index 0000000..6acb13e --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/UniformMessage/Client.php @@ -0,0 +1,146 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\MiniProgram\UniformMessage; + +use EasyWeChat\Kernel\Exceptions\InvalidArgumentException; +use EasyWeChat\OfficialAccount\TemplateMessage\Client as BaseClient; + +class Client extends BaseClient +{ + const API_SEND = 'cgi-bin/message/wxopen/template/uniform_send'; + + /** + * {@inheritdoc}. + * + * @var array + */ + protected $message = [ + 'touser' => '', + ]; + + /** + * Weapp Attributes. + * + * @var array + */ + protected $weappMessage = [ + 'template_id' => '', + 'page' => '', + 'form_id' => '', + 'data' => [], + 'emphasis_keyword' => '', + ]; + + /** + * Official account attributes. + * + * @var array + */ + protected $mpMessage = [ + 'appid' => '', + 'template_id' => '', + 'url' => '', + 'miniprogram' => [], + 'data' => [], + ]; + + /** + * Required attributes. + * + * @var array + */ + protected $required = ['touser', 'template_id', 'form_id', 'miniprogram', 'appid']; + + /** + * @param array $data + * + * @return array + * + * @throws InvalidArgumentException + */ + protected function formatMessage(array $data = []) + { + $params = array_merge($this->message, $data); + + if (empty($params['touser'])) { + throw new InvalidArgumentException(sprintf('Attribute "touser" can not be empty!')); + } + + if (!empty($params['weapp_template_msg'])) { + $params['weapp_template_msg'] = $this->formatWeappMessage($params['weapp_template_msg']); + } + + if (!empty($params['mp_template_msg'])) { + $params['mp_template_msg'] = $this->formatMpMessage($params['mp_template_msg']); + } + + return $params; + } + + /** + * @param array $data + * + * @return array + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException + */ + protected function formatWeappMessage(array $data = []) + { + $params = $this->baseFormat($data, $this->weappMessage); + + $params['data'] = $this->formatData($params['data'] ?? []); + + return $params; + } + + /** + * @param array $data + * + * @return array + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException + */ + protected function formatMpMessage(array $data = []) + { + $params = $this->baseFormat($data, $this->mpMessage); + + if (empty($params['miniprogram']['appid'])) { + $params['miniprogram']['appid'] = $this->app['config']['app_id']; + } + + $params['data'] = $this->formatData($params['data'] ?? []); + + return $params; + } + + /** + * @param array $data + * @param array $default + * + * @return array + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException + */ + protected function baseFormat($data = [], $default = []) + { + $params = array_merge($default, $data); + foreach ($params as $key => $value) { + if (in_array($key, $this->required, true) && empty($value) && empty($default[$key])) { + throw new InvalidArgumentException(sprintf('Attribute "%s" can not be empty!', $key)); + } + + $params[$key] = empty($value) ? $default[$key] : $value; + } + + return $params; + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/UniformMessage/ServiceProvider.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/UniformMessage/ServiceProvider.php new file mode 100644 index 0000000..0e86db3 --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/MiniProgram/UniformMessage/ServiceProvider.php @@ -0,0 +1,28 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\MiniProgram\UniformMessage; + +use Pimple\Container; +use Pimple\ServiceProviderInterface; + +class ServiceProvider implements ServiceProviderInterface +{ + /** + * {@inheritdoc}. + */ + public function register(Container $app) + { + $app['uniform_message'] = function ($app) { + return new Client($app); + }; + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Application.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Application.php new file mode 100644 index 0000000..745363f --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Application.php @@ -0,0 +1,88 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\OfficialAccount; + +use EasyWeChat\BasicService; +use EasyWeChat\Kernel\ServiceContainer; + +/** + * Class Application. + * + * @author overtrue + * + * @property \EasyWeChat\BasicService\Media\Client $media + * @property \EasyWeChat\BasicService\Url\Client $url + * @property \EasyWeChat\BasicService\QrCode\Client $qrcode + * @property \EasyWeChat\BasicService\Jssdk\Client $jssdk + * @property \EasyWeChat\OfficialAccount\Auth\AccessToken $access_token + * @property \EasyWeChat\OfficialAccount\Server\Guard $server + * @property \EasyWeChat\OfficialAccount\User\UserClient $user + * @property \EasyWeChat\OfficialAccount\User\TagClient $user_tag + * @property \EasyWeChat\OfficialAccount\Menu\Client $menu + * @property \EasyWeChat\OfficialAccount\TemplateMessage\Client $template_message + * @property \EasyWeChat\OfficialAccount\Material\Client $material + * @property \EasyWeChat\OfficialAccount\CustomerService\Client $customer_service + * @property \EasyWeChat\OfficialAccount\CustomerService\SessionClient $customer_service_session + * @property \EasyWeChat\OfficialAccount\Semantic\Client $semantic + * @property \EasyWeChat\OfficialAccount\DataCube\Client $data_cube + * @property \EasyWeChat\OfficialAccount\AutoReply\Client $auto_reply + * @property \EasyWeChat\OfficialAccount\Broadcasting\Client $broadcasting + * @property \EasyWeChat\OfficialAccount\Card\Card $card + * @property \EasyWeChat\OfficialAccount\Device\Client $device + * @property \EasyWeChat\OfficialAccount\ShakeAround\ShakeAround $shake_around + * @property \EasyWeChat\OfficialAccount\POI\Client $poi + * @property \EasyWeChat\OfficialAccount\Store\Client $store + * @property \EasyWeChat\OfficialAccount\Base\Client $base + * @property \EasyWeChat\OfficialAccount\Comment\Client $comment + * @property \EasyWeChat\OfficialAccount\OCR\Client $ocr + * @property \EasyWeChat\OfficialAccount\Goods\Client $goods + * @property \Overtrue\Socialite\Providers\WeChatProvider $oauth + * @property \EasyWeChat\OfficialAccount\WiFi\Client $wifi + * @property \EasyWeChat\OfficialAccount\WiFi\CardClient $wifi_card + * @property \EasyWeChat\OfficialAccount\WiFi\DeviceClient $wifi_device + * @property \EasyWeChat\OfficialAccount\WiFi\ShopClient $wifi_shop + */ +class Application extends ServiceContainer +{ + /** + * @var array + */ + protected $providers = [ + Auth\ServiceProvider::class, + Server\ServiceProvider::class, + User\ServiceProvider::class, + OAuth\ServiceProvider::class, + Menu\ServiceProvider::class, + TemplateMessage\ServiceProvider::class, + Material\ServiceProvider::class, + CustomerService\ServiceProvider::class, + Semantic\ServiceProvider::class, + DataCube\ServiceProvider::class, + POI\ServiceProvider::class, + AutoReply\ServiceProvider::class, + Broadcasting\ServiceProvider::class, + Card\ServiceProvider::class, + Device\ServiceProvider::class, + ShakeAround\ServiceProvider::class, + Store\ServiceProvider::class, + Comment\ServiceProvider::class, + Base\ServiceProvider::class, + OCR\ServiceProvider::class, + Goods\ServiceProvider::class, + WiFi\ServiceProvider::class, + // Base services + BasicService\QrCode\ServiceProvider::class, + BasicService\Media\ServiceProvider::class, + BasicService\Url\ServiceProvider::class, + BasicService\Jssdk\ServiceProvider::class, + ]; +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Auth/AccessToken.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Auth/AccessToken.php new file mode 100644 index 0000000..aca1aca --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Auth/AccessToken.php @@ -0,0 +1,39 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\OfficialAccount\Auth; + +use EasyWeChat\Kernel\AccessToken as BaseAccessToken; + +/** + * Class AuthorizerAccessToken. + * + * @author overtrue + */ +class AccessToken extends BaseAccessToken +{ + /** + * @var string + */ + protected $endpointToGetToken = 'https://api.weixin.qq.com/cgi-bin/token'; + + /** + * @return array + */ + protected function getCredentials(): array + { + return [ + 'grant_type' => 'client_credential', + 'appid' => $this->app['config']['app_id'], + 'secret' => $this->app['config']['secret'], + ]; + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Auth/ServiceProvider.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Auth/ServiceProvider.php new file mode 100644 index 0000000..e748730 --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Auth/ServiceProvider.php @@ -0,0 +1,33 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\OfficialAccount\Auth; + +use Pimple\Container; +use Pimple\ServiceProviderInterface; + +/** + * Class ServiceProvider. + * + * @author overtrue + */ +class ServiceProvider implements ServiceProviderInterface +{ + /** + * {@inheritdoc}. + */ + public function register(Container $app) + { + !isset($app['access_token']) && $app['access_token'] = function ($app) { + return new AccessToken($app); + }; + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/AutoReply/Client.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/AutoReply/Client.php new file mode 100644 index 0000000..6d2e4d6 --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/AutoReply/Client.php @@ -0,0 +1,34 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\OfficialAccount\AutoReply; + +use EasyWeChat\Kernel\BaseClient; + +/** + * Class Client. + * + * @author overtrue + */ +class Client extends BaseClient +{ + /** + * Get current auto reply settings. + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + */ + public function current() + { + return $this->httpGet('cgi-bin/get_current_autoreply_info'); + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/AutoReply/ServiceProvider.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/AutoReply/ServiceProvider.php new file mode 100644 index 0000000..4377550 --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/AutoReply/ServiceProvider.php @@ -0,0 +1,33 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\OfficialAccount\AutoReply; + +use Pimple\Container; +use Pimple\ServiceProviderInterface; + +/** + * Class ServiceProvider. + * + * @author overtrue + */ +class ServiceProvider implements ServiceProviderInterface +{ + /** + * {@inheritdoc}. + */ + public function register(Container $app) + { + $app['auto_reply'] = function ($app) { + return new Client($app); + }; + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Base/Client.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Base/Client.php new file mode 100644 index 0000000..ce8abc5 --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Base/Client.php @@ -0,0 +1,84 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\OfficialAccount\Base; + +use EasyWeChat\Kernel\BaseClient; +use EasyWeChat\Kernel\Exceptions\InvalidArgumentException; + +/** + * Class Client. + * + * @author mingyoung + */ +class Client extends BaseClient +{ + /** + * Clear quota. + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function clearQuota() + { + $params = [ + 'appid' => $this->app['config']['app_id'], + ]; + + return $this->httpPostJson('cgi-bin/clear_quota', $params); + } + + /** + * Get wechat callback ip. + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + */ + public function getValidIps() + { + return $this->httpGet('cgi-bin/getcallbackip'); + } + + /** + * Check the callback address network. + * + * @param string $action + * @param string $operator + * + * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string + * + * @throws InvalidArgumentException + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function checkCallbackUrl(string $action = 'all', string $operator = 'DEFAULT') + { + if (!in_array($action, ['dns', 'ping', 'all'], true)) { + throw new InvalidArgumentException('The action must be dns, ping, all.'); + } + + $operator = strtoupper($operator); + + if (!in_array($operator, ['CHINANET', 'UNICOM', 'CAP', 'DEFAULT'], true)) { + throw new InvalidArgumentException('The operator must be CHINANET, UNICOM, CAP, DEFAULT.'); + } + + $params = [ + 'action' => $action, + 'check_operator' => $operator, + ]; + + return $this->httpPostJson('cgi-bin/callback/check', $params); + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Base/ServiceProvider.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Base/ServiceProvider.php new file mode 100644 index 0000000..409593d --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Base/ServiceProvider.php @@ -0,0 +1,33 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\OfficialAccount\Base; + +use Pimple\Container; +use Pimple\ServiceProviderInterface; + +/** + * Class ServiceProvider. + * + * @author mingyoung + */ +class ServiceProvider implements ServiceProviderInterface +{ + /** + * {@inheritdoc}. + */ + public function register(Container $app) + { + $app['base'] = function ($app) { + return new Client($app); + }; + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Broadcasting/Client.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Broadcasting/Client.php new file mode 100644 index 0000000..6c2eee1 --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Broadcasting/Client.php @@ -0,0 +1,383 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\OfficialAccount\Broadcasting; + +use EasyWeChat\Kernel\BaseClient; +use EasyWeChat\Kernel\Contracts\MessageInterface; +use EasyWeChat\Kernel\Exceptions\RuntimeException; +use EasyWeChat\Kernel\Messages\Card; +use EasyWeChat\Kernel\Messages\Image; +use EasyWeChat\Kernel\Messages\Media; +use EasyWeChat\Kernel\Messages\Text; +use EasyWeChat\Kernel\Support\Arr; + +/** + * Class Client. + * + * @method \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string previewTextByName($text, $name); + * @method \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string previewNewsByName($mediaId, $name); + * @method \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string previewVoiceByName($mediaId, $name); + * @method \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string previewImageByName($mediaId, $name); + * @method \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string previewVideoByName($message, $name); + * @method \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string previewCardByName($cardId, $name); + * + * @author overtrue + */ +class Client extends BaseClient +{ + const PREVIEW_BY_OPENID = 'touser'; + const PREVIEW_BY_NAME = 'towxname'; + + /** + * Send a message. + * + * @param array $message + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \EasyWeChat\Kernel\Exceptions\RuntimeException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function send(array $message) + { + if (empty($message['filter']) && empty($message['touser'])) { + throw new RuntimeException('The message reception object is not specified'); + } + + $api = Arr::get($message, 'touser') ? 'cgi-bin/message/mass/send' : 'cgi-bin/message/mass/sendall'; + + return $this->httpPostJson($api, $message); + } + + /** + * Preview a message. + * + * @param array $message + * + * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function preview(array $message) + { + return $this->httpPostJson('cgi-bin/message/mass/preview', $message); + } + + /** + * Delete a broadcast. + * + * @param string $msgId + * @param int $index + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function delete(string $msgId, int $index = 0) + { + $options = [ + 'msg_id' => $msgId, + 'article_idx' => $index, + ]; + + return $this->httpPostJson('cgi-bin/message/mass/delete', $options); + } + + /** + * Get a broadcast status. + * + * @param string $msgId + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function status(string $msgId) + { + $options = [ + 'msg_id' => $msgId, + ]; + + return $this->httpPostJson('cgi-bin/message/mass/get', $options); + } + + /** + * Send a text message. + * + * @param string $message + * @param mixed $reception + * @param array $attributes + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \EasyWeChat\Kernel\Exceptions\RuntimeException + */ + public function sendText(string $message, $reception = null, array $attributes = []) + { + return $this->sendMessage(new Text($message), $reception, $attributes); + } + + /** + * Send a news message. + * + * @param string $mediaId + * @param mixed $reception + * @param array $attributes + * + * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \EasyWeChat\Kernel\Exceptions\RuntimeException + */ + public function sendNews(string $mediaId, $reception = null, array $attributes = []) + { + return $this->sendMessage(new Media($mediaId, 'mpnews'), $reception, $attributes); + } + + /** + * Send a voice message. + * + * @param string $mediaId + * @param mixed $reception + * @param array $attributes + * + * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \EasyWeChat\Kernel\Exceptions\RuntimeException + */ + public function sendVoice(string $mediaId, $reception = null, array $attributes = []) + { + return $this->sendMessage(new Media($mediaId, 'voice'), $reception, $attributes); + } + + /** + * Send a image message. + * + * @param string $mediaId + * @param mixed $reception + * @param array $attributes + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \EasyWeChat\Kernel\Exceptions\RuntimeException + */ + public function sendImage(string $mediaId, $reception = null, array $attributes = []) + { + return $this->sendMessage(new Image($mediaId), $reception, $attributes); + } + + /** + * Send a video message. + * + * @param string $mediaId + * @param mixed $reception + * @param array $attributes + * + * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \EasyWeChat\Kernel\Exceptions\RuntimeException + */ + public function sendVideo(string $mediaId, $reception = null, array $attributes = []) + { + return $this->sendMessage(new Media($mediaId, 'mpvideo'), $reception, $attributes); + } + + /** + * Send a card message. + * + * @param string $cardId + * @param mixed $reception + * @param array $attributes + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \EasyWeChat\Kernel\Exceptions\RuntimeException + */ + public function sendCard(string $cardId, $reception = null, array $attributes = []) + { + return $this->sendMessage(new Card($cardId), $reception, $attributes); + } + + /** + * Preview a text message. + * + * @param string $message message + * @param string $reception + * @param string $method + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\RuntimeException + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + */ + public function previewText(string $message, $reception, $method = self::PREVIEW_BY_OPENID) + { + return $this->previewMessage(new Text($message), $reception, $method); + } + + /** + * Preview a news message. + * + * @param string $mediaId message + * @param string $reception + * @param string $method + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\RuntimeException + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + */ + public function previewNews(string $mediaId, $reception, $method = self::PREVIEW_BY_OPENID) + { + return $this->previewMessage(new Media($mediaId, 'mpnews'), $reception, $method); + } + + /** + * Preview a voice message. + * + * @param string $mediaId message + * @param string $reception + * @param string $method + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\RuntimeException + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + */ + public function previewVoice(string $mediaId, $reception, $method = self::PREVIEW_BY_OPENID) + { + return $this->previewMessage(new Media($mediaId, 'voice'), $reception, $method); + } + + /** + * Preview a image message. + * + * @param string $mediaId message + * @param string $reception + * @param string $method + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\RuntimeException + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + */ + public function previewImage(string $mediaId, $reception, $method = self::PREVIEW_BY_OPENID) + { + return $this->previewMessage(new Image($mediaId), $reception, $method); + } + + /** + * Preview a video message. + * + * @param string $mediaId message + * @param string $reception + * @param string $method + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\RuntimeException + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + */ + public function previewVideo(string $mediaId, $reception, $method = self::PREVIEW_BY_OPENID) + { + return $this->previewMessage(new Media($mediaId, 'mpvideo'), $reception, $method); + } + + /** + * Preview a card message. + * + * @param string $cardId message + * @param string $reception + * @param string $method + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\RuntimeException + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + */ + public function previewCard(string $cardId, $reception, $method = self::PREVIEW_BY_OPENID) + { + return $this->previewMessage(new Card($cardId), $reception, $method); + } + + /** + * @param \EasyWeChat\Kernel\Contracts\MessageInterface $message + * @param string $reception + * @param string $method + * + * @return mixed + * + * @throws \EasyWeChat\Kernel\Exceptions\RuntimeException + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + */ + public function previewMessage(MessageInterface $message, string $reception, $method = self::PREVIEW_BY_OPENID) + { + $message = (new MessageBuilder())->message($message)->buildForPreview($method, $reception); + + return $this->preview($message); + } + + /** + * @param \EasyWeChat\Kernel\Contracts\MessageInterface $message + * @param mixed $reception + * @param array $attributes + * + * @return mixed + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \EasyWeChat\Kernel\Exceptions\RuntimeException + */ + public function sendMessage(MessageInterface $message, $reception = null, $attributes = []) + { + $message = (new MessageBuilder())->message($message)->with($attributes)->toAll(); + + if (\is_int($reception)) { + $message->toTag($reception); + } elseif (\is_array($reception)) { + $message->toUsers($reception); + } + + return $this->send($message->build()); + } + + /** + * @codeCoverageIgnore + * + * @param string $method + * @param array $args + * + * @return mixed + */ + public function __call($method, $args) + { + if (strpos($method, 'ByName') > 0) { + $method = strstr($method, 'ByName', true); + + if (method_exists($this, $method)) { + array_push($args, self::PREVIEW_BY_NAME); + + return $this->$method(...$args); + } + } + + throw new \BadMethodCallException(sprintf('Method %s not exists.', $method)); + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Broadcasting/MessageBuilder.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Broadcasting/MessageBuilder.php new file mode 100644 index 0000000..70465b0 --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Broadcasting/MessageBuilder.php @@ -0,0 +1,162 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\OfficialAccount\Broadcasting; + +use EasyWeChat\Kernel\Contracts\MessageInterface; +use EasyWeChat\Kernel\Exceptions\RuntimeException; + +/** + * Class MessageBuilder. + * + * @author overtrue + */ +class MessageBuilder +{ + /** + * @var array + */ + protected $to = []; + + /** + * @var \EasyWeChat\Kernel\Contracts\MessageInterface + */ + protected $message; + + /** + * @var array + */ + protected $attributes = []; + + /** + * Set message. + * + * @param \EasyWeChat\Kernel\Contracts\MessageInterface $message + * + * @return $this + */ + public function message(MessageInterface $message) + { + $this->message = $message; + + return $this; + } + + /** + * Set target user or group. + * + * @param array $to + * + * @return $this + */ + public function to(array $to) + { + $this->to = $to; + + return $this; + } + + /** + * @param int $tagId + * + * @return \EasyWeChat\OfficialAccount\Broadcasting\MessageBuilder + */ + public function toTag(int $tagId) + { + $this->to([ + 'filter' => [ + 'is_to_all' => false, + 'tag_id' => $tagId, + ], + ]); + + return $this; + } + + /** + * @param array $openids + * + * @return \EasyWeChat\OfficialAccount\Broadcasting\MessageBuilder + */ + public function toUsers(array $openids) + { + $this->to([ + 'touser' => $openids, + ]); + + return $this; + } + + /** + * @return $this + */ + public function toAll() + { + $this->to([ + 'filter' => ['is_to_all' => true], + ]); + + return $this; + } + + /** + * @param array $attributes + * + * @return \EasyWeChat\OfficialAccount\Broadcasting\MessageBuilder + */ + public function with(array $attributes) + { + $this->attributes = $attributes; + + return $this; + } + + /** + * Build message. + * + * @param array $prepends + * + * @return array + * + * @throws \EasyWeChat\Kernel\Exceptions\RuntimeException + */ + public function build(array $prepends = []): array + { + if (empty($this->message)) { + throw new RuntimeException('No message content to send.'); + } + + $content = $this->message->transformForJsonRequest(); + + if (empty($prepends)) { + $prepends = $this->to; + } + + $message = array_merge($prepends, $content, $this->attributes); + + return $message; + } + + /** + * Build preview message. + * + * @param string $by + * @param string $user + * + * @return array + * + * @throws \EasyWeChat\Kernel\Exceptions\RuntimeException + */ + public function buildForPreview(string $by, string $user): array + { + return $this->build([$by => $user]); + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Broadcasting/ServiceProvider.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Broadcasting/ServiceProvider.php new file mode 100644 index 0000000..1f956cf --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Broadcasting/ServiceProvider.php @@ -0,0 +1,33 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\OfficialAccount\Broadcasting; + +use Pimple\Container; +use Pimple\ServiceProviderInterface; + +/** + * Class ServiceProvider. + * + * @author overtrue + */ +class ServiceProvider implements ServiceProviderInterface +{ + /** + * {@inheritdoc}. + */ + public function register(Container $app) + { + $app['broadcasting'] = function ($app) { + return new Client($app); + }; + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Card/BoardingPassClient.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Card/BoardingPassClient.php new file mode 100644 index 0000000..b1575ab --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Card/BoardingPassClient.php @@ -0,0 +1,33 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\OfficialAccount\Card; + +/** + * Class BoardingPassClient. + * + * @author overtrue + */ +class BoardingPassClient extends Client +{ + /** + * @param array $params + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function checkin(array $params) + { + return $this->httpPostJson('card/boardingpass/checkin', $params); + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Card/Card.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Card/Card.php new file mode 100644 index 0000000..14e817b --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Card/Card.php @@ -0,0 +1,52 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\OfficialAccount\Card; + +use EasyWeChat\Kernel\Exceptions\InvalidArgumentException; + +/** + * Class Card. + * + * @author overtrue + * + * @property \EasyWeChat\OfficialAccount\Card\CodeClient $code + * @property \EasyWeChat\OfficialAccount\Card\MeetingTicketClient $meeting_ticket + * @property \EasyWeChat\OfficialAccount\Card\MemberCardClient $member_card + * @property \EasyWeChat\OfficialAccount\Card\GeneralCardClient $general_card + * @property \EasyWeChat\OfficialAccount\Card\MovieTicketClient $movie_ticket + * @property \EasyWeChat\OfficialAccount\Card\CoinClient $coin + * @property \EasyWeChat\OfficialAccount\Card\SubMerchantClient $sub_merchant + * @property \EasyWeChat\OfficialAccount\Card\BoardingPassClient $boarding_pass + * @property \EasyWeChat\OfficialAccount\Card\JssdkClient $jssdk + * @property \EasyWeChat\OfficialAccount\Card\GiftCardClient $gift_card + * @property \EasyWeChat\OfficialAccount\Card\GiftCardOrderClient $gift_card_order + * @property \EasyWeChat\OfficialAccount\Card\GiftCardPageClient $gift_card_page + * @property \EasyWeChat\OfficialAccount\Card\InvoiceClient $invoice + */ +class Card extends Client +{ + /** + * @param string $property + * + * @return mixed + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException + */ + public function __get($property) + { + if (isset($this->app["card.{$property}"])) { + return $this->app["card.{$property}"]; + } + + throw new InvalidArgumentException(sprintf('No card service named "%s".', $property)); + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Card/Client.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Card/Client.php new file mode 100644 index 0000000..5737d52 --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Card/Client.php @@ -0,0 +1,428 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\OfficialAccount\Card; + +use EasyWeChat\Kernel\BaseClient; +use EasyWeChat\Kernel\Traits\InteractsWithCache; + +/** + * Class Client. + * + * @author overtrue + */ +class Client extends BaseClient +{ + use InteractsWithCache; + + /** + * @var string + */ + protected $url; + + /** + * Ticket cache key. + * + * @var string + */ + protected $ticketCacheKey; + + /** + * Ticket cache prefix. + * + * @var string + */ + protected $ticketCachePrefix = 'easywechat.official_account.card.api_ticket.'; + + /** + * 获取卡券颜色. + * + * @return mixed + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + */ + public function colors() + { + return $this->httpGet('card/getcolors'); + } + + /** + * 卡券开放类目查询接口. + * + * @return mixed + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + */ + public function categories() + { + return $this->httpGet('card/getapplyprotocol'); + } + + /** + * 创建卡券. + * + * @param string $cardType + * @param array $attributes + * + * @return mixed + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function create($cardType = 'member_card', array $attributes) + { + $params = [ + 'card' => [ + 'card_type' => strtoupper($cardType), + strtolower($cardType) => $attributes, + ], + ]; + + return $this->httpPostJson('card/create', $params); + } + + /** + * 查看卡券详情. + * + * @param string $cardId + * + * @return mixed + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function get($cardId) + { + $params = [ + 'card_id' => $cardId, + ]; + + return $this->httpPostJson('card/get', $params); + } + + /** + * 批量查询卡列表. + * + * @param int $offset + * @param int $count + * @param string $statusList + * + * @return mixed + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function list($offset = 0, $count = 10, $statusList = 'CARD_STATUS_VERIFY_OK') + { + $params = [ + 'offset' => $offset, + 'count' => $count, + 'status_list' => $statusList, + ]; + + return $this->httpPostJson('card/batchget', $params); + } + + /** + * 更改卡券信息接口 and 设置跟随推荐接口. + * + * @param string $cardId + * @param string $type + * @param array $attributes + * + * @return mixed + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function update($cardId, $type, array $attributes = []) + { + $card = []; + $card['card_id'] = $cardId; + $card[strtolower($type)] = $attributes; + + return $this->httpPostJson('card/update', $card); + } + + /** + * 删除卡券接口. + * + * @param string $cardId + * + * @return mixed + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function delete($cardId) + { + $params = [ + 'card_id' => $cardId, + ]; + + return $this->httpPostJson('card/delete', $params); + } + + /** + * 创建二维码. + * + * @param array $cards + * + * @return mixed + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function createQrCode(array $cards) + { + return $this->httpPostJson('card/qrcode/create', $cards); + } + + /** + * ticket 换取二维码图片. + * + * @param string $ticket + * + * @return array + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function getQrCode($ticket) + { + $baseUri = 'https://mp.weixin.qq.com/cgi-bin/showqrcode'; + $params = [ + 'ticket' => $ticket, + ]; + + $response = $this->requestRaw($baseUri, 'GET', $params); + + return [ + 'status' => $response->getStatusCode(), + 'reason' => $response->getReasonPhrase(), + 'headers' => $response->getHeaders(), + 'body' => strval($response->getBody()), + 'url' => $baseUri.'?'.http_build_query($params), + ]; + } + + /** + * 通过ticket换取二维码 链接. + * + * @param string $ticket + * + * @return string + */ + public function getQrCodeUrl($ticket) + { + return sprintf('https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=%s', $ticket); + } + + /** + * 创建货架接口. + * + * @param string $banner + * @param string $pageTitle + * @param bool $canShare + * @param string $scene [SCENE_NEAR_BY 附近,SCENE_MENU 自定义菜单,SCENE_QRCODE 二维码,SCENE_ARTICLE 公众号文章, + * SCENE_H5 h5页面,SCENE_IVR 自动回复,SCENE_CARD_CUSTOM_CELL 卡券自定义cell] + * @param array $cardList + * + * @return mixed + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function createLandingPage($banner, $pageTitle, $canShare, $scene, $cardList) + { + $params = [ + 'banner' => $banner, + 'page_title' => $pageTitle, + 'can_share' => $canShare, + 'scene' => $scene, + 'card_list' => $cardList, + ]; + + return $this->httpPostJson('card/landingpage/create', $params); + } + + /** + * 图文消息群发卡券. + * + * @param string $cardId + * + * @return mixed + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function getHtml($cardId) + { + $params = [ + 'card_id' => $cardId, + ]; + + return $this->httpPostJson('card/mpnews/gethtml', $params); + } + + /** + * 设置测试白名单. + * + * @param array $openids + * + * @return mixed + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function setTestWhitelist($openids) + { + $params = [ + 'openid' => $openids, + ]; + + return $this->httpPostJson('card/testwhitelist/set', $params); + } + + /** + * 设置测试白名单(by username). + * + * @param array $usernames + * + * @return mixed + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function setTestWhitelistByName(array $usernames) + { + $params = [ + 'username' => $usernames, + ]; + + return $this->httpPostJson('card/testwhitelist/set', $params); + } + + /** + * 获取用户已领取卡券接口. + * + * @param string $openid + * @param string $cardId + * + * @return mixed + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function getUserCards($openid, $cardId = '') + { + $params = [ + 'openid' => $openid, + 'card_id' => $cardId, + ]; + + return $this->httpPostJson('card/user/getcardlist', $params); + } + + /** + * 设置微信买单接口. + * 设置买单的 card_id 必须已经配置了门店,否则会报错. + * + * @param string $cardId + * @param bool $isOpen + * + * @return mixed + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function setPayCell($cardId, $isOpen = true) + { + $params = [ + 'card_id' => $cardId, + 'is_open' => $isOpen, + ]; + + return $this->httpPostJson('card/paycell/set', $params); + } + + /** + * 设置自助核销接口 + * 设置买单的 card_id 必须已经配置了门店,否则会报错. + * + * @param string $cardId + * @param bool $isOpen + * @param bool $verifyCod + * @param bool $remarkAmount + * + * @return mixed + */ + public function setPayConsumeCell($cardId, $isOpen = true, $verifyCod = false, $remarkAmount = false) + { + $params = [ + 'card_id' => $cardId, + 'is_open' => $isOpen, + 'need_verify_cod' => $verifyCod, + 'need_remark_amount' => $remarkAmount, + ]; + + return $this->httpPostJson('card/selfconsumecell/set', $params); + } + + /** + * 增加库存. + * + * @param string $cardId + * @param int $amount + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + */ + public function increaseStock($cardId, $amount) + { + return $this->updateStock($cardId, $amount, 'increase'); + } + + /** + * 减少库存. + * + * @param string $cardId + * @param int $amount + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + */ + public function reduceStock($cardId, $amount) + { + return $this->updateStock($cardId, $amount, 'reduce'); + } + + /** + * 修改库存接口. + * + * @param string $cardId + * @param int $amount + * @param string $action + * + * @return mixed + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + protected function updateStock($cardId, $amount, $action = 'increase') + { + $key = 'increase' === $action ? 'increase_stock_value' : 'reduce_stock_value'; + $params = [ + 'card_id' => $cardId, + $key => abs($amount), + ]; + + return $this->httpPostJson('card/modifystock', $params); + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Card/CodeClient.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Card/CodeClient.php new file mode 100644 index 0000000..dcf96da --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Card/CodeClient.php @@ -0,0 +1,193 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\OfficialAccount\Card; + +use EasyWeChat\Kernel\BaseClient; + +/** + * Class CodeClient. + * + * @author overtrue + */ +class CodeClient extends BaseClient +{ + /** + * 导入code接口. + * + * @param string $cardId + * @param array $codes + * + * @return mixed + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function deposit(string $cardId, array $codes) + { + $params = [ + 'card_id' => $cardId, + 'code' => $codes, + ]; + + return $this->httpPostJson('card/code/deposit', $params); + } + + /** + * 查询导入code数目. + * + * @param string $cardId + * + * @return mixed + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function getDepositedCount(string $cardId) + { + $params = [ + 'card_id' => $cardId, + ]; + + return $this->httpPostJson('card/code/getdepositcount', $params); + } + + /** + * 核查code接口. + * + * @param string $cardId + * @param array $codes + * + * @return mixed + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function check(string $cardId, array $codes) + { + $params = [ + 'card_id' => $cardId, + 'code' => $codes, + ]; + + return $this->httpPostJson('card/code/checkcode', $params); + } + + /** + * 查询 Code 接口. + * + * @param string $code + * @param string $cardId + * @param bool $checkConsume + * + * @return mixed + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function get(string $code, string $cardId = '', bool $checkConsume = true) + { + $params = [ + 'code' => $code, + 'check_consume' => $checkConsume, + 'card_id' => $cardId, + ]; + + return $this->httpPostJson('card/code/get', $params); + } + + /** + * 更改Code接口. + * + * @param string $code + * @param string $newCode + * @param string $cardId + * + * @return mixed + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function update(string $code, string $newCode, string $cardId = '') + { + $params = [ + 'code' => $code, + 'new_code' => $newCode, + 'card_id' => $cardId, + ]; + + return $this->httpPostJson('card/code/update', $params); + } + + /** + * 设置卡券失效. + * + * @param string $code + * @param string $cardId + * + * @return mixed + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function disable(string $code, string $cardId = '') + { + $params = [ + 'code' => $code, + 'card_id' => $cardId, + ]; + + return $this->httpPostJson('card/code/unavailable', $params); + } + + /** + * 核销 Code 接口. + * + * @param string $code + * @param string|null $cardId + * + * @return mixed + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function consume(string $code, string $cardId = null) + { + $params = [ + 'code' => $code, + ]; + + if (!is_null($cardId)) { + $params['card_id'] = $cardId; + } + + return $this->httpPostJson('card/code/consume', $params); + } + + /** + * Code解码接口. + * + * @param string $encryptedCode + * + * @return mixed + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function decrypt(string $encryptedCode) + { + $params = [ + 'encrypt_code' => $encryptedCode, + ]; + + return $this->httpPostJson('card/code/decrypt', $params); + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Card/CoinClient.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Card/CoinClient.php new file mode 100644 index 0000000..b99d841 --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Card/CoinClient.php @@ -0,0 +1,119 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\OfficialAccount\Card; + +use EasyWeChat\Kernel\BaseClient; + +/** + * Class CoinClient. + * + * @author overtrue + */ +class CoinClient extends BaseClient +{ + /** + * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + */ + public function activate() + { + return $this->httpGet('card/pay/activate'); + } + + /** + * @param string $cardId + * @param int $quantity + * + * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function getPrice(string $cardId, int $quantity) + { + return $this->httpPostJson('card/pay/getpayprice', [ + 'card_id' => $cardId, + 'quantity' => $quantity, + ]); + } + + /** + * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + */ + public function summary() + { + return $this->httpGet('card/pay/getcoinsinfo'); + } + + /** + * @param int $count + * + * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function recharge(int $count) + { + return $this->httpPostJson('card/pay/recharge', [ + 'coin_count' => $count, + ]); + } + + /** + * @param string $orderId + * + * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function order(string $orderId) + { + return $this->httpPostJson('card/pay/getorder', ['order_id' => $orderId]); + } + + /** + * @param array $filters + * + * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function orders(array $filters) + { + return $this->httpPostJson('card/pay/getorderlist', $filters); + } + + /** + * @param string $cardId + * @param string $orderId + * @param int $quantity + * + * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function confirm(string $cardId, string $orderId, int $quantity) + { + return $this->httpPostJson('card/pay/confirm', [ + 'card_id' => $cardId, + 'order_id' => $orderId, + 'quantity' => $quantity, + ]); + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Card/GeneralCardClient.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Card/GeneralCardClient.php new file mode 100644 index 0000000..1505981 --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Card/GeneralCardClient.php @@ -0,0 +1,71 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\OfficialAccount\Card; + +/** + * Class GeneralCardClient. + * + * @author overtrue + */ +class GeneralCardClient extends Client +{ + /** + * 通用卡接口激活. + * + * @param array $info + * + * @return mixed + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function activate(array $info = []) + { + return $this->httpPostJson('card/generalcard/activate', $info); + } + + /** + * 通用卡撤销激活. + * + * @param string $cardId + * @param string $code + * + * @return mixed + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function deactivate(string $cardId, string $code) + { + $params = [ + 'card_id' => $cardId, + 'code' => $code, + ]; + + return $this->httpPostJson('card/generalcard/unactivate', $params); + } + + /** + * 更新会员信息. + * + * @param array $params + * + * @return mixed + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function updateUser(array $params = []) + { + return $this->httpPostJson('card/generalcard/updateuser', $params); + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Card/GiftCardClient.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Card/GiftCardClient.php new file mode 100644 index 0000000..d8779d0 --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Card/GiftCardClient.php @@ -0,0 +1,74 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\OfficialAccount\Card; + +use EasyWeChat\Kernel\BaseClient; + +/** + * Class GiftCardClient. + * + * @author overtrue + */ +class GiftCardClient extends BaseClient +{ + /** + * 申请微信支付礼品卡权限接口. + * + * @param string $subMchId + * + * @return mixed + */ + public function add(string $subMchId) + { + $params = [ + 'sub_mch_id' => $subMchId, + ]; + + return $this->httpPostJson('card/giftcard/pay/whitelist/add', $params); + } + + /** + * 绑定商户号到礼品卡小程序接口(商户号必须为公众号申请的商户号,否则报错). + * + * @param string $subMchId + * @param string $wxaAppid + * + * @return mixed + */ + public function bind(string $subMchId, string $wxaAppid) + { + $params = [ + 'sub_mch_id' => $subMchId, + 'wxa_appid' => $wxaAppid, + ]; + + return $this->httpPostJson('card/giftcard/pay/submch/bind', $params); + } + + /** + * 上传小程序代码. + * + * @param string $wxaAppid + * @param string $pageId + * + * @return mixed + */ + public function set(string $wxaAppid, string $pageId) + { + $params = [ + 'wxa_appid' => $wxaAppid, + 'page_id' => $pageId, + ]; + + return $this->httpPostJson('card/giftcard/wxa/set', $params); + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Card/GiftCardOrderClient.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Card/GiftCardOrderClient.php new file mode 100644 index 0000000..b4e1b15 --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Card/GiftCardOrderClient.php @@ -0,0 +1,78 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\OfficialAccount\Card; + +use EasyWeChat\Kernel\BaseClient; + +/** + * Class GiftCardOrderClient. + * + * @author overtrue + */ +class GiftCardOrderClient extends BaseClient +{ + /** + * 查询-单个礼品卡订单信息接口. + * + * @param string $orderId + * + * @return mixed + */ + public function get(string $orderId) + { + $params = [ + 'order_id' => $orderId, + ]; + + return $this->httpPostJson('card/giftcard/order/get', $params); + } + + /** + * 查询-批量查询礼品卡订单信息接口. + * + * @param int $beginTime + * @param int $endTime + * @param int $offset + * @param int $count + * @param string $sortType + * + * @return mixed + */ + public function list(int $beginTime, int $endTime, int $offset = 0, int $count = 10, string $sortType = 'ASC') + { + $params = [ + 'begin_time' => $beginTime, + 'end_time' => $endTime, + 'sort_type' => $sortType, + 'offset' => $offset, + 'count' => $count, + ]; + + return $this->httpPostJson('card/giftcard/order/batchget', $params); + } + + /** + * 退款接口. + * + * @param string $orderId + * + * @return mixed + */ + public function refund(string $orderId) + { + $params = [ + 'order_id' => $orderId, + ]; + + return $this->httpPostJson('card/giftcard/order/refund', $params); + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Card/GiftCardPageClient.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Card/GiftCardPageClient.php new file mode 100644 index 0000000..bf36109 --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Card/GiftCardPageClient.php @@ -0,0 +1,102 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\OfficialAccount\Card; + +use EasyWeChat\Kernel\BaseClient; + +/** + * Class GiftCardPageClient. + * + * @author overtrue + */ +class GiftCardPageClient extends BaseClient +{ + /** + * 创建-礼品卡货架接口. + * + * @param array $attributes + * + * @return mixed + */ + public function add(array $attributes) + { + $params = [ + 'page' => $attributes, + ]; + + return $this->httpPostJson('card/giftcard/page/add', $params); + } + + /** + * 查询-礼品卡货架信息接口. + * + * @param string $pageId + * + * @return mixed + */ + public function get(string $pageId) + { + $params = [ + 'page_id' => $pageId, + ]; + + return $this->httpPostJson('card/giftcard/page/get', $params); + } + + /** + * 修改-礼品卡货架信息接口. + * + * @param string $pageId + * @param string $bannerPicUrl + * @param array $themeList + * + * @return mixed + */ + public function update(string $pageId, string $bannerPicUrl, array $themeList) + { + $params = [ + 'page' => [ + 'page_id' => $pageId, + 'banner_pic_url' => $bannerPicUrl, + 'theme_list' => $themeList, + ], + ]; + + return $this->httpPostJson('card/giftcard/page/update', $params); + } + + /** + * 查询-礼品卡货架列表接口. + * + * @return mixed + */ + public function list() + { + return $this->httpPostJson('card/giftcard/page/batchget'); + } + + /** + * 下架-礼品卡货架接口(下架某一个货架或者全部货架). + * + * @param string $pageId + * + * @return mixed + */ + public function setMaintain(string $pageId = '') + { + $params = ($pageId ? ['page_id' => $pageId] : ['all' => true]) + [ + 'maintain' => true, + ]; + + return $this->httpPostJson('card/giftcard/maintain/set', $params); + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Card/InvoiceClient.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Card/InvoiceClient.php new file mode 100644 index 0000000..127b3af --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Card/InvoiceClient.php @@ -0,0 +1,113 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\OfficialAccount\Card; + +use EasyWeChat\Kernel\BaseClient; + +/** + * Class InvoiceClient. + * + * @author overtrue + */ +class InvoiceClient extends BaseClient +{ + /** + * 设置支付后开票信息接口. + * + * @param string $mchid + * @param string $sPappid + * + * @return mixed + */ + public function set(string $mchid, string $sPappid) + { + $params = [ + 'paymch_info' => [ + 'mchid' => $mchid, + 's_pappid' => $sPappid, + ], + ]; + + return $this->setBizAttr('set_pay_mch', $params); + } + + /** + * 查询支付后开票信息接口. + * + * @return mixed + */ + public function get() + { + return $this->setBizAttr('get_pay_mch'); + } + + /** + * 设置授权页字段信息接口. + * + * @param array $userData + * @param array $bizData + * + * @return mixed + */ + public function setAuthField(array $userData, array $bizData) + { + $params = [ + 'auth_field' => [ + 'user_field' => $userData, + 'biz_field' => $bizData, + ], + ]; + + return $this->setBizAttr('set_auth_field', $params); + } + + /** + * 查询授权页字段信息接口. + * + * @return mixed + */ + public function getAuthField() + { + return $this->setBizAttr('get_auth_field'); + } + + /** + * 查询开票信息. + * + * @param string $orderId + * @param string $appId + * + * @return mixed + */ + public function getAuthData(string $appId, string $orderId) + { + $params = [ + 'order_id' => $orderId, + 's_appid' => $appId, + ]; + + return $this->httpPost('card/invoice/getauthdata', $params); + } + + /** + * @param string $action + * @param array $params + * + * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + */ + private function setBizAttr(string $action, array $params = []) + { + return $this->httpPostJson('card/invoice/setbizattr', $params, ['action' => $action]); + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Card/JssdkClient.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Card/JssdkClient.php new file mode 100644 index 0000000..9a6bb51 --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Card/JssdkClient.php @@ -0,0 +1,85 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\OfficialAccount\Card; + +use EasyWeChat\BasicService\Jssdk\Client as Jssdk; +use EasyWeChat\Kernel\Support\Arr; +use function EasyWeChat\Kernel\Support\str_random; + +/** + * Class Jssdk. + * + * @author overtrue + */ +class JssdkClient extends Jssdk +{ + /** + * @param bool $refresh + * @param string $type + * + * @return array + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \EasyWeChat\Kernel\Exceptions\RuntimeException + * @throws \Psr\SimpleCache\InvalidArgumentException + */ + public function getTicket(bool $refresh = false, string $type = 'wx_card'): array + { + return parent::getTicket($refresh, $type); + } + + /** + * 微信卡券:JSAPI 卡券发放. + * + * @param array $cards + * + * @return string + */ + public function assign(array $cards) + { + return json_encode(array_map(function ($card) { + return $this->attachExtension($card['card_id'], $card); + }, $cards)); + } + + /** + * 生成 js添加到卡包 需要的 card_list 项. + * + * @param string $cardId + * @param array $extension + * + * @return array + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \EasyWeChat\Kernel\Exceptions\RuntimeException + * @throws \Psr\SimpleCache\InvalidArgumentException + */ + public function attachExtension($cardId, array $extension = []) + { + $timestamp = time(); + $nonce = str_random(6); + $ticket = $this->getTicket()['ticket']; + + $ext = array_merge(['timestamp' => $timestamp, 'nonce_str' => $nonce], Arr::only( + $extension, + ['code', 'openid', 'outer_id', 'balance', 'fixed_begintimestamp', 'outer_str'] + )); + + $ext['signature'] = $this->dictionaryOrderSignature($ticket, $timestamp, $cardId, $ext['code'] ?? '', $ext['openid'] ?? '', $nonce); + + return [ + 'cardId' => $cardId, + 'cardExt' => json_encode($ext), + ]; + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Card/MeetingTicketClient.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Card/MeetingTicketClient.php new file mode 100644 index 0000000..892c5ad --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Card/MeetingTicketClient.php @@ -0,0 +1,33 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\OfficialAccount\Card; + +/** + * Class MeetingTicketClient. + * + * @author overtrue + */ +class MeetingTicketClient extends Client +{ + /** + * @param array $params + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function updateUser(array $params) + { + return $this->httpPostJson('card/meetingticket/updateuser', $params); + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Card/MemberCardClient.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Card/MemberCardClient.php new file mode 100644 index 0000000..41d051c --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Card/MemberCardClient.php @@ -0,0 +1,123 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\OfficialAccount\Card; + +/** + * Class MemberCardClient. + * + * @author overtrue + */ +class MemberCardClient extends Client +{ + /** + * 会员卡接口激活. + * + * @param array $info + * + * @return mixed + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function activate(array $info = []) + { + return $this->httpPostJson('card/membercard/activate', $info); + } + + /** + * 设置开卡字段接口. + * + * @param string $cardId + * @param array $settings + * + * @return mixed + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function setActivationForm(string $cardId, array $settings) + { + $params = array_merge(['card_id' => $cardId], $settings); + + return $this->httpPostJson('card/membercard/activateuserform/set', $params); + } + + /** + * 拉取会员信息接口. + * + * @param string $cardId + * @param string $code + * + * @return mixed + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function getUser(string $cardId, string $code) + { + $params = [ + 'card_id' => $cardId, + 'code' => $code, + ]; + + return $this->httpPostJson('card/membercard/userinfo/get', $params); + } + + /** + * 更新会员信息. + * + * @param array $params + * + * @return mixed + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function updateUser(array $params = []) + { + return $this->httpPostJson('card/membercard/updateuser', $params); + } + + /** + * 获取用户提交资料. + * + * @param string $activateTicket + * + * @return mixed + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function getActivationForm($activateTicket) + { + $params = [ + 'activate_ticket' => $activateTicket, + ]; + + return $this->httpPostJson('card/membercard/activatetempinfo/get', $params); + } + + /** + * 获取开卡组件链接接口. + * + * @param array $params 包含会员卡ID和随机字符串 + * + * @return string 开卡组件链接 + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function getActivateUrl(array $params = []) + { + return $this->httpPostJson('card/membercard/activate/geturl', $params); + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Card/MovieTicketClient.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Card/MovieTicketClient.php new file mode 100644 index 0000000..e6d9036 --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Card/MovieTicketClient.php @@ -0,0 +1,33 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\OfficialAccount\Card; + +/** + * Class MovieTicketClient. + * + * @author overtrue + */ +class MovieTicketClient extends Client +{ + /** + * @param array $params + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function updateUser(array $params) + { + return $this->httpPostJson('card/movieticket/updateuser', $params); + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Card/ServiceProvider.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Card/ServiceProvider.php new file mode 100644 index 0000000..3807fa3 --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Card/ServiceProvider.php @@ -0,0 +1,89 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\OfficialAccount\Card; + +use Pimple\Container; +use Pimple\ServiceProviderInterface; + +/** + * Class ServiceProvider. + * + * @author overtrue + */ +class ServiceProvider implements ServiceProviderInterface +{ + /** + * {@inheritdoc}. + */ + public function register(Container $app) + { + $app['card'] = function ($app) { + return new Card($app); + }; + + $app['card.client'] = function ($app) { + return new Client($app); + }; + + $app['card.coin'] = function ($app) { + return new CoinClient($app); + }; + + $app['card.sub_merchant'] = function ($app) { + return new SubMerchantClient($app); + }; + + $app['card.code'] = function ($app) { + return new CodeClient($app); + }; + + $app['card.movie_ticket'] = function ($app) { + return new MovieTicketClient($app); + }; + + $app['card.member_card'] = function ($app) { + return new MemberCardClient($app); + }; + + $app['card.general_card'] = function ($app) { + return new GeneralCardClient($app); + }; + + $app['card.boarding_pass'] = function ($app) { + return new BoardingPassClient($app); + }; + + $app['card.meeting_ticket'] = function ($app) { + return new MeetingTicketClient($app); + }; + + $app['card.jssdk'] = function ($app) { + return new JssdkClient($app); + }; + + $app['card.gift_card'] = function ($app) { + return new GiftCardClient($app); + }; + + $app['card.gift_card_order'] = function ($app) { + return new GiftCardOrderClient($app); + }; + + $app['card.gift_card_page'] = function ($app) { + return new GiftCardPageClient($app); + }; + + $app['card.invoice'] = function ($app) { + return new InvoiceClient($app); + }; + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Card/SubMerchantClient.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Card/SubMerchantClient.php new file mode 100644 index 0000000..f058492 --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Card/SubMerchantClient.php @@ -0,0 +1,121 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\OfficialAccount\Card; + +use EasyWeChat\Kernel\BaseClient; +use EasyWeChat\Kernel\Support\Arr; + +/** + * Class SubMerchantClient. + * + * @author overtrue + */ +class SubMerchantClient extends BaseClient +{ + /** + * 添加子商户. + * + * @param array $info + * + * @return mixed + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function create(array $info = []) + { + $params = [ + 'info' => Arr::only($info, [ + 'brand_name', + 'logo_url', + 'protocol', + 'end_time', + 'primary_category_id', + 'secondary_category_id', + 'agreement_media_id', + 'operator_media_id', + 'app_id', + ]), + ]; + + return $this->httpPostJson('card/submerchant/submit', $params); + } + + /** + * 更新子商户. + * + * @param int $merchantId + * @param array $info + * + * @return mixed + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function update(int $merchantId, array $info = []) + { + $params = [ + 'info' => array_merge(['merchant_id' => $merchantId], + Arr::only($info, [ + 'brand_name', + 'logo_url', + 'protocol', + 'end_time', + 'primary_category_id', + 'secondary_category_id', + 'agreement_media_id', + 'operator_media_id', + 'app_id', + ])), + ]; + + return $this->httpPostJson('card/submerchant/update', $params); + } + + /** + * 获取子商户信息. + * + * @param int $merchantId + * + * @return mixed + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function get(int $merchantId) + { + return $this->httpPostJson('card/submerchant/get', ['merchant_id' => $merchantId]); + } + + /** + * 批量获取子商户信息. + * + * @param int $beginId + * @param int $limit + * @param string $status + * + * @return mixed + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function list(int $beginId = 0, int $limit = 50, string $status = 'CHECKING') + { + $params = [ + 'begin_id' => $beginId, + 'limit' => $limit, + 'status' => $status, + ]; + + return $this->httpPostJson('card/submerchant/batchget', $params); + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Comment/Client.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Comment/Client.php new file mode 100644 index 0000000..4f45b74 --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Comment/Client.php @@ -0,0 +1,208 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\OfficialAccount\Comment; + +use EasyWeChat\Kernel\BaseClient; + +/** + * Class Client. + * + * @author overtrue + */ +class Client extends BaseClient +{ + /** + * Open article comment. + * + * @param string $msgId + * @param int|null $index + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function open(string $msgId, int $index = null) + { + $params = [ + 'msg_data_id' => $msgId, + 'index' => $index, + ]; + + return $this->httpPostJson('cgi-bin/comment/open', $params); + } + + /** + * Close comment. + * + * @param string $msgId + * @param int|null $index + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function close(string $msgId, int $index = null) + { + $params = [ + 'msg_data_id' => $msgId, + 'index' => $index, + ]; + + return $this->httpPostJson('cgi-bin/comment/close', $params); + } + + /** + * Get article comments. + * + * @param string $msgId + * @param int $index + * @param int $begin + * @param int $count + * @param int $type + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function list(string $msgId, int $index, int $begin, int $count, int $type = 0) + { + $params = [ + 'msg_data_id' => $msgId, + 'index' => $index, + 'begin' => $begin, + 'count' => $count, + 'type' => $type, + ]; + + return $this->httpPostJson('cgi-bin/comment/list', $params); + } + + /** + * Mark elect comment. + * + * @param string $msgId + * @param int $index + * @param int $commentId + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function markElect(string $msgId, int $index, int $commentId) + { + $params = [ + 'msg_data_id' => $msgId, + 'index' => $index, + 'user_comment_id' => $commentId, + ]; + + return $this->httpPostJson('cgi-bin/comment/markelect', $params); + } + + /** + * Unmark elect comment. + * + * @param string $msgId + * @param int $index + * @param int $commentId + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function unmarkElect(string $msgId, int $index, int $commentId) + { + $params = [ + 'msg_data_id' => $msgId, + 'index' => $index, + 'user_comment_id' => $commentId, + ]; + + return $this->httpPostJson('cgi-bin/comment/unmarkelect', $params); + } + + /** + * Delete comment. + * + * @param string $msgId + * @param int $index + * @param int $commentId + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function delete(string $msgId, int $index, int $commentId) + { + $params = [ + 'msg_data_id' => $msgId, + 'index' => $index, + 'user_comment_id' => $commentId, + ]; + + return $this->httpPostJson('cgi-bin/comment/delete', $params); + } + + /** + * Reply to a comment. + * + * @param string $msgId + * @param int $index + * @param int $commentId + * @param string $content + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function reply(string $msgId, int $index, int $commentId, string $content) + { + $params = [ + 'msg_data_id' => $msgId, + 'index' => $index, + 'user_comment_id' => $commentId, + 'content' => $content, + ]; + + return $this->httpPostJson('cgi-bin/comment/reply/add', $params); + } + + /** + * Delete a reply. + * + * @param string $msgId + * @param int $index + * @param int $commentId + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function deleteReply(string $msgId, int $index, int $commentId) + { + $params = [ + 'msg_data_id' => $msgId, + 'index' => $index, + 'user_comment_id' => $commentId, + ]; + + return $this->httpPostJson('cgi-bin/comment/reply/delete', $params); + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Comment/ServiceProvider.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Comment/ServiceProvider.php new file mode 100644 index 0000000..8d6806c --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Comment/ServiceProvider.php @@ -0,0 +1,44 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +/** + * ServiceProvider.php. + * + * This file is part of the wechat. + * + * (c) overtrue + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\OfficialAccount\Comment; + +use Pimple\Container; +use Pimple\ServiceProviderInterface; + +/** + * Class ServiceProvider. + * + * @author overtrue + */ +class ServiceProvider implements ServiceProviderInterface +{ + /** + * {@inheritdoc}. + */ + public function register(Container $app) + { + $app['comment'] = function ($app) { + return new Client($app); + }; + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/CustomerService/Client.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/CustomerService/Client.php new file mode 100644 index 0000000..64e43e5 --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/CustomerService/Client.php @@ -0,0 +1,230 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\OfficialAccount\CustomerService; + +use EasyWeChat\Kernel\BaseClient; + +/** + * Class Client. + * + * @author overtrue + */ +class Client extends BaseClient +{ + /** + * List all staffs. + * + * @return mixed + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + */ + public function list() + { + return $this->httpGet('cgi-bin/customservice/getkflist'); + } + + /** + * List all online staffs. + * + * @return mixed + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + */ + public function online() + { + return $this->httpGet('cgi-bin/customservice/getonlinekflist'); + } + + /** + * Create a staff. + * + * @param string $account + * @param string $nickname + * + * @return mixed + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function create(string $account, string $nickname) + { + $params = [ + 'kf_account' => $account, + 'nickname' => $nickname, + ]; + + return $this->httpPostJson('customservice/kfaccount/add', $params); + } + + /** + * Update a staff. + * + * @param string $account + * @param string $nickname + * + * @return mixed + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function update(string $account, string $nickname) + { + $params = [ + 'kf_account' => $account, + 'nickname' => $nickname, + ]; + + return $this->httpPostJson('customservice/kfaccount/update', $params); + } + + /** + * Delete a staff. + * + * @param string $account + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function delete(string $account) + { + return $this->httpPostJson('customservice/kfaccount/del', [], ['kf_account' => $account]); + } + + /** + * Invite a staff. + * + * @param string $account + * @param string $wechatId + * + * @return mixed + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function invite(string $account, string $wechatId) + { + $params = [ + 'kf_account' => $account, + 'invite_wx' => $wechatId, + ]; + + return $this->httpPostJson('customservice/kfaccount/inviteworker', $params); + } + + /** + * Set staff avatar. + * + * @param string $account + * @param string $path + * + * @return mixed + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function setAvatar(string $account, string $path) + { + return $this->httpUpload('customservice/kfaccount/uploadheadimg', ['media' => $path], [], ['kf_account' => $account]); + } + + /** + * Get message builder. + * + * @param \EasyWeChat\Kernel\Messages\Message|string $message + * + * @return \EasyWeChat\OfficialAccount\CustomerService\Messenger + */ + public function message($message) + { + $messageBuilder = new Messenger($this); + + return $messageBuilder->message($message); + } + + /** + * Send a message. + * + * @param array $message + * + * @return mixed + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function send(array $message) + { + return $this->httpPostJson('cgi-bin/message/custom/send', $message); + } + + /** + * Show typing status. + * + * @param string $openid + * + * @return mixed + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function showTypingStatusToUser(string $openid) + { + return $this->httpPostJson('cgi-bin/message/custom/typing', [ + 'touser' => $openid, + 'command' => 'Typing', + ]); + } + + /** + * Hide typing status. + * + * @param string $openid + * + * @return mixed + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function hideTypingStatusToUser(string $openid) + { + return $this->httpPostJson('cgi-bin/message/custom/typing', [ + 'touser' => $openid, + 'command' => 'CancelTyping', + ]); + } + + /** + * Get messages history. + * + * @param int $startTime + * @param int $endTime + * @param int $msgId + * @param int $number + * + * @return mixed + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function messages($startTime, $endTime, int $msgId = 1, int $number = 10000) + { + $params = [ + 'starttime' => is_numeric($startTime) ? $startTime : strtotime($startTime), + 'endtime' => is_numeric($endTime) ? $endTime : strtotime($endTime), + 'msgid' => $msgId, + 'number' => $number, + ]; + + return $this->httpPostJson('customservice/msgrecord/getmsglist', $params); + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/CustomerService/Messenger.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/CustomerService/Messenger.php new file mode 100644 index 0000000..69bf2f3 --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/CustomerService/Messenger.php @@ -0,0 +1,165 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\OfficialAccount\CustomerService; + +use EasyWeChat\Kernel\Exceptions\RuntimeException; +use EasyWeChat\Kernel\Messages\Message; +use EasyWeChat\Kernel\Messages\Raw as RawMessage; +use EasyWeChat\Kernel\Messages\Text; + +/** + * Class MessageBuilder. + * + * @author overtrue + */ +class Messenger +{ + /** + * Messages to send. + * + * @var \EasyWeChat\Kernel\Messages\Message; + */ + protected $message; + + /** + * Messages target user open id. + * + * @var string + */ + protected $to; + + /** + * Messages sender staff id. + * + * @var string + */ + protected $account; + + /** + * Customer service instance. + * + * @var \EasyWeChat\OfficialAccount\CustomerService\Client + */ + protected $client; + + /** + * MessageBuilder constructor. + * + * @param \EasyWeChat\OfficialAccount\CustomerService\Client $client + */ + public function __construct(Client $client) + { + $this->client = $client; + } + + /** + * Set message to send. + * + * @param string|Message $message + * + * @return Messenger + */ + public function message($message) + { + if (is_string($message)) { + $message = new Text($message); + } + + $this->message = $message; + + return $this; + } + + /** + * Set staff account to send message. + * + * @param string $account + * + * @return Messenger + */ + public function by(string $account) + { + $this->account = $account; + + return $this; + } + + /** + * @param string $account + * + * @return Messenger + */ + public function from(string $account) + { + return $this->by($account); + } + + /** + * Set target user open id. + * + * @param string $openid + * + * @return Messenger + */ + public function to($openid) + { + $this->to = $openid; + + return $this; + } + + /** + * Send the message. + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \EasyWeChat\Kernel\Exceptions\RuntimeException + */ + public function send() + { + if (empty($this->message)) { + throw new RuntimeException('No message to send.'); + } + + if ($this->message instanceof RawMessage) { + $message = json_decode($this->message->get('content'), true); + } else { + $prepends = [ + 'touser' => $this->to, + ]; + if ($this->account) { + $prepends['customservice'] = ['kf_account' => $this->account]; + } + $message = $this->message->transformForJsonRequest($prepends); + } + + return $this->client->send($message); + } + + /** + * Return property. + * + * @param string $property + * + * @return mixed + */ + public function __get(string $property) + { + if (property_exists($this, $property)) { + return $this->$property; + } + + return null; + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/CustomerService/ServiceProvider.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/CustomerService/ServiceProvider.php new file mode 100644 index 0000000..a879ce8 --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/CustomerService/ServiceProvider.php @@ -0,0 +1,37 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\OfficialAccount\CustomerService; + +use Pimple\Container; +use Pimple\ServiceProviderInterface; + +/** + * Class ServiceProvider. + * + * @author overtrue + */ +class ServiceProvider implements ServiceProviderInterface +{ + /** + * {@inheritdoc}. + */ + public function register(Container $app) + { + $app['customer_service'] = function ($app) { + return new Client($app); + }; + + $app['customer_service_session'] = function ($app) { + return new SessionClient($app); + }; + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/CustomerService/SessionClient.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/CustomerService/SessionClient.php new file mode 100644 index 0000000..b92b6db --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/CustomerService/SessionClient.php @@ -0,0 +1,104 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\OfficialAccount\CustomerService; + +use EasyWeChat\Kernel\BaseClient; + +/** + * Class SessionClient. + * + * @author overtrue + */ +class SessionClient extends BaseClient +{ + /** + * List all sessions of $account. + * + * @param string $account + * + * @return mixed + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + */ + public function list(string $account) + { + return $this->httpGet('customservice/kfsession/getsessionlist', ['kf_account' => $account]); + } + + /** + * List all the people waiting. + * + * @return mixed + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + */ + public function waiting() + { + return $this->httpGet('customservice/kfsession/getwaitcase'); + } + + /** + * Create a session. + * + * @param string $account + * @param string $openid + * + * @return mixed + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function create(string $account, string $openid) + { + $params = [ + 'kf_account' => $account, + 'openid' => $openid, + ]; + + return $this->httpPostJson('customservice/kfsession/create', $params); + } + + /** + * Close a session. + * + * @param string $account + * @param string $openid + * + * @return mixed + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function close(string $account, string $openid) + { + $params = [ + 'kf_account' => $account, + 'openid' => $openid, + ]; + + return $this->httpPostJson('customservice/kfsession/close', $params); + } + + /** + * Get a session. + * + * @param string $openid + * + * @return mixed + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + */ + public function get(string $openid) + { + return $this->httpGet('customservice/kfsession/getsession', ['openid' => $openid]); + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/DataCube/Client.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/DataCube/Client.php new file mode 100644 index 0000000..0bf1c21 --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/DataCube/Client.php @@ -0,0 +1,340 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\OfficialAccount\DataCube; + +use EasyWeChat\Kernel\BaseClient; + +/** + * Class Client. + * + * @author overtrue + */ +class Client extends BaseClient +{ + /** + * 获取用户增减数据. + * + * @param string $from + * @param string $to + * + * @return mixed + */ + public function userSummary(string $from, string $to) + { + return $this->query('datacube/getusersummary', $from, $to); + } + + /** + * 获取累计用户数据. + * + * @param string $from + * @param string $to + * + * @return mixed + */ + public function userCumulate(string $from, string $to) + { + return $this->query('datacube/getusercumulate', $from, $to); + } + + /** + * 获取图文群发每日数据. + * + * @param string $from + * @param string $to + * + * @return mixed + */ + public function articleSummary(string $from, string $to) + { + return $this->query('datacube/getarticlesummary', $from, $to); + } + + /** + * 获取图文群发总数据. + * + * @param string $from + * @param string $to + * + * @return mixed + */ + public function articleTotal(string $from, string $to) + { + return $this->query('datacube/getarticletotal', $from, $to); + } + + /** + * 获取图文统计数据. + * + * @param string $from + * @param string $to + * + * @return mixed + */ + public function userReadSummary(string $from, string $to) + { + return $this->query('datacube/getuserread', $from, $to); + } + + /** + * 获取图文统计分时数据. + * + * @param string $from + * @param string $to + * + * @return mixed + */ + public function userReadHourly(string $from, string $to) + { + return $this->query('datacube/getuserreadhour', $from, $to); + } + + /** + * 获取图文分享转发数据. + * + * @param string $from + * @param string $to + * + * @return mixed + */ + public function userShareSummary(string $from, string $to) + { + return $this->query('datacube/getusershare', $from, $to); + } + + /** + * 获取图文分享转发分时数据. + * + * @param string $from + * @param string $to + * + * @return mixed + */ + public function userShareHourly(string $from, string $to) + { + return $this->query('datacube/getusersharehour', $from, $to); + } + + /** + * 获取消息发送概况数据. + * + * @param string $from + * @param string $to + * + * @return mixed + */ + public function upstreamMessageSummary(string $from, string $to) + { + return $this->query('datacube/getupstreammsg', $from, $to); + } + + /** + * 获取消息分送分时数据. + * + * @param string $from + * @param string $to + * + * @return mixed + */ + public function upstreamMessageHourly(string $from, string $to) + { + return $this->query('datacube/getupstreammsghour', $from, $to); + } + + /** + * 获取消息发送周数据. + * + * @param string $from + * @param string $to + * + * @return mixed + */ + public function upstreamMessageWeekly(string $from, string $to) + { + return $this->query('datacube/getupstreammsgweek', $from, $to); + } + + /** + * 获取消息发送月数据. + * + * @param string $from + * @param string $to + * + * @return mixed + */ + public function upstreamMessageMonthly(string $from, string $to) + { + return $this->query('datacube/getupstreammsgmonth', $from, $to); + } + + /** + * 获取消息发送分布数据. + * + * @param string $from + * @param string $to + * + * @return mixed + */ + public function upstreamMessageDistSummary(string $from, string $to) + { + return $this->query('datacube/getupstreammsgdist', $from, $to); + } + + /** + * 获取消息发送分布周数据. + * + * @param string $from + * @param string $to + * + * @return mixed + */ + public function upstreamMessageDistWeekly(string $from, string $to) + { + return $this->query('datacube/getupstreammsgdistweek', $from, $to); + } + + /** + * 获取消息发送分布月数据. + * + * @param string $from + * @param string $to + * + * @return mixed + */ + public function upstreamMessageDistMonthly(string $from, string $to) + { + return $this->query('datacube/getupstreammsgdistmonth', $from, $to); + } + + /** + * 获取接口分析数据. + * + * @param string $from + * @param string $to + * + * @return mixed + */ + public function interfaceSummary(string $from, string $to) + { + return $this->query('datacube/getinterfacesummary', $from, $to); + } + + /** + * 获取接口分析分时数据. + * + * @param string $from + * @param string $to + * + * @return mixed + */ + public function interfaceSummaryHourly(string $from, string $to) + { + return $this->query('datacube/getinterfacesummaryhour', $from, $to); + } + + /** + * 拉取卡券概况数据接口. + * + * @param string $from + * @param string $to + * @param int $condSource + * + * @return mixed + */ + public function cardSummary(string $from, string $to, $condSource = 0) + { + $ext = [ + 'cond_source' => intval($condSource), + ]; + + return $this->query('datacube/getcardbizuininfo', $from, $to, $ext); + } + + /** + * 获取免费券数据接口. + * + * @param string $from + * @param string $to + * @param int $condSource + * @param string $cardId + * + * @return mixed + */ + public function freeCardSummary(string $from, string $to, int $condSource = 0, string $cardId = '') + { + $ext = [ + 'cond_source' => intval($condSource), + 'card_id' => $cardId, + ]; + + return $this->query('datacube/getcardcardinfo', $from, $to, $ext); + } + + /** + * 拉取会员卡数据接口. + * + * @param string $from + * @param string $to + * @param int $condSource + * + * @return mixed + */ + public function memberCardSummary(string $from, string $to, $condSource = 0) + { + $ext = [ + 'cond_source' => intval($condSource), + ]; + + return $this->query('datacube/getcardmembercardinfo', $from, $to, $ext); + } + + /** + * 拉取单张会员卡数据接口. + * + * @param string $from + * @param string $to + * @param string $cardId + * + * @return mixed + */ + public function memberCardSummaryById(string $from, string $to, string $cardId) + { + $ext = [ + 'card_id' => $cardId, + ]; + + return $this->query('datacube/getcardmembercarddetail', $from, $to, $ext); + } + + /** + * 查询数据. + * + * @param string $api + * @param string $from + * @param string $to + * @param array $ext + * + * @return mixed + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + protected function query(string $api, string $from, string $to, array $ext = []) + { + $params = array_merge([ + 'begin_date' => $from, + 'end_date' => $to, + ], $ext); + + return $this->httpPostJson($api, $params); + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/DataCube/ServiceProvider.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/DataCube/ServiceProvider.php new file mode 100644 index 0000000..bfec89a --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/DataCube/ServiceProvider.php @@ -0,0 +1,33 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\OfficialAccount\DataCube; + +use Pimple\Container; +use Pimple\ServiceProviderInterface; + +/** + * Class ServiceProvider. + * + * @author overtrue + */ +class ServiceProvider implements ServiceProviderInterface +{ + /** + * {@inheritdoc}. + */ + public function register(Container $app) + { + $app['data_cube'] = function ($app) { + return new Client($app); + }; + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Device/Client.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Device/Client.php new file mode 100644 index 0000000..8dc9d73 --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Device/Client.php @@ -0,0 +1,251 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\OfficialAccount\Device; + +use EasyWeChat\Kernel\BaseClient; + +/** + * Class Client. + * + * @see http://iot.weixin.qq.com/wiki/new/index.html + * + * @author soone <66812590@qq.com> + */ +class Client extends BaseClient +{ + /** + * @param string $deviceId + * @param string $openid + * @param string $content + * + * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function message(string $deviceId, string $openid, string $content) + { + $params = [ + 'device_type' => $this->app['config']['device_type'], + 'device_id' => $deviceId, + 'open_id' => $openid, + 'content' => base64_encode($content), + ]; + + return $this->httpPostJson('device/transmsg', $params); + } + + /** + * Get device qrcode. + * + * @param array $deviceIds + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function qrCode(array $deviceIds) + { + $params = [ + 'device_num' => count($deviceIds), + 'device_id_list' => $deviceIds, + ]; + + return $this->httpPostJson('device/create_qrcode', $params); + } + + /** + * @param array $devices + * @param string $productId + * @param int $opType + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function authorize(array $devices, string $productId, int $opType = 0) + { + $params = [ + 'device_num' => count($devices), + 'device_list' => $devices, + 'op_type' => $opType, + 'product_id' => $productId, + ]; + + return $this->httpPostJson('device/authorize_device', $params); + } + + /** + * 获取 device id 和二维码 + * + * @param string $productId + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + */ + public function createId(string $productId) + { + $params = [ + 'product_id' => $productId, + ]; + + return $this->httpGet('device/getqrcode', $params); + } + + /** + * @param string $openid + * @param string $deviceId + * @param string $ticket + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function bind(string $openid, string $deviceId, string $ticket) + { + $params = [ + 'ticket' => $ticket, + 'device_id' => $deviceId, + 'openid' => $openid, + ]; + + return $this->httpPostJson('device/bind', $params); + } + + /** + * @param string $openid + * @param string $deviceId + * @param string $ticket + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function unbind(string $openid, string $deviceId, string $ticket) + { + $params = [ + 'ticket' => $ticket, + 'device_id' => $deviceId, + 'openid' => $openid, + ]; + + return $this->httpPostJson('device/unbind', $params); + } + + /** + * @param string $openid + * @param string $deviceId + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function forceBind(string $openid, string $deviceId) + { + $params = [ + 'device_id' => $deviceId, + 'openid' => $openid, + ]; + + return $this->httpPostJson('device/compel_bind', $params); + } + + /** + * @param string $openid + * @param string $deviceId + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function forceUnbind(string $openid, string $deviceId) + { + $params = [ + 'device_id' => $deviceId, + 'openid' => $openid, + ]; + + return $this->httpPostJson('device/compel_unbind', $params); + } + + /** + * @param string $deviceId + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + */ + public function status(string $deviceId) + { + $params = [ + 'device_id' => $deviceId, + ]; + + return $this->httpGet('device/get_stat', $params); + } + + /** + * @param string $ticket + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + */ + public function verify(string $ticket) + { + $params = [ + 'ticket' => $ticket, + ]; + + return $this->httpPost('device/verify_qrcode', $params); + } + + /** + * @param string $deviceId + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + */ + public function openid(string $deviceId) + { + $params = [ + 'device_type' => $this->app['config']['device_type'], + 'device_id' => $deviceId, + ]; + + return $this->httpGet('device/get_openid', $params); + } + + /** + * @param string $openid + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + */ + public function listByOpenid(string $openid) + { + $params = [ + 'openid' => $openid, + ]; + + return $this->httpGet('device/get_bind_device', $params); + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Device/ServiceProvider.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Device/ServiceProvider.php new file mode 100644 index 0000000..e3dce8e --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Device/ServiceProvider.php @@ -0,0 +1,33 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\OfficialAccount\Device; + +use Pimple\Container; +use Pimple\ServiceProviderInterface; + +/** + * Class ServiceProvider. + * + * @author soone <66812590@qq.com + */ +class ServiceProvider implements ServiceProviderInterface +{ + /** + * {@inheritdoc}. + */ + public function register(Container $app) + { + $app['device'] = function ($app) { + return new Client($app); + }; + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Goods/Client.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Goods/Client.php new file mode 100644 index 0000000..c720e31 --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Goods/Client.php @@ -0,0 +1,113 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\OfficialAccount\Goods; + +use EasyWeChat\Kernel\BaseClient; + +/** + * Class Client. + * + * @author her-cat + */ +class Client extends BaseClient +{ + /** + * Add the goods. + * + * @param array $data + * + * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function add(array $data) + { + return $this->httpPostJson('scan/product/v2/add', [ + 'product' => $data, + ]); + } + + /** + * Update the goods. + * + * @param array $data + * + * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function update(array $data) + { + return $this->httpPostJson('scan/product/v2/add', [ + 'product' => $data, + ]); + } + + /** + * Get add or update goods results. + * + * @param string $ticket + * + * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function status(string $ticket) + { + return $this->httpPostJson('scan/product/v2/status', [ + 'status_ticket' => $ticket, + ]); + } + + /** + * Get goods information. + * + * @param string $pid + * + * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function get(string $pid) + { + return $this->httpPostJson('scan/product/v2/getinfo', [ + 'product' => [ + 'pid' => $pid, + ], + ]); + } + + /** + * Get a list of goods. + * + * @param string $context + * @param int $page + * @param int $size + * + * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function list(string $context = '', int $page = 1, int $size = 10) + { + return $this->httpPostJson('scan/product/v2/getinfobypage', [ + 'page_context' => $context, + 'page_num' => $page, + 'page_size' => $size, + ]); + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Goods/ServiceProvider.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Goods/ServiceProvider.php new file mode 100644 index 0000000..38a0902 --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Goods/ServiceProvider.php @@ -0,0 +1,33 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\OfficialAccount\Goods; + +use Pimple\Container; +use Pimple\ServiceProviderInterface; + +/** + * Class ServiceProvider. + * + * @author her-cat + */ +class ServiceProvider implements ServiceProviderInterface +{ + /** + * {@inheritdoc}. + */ + public function register(Container $app) + { + $app['goods'] = function ($app) { + return new Client($app); + }; + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Material/Client.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Material/Client.php new file mode 100644 index 0000000..a62fded --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Material/Client.php @@ -0,0 +1,301 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\OfficialAccount\Material; + +use EasyWeChat\Kernel\BaseClient; +use EasyWeChat\Kernel\Exceptions\InvalidArgumentException; +use EasyWeChat\Kernel\Http\StreamResponse; +use EasyWeChat\Kernel\Messages\Article; + +/** + * Class Client. + * + * @author overtrue + */ +class Client extends BaseClient +{ + /** + * Allow media type. + * + * @var array + */ + protected $allowTypes = ['image', 'voice', 'video', 'thumb', 'news_image']; + + /** + * Upload image. + * + * @param string $path + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function uploadImage(string $path) + { + return $this->upload('image', $path); + } + + /** + * Upload voice. + * + * @param string $path + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function uploadVoice(string $path) + { + return $this->upload('voice', $path); + } + + /** + * Upload thumb. + * + * @param string $path + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function uploadThumb(string $path) + { + return $this->upload('thumb', $path); + } + + /** + * Upload video. + * + * @param string $path + * @param string $title + * @param string $description + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function uploadVideo(string $path, string $title, string $description) + { + $params = [ + 'description' => json_encode( + [ + 'title' => $title, + 'introduction' => $description, + ], JSON_UNESCAPED_UNICODE), + ]; + + return $this->upload('video', $path, $params); + } + + /** + * Upload articles. + * + * @param array|Article $articles + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function uploadArticle($articles) + { + if ($articles instanceof Article || !empty($articles['title'])) { + $articles = [$articles]; + } + + $params = ['articles' => array_map(function ($article) { + if ($article instanceof Article) { + return $article->transformForJsonRequestWithoutType(); + } + + return $article; + }, $articles)]; + + return $this->httpPostJson('cgi-bin/material/add_news', $params); + } + + /** + * Update article. + * + * @param string $mediaId + * @param array|Article $article + * @param int $index + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function updateArticle(string $mediaId, $article, int $index = 0) + { + if ($article instanceof Article) { + $article = $article->transformForJsonRequestWithoutType(); + } + + $params = [ + 'media_id' => $mediaId, + 'index' => $index, + 'articles' => isset($article['title']) ? $article : (isset($article[$index]) ? $article[$index] : []), + ]; + + return $this->httpPostJson('cgi-bin/material/update_news', $params); + } + + /** + * Upload image for article. + * + * @param string $path + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + */ + public function uploadArticleImage(string $path) + { + return $this->upload('news_image', $path); + } + + /** + * Fetch material. + * + * @param string $mediaId + * + * @return mixed + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function get(string $mediaId) + { + $response = $this->requestRaw('cgi-bin/material/get_material', 'POST', ['json' => ['media_id' => $mediaId]]); + + if (false !== stripos($response->getHeaderLine('Content-disposition'), 'attachment')) { + return StreamResponse::buildFromPsrResponse($response); + } + + return $this->castResponseToType($response, $this->app['config']->get('response_type')); + } + + /** + * Delete material by media ID. + * + * @param string $mediaId + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function delete(string $mediaId) + { + return $this->httpPostJson('cgi-bin/material/del_material', ['media_id' => $mediaId]); + } + + /** + * List materials. + * + * example: + * + * { + * "total_count": TOTAL_COUNT, + * "item_count": ITEM_COUNT, + * "item": [{ + * "media_id": MEDIA_ID, + * "name": NAME, + * "update_time": UPDATE_TIME + * }, + * // more... + * ] + * } + * + * @param string $type + * @param int $offset + * @param int $count + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function list(string $type, int $offset = 0, int $count = 20) + { + $params = [ + 'type' => $type, + 'offset' => $offset, + 'count' => $count, + ]; + + return $this->httpPostJson('cgi-bin/material/batchget_material', $params); + } + + /** + * Get stats of materials. + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + */ + public function stats() + { + return $this->httpGet('cgi-bin/material/get_materialcount'); + } + + /** + * Upload material. + * + * @param string $type + * @param string $path + * @param array $form + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function upload(string $type, string $path, array $form = []) + { + if (!file_exists($path) || !is_readable($path)) { + throw new InvalidArgumentException(sprintf('File does not exist, or the file is unreadable: "%s"', $path)); + } + + $form['type'] = $type; + + return $this->httpUpload($this->getApiByType($type), ['media' => $path], $form); + } + + /** + * Get API by type. + * + * @param string $type + * + * @return string + */ + public function getApiByType(string $type) + { + switch ($type) { + case 'news_image': + return 'cgi-bin/media/uploadimg'; + default: + return 'cgi-bin/material/add_material'; + } + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Material/ServiceProvider.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Material/ServiceProvider.php new file mode 100644 index 0000000..089a8f8 --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Material/ServiceProvider.php @@ -0,0 +1,44 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +/** + * ServiceProvider.php. + * + * This file is part of the wechat. + * + * (c) overtrue + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\OfficialAccount\Material; + +use Pimple\Container; +use Pimple\ServiceProviderInterface; + +/** + * Class ServiceProvider. + * + * @author overtrue + */ +class ServiceProvider implements ServiceProviderInterface +{ + /** + * {@inheritdoc}. + */ + public function register(Container $app) + { + $app['material'] = function ($app) { + return new Client($app); + }; + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Menu/Client.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Menu/Client.php new file mode 100644 index 0000000..9c132c6 --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Menu/Client.php @@ -0,0 +1,103 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\OfficialAccount\Menu; + +use EasyWeChat\Kernel\BaseClient; + +/** + * Class Client. + * + * @author overtrue + */ +class Client extends BaseClient +{ + /** + * Get all menus. + * + * @return mixed + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + */ + public function list() + { + return $this->httpGet('cgi-bin/menu/get'); + } + + /** + * Get current menus. + * + * @return mixed + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + */ + public function current() + { + return $this->httpGet('cgi-bin/get_current_selfmenu_info'); + } + + /** + * Add menu. + * + * @param array $buttons + * @param array $matchRule + * + * @return mixed + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function create(array $buttons, array $matchRule = []) + { + if (!empty($matchRule)) { + return $this->httpPostJson('cgi-bin/menu/addconditional', [ + 'button' => $buttons, + 'matchrule' => $matchRule, + ]); + } + + return $this->httpPostJson('cgi-bin/menu/create', ['button' => $buttons]); + } + + /** + * Destroy menu. + * + * @param int $menuId + * + * @return mixed + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function delete(int $menuId = null) + { + if (is_null($menuId)) { + return $this->httpGet('cgi-bin/menu/delete'); + } + + return $this->httpPostJson('cgi-bin/menu/delconditional', ['menuid' => $menuId]); + } + + /** + * Test conditional menu. + * + * @param string $userId + * + * @return mixed + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function match(string $userId) + { + return $this->httpPostJson('cgi-bin/menu/trymatch', ['user_id' => $userId]); + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Menu/ServiceProvider.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Menu/ServiceProvider.php new file mode 100644 index 0000000..e79b105 --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Menu/ServiceProvider.php @@ -0,0 +1,33 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\OfficialAccount\Menu; + +use Pimple\Container; +use Pimple\ServiceProviderInterface; + +/** + * Class ServiceProvider. + * + * @author overtrue + */ +class ServiceProvider implements ServiceProviderInterface +{ + /** + * {@inheritdoc}. + */ + public function register(Container $app) + { + $app['menu'] = function ($app) { + return new Client($app); + }; + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/OAuth/ServiceProvider.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/OAuth/ServiceProvider.php new file mode 100644 index 0000000..ba176dc --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/OAuth/ServiceProvider.php @@ -0,0 +1,66 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\OfficialAccount\OAuth; + +use Overtrue\Socialite\SocialiteManager as Socialite; +use Pimple\Container; +use Pimple\ServiceProviderInterface; + +/** + * Class ServiceProvider. + * + * @author overtrue + */ +class ServiceProvider implements ServiceProviderInterface +{ + /** + * {@inheritdoc}. + */ + public function register(Container $app) + { + $app['oauth'] = function ($app) { + $socialite = (new Socialite([ + 'wechat' => [ + 'client_id' => $app['config']['app_id'], + 'client_secret' => $app['config']['secret'], + 'redirect' => $this->prepareCallbackUrl($app), + ], + ], $app['request']))->driver('wechat'); + + $scopes = (array) $app['config']->get('oauth.scopes', ['snsapi_userinfo']); + + if (!empty($scopes)) { + $socialite->scopes($scopes); + } + + return $socialite; + }; + } + + /** + * Prepare the OAuth callback url for wechat. + * + * @param Container $app + * + * @return string + */ + private function prepareCallbackUrl($app) + { + $callback = $app['config']->get('oauth.callback'); + if (0 === stripos($callback, 'http')) { + return $callback; + } + $baseUrl = $app['request']->getSchemeAndHttpHost(); + + return $baseUrl.'/'.ltrim($callback, '/'); + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/OCR/Client.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/OCR/Client.php new file mode 100644 index 0000000..6aa44bc --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/OCR/Client.php @@ -0,0 +1,85 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\OfficialAccount\OCR; + +use EasyWeChat\Kernel\BaseClient; +use EasyWeChat\Kernel\Exceptions\InvalidArgumentException; + +/** + * Class Client. + * + * @author joyeekk + */ +class Client extends BaseClient +{ + /** + * Allow image parameter type. + * + * @var array + */ + protected $allowTypes = ['photo', 'scan']; + + /** + * ID card OCR. + * + * @param string $path + * @param string $type + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + */ + public function idCard(string $path, string $type = 'photo') + { + if (!\in_array($type, $this->allowTypes, true)) { + throw new InvalidArgumentException(sprintf("Unsupported type: '%s'", $type)); + } + + return $this->httpGet('cv/ocr/idcard', [ + 'type' => $type, + 'img_url' => $path, + ]); + } + + /** + * Bank card OCR. + * + * @param string $path + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + */ + public function bankCard(string $path) + { + return $this->httpGet('cv/ocr/bankcard', [ + 'img_url' => $path, + ]); + } + + /** + * Vehicle license OCR. + * + * @param string $path + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + */ + public function vehicleLicense(string $path) + { + return $this->httpGet('cv/ocr/driving', [ + 'img_url' => $path, + ]); + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/OCR/ServiceProvider.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/OCR/ServiceProvider.php new file mode 100644 index 0000000..1773079 --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/OCR/ServiceProvider.php @@ -0,0 +1,33 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\OfficialAccount\OCR; + +use Pimple\Container; +use Pimple\ServiceProviderInterface; + +/** + * Class ServiceProvider. + * + * @author joyeekk + */ +class ServiceProvider implements ServiceProviderInterface +{ + /** + * {@inheritdoc}. + */ + public function register(Container $app) + { + $app['ocr'] = function ($app) { + return new Client($app); + }; + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/POI/Client.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/POI/Client.php new file mode 100644 index 0000000..6a8e570 --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/POI/Client.php @@ -0,0 +1,145 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\OfficialAccount\POI; + +use EasyWeChat\Kernel\BaseClient; + +/** + * Class Client. + * + * @author overtrue + */ +class Client extends BaseClient +{ + /** + * Get POI supported categories. + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + */ + public function categories() + { + return $this->httpGet('cgi-bin/poi/getwxcategory'); + } + + /** + * Get POI by ID. + * + * @param int $poiId + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function get(int $poiId) + { + return $this->httpPostJson('cgi-bin/poi/getpoi', ['poi_id' => $poiId]); + } + + /** + * List POI. + * + * @param int $offset + * @param int $limit + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function list(int $offset = 0, int $limit = 10) + { + $params = [ + 'begin' => $offset, + 'limit' => $limit, + ]; + + return $this->httpPostJson('cgi-bin/poi/getpoilist', $params); + } + + /** + * Create a POI. + * + * @param array $baseInfo + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function create(array $baseInfo) + { + $params = [ + 'business' => [ + 'base_info' => $baseInfo, + ], + ]; + + return $this->httpPostJson('cgi-bin/poi/addpoi', $params); + } + + /** + * @param array $databaseInfo + * + * @return int + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + * @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException + */ + public function createAndGetId(array $databaseInfo) + { + /** @var array $response */ + $response = $this->detectAndCastResponseToType($this->create($databaseInfo), 'array'); + + return $response['poi_id']; + } + + /** + * Update a POI. + * + * @param int $poiId + * @param array $baseInfo + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function update(int $poiId, array $baseInfo) + { + $params = [ + 'business' => [ + 'base_info' => array_merge($baseInfo, ['poi_id' => $poiId]), + ], + ]; + + return $this->httpPostJson('cgi-bin/poi/updatepoi', $params); + } + + /** + * Delete a POI. + * + * @param int $poiId + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function delete(int $poiId) + { + return $this->httpPostJson('cgi-bin/poi/delpoi', ['poi_id' => $poiId]); + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/POI/ServiceProvider.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/POI/ServiceProvider.php new file mode 100644 index 0000000..156440b --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/POI/ServiceProvider.php @@ -0,0 +1,33 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\OfficialAccount\POI; + +use Pimple\Container; +use Pimple\ServiceProviderInterface; + +/** + * Class ServiceProvider. + * + * @author overtrue + */ +class ServiceProvider implements ServiceProviderInterface +{ + /** + * {@inheritdoc}. + */ + public function register(Container $app) + { + $app['poi'] = function ($app) { + return new Client($app); + }; + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Semantic/Client.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Semantic/Client.php new file mode 100644 index 0000000..e83792f --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Semantic/Client.php @@ -0,0 +1,45 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\OfficialAccount\Semantic; + +use EasyWeChat\Kernel\BaseClient; + +/** + * Class Client. + * + * @author overtrue + */ +class Client extends BaseClient +{ + /** + * Get the semantic content of giving string. + * + * @param string $keyword + * @param string $categories + * @param array $optional + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function query(string $keyword, string $categories, array $optional = []) + { + $params = [ + 'query' => $keyword, + 'category' => $categories, + 'appid' => $this->app['config']['app_id'], + ]; + + return $this->httpPostJson('semantic/semproxy/search', array_merge($params, $optional)); + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Semantic/ServiceProvider.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Semantic/ServiceProvider.php new file mode 100644 index 0000000..835b7fc --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Semantic/ServiceProvider.php @@ -0,0 +1,31 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\OfficialAccount\Semantic; + +use Pimple\Container; +use Pimple\ServiceProviderInterface; + +/** + * Class ServiceProvider. + */ +class ServiceProvider implements ServiceProviderInterface +{ + /** + * {@inheritdoc}. + */ + public function register(Container $app) + { + $app['semantic'] = function ($app) { + return new Client($app); + }; + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Server/Guard.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Server/Guard.php new file mode 100644 index 0000000..c723847 --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Server/Guard.php @@ -0,0 +1,30 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\OfficialAccount\Server; + +use EasyWeChat\Kernel\ServerGuard; + +/** + * Class Guard. + * + * @author overtrue + */ +class Guard extends ServerGuard +{ + /** + * @return bool + */ + protected function shouldReturnRawResponse(): bool + { + return !is_null($this->app['request']->get('echostr')); + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Server/Handlers/EchoStrHandler.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Server/Handlers/EchoStrHandler.php new file mode 100644 index 0000000..f076abf --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Server/Handlers/EchoStrHandler.php @@ -0,0 +1,51 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\OfficialAccount\Server\Handlers; + +use EasyWeChat\Kernel\Contracts\EventHandlerInterface; +use EasyWeChat\Kernel\Decorators\FinallyResult; +use EasyWeChat\Kernel\ServiceContainer; + +/** + * Class EchoStrHandler. + * + * @author overtrue + */ +class EchoStrHandler implements EventHandlerInterface +{ + /** + * @var ServiceContainer + */ + protected $app; + + /** + * EchoStrHandler constructor. + * + * @param ServiceContainer $app + */ + public function __construct(ServiceContainer $app) + { + $this->app = $app; + } + + /** + * @param mixed $payload + * + * @return FinallyResult|null + */ + public function handle($payload = null) + { + if ($str = $this->app['request']->get('echostr')) { + return new FinallyResult($str); + } + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Server/ServiceProvider.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Server/ServiceProvider.php new file mode 100644 index 0000000..0c6716b --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Server/ServiceProvider.php @@ -0,0 +1,46 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\OfficialAccount\Server; + +use EasyWeChat\Kernel\Encryptor; +use EasyWeChat\OfficialAccount\Server\Handlers\EchoStrHandler; +use Pimple\Container; +use Pimple\ServiceProviderInterface; + +/** + * Class ServiceProvider. + * + * @author overtrue + */ +class ServiceProvider implements ServiceProviderInterface +{ + /** + * {@inheritdoc}. + */ + public function register(Container $app) + { + !isset($app['encryptor']) && $app['encryptor'] = function ($app) { + return new Encryptor( + $app['config']['app_id'], + $app['config']['token'], + $app['config']['aes_key'] + ); + }; + + !isset($app['server']) && $app['server'] = function ($app) { + $guard = new Guard($app); + $guard->push(new EchoStrHandler($app)); + + return $guard; + }; + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/ShakeAround/Client.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/ShakeAround/Client.php new file mode 100644 index 0000000..c401008 --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/ShakeAround/Client.php @@ -0,0 +1,81 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\OfficialAccount\ShakeAround; + +use EasyWeChat\Kernel\BaseClient; + +/** + * Class Client. + * + * @author overtrue + */ +class Client extends BaseClient +{ + /** + * @param array $data + * + * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function register($data) + { + return $this->httpPostJson('shakearound/account/register', $data); + } + + /** + * Get audit status. + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + */ + public function status() + { + return $this->httpGet('shakearound/account/auditstatus'); + } + + /** + * Get shake info. + * + * @param string $ticket + * @param bool $needPoi + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function user(string $ticket, bool $needPoi = false) + { + $params = [ + 'ticket' => $ticket, + ]; + + if ($needPoi) { + $params['need_poi'] = 1; + } + + return $this->httpPostJson('shakearound/user/getshakeinfo', $params); + } + + /** + * @param string $ticket + * + * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string + */ + public function userWithPoi(string $ticket) + { + return $this->user($ticket, true); + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/ShakeAround/DeviceClient.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/ShakeAround/DeviceClient.php new file mode 100644 index 0000000..859a120 --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/ShakeAround/DeviceClient.php @@ -0,0 +1,190 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\OfficialAccount\ShakeAround; + +use EasyWeChat\Kernel\BaseClient; + +/** + * Class DeviceClient. + * + * @author allen05ren + */ +class DeviceClient extends BaseClient +{ + /** + * @param array $data + * + * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function apply(array $data) + { + return $this->httpPostJson('shakearound/device/applyid', $data); + } + + /** + * Get audit status. + * + * @param int $applyId + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function status(int $applyId) + { + $params = [ + 'apply_id' => $applyId, + ]; + + return $this->httpPostJson('shakearound/device/applystatus', $params); + } + + /** + * Update a device comment. + * + * @param array $deviceIdentifier + * @param string $comment + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function update(array $deviceIdentifier, string $comment) + { + $params = [ + 'device_identifier' => $deviceIdentifier, + 'comment' => $comment, + ]; + + return $this->httpPostJson('shakearound/device/update', $params); + } + + /** + * Bind location for device. + * + * @param array $deviceIdentifier + * @param int $poiId + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function bindPoi(array $deviceIdentifier, int $poiId) + { + $params = [ + 'device_identifier' => $deviceIdentifier, + 'poi_id' => $poiId, + ]; + + return $this->httpPostJson('shakearound/device/bindlocation', $params); + } + + /** + * @param array $deviceIdentifier + * @param int $poiId + * @param string $appId + * + * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function bindThirdPoi(array $deviceIdentifier, int $poiId, string $appId) + { + $params = [ + 'device_identifier' => $deviceIdentifier, + 'poi_id' => $poiId, + 'type' => 2, + 'poi_appid' => $appId, + ]; + + return $this->httpPostJson('shakearound/device/bindlocation', $params); + } + + /** + * Fetch batch of devices by deviceIds. + * + * @param array $deviceIdentifiers + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + */ + public function listByIds(array $deviceIdentifiers) + { + $params = [ + 'type' => 1, + 'device_identifiers' => $deviceIdentifiers, + ]; + + return $this->search($params); + } + + /** + * Pagination to get batch of devices. + * + * @param int $lastId + * @param int $count + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + */ + public function list(int $lastId, int $count) + { + $params = [ + 'type' => 2, + 'last_seen' => $lastId, + 'count' => $count, + ]; + + return $this->search($params); + } + + /** + * Fetch batch of devices by applyId. + * + * @param int $applyId + * @param int $lastId + * @param int $count + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + */ + public function listByApplyId(int $applyId, int $lastId, int $count) + { + $params = [ + 'type' => 3, + 'apply_id' => $applyId, + 'last_seen' => $lastId, + 'count' => $count, + ]; + + return $this->search($params); + } + + /** + * Fetch batch of devices. + * + * @param array $params + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function search(array $params) + { + return $this->httpPostJson('shakearound/device/search', $params); + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/ShakeAround/GroupClient.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/ShakeAround/GroupClient.php new file mode 100644 index 0000000..9fd578d --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/ShakeAround/GroupClient.php @@ -0,0 +1,167 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\OfficialAccount\ShakeAround; + +use EasyWeChat\Kernel\BaseClient; + +/** + * Class GroupClient. + * + * @author allen05ren + */ +class GroupClient extends BaseClient +{ + /** + * Add device group. + * + * @param string $name + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function create(string $name) + { + $params = [ + 'group_name' => $name, + ]; + + return $this->httpPostJson('shakearound/device/group/add', $params); + } + + /** + * Update a device group name. + * + * @param int $groupId + * @param string $name + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function update(int $groupId, string $name) + { + $params = [ + 'group_id' => $groupId, + 'group_name' => $name, + ]; + + return $this->httpPostJson('shakearound/device/group/update', $params); + } + + /** + * Delete device group. + * + * @param int $groupId + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function delete(int $groupId) + { + $params = [ + 'group_id' => $groupId, + ]; + + return $this->httpPostJson('shakearound/device/group/delete', $params); + } + + /** + * List all device groups. + * + * @param int $begin + * @param int $count + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function list(int $begin, int $count) + { + $params = [ + 'begin' => $begin, + 'count' => $count, + ]; + + return $this->httpPostJson('shakearound/device/group/getlist', $params); + } + + /** + * Get detail of a device group. + * + * @param int $groupId + * @param int $begin + * @param int $count + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function get(int $groupId, int $begin, int $count) + { + $params = [ + 'group_id' => $groupId, + 'begin' => $begin, + 'count' => $count, + ]; + + return $this->httpPostJson('shakearound/device/group/getdetail', $params); + } + + /** + * Add one or more devices to a device group. + * + * @param int $groupId + * @param array $deviceIdentifiers + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function addDevices(int $groupId, array $deviceIdentifiers) + { + $params = [ + 'group_id' => $groupId, + 'device_identifiers' => $deviceIdentifiers, + ]; + + return $this->httpPostJson('shakearound/device/group/adddevice', $params); + } + + /** + * Remove one or more devices from a device group. + * + * @param int $groupId + * @param array $deviceIdentifiers + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function removeDevices(int $groupId, array $deviceIdentifiers) + { + $params = [ + 'group_id' => $groupId, + 'device_identifiers' => $deviceIdentifiers, + ]; + + return $this->httpPostJson('shakearound/device/group/deletedevice', $params); + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/ShakeAround/MaterialClient.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/ShakeAround/MaterialClient.php new file mode 100644 index 0000000..edc40b2 --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/ShakeAround/MaterialClient.php @@ -0,0 +1,44 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\OfficialAccount\ShakeAround; + +use EasyWeChat\Kernel\BaseClient; +use EasyWeChat\Kernel\Exceptions\InvalidArgumentException; + +/** + * Class MaterialClient. + * + * @author allen05ren + */ +class MaterialClient extends BaseClient +{ + /** + * Upload image material. + * + * @param string $path + * @param string $type + * + * @return string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function uploadImage(string $path, string $type = 'icon') + { + if (!file_exists($path) || !is_readable($path)) { + throw new InvalidArgumentException(sprintf('File does not exist, or the file is unreadable: "%s"', $path)); + } + + return $this->httpUpload('shakearound/material/add', ['media' => $path], [], ['type' => strtolower($type)]); + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/ShakeAround/PageClient.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/ShakeAround/PageClient.php new file mode 100644 index 0000000..73ba1ac --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/ShakeAround/PageClient.php @@ -0,0 +1,110 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\OfficialAccount\ShakeAround; + +use EasyWeChat\Kernel\BaseClient; + +/** + * Class PageClient. + * + * @author allen05ren + */ +class PageClient extends BaseClient +{ + /** + * @param array $data + * + * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function create(array $data) + { + return $this->httpPostJson('shakearound/page/add', $data); + } + + /** + * @param int $pageId + * @param array $data + * + * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function update(int $pageId, array $data) + { + return $this->httpPostJson('shakearound/page/update', array_merge(['page_id' => $pageId], $data)); + } + + /** + * Fetch batch of pages by pageIds. + * + * @param array $pageIds + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function listByIds(array $pageIds) + { + $params = [ + 'type' => 1, + 'page_ids' => $pageIds, + ]; + + return $this->httpPostJson('shakearound/page/search', $params); + } + + /** + * Pagination to get batch of pages. + * + * @param int $begin + * @param int $count + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function list(int $begin, int $count) + { + $params = [ + 'type' => 2, + 'begin' => $begin, + 'count' => $count, + ]; + + return $this->httpPostJson('shakearound/page/search', $params); + } + + /** + * delete a page. + * + * @param int $pageId + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function delete(int $pageId) + { + $params = [ + 'page_id' => $pageId, + ]; + + return $this->httpPostJson('shakearound/page/delete', $params); + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/ShakeAround/RelationClient.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/ShakeAround/RelationClient.php new file mode 100644 index 0000000..de80911 --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/ShakeAround/RelationClient.php @@ -0,0 +1,87 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\OfficialAccount\ShakeAround; + +use EasyWeChat\Kernel\BaseClient; + +/** + * Class RelationClient. + * + * @author allen05ren + */ +class RelationClient extends BaseClient +{ + /** + * Bind pages for device. + * + * @param array $deviceIdentifier + * @param array $pageIds + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function bindPages(array $deviceIdentifier, array $pageIds) + { + $params = [ + 'device_identifier' => $deviceIdentifier, + 'page_ids' => $pageIds, + ]; + + return $this->httpPostJson('shakearound/device/bindpage', $params); + } + + /** + * Get pageIds by deviceId. + * + * @param array $deviceIdentifier + * + * @return array|\EasyWeChat\Kernel\Support\Collection + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function listByDeviceId(array $deviceIdentifier) + { + $params = [ + 'type' => 1, + 'device_identifier' => $deviceIdentifier, + ]; + + return $this->httpPostJson('shakearound/relation/search', $params); + } + + /** + * Get devices by pageId. + * + * @param int $pageId + * @param int $begin + * @param int $count + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function listByPageId(int $pageId, int $begin, int $count) + { + $params = [ + 'type' => 2, + 'page_id' => $pageId, + 'begin' => $begin, + 'count' => $count, + ]; + + return $this->httpPostJson('shakearound/relation/search', $params); + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/ShakeAround/ServiceProvider.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/ShakeAround/ServiceProvider.php new file mode 100644 index 0000000..a13d2b0 --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/ShakeAround/ServiceProvider.php @@ -0,0 +1,57 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\OfficialAccount\ShakeAround; + +use Pimple\Container; +use Pimple\ServiceProviderInterface; + +/** + * Class ServiceProvider. + * + * @author allen05ren + */ +class ServiceProvider implements ServiceProviderInterface +{ + /** + * {@inheritdoc}. + */ + public function register(Container $app) + { + $app['shake_around'] = function ($app) { + return new ShakeAround($app); + }; + + $app['shake_around.device'] = function ($app) { + return new DeviceClient($app); + }; + + $app['shake_around.page'] = function ($app) { + return new PageClient($app); + }; + + $app['shake_around.material'] = function ($app) { + return new MaterialClient($app); + }; + + $app['shake_around.group'] = function ($app) { + return new GroupClient($app); + }; + + $app['shake_around.relation'] = function ($app) { + return new RelationClient($app); + }; + + $app['shake_around.stats'] = function ($app) { + return new StatsClient($app); + }; + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/ShakeAround/ShakeAround.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/ShakeAround/ShakeAround.php new file mode 100644 index 0000000..666a38a --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/ShakeAround/ShakeAround.php @@ -0,0 +1,44 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\OfficialAccount\ShakeAround; + +use EasyWeChat\Kernel\Exceptions\InvalidArgumentException; + +/** + * Class Card. + * + * @author overtrue + * + * @property \EasyWeChat\OfficialAccount\ShakeAround\DeviceClient $device + * @property \EasyWeChat\OfficialAccount\ShakeAround\GroupClient $group + * @property \EasyWeChat\OfficialAccount\ShakeAround\MaterialClient $material + * @property \EasyWeChat\OfficialAccount\ShakeAround\RelationClient $relation + * @property \EasyWeChat\OfficialAccount\ShakeAround\StatsClient $stats + */ +class ShakeAround extends Client +{ + /** + * @param string $property + * + * @return mixed + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException + */ + public function __get($property) + { + if (isset($this->app["shake_around.{$property}"])) { + return $this->app["shake_around.{$property}"]; + } + + throw new InvalidArgumentException(sprintf('No shake_around service named "%s".', $property)); + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/ShakeAround/StatsClient.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/ShakeAround/StatsClient.php new file mode 100644 index 0000000..a4b55eb --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/ShakeAround/StatsClient.php @@ -0,0 +1,110 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\OfficialAccount\ShakeAround; + +use EasyWeChat\Kernel\BaseClient; + +/** + * Class StatsClient. + * + * @author allen05ren + */ +class StatsClient extends BaseClient +{ + /** + * Fetch statistics data by deviceId. + * + * @param array $deviceIdentifier + * @param int $beginTime (Unix timestamp) + * @param int $endTime (Unix timestamp) + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function deviceSummary(array $deviceIdentifier, int $beginTime, int $endTime) + { + $params = [ + 'device_identifier' => $deviceIdentifier, + 'begin_date' => $beginTime, + 'end_date' => $endTime, + ]; + + return $this->httpPostJson('shakearound/statistics/device', $params); + } + + /** + * Fetch all devices statistics data by date. + * + * @param int $timestamp + * @param int $pageIndex + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function devicesSummary(int $timestamp, int $pageIndex) + { + $params = [ + 'date' => $timestamp, + 'page_index' => $pageIndex, + ]; + + return $this->httpPostJson('shakearound/statistics/devicelist', $params); + } + + /** + * Fetch statistics data by pageId. + * + * @param int $pageId + * @param int $beginTime (Unix timestamp) + * @param int $endTime (Unix timestamp) + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function pageSummary(int $pageId, int $beginTime, int $endTime) + { + $params = [ + 'page_id' => $pageId, + 'begin_date' => $beginTime, + 'end_date' => $endTime, + ]; + + return $this->httpPostJson('shakearound/statistics/page', $params); + } + + /** + * Fetch all pages statistics data by date. + * + * @param int $timestamp + * @param int $pageIndex + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function pagesSummary(int $timestamp, int $pageIndex) + { + $params = [ + 'date' => $timestamp, + 'page_index' => $pageIndex, + ]; + + return $this->httpPostJson('shakearound/statistics/pagelist', $params); + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Store/Client.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Store/Client.php new file mode 100644 index 0000000..3643096 --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Store/Client.php @@ -0,0 +1,209 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\OfficialAccount\Store; + +use EasyWeChat\Kernel\BaseClient; + +/** + * Class Client. + * + * @author bigface + */ +class Client extends BaseClient +{ + /** + * Get WXA supported categories. + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + */ + public function categories() + { + return $this->httpGet('wxa/get_merchant_category'); + } + + /** + * Get district from tencent map . + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + */ + public function districts() + { + return $this->httpGet('wxa/get_district'); + } + + /** + * Search store from tencent map. + * + * @param int $districtId + * @param string $keyword + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function searchFromMap(int $districtId, string $keyword) + { + $params = [ + 'districtid' => $districtId, + 'keyword' => $keyword, + ]; + + return $this->httpPostJson('wxa/search_map_poi', $params); + } + + /** + * Get store check status. + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function getStatus() + { + return $this->httpPostJson('wxa/get_merchant_audit_info'); + } + + /** + * Create a merchant. + * + * @param array $baseInfo + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function createMerchant(array $baseInfo) + { + return $this->httpPostJson('wxa/apply_merchant', $baseInfo); + } + + /** + * Update a merchant. + * + * @param array $params + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function updateMerchant(array $params) + { + return $this->httpPostJson('wxa/modify_merchant', $params); + } + + /** + * Create a store from tencent map. + * + * @param array $baseInfo + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function createFromMap(array $baseInfo) + { + return $this->httpPostJson('wxa/create_map_poi', $baseInfo); + } + + /** + * Create a store. + * + * @param array $baseInfo + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function create(array $baseInfo) + { + return $this->httpPostJson('wxa/add_store', $baseInfo); + } + + /** + * Update a store. + * + * @param int $poiId + * @param array $baseInfo + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function update(int $poiId, array $baseInfo) + { + $params = array_merge($baseInfo, ['poi_id' => $poiId]); + + return $this->httpPostJson('wxa/update_store', $params); + } + + /** + * Get store by ID. + * + * @param int $poiId + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function get(int $poiId) + { + return $this->httpPostJson('wxa/get_store_info', ['poi_id' => $poiId]); + } + + /** + * List store. + * + * @param int $offset + * @param int $limit + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function list(int $offset = 0, int $limit = 10) + { + $params = [ + 'offset' => $offset, + 'limit' => $limit, + ]; + + return $this->httpPostJson('wxa/get_store_list', $params); + } + + /** + * Delete a store. + * + * @param int $poiId + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function delete(int $poiId) + { + return $this->httpPostJson('wxa/del_store', ['poi_id' => $poiId]); + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Store/ServiceProvider.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Store/ServiceProvider.php new file mode 100644 index 0000000..f5c48d7 --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/Store/ServiceProvider.php @@ -0,0 +1,33 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\OfficialAccount\Store; + +use Pimple\Container; +use Pimple\ServiceProviderInterface; + +/** + * Class ServiceProvider. + * + * @author bigface + */ +class ServiceProvider implements ServiceProviderInterface +{ + /** + * {@inheritdoc}. + */ + public function register(Container $app) + { + $app['store'] = function ($app) { + return new Client($app); + }; + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/TemplateMessage/Client.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/TemplateMessage/Client.php new file mode 100644 index 0000000..be1fa4d --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/TemplateMessage/Client.php @@ -0,0 +1,234 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\OfficialAccount\TemplateMessage; + +use EasyWeChat\Kernel\BaseClient; +use EasyWeChat\Kernel\Exceptions\InvalidArgumentException; +use ReflectionClass; + +/** + * Class Client. + * + * @author overtrue + */ +class Client extends BaseClient +{ + const API_SEND = 'cgi-bin/message/template/send'; + + /** + * Attributes. + * + * @var array + */ + protected $message = [ + 'touser' => '', + 'template_id' => '', + 'url' => '', + 'data' => [], + 'miniprogram' => '', + ]; + + /** + * Required attributes. + * + * @var array + */ + protected $required = ['touser', 'template_id']; + + /** + * Set industry. + * + * @param int $industryOne + * @param int $industryTwo + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function setIndustry($industryOne, $industryTwo) + { + $params = [ + 'industry_id1' => $industryOne, + 'industry_id2' => $industryTwo, + ]; + + return $this->httpPostJson('cgi-bin/template/api_set_industry', $params); + } + + /** + * Get industry. + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function getIndustry() + { + return $this->httpPostJson('cgi-bin/template/get_industry'); + } + + /** + * Add a template and get template ID. + * + * @param string $shortId + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function addTemplate($shortId) + { + $params = ['template_id_short' => $shortId]; + + return $this->httpPostJson('cgi-bin/template/api_add_template', $params); + } + + /** + * Get private templates. + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function getPrivateTemplates() + { + return $this->httpPostJson('cgi-bin/template/get_all_private_template'); + } + + /** + * Delete private template. + * + * @param string $templateId + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function deletePrivateTemplate($templateId) + { + $params = ['template_id' => $templateId]; + + return $this->httpPostJson('cgi-bin/template/del_private_template', $params); + } + + /** + * Send a template message. + * + * @param array $data + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function send(array $data = []) + { + $params = $this->formatMessage($data); + + $this->restoreMessage(); + + return $this->httpPostJson(static::API_SEND, $params); + } + + /** + * Send template-message for subscription. + * + * @param array $data + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function sendSubscription(array $data = []) + { + $params = $this->formatMessage($data); + + $this->restoreMessage(); + + return $this->httpPostJson('cgi-bin/message/template/subscribe', $params); + } + + /** + * @param array $data + * + * @return array + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException + */ + protected function formatMessage(array $data = []) + { + $params = array_merge($this->message, $data); + + foreach ($params as $key => $value) { + if (in_array($key, $this->required, true) && empty($value) && empty($this->message[$key])) { + throw new InvalidArgumentException(sprintf('Attribute "%s" can not be empty!', $key)); + } + + $params[$key] = empty($value) ? $this->message[$key] : $value; + } + + $params['data'] = $this->formatData($params['data'] ?? []); + + return $params; + } + + /** + * @param array $data + * + * @return array + */ + protected function formatData(array $data) + { + $formatted = []; + + foreach ($data as $key => $value) { + if (is_array($value)) { + if (isset($value['value'])) { + $formatted[$key] = $value; + + continue; + } + + if (count($value) >= 2) { + $value = [ + 'value' => $value[0], + 'color' => $value[1], + ]; + } + } else { + $value = [ + 'value' => strval($value), + ]; + } + + $formatted[$key] = $value; + } + + return $formatted; + } + + /** + * Restore message. + */ + protected function restoreMessage() + { + $this->message = (new ReflectionClass(static::class))->getDefaultProperties()['message']; + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/TemplateMessage/ServiceProvider.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/TemplateMessage/ServiceProvider.php new file mode 100644 index 0000000..98476fc --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/TemplateMessage/ServiceProvider.php @@ -0,0 +1,33 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\OfficialAccount\TemplateMessage; + +use Pimple\Container; +use Pimple\ServiceProviderInterface; + +/** + * Class ServiceProvider. + * + * @author overtrue + */ +class ServiceProvider implements ServiceProviderInterface +{ + /** + * {@inheritdoc}. + */ + public function register(Container $app) + { + $app['template_message'] = function ($app) { + return new Client($app); + }; + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/User/ServiceProvider.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/User/ServiceProvider.php new file mode 100644 index 0000000..c11d8b3 --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/User/ServiceProvider.php @@ -0,0 +1,35 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\OfficialAccount\User; + +use Pimple\Container; +use Pimple\ServiceProviderInterface; + +/** + * Class ServiceProvider. + */ +class ServiceProvider implements ServiceProviderInterface +{ + /** + * {@inheritdoc}. + */ + public function register(Container $app) + { + $app['user'] = function ($app) { + return new UserClient($app); + }; + + $app['user_tag'] = function ($app) { + return new TagClient($app); + }; + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/User/TagClient.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/User/TagClient.php new file mode 100644 index 0000000..d41e363 --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/User/TagClient.php @@ -0,0 +1,175 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\OfficialAccount\User; + +use EasyWeChat\Kernel\BaseClient; + +/** + * Class TagClient. + * + * @author overtrue + */ +class TagClient extends BaseClient +{ + /** + * Create tag. + * + * @param string $name + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function create(string $name) + { + $params = [ + 'tag' => ['name' => $name], + ]; + + return $this->httpPostJson('cgi-bin/tags/create', $params); + } + + /** + * List all tags. + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + */ + public function list() + { + return $this->httpGet('cgi-bin/tags/get'); + } + + /** + * Update a tag name. + * + * @param int $tagId + * @param string $name + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function update(int $tagId, string $name) + { + $params = [ + 'tag' => [ + 'id' => $tagId, + 'name' => $name, + ], + ]; + + return $this->httpPostJson('cgi-bin/tags/update', $params); + } + + /** + * Delete tag. + * + * @param int $tagId + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function delete(int $tagId) + { + $params = [ + 'tag' => ['id' => $tagId], + ]; + + return $this->httpPostJson('cgi-bin/tags/delete', $params); + } + + /** + * Get user tags. + * + * @param string $openid + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function userTags(string $openid) + { + $params = ['openid' => $openid]; + + return $this->httpPostJson('cgi-bin/tags/getidlist', $params); + } + + /** + * Get users from a tag. + * + * @param int $tagId + * @param string $nextOpenId + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function usersOfTag(int $tagId, string $nextOpenId = '') + { + $params = [ + 'tagid' => $tagId, + 'next_openid' => $nextOpenId, + ]; + + return $this->httpPostJson('cgi-bin/user/tag/get', $params); + } + + /** + * Batch tag users. + * + * @param array $openids + * @param int $tagId + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function tagUsers(array $openids, int $tagId) + { + $params = [ + 'openid_list' => $openids, + 'tagid' => $tagId, + ]; + + return $this->httpPostJson('cgi-bin/tags/members/batchtagging', $params); + } + + /** + * Untag users from a tag. + * + * @param array $openids + * @param int $tagId + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function untagUsers(array $openids, int $tagId) + { + $params = [ + 'openid_list' => $openids, + 'tagid' => $tagId, + ]; + + return $this->httpPostJson('cgi-bin/tags/members/batchuntagging', $params); + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/User/UserClient.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/User/UserClient.php new file mode 100644 index 0000000..6b9491f --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/User/UserClient.php @@ -0,0 +1,172 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\OfficialAccount\User; + +use EasyWeChat\Kernel\BaseClient; + +/** + * Class UserClient. + * + * @author overtrue + */ +class UserClient extends BaseClient +{ + /** + * Fetch a user by open id. + * + * @param string $openid + * @param string $lang + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + */ + public function get(string $openid, string $lang = 'zh_CN') + { + $params = [ + 'openid' => $openid, + 'lang' => $lang, + ]; + + return $this->httpGet('cgi-bin/user/info', $params); + } + + /** + * Batch get users. + * + * @param array $openids + * @param string $lang + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function select(array $openids, string $lang = 'zh_CN') + { + return $this->httpPostJson('cgi-bin/user/info/batchget', [ + 'user_list' => array_map(function ($openid) use ($lang) { + return [ + 'openid' => $openid, + 'lang' => $lang, + ]; + }, $openids), + ]); + } + + /** + * List users. + * + * @param string $nextOpenId + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + */ + public function list(string $nextOpenId = null) + { + $params = ['next_openid' => $nextOpenId]; + + return $this->httpGet('cgi-bin/user/get', $params); + } + + /** + * Set user remark. + * + * @param string $openid + * @param string $remark + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function remark(string $openid, string $remark) + { + $params = [ + 'openid' => $openid, + 'remark' => $remark, + ]; + + return $this->httpPostJson('cgi-bin/user/info/updateremark', $params); + } + + /** + * Get black list. + * + * @param string|null $beginOpenid + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function blacklist(string $beginOpenid = null) + { + $params = ['begin_openid' => $beginOpenid]; + + return $this->httpPostJson('cgi-bin/tags/members/getblacklist', $params); + } + + /** + * Batch block user. + * + * @param array|string $openidList + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function block($openidList) + { + $params = ['openid_list' => (array) $openidList]; + + return $this->httpPostJson('cgi-bin/tags/members/batchblacklist', $params); + } + + /** + * Batch unblock user. + * + * @param array $openidList + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function unblock($openidList) + { + $params = ['openid_list' => (array) $openidList]; + + return $this->httpPostJson('cgi-bin/tags/members/batchunblacklist', $params); + } + + /** + * @param string $oldAppId + * @param array $openidList + * + * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function changeOpenid(string $oldAppId, array $openidList) + { + $params = [ + 'from_appid' => $oldAppId, + 'openid_list' => $openidList, + ]; + + return $this->httpPostJson('cgi-bin/changeopenid', $params); + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/WiFi/CardClient.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/WiFi/CardClient.php new file mode 100644 index 0000000..76a4e6a --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/WiFi/CardClient.php @@ -0,0 +1,52 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\OfficialAccount\WiFi; + +use EasyWeChat\Kernel\BaseClient; + +/** + * Class CardClient. + * + * @author her-cat + */ +class CardClient extends BaseClient +{ + /** + * Set shop card coupon delivery information. + * + * @param array $data + * + * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function set(array $data) + { + return $this->httpPostJson('bizwifi/couponput/set', $data); + } + + /** + * Get shop card coupon delivery information. + * + * @param int $shopId + * + * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function get(int $shopId = 0) + { + return $this->httpPostJson('bizwifi/couponput/get', ['shop_id' => $shopId]); + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/WiFi/Client.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/WiFi/Client.php new file mode 100644 index 0000000..076957d --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/WiFi/Client.php @@ -0,0 +1,98 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\OfficialAccount\WiFi; + +use EasyWeChat\Kernel\BaseClient; + +/** + * Class Client. + * + * @author her-cat + */ +class Client extends BaseClient +{ + /** + * Get Wi-Fi statistics. + * + * @param string $beginDate + * @param string $endDate + * @param int $shopId + * + * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function summary(string $beginDate, string $endDate, int $shopId = -1) + { + $data = [ + 'begin_date' => $beginDate, + 'end_date' => $endDate, + 'shop_id' => $shopId, + ]; + + return $this->httpPostJson('bizwifi/statistics/list', $data); + } + + /** + * Get the material QR code. + * + * @param int $shopId + * @param string $ssid + * @param int $type + * + * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function getQrCodeUrl(int $shopId, string $ssid, int $type = 0) + { + $data = [ + 'shop_id' => $shopId, + 'ssid' => $ssid, + 'img_id' => $type, + ]; + + return $this->httpPostJson('bizwifi/qrcode/get', $data); + } + + /** + * Wi-Fi completion page jump applet. + * + * @param array $data + * + * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function setFinishPage(array $data) + { + return $this->httpPostJson('bizwifi/finishpage/set', $data); + } + + /** + * Set the top banner jump applet. + * + * @param array $data + * + * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function setHomePage(array $data) + { + return $this->httpPostJson('bizwifi/homepage/set', $data); + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/WiFi/DeviceClient.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/WiFi/DeviceClient.php new file mode 100644 index 0000000..8fecbf7 --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/WiFi/DeviceClient.php @@ -0,0 +1,127 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\OfficialAccount\WiFi; + +use EasyWeChat\Kernel\BaseClient; + +/** + * Class DeviceClient. + * + * @author her-cat + */ +class DeviceClient extends BaseClient +{ + /** + * Add a password device. + * + * @param int $shopId + * @param string $ssid + * @param string $password + * + * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function addPasswordDevice(int $shopId, string $ssid, string $password) + { + $data = [ + 'shop_id' => $shopId, + 'ssid' => $ssid, + 'password' => $password, + ]; + + return $this->httpPostJson('bizwifi/device/add', $data); + } + + /** + * Add a portal device. + * + * @param int $shopId + * @param string $ssid + * @param bool $reset + * + * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function addPortalDevice(int $shopId, string $ssid, bool $reset = false) + { + $data = [ + 'shop_id' => $shopId, + 'ssid' => $ssid, + 'reset' => $reset, + ]; + + return $this->httpPostJson('bizwifi/apportal/register', $data); + } + + /** + * Delete device by MAC address. + * + * @param string $macAddress + * + * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function delete(string $macAddress) + { + return $this->httpPostJson('bizwifi/device/delete', ['bssid' => $macAddress]); + } + + /** + * Get a list of devices. + * + * @param int $page + * @param int $size + * + * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function list(int $page = 1, int $size = 10) + { + $data = [ + 'pageindex' => $page, + 'pagesize' => $size, + ]; + + return $this->httpPostJson('bizwifi/device/list', $data); + } + + /** + * Get a list of devices by shop ID. + * + * @param int $shopId + * @param int $page + * @param int $size + * + * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function listByShopId(int $shopId, int $page = 1, int $size = 10) + { + $data = [ + 'shop_id' => $shopId, + 'pageindex' => $page, + 'pagesize' => $size, + ]; + + return $this->httpPostJson('bizwifi/device/list', $data); + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/WiFi/ServiceProvider.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/WiFi/ServiceProvider.php new file mode 100644 index 0000000..7a28b51 --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/WiFi/ServiceProvider.php @@ -0,0 +1,45 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\OfficialAccount\WiFi; + +use Pimple\Container; +use Pimple\ServiceProviderInterface; + +/** + * Class ServiceProvider. + * + * @author her-cat + */ +class ServiceProvider implements ServiceProviderInterface +{ + /** + * {@inheritdoc} + */ + public function register(Container $app) + { + $app['wifi'] = function ($app) { + return new Client($app); + }; + + $app['wifi_card'] = function ($app) { + return new CardClient($app); + }; + + $app['wifi_device'] = function ($app) { + return new DeviceClient($app); + }; + + $app['wifi_shop'] = function ($app) { + return new ShopClient($app); + }; + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/WiFi/ShopClient.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/WiFi/ShopClient.php new file mode 100644 index 0000000..34f1c97 --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OfficialAccount/WiFi/ShopClient.php @@ -0,0 +1,100 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\OfficialAccount\WiFi; + +use EasyWeChat\Kernel\BaseClient; + +/** + * Class ShopClient. + * + * @author her-cat + */ +class ShopClient extends BaseClient +{ + /** + * Get shop Wi-Fi information. + * + * @param int $shopId + * + * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function get(int $shopId) + { + return $this->httpPostJson('bizwifi/shop/get', ['shop_id' => $shopId]); + } + + /** + * Get a list of Wi-Fi shops. + * + * @param int $page + * @param int $size + * + * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function list(int $page = 1, int $size = 10) + { + $data = [ + 'pageindex' => $page, + 'pagesize' => $size, + ]; + + return $this->httpPostJson('bizwifi/shop/list', $data); + } + + /** + * Update shop Wi-Fi information. + * + * @param int $shopId + * @param array $data + * + * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function update(int $shopId, array $data) + { + $data = array_merge(['shop_id' => $shopId], $data); + + return $this->httpPostJson('bizwifi/shop/update', $data); + } + + /** + * Clear shop network and equipment. + * + * @param int $shopId + * @param string|null $ssid + * + * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function clearDevice(int $shopId, string $ssid = null) + { + $data = [ + 'shop_id' => $shopId, + ]; + + if (!is_null($ssid)) { + $data['ssid'] = $ssid; + } + + return $this->httpPostJson('bizwifi/shop/clean', $data); + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/OpenWork/Application.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OpenWork/Application.php new file mode 100644 index 0000000..bde1421 --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OpenWork/Application.php @@ -0,0 +1,85 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\OpenWork; + +use EasyWeChat\Kernel\ServiceContainer; +use EasyWeChat\OpenWork\Work\Application as Work; + +/** + * Application. + * + * @author xiaomin + * + * @property \EasyWeChat\OpenWork\Server\Guard $server + * @property \EasyWeChat\OpenWork\Corp\Client $corp + * @property \EasyWeChat\OpenWork\Provider\Client $provider + * @property \EasyWeChat\OpenWork\SuiteAuth\AccessToken $suite_access_token + * @property \EasyWeChat\OpenWork\Auth\AccessToken $provider_access_token + * @property \EasyWeChat\OpenWork\SuiteAuth\SuiteTicket $suite_ticket + * @property \EasyWeChat\OpenWork\MiniProgram\Auth\Client $mini_program + */ +class Application extends ServiceContainer +{ + /** + * @var array + */ + protected $providers = [ + Auth\ServiceProvider::class, + SuiteAuth\ServiceProvider::class, + Server\ServiceProvider::class, + Corp\ServiceProvider::class, + Provider\ServiceProvider::class, + MiniProgram\ServiceProvider::class, + ]; + + /** + * @var array + */ + protected $defaultConfig = [ + // http://docs.guzzlephp.org/en/stable/request-options.html + 'http' => [ + 'base_uri' => 'https://qyapi.weixin.qq.com/', + ], + ]; + + /** + * Creates the miniProgram application. + * + * @return \EasyWeChat\Work\MiniProgram\Application + */ + public function miniProgram(): \EasyWeChat\Work\MiniProgram\Application + { + return new \EasyWeChat\Work\MiniProgram\Application($this->getConfig()); + } + + /** + * @param string $authCorpId 企业 corp_id + * @param string $permanentCode 企业永久授权码 + * + * @return Work + */ + public function work(string $authCorpId, string $permanentCode): Work + { + return new Work($authCorpId, $permanentCode, $this); + } + + /** + * @param string $method + * @param array $arguments + * + * @return mixed + */ + public function __call($method, $arguments) + { + return $this['base']->$method(...$arguments); + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/OpenWork/Auth/AccessToken.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OpenWork/Auth/AccessToken.php new file mode 100644 index 0000000..3f00a25 --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OpenWork/Auth/AccessToken.php @@ -0,0 +1,52 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\OpenWork\Auth; + +use EasyWeChat\Kernel\AccessToken as BaseAccessToken; + +/** + * AccessToken. + * + * @author xiaomin + */ +class AccessToken extends BaseAccessToken +{ + protected $requestMethod = 'POST'; + + /** + * @var string + */ + protected $endpointToGetToken = 'cgi-bin/service/get_provider_token'; + + /** + * @var string + */ + protected $tokenKey = 'provider_access_token'; + + /** + * @var string + */ + protected $cachePrefix = 'easywechat.kernel.provider_access_token.'; + + /** + * Credential for get token. + * + * @return array + */ + protected function getCredentials(): array + { + return [ + 'corpid' => $this->app['config']['corp_id'], //服务商的corpid + 'provider_secret' => $this->app['config']['secret'], + ]; + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/OpenWork/Auth/ServiceProvider.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OpenWork/Auth/ServiceProvider.php new file mode 100644 index 0000000..78aba05 --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OpenWork/Auth/ServiceProvider.php @@ -0,0 +1,33 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\OpenWork\Auth; + +use Pimple\Container; +use Pimple\ServiceProviderInterface; + +/** + * ServiceProvider. + * + * @author xiaomin + */ +class ServiceProvider implements ServiceProviderInterface +{ + /** + * {@inheritdoc}. + */ + public function register(Container $app) + { + isset($app['provider_access_token']) || $app['provider_access_token'] = function ($app) { + return new AccessToken($app); + }; + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/OpenWork/Corp/Client.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OpenWork/Corp/Client.php new file mode 100644 index 0000000..689f573 --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OpenWork/Corp/Client.php @@ -0,0 +1,217 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\OpenWork\Corp; + +use EasyWeChat\Kernel\BaseClient; +use EasyWeChat\Kernel\ServiceContainer; + +/** + * Client. + * + * @author xiaomin + */ +class Client extends BaseClient +{ + /** + * Client constructor. + * 三方接口有三个access_token,这里用的是suite_access_token. + * + * @param \EasyWeChat\Kernel\ServiceContainer $app + */ + public function __construct(ServiceContainer $app) + { + parent::__construct($app, $app['suite_access_token']); + } + + /** + * 企业微信安装应用授权 url. + * + * @param string $preAuthCode 预授权码 + * @param string $redirectUri 回调地址 + * @param string $state + * + * @return string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + */ + public function getPreAuthorizationUrl(string $preAuthCode = '', string $redirectUri = '', string $state = '') + { + $redirectUri || $redirectUri = $this->app->config['redirect_uri_install']; + $preAuthCode || $preAuthCode = $this->getPreAuthCode()['pre_auth_code']; + $state || $state = rand(); + + $params = [ + 'suite_id' => $this->app['config']['suite_id'], + 'redirect_uri' => $redirectUri, + 'pre_auth_code' => $preAuthCode, + 'state' => $state, + ]; + + return 'https://open.work.weixin.qq.com/3rdapp/install?'.http_build_query($params); + } + + /** + * 获取预授权码. + * + * @return mixed + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + */ + public function getPreAuthCode() + { + return $this->httpGet('cgi-bin/service/get_pre_auth_code'); + } + + /** + * 设置授权配置. + * 该接口可对某次授权进行配置. + * + * @param string $preAuthCode + * @param array $sessionInfo + * + * @return mixed + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function setSession(string $preAuthCode, array $sessionInfo) + { + $params = [ + 'pre_auth_code' => $preAuthCode, + 'session_info' => $sessionInfo, + ]; + + return $this->httpPostJson('cgi-bin/service/set_session_info', $params); + } + + /** + * 获取企业永久授权码. + * + * @param string $authCode 临时授权码,会在授权成功时附加在redirect_uri中跳转回第三方服务商网站,或通过回调推送给服务商。长度为64至512个字节 + * + * @return mixed + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function getPermanentByCode(string $authCode) + { + $params = [ + 'auth_code' => $authCode, + ]; + + return $this->httpPostJson('cgi-bin/service/get_permanent_code', $params); + } + + /** + * 获取企业授权信息. + * + * @param string $authCorpId + * @param string $permanentCode + * + * @return mixed + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function getAuthorization(string $authCorpId, string $permanentCode) + { + $params = [ + 'auth_corpid' => $authCorpId, + 'permanent_code' => $permanentCode, + ]; + + return $this->httpPostJson('cgi-bin/service/get_auth_info', $params); + } + + /** + * 获取应用的管理员列表. + * + * @param string $authCorpId + * @param string $agentId + * + * @return mixed + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function getManagers(string $authCorpId, string $agentId) + { + $params = [ + 'auth_corpid' => $authCorpId, + 'agentid' => $agentId, + ]; + + return $this->httpPostJson('cgi-bin/service/get_admin_list', $params); + } + + /** + * 获取登录url. + * + * @param string $redirectUri + * @param string $scope + * @param string|null $state + * + * @return string + */ + public function getOAuthRedirectUrl(string $redirectUri = '', string $scope = 'snsapi_userinfo', string $state = null) + { + $redirectUri || $redirectUri = $this->app->config['redirect_uri_oauth']; + $state || $state = rand(); + $params = [ + 'appid' => $this->app['config']['suite_id'], + 'redirect_uri' => $redirectUri, + 'response_type' => 'code', + 'scope' => $scope, + 'state' => $state, + ]; + + return 'https://open.weixin.qq.com/connect/oauth2/authorize?'.http_build_query($params).'#wechat_redirect'; + } + + /** + * 第三方根据code获取企业成员信息. + * + * @param string $code + * + * @return mixed + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + */ + public function getUserByCode(string $code) + { + $params = [ + 'code' => $code, + ]; + + return $this->httpGet('cgi-bin/service/getuserinfo3rd', $params); + } + + /** + * 第三方使用user_ticket获取成员详情. + * + * @param string $userTicket + * + * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function getUserByTicket(string $userTicket) + { + $params = [ + 'user_ticket' => $userTicket, + ]; + + return $this->httpPostJson('cgi-bin/service/getuserdetail3rd', $params); + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/OpenWork/Corp/ServiceProvider.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OpenWork/Corp/ServiceProvider.php new file mode 100644 index 0000000..0cc8ea9 --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OpenWork/Corp/ServiceProvider.php @@ -0,0 +1,38 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\OpenWork\Corp; + +use Pimple\Container; +use Pimple\ServiceProviderInterface; + +/** + * ServiceProvider. + * + * @author xiaomin + */ +class ServiceProvider implements ServiceProviderInterface +{ + /** + * Registers services on the given container. + * + * This method should only be used to configure services and parameters. + * It should not get services. + * + * @param \Pimple\Container $app + */ + public function register(Container $app) + { + isset($app['corp']) || $app['corp'] = function ($app) { + return new Client($app); + }; + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/OpenWork/MiniProgram/Client.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OpenWork/MiniProgram/Client.php new file mode 100644 index 0000000..29dae19 --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OpenWork/MiniProgram/Client.php @@ -0,0 +1,50 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\OpenWork\MiniProgram; + +use EasyWeChat\Kernel\BaseClient; +use EasyWeChat\Kernel\ServiceContainer; + +/** + * Class Client. + */ +class Client extends BaseClient +{ + /** + * Client constructor. + * + * @param \EasyWeChat\Kernel\ServiceContainer $app + */ + public function __construct(ServiceContainer $app) + { + parent::__construct($app, $app['suite_access_token']); + } + + /** + * Get session info by code. + * + * @param string $code + * + * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + */ + public function session(string $code) + { + $params = [ + 'js_code' => $code, + 'grant_type' => 'authorization_code', + ]; + + return $this->httpGet('cgi-bin/service/miniprogram/jscode2session', $params); + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/OpenWork/MiniProgram/ServiceProvider.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OpenWork/MiniProgram/ServiceProvider.php new file mode 100644 index 0000000..8e7dba2 --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OpenWork/MiniProgram/ServiceProvider.php @@ -0,0 +1,31 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\OpenWork\MiniProgram; + +use Pimple\Container; +use Pimple\ServiceProviderInterface; + +/** + * ServiceProvider. + */ +class ServiceProvider implements ServiceProviderInterface +{ + /** + * {@inheritdoc}. + */ + public function register(Container $app) + { + !isset($app['mini_program']) && $app['mini_program'] = function ($app) { + return new Client($app); + }; + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/OpenWork/Provider/Client.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OpenWork/Provider/Client.php new file mode 100644 index 0000000..690d988 --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OpenWork/Provider/Client.php @@ -0,0 +1,206 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\OpenWork\Provider; + +use EasyWeChat\Kernel\BaseClient; +use EasyWeChat\Kernel\ServiceContainer; + +/** + * Client. + * + * @author xiaomin + */ +class Client extends BaseClient +{ + /** + * Client constructor. + * + * + * @param ServiceContainer $app + */ + public function __construct(ServiceContainer $app) + { + parent::__construct($app, $app['provider_access_token']); + } + + /** + * 单点登录 - 获取登录的地址. + * + * @param string $redirectUri + * @param string $userType + * @param string $state + * + * @return string + */ + public function getLoginUrl(string $redirectUri = '', string $userType = 'admin', string $state = '') + { + $redirectUri || $redirectUri = $this->app->config['redirect_uri_single']; + $state || $state = rand(); + $params = [ + 'appid' => $this->app['config']['corp_id'], + 'redirect_uri' => $redirectUri, + 'usertype' => $userType, + 'state' => $state, + ]; + + return 'https://open.work.weixin.qq.com/wwopen/sso/3rd_qrConnect?'.http_build_query($params); + } + + /** + * 单点登录 - 获取登录用户信息. + * + * @param string $authCode + * + * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function getLoginInfo(string $authCode) + { + $params = [ + 'auth_code' => $authCode, + ]; + + return $this->httpPostJson('cgi-bin/service/get_login_info', $params); + } + + /** + * 获取注册定制化URL. + * + * @param string $registerCode + * + * @return string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + * @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException + */ + public function getRegisterUri(string $registerCode = '') + { + if (!$registerCode) { + /** @var array $response */ + $response = $this->detectAndCastResponseToType($this->getRegisterCode(), 'array'); + + $registerCode = $response['register_code']; + } + + $params = ['register_code' => $registerCode]; + + return 'https://open.work.weixin.qq.com/3rdservice/wework/register?'.http_build_query($params); + } + + /** + * 获取注册码. + * + * @param string $corpName + * @param string $adminName + * @param string $adminMobile + * @param string $state + * + * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function getRegisterCode( + string $corpName = '', + string $adminName = '', + string $adminMobile = '', + string $state = '' + ) { + $params = []; + $params['template_id'] = $this->app['config']['reg_template_id']; + !empty($corpName) && $params['corp_name'] = $corpName; + !empty($adminName) && $params['admin_name'] = $adminName; + !empty($adminMobile) && $params['admin_mobile'] = $adminMobile; + !empty($state) && $params['state'] = $state; + + return $this->httpPostJson('cgi-bin/service/get_register_code', $params); + } + + /** + * 查询注册状态. + * + * Desc:该API用于查询企业注册状态,企业注册成功返回注册信息. + * + * @param string $registerCode + * + * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function getRegisterInfo(string $registerCode) + { + $params = [ + 'register_code' => $registerCode, + ]; + + return $this->httpPostJson('cgi-bin/service/get_register_info', $params); + } + + /** + * 设置授权应用可见范围. + * + * Desc:调用该接口前提是开启通讯录迁移,收到授权成功通知后可调用。 + * 企业注册初始化安装应用后,应用默认可见范围为根部门。 + * 如需修改应用可见范围,服务商可以调用该接口设置授权应用的可见范围。 + * 该接口只能使用注册完成回调事件或者查询注册状态返回的access_token。 + * 调用设置通讯录同步完成后或者access_token超过30分钟失效(即解除通讯录锁定状态)则不能继续调用该接口。 + * + * @param string $accessToken + * @param string $agentId + * @param array $allowUser + * @param array $allowParty + * @param array $allowTag + * + * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + */ + public function setAgentScope( + string $accessToken, + string $agentId, + array $allowUser = [], + array $allowParty = [], + array $allowTag = [] + ) { + $params = [ + 'agentid' => $agentId, + 'allow_user' => $allowUser, + 'allow_party' => $allowParty, + 'allow_tag' => $allowTag, + 'access_token' => $accessToken, + ]; + + return $this->httpGet('cgi-bin/agent/set_scope', $params); + } + + /** + * 设置通讯录同步完成. + * + * Desc:该API用于设置通讯录同步完成,解除通讯录锁定状态,同时使通讯录迁移access_token失效。 + * + * @param string $accessToken + * + * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + */ + public function contactSyncSuccess(string $accessToken) + { + $params = ['access_token' => $accessToken]; + + return $this->httpGet('cgi-bin/sync/contact_sync_success', $params); + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/OpenWork/Provider/ServiceProvider.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OpenWork/Provider/ServiceProvider.php new file mode 100644 index 0000000..2185fec --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OpenWork/Provider/ServiceProvider.php @@ -0,0 +1,36 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\OpenWork\Provider; + +use Pimple\Container; +use Pimple\ServiceProviderInterface; + +/** + * ServiceProvider. + * + * @author xiaomin + */ +class ServiceProvider implements ServiceProviderInterface +{ + protected $app; + + /** + * @param Container $app + */ + public function register(Container $app) + { + $this->app = $app; + isset($app['provider']) || $app['provider'] = function ($app) { + return new Client($app); + }; + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/OpenWork/Server/Guard.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OpenWork/Server/Guard.php new file mode 100644 index 0000000..5700a77 --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OpenWork/Server/Guard.php @@ -0,0 +1,68 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\OpenWork\Server; + +use EasyWeChat\Kernel\Encryptor; +use EasyWeChat\Kernel\ServerGuard; + +/** + * Guard. + * + * @author xiaomin + */ +class Guard extends ServerGuard +{ + /** + * @var bool + */ + protected $alwaysValidate = true; + + /** + * @return $this + */ + public function validate() + { + return $this; + } + + /** + * @return bool + */ + protected function shouldReturnRawResponse(): bool + { + return !is_null($this->app['request']->get('echostr')); + } + + protected function isSafeMode(): bool + { + return true; + } + + /** + * @param array $message + * + * @return mixed + * + * @throws \EasyWeChat\Kernel\Exceptions\RuntimeException + */ + protected function decryptMessage(array $message) + { + $encryptor = new Encryptor($message['ToUserName'], $this->app['config']->get('token'), $this->app['config']->get('aes_key')); + + return $message = $encryptor->decrypt( + $message['Encrypt'], + $this->app['request']->get('msg_signature'), + $this->app['request']->get('nonce'), + $this->app['request']->get('timestamp') + ); + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/OpenWork/Server/Handlers/EchoStrHandler.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OpenWork/Server/Handlers/EchoStrHandler.php new file mode 100644 index 0000000..78af701 --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OpenWork/Server/Handlers/EchoStrHandler.php @@ -0,0 +1,62 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\OpenWork\Server\Handlers; + +use EasyWeChat\Kernel\Contracts\EventHandlerInterface; +use EasyWeChat\Kernel\Decorators\FinallyResult; +use EasyWeChat\Kernel\ServiceContainer; + +/** + * EchoStrHandler. + * + * @author xiaomin + */ +class EchoStrHandler implements EventHandlerInterface +{ + /** + * @var ServiceContainer + */ + protected $app; + + /** + * EchoStrHandler constructor. + * + * @param ServiceContainer $app + */ + public function __construct(ServiceContainer $app) + { + $this->app = $app; + } + + /** + * @param mixed $payload + * + * @return FinallyResult|null + */ + public function handle($payload = null) + { + if ($decrypted = $this->app['request']->get('echostr')) { + $str = $this->app['encryptor_corp']->decrypt( + $decrypted, + $this->app['request']->get('msg_signature'), + $this->app['request']->get('nonce'), + $this->app['request']->get('timestamp') + ); + + return new FinallyResult($str); + } + //把SuiteTicket缓存起来 + if (!empty($payload['SuiteTicket'])) { + $this->app['suite_ticket']->setTicket($payload['SuiteTicket']); + } + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/OpenWork/Server/ServiceProvider.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OpenWork/Server/ServiceProvider.php new file mode 100644 index 0000000..d33d5c8 --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OpenWork/Server/ServiceProvider.php @@ -0,0 +1,56 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\OpenWork\Server; + +use EasyWeChat\Kernel\Encryptor; +use EasyWeChat\OpenWork\Server\Handlers\EchoStrHandler; +use Pimple\Container; +use Pimple\ServiceProviderInterface; + +/** + * ServiceProvider. + * + * @author xiaomin + */ +class ServiceProvider implements ServiceProviderInterface +{ + /** + * {@inheritdoc}. + */ + public function register(Container $app) + { + //微信第三方在校验url是使用的是GET方式请求和corp_id进行加密 + !isset($app['encryptor_corp']) && $app['encryptor_corp'] = function ($app) { + return new Encryptor( + $app['config']['corp_id'], + $app['config']['token'], + $app['config']['aes_key'] + ); + }; + + //微信第三方推送数据时使用的是suite_id进行加密 + !isset($app['encryptor']) && $app['encryptor'] = function ($app) { + return new Encryptor( + $app['config']['suite_id'], + $app['config']['token'], + $app['config']['aes_key'] + ); + }; + + !isset($app['server']) && $app['server'] = function ($app) { + $guard = new Guard($app); + $guard->push(new EchoStrHandler($app)); + + return $guard; + }; + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/OpenWork/SuiteAuth/AccessToken.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OpenWork/SuiteAuth/AccessToken.php new file mode 100644 index 0000000..e4e248d --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OpenWork/SuiteAuth/AccessToken.php @@ -0,0 +1,56 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\OpenWork\SuiteAuth; + +use EasyWeChat\Kernel\AccessToken as BaseAccessToken; + +/** + * AccessToken. + * + * @author xiaomin + */ +class AccessToken extends BaseAccessToken +{ + /** + * @var string + */ + protected $requestMethod = 'POST'; + + /** + * @var string + */ + protected $endpointToGetToken = 'cgi-bin/service/get_suite_token'; + + /** + * @var string + */ + protected $tokenKey = 'suite_access_token'; + + /** + * @var string + */ + protected $cachePrefix = 'easywechat.kernel.suite_access_token.'; + + /** + * Credential for get token. + * + * @return array + */ + protected function getCredentials(): array + { + return [ + 'suite_id' => $this->app['config']['suite_id'], + 'suite_secret' => $this->app['config']['suite_secret'], + 'suite_ticket' => $this->app['suite_ticket']->getTicket(), + ]; + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/OpenWork/SuiteAuth/ServiceProvider.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OpenWork/SuiteAuth/ServiceProvider.php new file mode 100644 index 0000000..a4f5386 --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OpenWork/SuiteAuth/ServiceProvider.php @@ -0,0 +1,37 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\OpenWork\SuiteAuth; + +use Pimple\Container; +use Pimple\ServiceProviderInterface; + +/** + * ServiceProvider. + * + * @author xiaomin + */ +class ServiceProvider implements ServiceProviderInterface +{ + /** + * {@inheritdoc}. + */ + public function register(Container $app) + { + $app['suite_ticket'] = function ($app) { + return new SuiteTicket($app); + }; + + isset($app['suite_access_token']) || $app['suite_access_token'] = function ($app) { + return new AccessToken($app); + }; + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/OpenWork/SuiteAuth/SuiteTicket.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OpenWork/SuiteAuth/SuiteTicket.php new file mode 100644 index 0000000..4c01710 --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OpenWork/SuiteAuth/SuiteTicket.php @@ -0,0 +1,85 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\OpenWork\SuiteAuth; + +use EasyWeChat\Kernel\Exceptions\RuntimeException; +use EasyWeChat\Kernel\Traits\InteractsWithCache; +use EasyWeChat\OpenWork\Application; + +/** + * SuiteTicket. + * + * @author xiaomin + */ +class SuiteTicket +{ + use InteractsWithCache; + + /** + * @var Application + */ + protected $app; + + /** + * SuiteTicket constructor. + * + * @param Application $app + */ + public function __construct(Application $app) + { + $this->app = $app; + } + + /** + * @param string $ticket + * + * @return $this + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException + * @throws \EasyWeChat\Kernel\Exceptions\RuntimeException + * @throws \Psr\SimpleCache\InvalidArgumentException + */ + public function setTicket(string $ticket) + { + $this->getCache()->set($this->getCacheKey(), $ticket, 1800); + + if (!$this->getCache()->has($this->getCacheKey())) { + throw new RuntimeException('Failed to cache suite ticket.'); + } + + return $this; + } + + /** + * @return string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException + * @throws \EasyWeChat\Kernel\Exceptions\RuntimeException + * @throws \Psr\SimpleCache\InvalidArgumentException + */ + public function getTicket(): string + { + if ($cached = $this->getCache()->get($this->getCacheKey())) { + return $cached; + } + + throw new RuntimeException('Credential "suite_ticket" does not exist in cache.'); + } + + /** + * @return string + */ + protected function getCacheKey(): string + { + return 'easywechat.open_work.suite_ticket.'.$this->app['config']['suite_id']; + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/OpenWork/Work/Application.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OpenWork/Work/Application.php new file mode 100644 index 0000000..676013d --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OpenWork/Work/Application.php @@ -0,0 +1,41 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\OpenWork\Work; + +use EasyWeChat\OpenWork\Application as OpenWork; +use EasyWeChat\OpenWork\Work\Auth\AccessToken; +use EasyWeChat\Work\Application as Work; + +/** + * Application. + * + * @author xiaomin + */ +class Application extends Work +{ + /** + * Application constructor. + * + * @param string $authCorpId + * @param string $permanentCode + * @param OpenWork $component + * @param array $prepends + */ + public function __construct(string $authCorpId, string $permanentCode, OpenWork $component, array $prepends = []) + { + parent::__construct($component->getConfig(), $prepends + [ + 'access_token' => function ($app) use ($authCorpId, $permanentCode, $component) { + return new AccessToken($app, $authCorpId, $permanentCode, $component); + }, + ]); + } +} diff --git a/addons/weliam_smartcity/vendor/overtrue/wechat/src/OpenWork/Work/Auth/AccessToken.php b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OpenWork/Work/Auth/AccessToken.php new file mode 100644 index 0000000..e80758a --- /dev/null +++ b/addons/weliam_smartcity/vendor/overtrue/wechat/src/OpenWork/Work/Auth/AccessToken.php @@ -0,0 +1,80 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\OpenWork\Work\Auth; + +use EasyWeChat\Kernel\AccessToken as BaseAccessToken; +use EasyWeChat\OpenWork\Application; +use Pimple\Container; + +/** + * AccessToken. + * + * @author xiaomin + */ +class AccessToken extends BaseAccessToken +{ + /** + * @var string + */ + protected $requestMethod = 'POST'; + + /** + * @var string 授权方企业ID + */ + protected $authCorpid; + + /** + * @var string 授权方企业永久授权码,通过get_permanent_code获取 + */ + protected $permanentCode; + + protected $component; + + /** + * AccessToken constructor. + * + * @param Container $app + * @param string $authCorpId + * @param string $permanentCode + * @param Application $component + */ + public function __construct(Container $app, string $authCorpId, string $permanentCode, Application $component) + { + $this->authCorpid = $authCorpId; + $this->permanentCode = $permanentCode; + $this->component = $component; + parent::__construct($app); + } + + /** + * Credential for get token. + * + * @return array + */ + protected function getCredentials(): array + { + return [ + 'auth_corpid' => $this->authCorpid, + 'permanent_code' => $this->permanentCode, + ]; + } + + /** + * @return string + */ + public function getEndpoint(): string + { + return 'cgi-bin/service/get_corp_token?'.http_build_query([ + 'suite_access_token' => $this->component['suite_access_token']->getToken()['suite_access_token'], + ]); + } +}