测试短信调用

This commit is contained in:
liu 2024-06-26 16:38:04 +08:00
parent 338354ee77
commit fdddbbec51

View File

@ -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]]);