Kirin 4 năm trước cách đây
mục cha
commit
9b5386cb16
2 tập tin đã thay đổi với 52 bổ sung47 xóa
  1. 18 16
      app/api/controller/PublicController.php
  2. 34 31
      crmeb/services/NewSMSService.php

+ 18 - 16
app/api/controller/PublicController.php

@@ -18,6 +18,7 @@ use app\models\user\UserMoneyOrder;
 use app\models\user\WechatUser;
 use app\Request;
 use crmeb\services\CacheService;
+use crmeb\services\NewSMSService;
 use crmeb\services\UtilService;
 use crmeb\services\workerman\ChannelService;
 use think\db\exception\DataNotFoundException;
@@ -37,22 +38,23 @@ class PublicController
 
     public function test()
     {
-        try {
-            Db::startTrans();
-            CashTradeOrder::orderClose();//挂出结束退回
-            Db::commit();
-        } catch (\Exception $e) {
-            var_dump($e->getMessage());
-            Db::rollback();
-        }
-        try {
-            Db::startTrans();
-            CashTradeOrder::getBack();//挂出结束退回
-            Db::commit();
-        } catch (\Exception $e) {
-            var_dump($e->getMessage());
-            Db::rollback();
-        }
+        NewSMSService::send('15068611369', ['code' => 123456]);
+//        try {
+//            Db::startTrans();
+//            CashTradeOrder::orderClose();//挂出结束退回
+//            Db::commit();
+//        } catch (\Exception $e) {
+//            var_dump($e->getMessage());
+//            Db::rollback();
+//        }
+//        try {
+//            Db::startTrans();
+//            CashTradeOrder::getBack();//挂出结束退回
+//            Db::commit();
+//        } catch (\Exception $e) {
+//            var_dump($e->getMessage());
+//            Db::rollback();
+//        }
     }
 
     public function version(Request $request)

+ 34 - 31
crmeb/services/NewSMSService.php

@@ -34,10 +34,11 @@ class NewSMSService
      * method: sendSmsCode
      * param: phone - {string} 手机号
      */
-    public static function send($phone, array $param, $template = "VERIFICATION_CODE")
+    public static function send($phone, array $param, $template = "DEFAULT")
     {
         $code = $param['code'];
-        $target = "http://cf.51welink.com/submitdata/Service.asmx/g_Submit";
+        $target = 'http://www.qunfaduanxin.vip/api/send';
+//        $target = "http://cf.51welink.com/submitdata/Service.asmx/g_Submit";
         $company = '优交所';
         switch ($template) {
             case 'REGISTER':
@@ -79,8 +80,10 @@ class NewSMSService
 
         }
 
-        $post_data = "sname=dlycwl01&spwd=ycwl123456&scorpid=&sprdid=1012818&sdst=" . $phone . "&smsg=" . rawurlencode($content);
-        $gets = self::post($post_data, $target);
+//        $post_data = "sname=dlycwl01&spwd=ycwl123456&scorpid=&sprdid=1012818&sdst=" . $phone . "&smsg=" . rawurlencode($content);
+        $post_data = "?username=16520929823&password=" . strtoupper(md5('6520929823')) . "&gwid=c2i00vx1&mobile=" . $phone . "&message=" . $content;
+//        $gets = self::post($post_data, $target);
+        $gets = do_request($target . $post_data, []);
         @file_put_contents('sms.log', json_encode($gets), FILE_APPEND);
         if ($gets) {
             return ['status' => 200, 'msg' => '短信发送成功'];
@@ -89,31 +92,31 @@ class NewSMSService
         }
     }
 
-    //第三方短信平台
-    private static function post($data, $target)
-    {
-        $url_info = parse_url($target);
-        $httpheader = "POST " . $url_info['path'] . " HTTP/1.0\r\n";
-        $httpheader .= "Host:" . $url_info['host'] . "\r\n";
-        $httpheader .= "Content-Type:application/x-www-form-urlencoded\r\n";
-        $httpheader .= "Content-Length:" . strlen($data) . "\r\n";
-        $httpheader .= "Connection:close\r\n\r\n";
-        //$httpheader .= "Connection:Keep-Alive\r\n\r\n";
-        $httpheader .= $data;
-
-        $fd = fsockopen($url_info['host'], 80);
-        fwrite($fd, $httpheader);
-        $gets = "";
-        while (!feof($fd)) {
-            $gets .= fread($fd, 128);
-        }
-        fclose($fd);
-        if ($gets != '') {
-            $start = strpos($gets, '<?xml');
-            if ($start > 0) {
-                $gets = substr($gets, $start);
-            }
-        }
-        return $gets;
-    }
+//    //第三方短信平台
+//    private static function post($data, $target)
+//    {
+//        $url_info = parse_url($target);
+//        $httpheader = "POST " . $url_info['path'] . " HTTP/1.0\r\n";
+//        $httpheader .= "Host:" . $url_info['host'] . "\r\n";
+//        $httpheader .= "Content-Type:application/x-www-form-urlencoded\r\n";
+//        $httpheader .= "Content-Length:" . strlen($data) . "\r\n";
+//        $httpheader .= "Connection:close\r\n\r\n";
+//        //$httpheader .= "Connection:Keep-Alive\r\n\r\n";
+//        $httpheader .= $data;
+//
+//        $fd = fsockopen($url_info['host'], 80);
+//        fwrite($fd, $httpheader);
+//        $gets = "";
+//        while (!feof($fd)) {
+//            $gets .= fread($fd, 128);
+//        }
+//        fclose($fd);
+//        if ($gets != '') {
+//            $start = strpos($gets, '<?xml');
+//            if ($start > 0) {
+//                $gets = substr($gets, $start);
+//            }
+//        }
+//        return $gets;
+//    }
 }