瀏覽代碼

知识付费发通知短信

lizhen_gitee 6 天之前
父節點
當前提交
5d5b76fc0f

+ 2 - 0
app/Admin/Controllers/Traits/WxSettingTraits/formApiTrait.php

@@ -80,6 +80,7 @@ HTML
                 $form->text('app_sms_aliyun_sign_name', '短信签名名称(不是模版名称!)')->placeholder('宠也')->default(Settings::get('app_sms_aliyun_sign_name', ''));
                 $form->text('app_sms_aliyun_template_id', '国内短信模版ID')->placeholder('SMS_44220021')->default(Settings::get('app_sms_aliyun_template_id', ''));
                 $form->text('app_sms_aliyun_out_template_id', '国际短信模版ID')->placeholder('SMS_211488031')->default(Settings::get('app_sms_aliyun_out_template_id', ''));
+                $form->text('app_sms_aliyun_notice_template_id', '国内知识付费通知短信模版ID')->placeholder('SMS_482965175')->default(Settings::get('app_sms_aliyun_notice_template_id', ''));
             })->when(2, function (Form $form){
                 $form->text('app_sms_smsbao_username', '用户名')->help('<a href="https://www.smsbao.com/" target="_blank">官网:https://www.smsbao.com/</a>>')->default(Settings::get('app_sms_smsbao_username', ''));
                 $form->text('app_sms_smsbao_password', '密码')->default(Settings::get('app_sms_smsbao_password', ''));
@@ -157,6 +158,7 @@ HTML
         Settings::set('app_sms_aliyun_sign_name', $request->input('app_sms_aliyun_sign_name'), true);
         Settings::set('app_sms_aliyun_template_id', $request->input('app_sms_aliyun_template_id'), true);
         Settings::set('app_sms_aliyun_out_template_id', $request->input('app_sms_aliyun_out_template_id'), true);
+        Settings::set('app_sms_aliyun_notice_template_id', $request->input('app_sms_aliyun_notice_template_id'), true);
 
         Settings::set('app_sms_tecent_secretId', $request->input('app_sms_tecent_secretId'), true);
         Settings::set('app_sms_tecent_secretKey', $request->input('app_sms_tecent_secretKey'), true);

+ 1 - 1
app/Http/Controllers/Api/AskController.php

@@ -99,7 +99,7 @@ class AskController extends BaseController
             $phone = $blogger_userinfo->phone;
 
             //
-            //$res = Utils::sendSMS($idd,$phone, $code, 60, 'code:'.$idd.':'.$phone);
+            $res = Utils::sendSMSnotice($idd,$phone);
         }
 
 

+ 1 - 1
app/Http/Controllers/Api/ChatController.php

@@ -339,7 +339,7 @@ class ChatController extends BaseController
                             $phone = $ask_userinfo->phone;
 
                             //
-                            //$res = Utils::sendSMS($idd,$phone, $code, 60, 'code:'.$idd.':'.$phone);
+                            $res = Utils::sendSMSnotice($idd,$phone);
                         }
                     }
                 }

+ 82 - 0
app/Wen/Utils/Utils.php

@@ -957,6 +957,88 @@ class Utils
         }
     }
 
+    //知识付费用的短信通知
+    public static function sendSMSnotice($iddcode, $phone){
+        $resp = [
+            'code' => 0,
+            'msg' => ''
+        ];
+        $platform = Settings::get('app_sms_platform', 0);
+        try{
+            $number = new PhoneNumber($phone, $iddcode);
+            if($platform == 0){
+
+            }else if($platform == 1){
+                if($iddcode != 86){
+                    $config = [
+                        // HTTP 请求的超时时间(秒)
+                        'timeout' => 5.0,
+                        // 默认发送配置
+                        'default' => [
+                            // 网关调用策略,默认:顺序调用
+                            'strategy' => \Overtrue\EasySms\Strategies\OrderStrategy::class,
+                            // 默认可用的发送网关
+                            'gateways' => [
+                                'AliyunIntl',
+                            ],
+                        ],
+                        // 可用的网关配置
+                        'gateways' => [
+                            'errorlog' => [
+                                'file' => storage_path('logs/sms.log'),
+                            ],
+                            'AliyunIntl' => [
+                                'access_key_id' => Settings::get('app_sms_aliyun_secretId', ''), // SECRET ID
+                                'access_key_secret' => Settings::get('app_sms_aliyun_secretKey', ''), // SECRET KEY
+                                'sign_name' => Settings::get('app_sms_aliyun_sign_name'), // 短信签名
+                            ],
+                        ],
+                    ];
+                }else{
+                    $config = [
+                        // HTTP 请求的超时时间(秒)
+                        'timeout' => 5.0,
+                        // 默认发送配置
+                        'default' => [
+                            // 网关调用策略,默认:顺序调用
+                            'strategy' => \Overtrue\EasySms\Strategies\OrderStrategy::class,
+                            // 默认可用的发送网关
+                            'gateways' => [
+                                'aliyun',
+                            ],
+                        ],
+                        // 可用的网关配置
+                        'gateways' => [
+                            'errorlog' => [
+                                'file' => storage_path('logs/sms.log'),
+                            ],
+                            'aliyun' => [
+                                'access_key_id' => Settings::get('app_sms_aliyun_secretId', ''), // SECRET ID
+                                'access_key_secret' => Settings::get('app_sms_aliyun_secretKey', ''), // SECRET KEY
+                                'sign_name' => Settings::get('app_sms_aliyun_sign_name'), // 短信签名
+                            ]
+                        ],
+                    ];
+                }
+                $easySms = new EasySms($config);
+                $rs = $easySms->send($number, [
+                    'content'  => '您好,您在乙勇前行发起的或者收到的付费咨询,对方已经回复您,请及时登录查看和回复。',
+                    'template' => $iddcode != 86 ? Settings::get('app_sms_aliyun_notice_template_id', '') : Settings::get('app_sms_aliyun_notice_template_id', ''),
+                ]);
+                //dd($rs);
+            }else if($platform == 2){
+
+            }
+
+
+            $resp['code'] = 200;
+            return $resp;
+        }catch (\Exception $e){
+
+            return $resp;
+        }
+    }
+
     public static function get_online_tenants(){
         $is_multi_site = Settings::get('is_multi_site', 0);
         if($is_multi_site > 0){