diff --git a/app/Admin/Common/Sms.php b/app/Admin/Common/Sms.php new file mode 100644 index 0000000..0309edf --- /dev/null +++ b/app/Admin/Common/Sms.php @@ -0,0 +1,41 @@ +regionId('cn-shenzhen') + ->asDefaultClient(); + try { + $result = AlibabaCloud::rpc() + ->product('Dysmsapi') + ->version('2017-05-25') + ->action('SendSms') + ->method('POST') + ->host('dysmsapi.aliyuncs.com') + ->options([ + 'query' => $params, + ]) + ->request(); + dd($result); + }catch (ClientException $e){ + echo $e->getErrorMessage() . PHP_EOL; + }catch (ServerException $e){ + echo $e->getErrorMessage() . PHP_EOL; + } + } +} diff --git a/app/Admin/Controllers/LanzuMpWithdrawController.php b/app/Admin/Controllers/LanzuMpWithdrawController.php index 5fb4ea7..30a4d99 100755 --- a/app/Admin/Controllers/LanzuMpWithdrawController.php +++ b/app/Admin/Controllers/LanzuMpWithdrawController.php @@ -3,6 +3,7 @@ namespace App\Admin\Controllers; use App\Admin\Common\FinancialRecord; +use App\Admin\Common\Sms; use App\Admin\Repositories\LanzuMpWithdraw; use App\Models\ImsCjdcMarket; use App\Models\LanzuMpWithdraw as modelMpInfo; @@ -204,12 +205,21 @@ class LanzuMpWithdrawController extends AdminController $form->number('money', '提现金额')->required()->min(0); $form->ignore(['balance']); //添加成功之后,扣减掉可提现金额 - $form->saved(function (Form $form, $result) use ($mpb) { - + $form->saved(function (Form $form, $result) use ($mpb,$mp) { if ($form->isCreating()) { if ($result) { $mpb->balance = $mpb->balance - $form->money; $mpb->save(); + + //发送短信通知 + $params = [ + 'RegionId' => "cn-shenzhen", + 'PhoneNumbers' => env('SMS_MM_TEL'), + 'SignName' => "懒族生活", + 'TemplateCode' => "SMS_201680806", + 'TemplateParam' => json_encode(['name'=>"[{$mp->name}]",'money'=>$form->money.'元']), + ]; + Sms::sent($params); } } }); diff --git a/app/Admin/Controllers/Test.php b/app/Admin/Controllers/Test.php index c9db6e8..456f503 100644 --- a/app/Admin/Controllers/Test.php +++ b/app/Admin/Controllers/Test.php @@ -8,28 +8,32 @@ use AlibabaCloud\Client\AlibabaCloud; use AlibabaCloud\Client\Exception\ClientException; use AlibabaCloud\Client\Exception\ServerException; use Dcat\Admin\Controllers\AdminController; +use Graze\GuzzleHttp\JsonRpc\Client; class Test extends AdminController { public function sentSms() { - AlibabaCloud::accessKeyClient('LTAI4GBjK1Ha8r8fvDdq9atk','ZbRGJT44SEE2GGGy29bPmBVY2e2D6l') + $params = [ + 'RegionId' => "cn-shenzhen", + 'PhoneNumbers' => "13481194554", + 'SignName' => "懒族生活", + 'TemplateCode' => "SMS_201720790", + 'TemplateParam' => json_encode(['name'=>'DESION','money'=>999]), + ]; + AlibabaCloud::accessKeyClient(env('OSS_ACCESS_ID'),env('OSS_ACCESS_SECRET')) ->regionId('cn-shenzhen') ->asDefaultClient(); try { $result = AlibabaCloud::rpc() ->product('Dysmsapi') - ->version('2020-09-4') + ->version('2017-05-25') ->action('SendSms') ->method('POST') ->host('dysmsapi.aliyuncs.com') ->options([ - 'query' => [ - 'RegionId' => "cn-shenzhen", - 'PhoneNumbers' => "13481194554", - 'SignName' => "懒族 ", - ], + 'query' => $params ]) ->request(); dd($result); @@ -39,4 +43,40 @@ class Test extends AdminController echo $e->getErrorMessage() . PHP_EOL; } } + + + + public function testRpc() + { + $client = Client::factory('http://store.api.lanzulive.com:9505'); + $request = $client->request(uniqid(),'/myrpc/mymethod', ['args' => null]); + $response = $client->send($request); + return $response->getBody()->getContents(); + } + + + + + + + + + + + + + + + + + + + + + + + + + + } diff --git a/app/Admin/routes.php b/app/Admin/routes.php index 258b144..4d93c8b 100644 --- a/app/Admin/routes.php +++ b/app/Admin/routes.php @@ -44,5 +44,6 @@ Route::group([ //统计店铺新增用户 $router->resource('/storeUserReport', 'StoreUserReportController'); - $router->any('/test', 'Test@test'); + $router->any('/sentsms', 'Test@sentSms'); + $router->any('/rpc', 'Test@testRpc'); }); diff --git a/composer.json b/composer.json index 948dc92..ff066a8 100644 --- a/composer.json +++ b/composer.json @@ -13,6 +13,7 @@ "dcat/laravel-admin": "^1.6", "fideloper/proxy": "^4.2", "fruitcake/laravel-cors": "^1.0", + "graze/guzzle-jsonrpc": "^3.2", "guzzlehttp/guzzle": "^6.3", "iidestiny/laravel-filesystem-oss": "^2.0", "laravel/framework": "^7.0", diff --git a/composer.lock b/composer.lock index 669e029..7cf463a 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "5fc4493cba11b36fcbba5ca797e0355a", + "content-hash": "a9fe5983d07b33755016777d63217c0a", "packages": [ { "name": "adbario/php-dot-notation", @@ -1261,6 +1261,71 @@ ], "time": "2020-04-28T08:47:37+00:00" }, + { + "name": "graze/guzzle-jsonrpc", + "version": "3.2.1", + "source": { + "type": "git", + "url": "https://github.com/graze/guzzle-jsonrpc.git", + "reference": "c4513b7659534792b906723158a8388f54275a61" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/graze/guzzle-jsonrpc/zipball/c4513b7659534792b906723158a8388f54275a61", + "reference": "c4513b7659534792b906723158a8388f54275a61", + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] + }, + "require": { + "guzzlehttp/guzzle": "^6.0", + "guzzlehttp/promises": "^1.0", + "php": ">=5.5", + "psr/http-message": "^1.0" + }, + "require-dev": { + "adlawson/timezone": "~1.0", + "fabpot/php-cs-fixer": "~0.5", + "mockery/mockery": "~0.9", + "phpunit/phpunit": "~4.3" + }, + "type": "library", + "autoload": { + "files": [ + "src/functions_include.php" + ], + "psr-4": { + "Graze\\GuzzleHttp\\JsonRpc\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Graze tech team", + "homepage": "https://github.com/graze/guzzle-jsonrpc/graphs/contributors" + } + ], + "description": "JSON-RPC 2.0 client for Guzzle", + "homepage": "https://github.com/graze/guzzle-jsonrpc", + "keywords": [ + "Guzzle", + "guzzlehttp", + "http", + "json", + "json-rpc", + "jsonrpc", + "ring", + "rpc" + ], + "time": "2016-02-16T15:18:21+00:00" + }, { "name": "guzzlehttp/guzzle", "version": "6.5.5",