Browse Source

增加 短信通知RPC

master
lanzu_qsy 5 years ago
parent
commit
61245a039c
  1. 36
      app/JsonRpc/AlismsService.php
  2. 10
      app/JsonRpc/SmsServiceInterface.php
  3. 1
      config/autoload/dependencies.php

36
app/JsonRpc/AlismsService.php

@ -0,0 +1,36 @@
<?php
namespace App\JsonRpc;
use App\Service\SmsAliService;
use Hyperf\RpcServer\Annotation\RpcService;
use Hyperf\Di\Annotation\Inject;
/**
* @RpcService(name="AlismsService", protocol="jsonrpc-http", server="jsonrpc-http", publishTo="")
* Class AliSmsService
* @package App\JsonRpc
*/
class AlismsService implements SmsServiceInterface
{
/**
* @Inject
* @var SmsAliService
*/
private $smsAliService;
/**
* 阿里短信
* @param $phone
* @param $template
* @param $templateParams
* @param string $signName
* @return array|bool
*/
public function sent($phone, $template, $templateParams, $signName = '懒族生活')
{
return $this->smsAliService->send($phone, $template, $templateParams, $signName = '懒族生活');
}
}

10
app/JsonRpc/SmsServiceInterface.php

@ -0,0 +1,10 @@
<?php
namespace App\JsonRpc;
interface SmsServiceInterface
{
public function sent($phone, $template, $templateParams, $signName='懒族生活');
}

1
config/autoload/dependencies.php

@ -36,4 +36,5 @@ return [
\App\Service\SmsServiceInterface::class => \App\Service\SmsAliService::class,
\App\Service\OrderListServiceInterface::class => \App\Service\OrderListService::class,
\App\Service\StoreServiceInterface::class => \App\Service\StoreService::class,
\App\JsonRpc\SmsServiceInterface::class => \App\JsonRpc\AlismsService::class,
];
Loading…
Cancel
Save