From fdddbbec51e59e38818529323481f68eae247e4b Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Wed, 26 Jun 2024 16:38:04 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=95=E7=9F=AD=E4=BF=A1=E8=B0=83?= =?UTF-8?q?=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/controller/IndexController.php | 53 +++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) diff --git a/app/api/controller/IndexController.php b/app/api/controller/IndexController.php index 8c4d47047..cd0862a83 100644 --- a/app/api/controller/IndexController.php +++ b/app/api/controller/IndexController.php @@ -14,6 +14,8 @@ use app\common\service\PushService; use app\common\service\wechat\WechatTemplate; use app\statistics\logic\OrderLogic; use Exception; +use Overtrue\EasySms\EasySms; +use Overtrue\EasySms\Exceptions\NoGatewayAvailableException; use support\Cache; use think\facade\Db; use Webman\Config; @@ -29,7 +31,56 @@ class IndexController extends BaseApiController public $notNeedLogin = ['index', 'app_update', 'express_list', 'province', 'city', 'area', 'street', 'village', 'brigade', 'config']; public function index() - { $all_where['paid'] = 1; + { + $config = [ + // HTTP 请求的超时时间(秒) + 'timeout' => 5.0, + + // 默认发送配置 + 'default' => [ + // 网关调用策略,默认:顺序调用 + 'strategy' => \Overtrue\EasySms\Strategies\OrderStrategy::class, + + // 默认可用的发送网关 + 'gateways' => [ + 'yunpian', 'aliyun', + ], + ], + // 可用的网关配置 + 'gateways' => [ + 'errorlog' => [ + 'file' => runtime_path() . '/logs/' . date('Ymd') . '/easy-sms.log', + ], + 'aliyun' => [ + 'access_key_id' => 'LTAI5t7mhH3ij2cNWs1zhPmv', + 'access_key_secret' => 'gqo2wMpvi8h5bDBmCpMje6BaiXvcPu', + 'sign_name' => '里海科技', + ], + //... + ], + ]; + + try { + $easySms = new EasySms($config); + $template = getenv('SMS_TEMPLATE'); + $a = $easySms->send(18715753257, [ + 'content' => '您的验证码为: 6379', + 'template' => $template, + 'data' => [ + 'code' => 6379 + ], + ]); +// d($a); + }catch (NoGatewayAvailableException $exception){ + throw new \Exception($exception->getExceptions()); + } + + d($a,getenv('SMS_TEMPLATE')); + + + + + $all_where['paid'] = 1; d(OrderLogic::dayPayPrice($all_where,date('Y-m-d',time()))); $uid=9; $a= PushService::push('wechat_mmp_'.$uid, $uid, ['type'=>'INDUSTRYMEMBERS','msg'=>'支付超时,订单已被取消,请重新提交订单','data'=>['id'=>5]]);