Browse Source
Merge branch 'phoenix' of http://120.24.33.109:11081/hyzjshwo/lanzu_api_hyperf into phoenix
master
Merge branch 'phoenix' of http://120.24.33.109:11081/hyzjshwo/lanzu_api_hyperf into phoenix
master
12 changed files with 70 additions and 95 deletions
-
2app/Constants/v3/ErrorCode.php
-
5app/Constants/v3/SmsTemplateCode.php
-
9app/Controller/v3/GoodsRecommendController.php
-
2app/Controller/v3/WithdrawController.php
-
13app/Service/v3/Implementations/FinancialRecordService.php
-
25app/Service/v3/Implementations/PaymentService.php
-
4app/Service/v3/Implementations/SearchService.php
-
21app/Service/v3/Implementations/SmsAliSendService.php
-
69app/Service/v3/Implementations/SmsAliService.php
-
4app/Service/v3/Interfaces/SmsSendServiceInterface.php
-
9app/Service/v3/Interfaces/SmsServiceInterface.php
-
2config/autoload/dependencies.php
@ -1,69 +0,0 @@ |
|||||
<?php |
|
||||
|
|
||||
namespace App\Service\v3\Implementations; |
|
||||
|
|
||||
use AlibabaCloud\Client\AlibabaCloud; |
|
||||
use AlibabaCloud\Client\Exception\ClientException; |
|
||||
use AlibabaCloud\Client\Exception\ServerException; |
|
||||
use App\Commons\Log; |
|
||||
use App\Model\v3\CsInfo; |
|
||||
use App\Model\v3\Market; |
|
||||
use App\Service\v3\Interfaces\SmsServiceInterface; |
|
||||
use Hyperf\Di\Annotation\Inject; |
|
||||
|
|
||||
class SmsAliService implements SmsServiceInterface |
|
||||
{ |
|
||||
const TEMPLATE_COMMUNITY_FINANCIAL = 'SMS_200690862'; |
|
||||
|
|
||||
/** |
|
||||
* @Inject |
|
||||
* @var Log |
|
||||
*/ |
|
||||
protected $log; |
|
||||
|
|
||||
public function send($phone, $template, $templateParams, $signName='懒族生活') |
|
||||
{ |
|
||||
|
|
||||
$alisms = config('alisms'); |
|
||||
AlibabaCloud::accessKeyClient($alisms['app_key'], $alisms['app_secret']) |
|
||||
->regionId($alisms['regionid']) |
|
||||
->asDefaultClient(); |
|
||||
|
|
||||
try { |
|
||||
$result = AlibabaCloud::rpc() |
|
||||
->product($alisms['product']) |
|
||||
// ->scheme('https') // https | http
|
|
||||
->version('2017-05-25') |
|
||||
->action('SendSms') |
|
||||
->method('POST') |
|
||||
->host($alisms['host']) |
|
||||
->options([ |
|
||||
'query' => [ |
|
||||
'RegionId' => $alisms['regionid'], |
|
||||
'PhoneNumbers' => $phone, |
|
||||
'SignName' => $signName, |
|
||||
'TemplateCode' => $template, |
|
||||
'TemplateParam' => $templateParams, |
|
||||
], |
|
||||
]) |
|
||||
->request(); |
|
||||
return $result->toArray(); |
|
||||
} catch (ClientException $e) { |
|
||||
$this->log->event('alisms', ['alisms_error_ClientException' => $e->getErrorMessage()]); |
|
||||
return false; |
|
||||
} catch (ServerException $e) { |
|
||||
$this->log->event('alisms', ['alisms_error_ServerException' => $e->getErrorMessage()]); |
|
||||
return false; |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
public function sendForCommunityFinancial($userId, $money) |
|
||||
{ |
|
||||
|
|
||||
$csInfo = CsInfo::query()->where(['admin_user_id' => $userId])->first(); |
|
||||
$market = Market::query()->where(['id' => $csInfo->market_id])->first(); |
|
||||
|
|
||||
$params = ['user_name' => $csInfo->name, 'market_name' => $market->name, 'money' => $money]; |
|
||||
return $this->send($csInfo->phone, self::TEMPLATE_COMMUNITY_FINANCIAL, json_encode($params)); |
|
||||
} |
|
||||
} |
|
||||
@ -1,9 +0,0 @@ |
|||||
<?php |
|
||||
|
|
||||
namespace App\Service\v3\Interfaces; |
|
||||
|
|
||||
interface SmsServiceInterface |
|
||||
{ |
|
||||
public function send($phone, $template, $templateParams); |
|
||||
public function sendForCommunityFinancial($userId, $money); |
|
||||
} |
|
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue