| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- <?php
- /**
- * Created by PhpStorm.
- * Author: 芸众商城 www.yunzshop.com
- * Date: 2021/2/2
- * Time: 15:33
- */
- namespace app\common\modules\sms\factory;
- use app\common\modules\sms\Sms;
- use iscms\Alisms\SendsmsPusher;
- use app\platform\modules\system\models\SystemSetting;
- use GuzzleHttp\Client;
- class ElisoftSms extends Sms
- {
- public function sendBalance($mobile, $ext)
- {
- return ;
- }
- public function sendGoods($mobile, $ext)
- {
- return;
- }
- public function sendMemberRecharge($mobile, $ext)
- {
- return;
- }
- public function _sendCode($mobile, $state, $ext = null)
- {
- try {
- if (!app('plugins')->isEnabled('elisoftsms')) {
- throw new \Exception('未开启验证码,请联系管理员!');
- }
- $setting = SystemSetting::settingLoad('sms', 'system_sms');
- $code = $this->getCode($mobile,$this->key);
- $msg = '【' . $this->sms['elisoft_signname'] . '】' . '您的验证码是:' . $code . '。请不要把验证码泄露给其他人。如非本人操作,可不用理会!';
- $account = $this->sms['elisoft_account'];
- $passward = $this->sms['elisoft_password'];
- if($setting['interior_sms_type']==1){
- $param = [
- 'c' => urlencode($msg),
- 'p' => $mobile,
- ];
- $sms = new \Yunshop\Elisoftsms\services\ElisoftSmsService($account,$passward);
- $res = $sms->setAction('sendbatch')->send($param);
- if ($res['result'] != 1) {
- throw new \Exception($res['errormsg']);
- }
- }else{
- $msgArr=[
- '-1'=>'Uid或密码为空',
- '-2'=>'下发号码为空',
- '-3'=>'下发内容为空',
- '-4'=>'内容超长',
- '-5'=>'下发号码超长',
- '-6'=>'uid或密码不正确',
- '-7'=>'短信余额不足',
- '-8'=>'IP地址鉴权不对',
- '-9'=>'协议类型不对',
- '-99'=>'系统异常'
- ];
- $url="http://3qdx.com:18002/send.do";
- $param=['uid'=>$setting['klws_account'],'pw'=>md5($setting['klws_password'].date('YmdHis')),'mb'=>$mobile,'tm'=>date('YmdHis'),'ms'=>$msg];
- $url=$url.'?'.http_build_query($param);
- $client = new Client();
- $res=$client->get($url)->getBody()->getContents();
- if (in_array($res,['-1','-2','-3','-4','-5','-6','-7','-8','-9','-99'])) {
- throw new \Exception($res);
- }
- }
- return true;
- } catch (\Exception $e) {
- \Log::debug('elisoftsms短信'.$e->getMessage(),[isset($res)?$res:'',isset($param)?$param:'']);
- return $e->getMessage();
- }
- }
- }
|