Browse Source

Y短信更改牛信云

bianjunhui 3 years ago
parent
commit
e506f54daf

+ 11 - 0
application/lib/data/adminAction.php

@@ -629,6 +629,17 @@ class AdvertAdminAction extends BaseAction{
             $sql = trim($sql, ',').';';
             $result = $this->getDbEntity()->insert_sql($sql);
             return $result;
+        }
+        //插入待发送短信参数数据--牛信云
+        public function add_sms_data_queue_new($data){
+            $sql = 'INSERT INTO `ly_sms_data_tmp_new` (`params_json`) VALUES ';
+            foreach($data as $value){
+                $params_json = serialize($value);
+                $sql .= "('{$params_json}'),";
+            }
+            $sql = trim($sql, ',').';';
+            $result = $this->getDbEntity()->insert_sql($sql);
+            return $result;
         }
 		//查询代发邮件数量
 		public function selectEmailTmpData(){

+ 21 - 1
application/module/ctrl/Send_sms_adminAction.class.php

@@ -115,6 +115,7 @@ class Send_sms_adminAction extends Action
             for($i=1;$i<=$p;$i++){
                 $min = $c*($i-1);
                 $data = array();
+                $x_smtpapi=array();
                 $customer_list_now = array_slice($customer_list, $min, $c);
                 foreach($customer_list_now as $key=>$list){
                     $countryMobile = $this->getCountryMobile($list['country']);
@@ -125,6 +126,10 @@ class Send_sms_adminAction extends Action
                     }
 
                     $data[$key]['mobile'] =$countryMobile.$list['tel'];
+                    if($uid==7){//--牛信云
+                        $x_smtpapi[] = $countryMobile.$list['tel'];
+                    }
+
                 }
                 $params = array(
                     'to' => $data,
@@ -132,9 +137,24 @@ class Send_sms_adminAction extends Action
                     'uid' => $uid,
                     'template_body' => $content
                 );
+                if($uid==7){//--牛信云
+                    $params = array(
+                        'appkey' => 'FH1W2L97',
+                        'secretkey'  =>'OCio2JBh',
+                        'phone' => $x_smtpapi,
+                        'content'     => $content,
+                        'source_address' => $from,
+                        'uid' => $uid
+                    );
+                }
                 $params_arr[] = $params;
             }
-            $result = $admin->add_sms_data_queue($params_arr);
+            if($uid==7){
+                $result = $admin->add_sms_data_queue_new($params_arr);
+            }else{
+                $result = $admin->add_sms_data_queue($params_arr);
+            }
+
             if ($result) {
                 $info = '短信已进入待发送队列';
             } else {

+ 16 - 18
jb/smsQueue.php

@@ -6,8 +6,8 @@
  */
 
 require_once('class.mysql.php');
-require_once('/www/wwwroot/edm.alipearl.net/frame/alisms.php');
-//require_once('../frame/alisms.php');
+require_once ('/www/wwwroot/edm.alipearl.net/frame/common.php');
+//require_once('../frame/common.php');
 set_time_limit(1800);
 $dbms = 'mysql';
 $host = 'localhost';
@@ -15,30 +15,28 @@ $DB_Database = $dbName = 'edm_alipearl_net';
 $user = 'edm_alipearl_net';
 $pass = '6fP8Pf6dLdmFBYR4';
 $db_charset = "utf8";
-
 $db = new Daopdo($host, $user, $pass, $dbName, $db_charset);
-
-$sql['email_data'] = 'SELECT `id`,`params_json` FROM `ly_sms_data_tmp` ORDER BY `id` ASC LIMIT 1;';
-
+$sql['email_data'] = 'SELECT `id`,`params_json` FROM `ly_sms_data_tmp_new` ORDER BY `id` ASC LIMIT 1;';
 $email_data = $db->query($sql['email_data'], 'Row');
 if (empty($email_data)) {
     exit(0);
 } else {
-    $sql['delQueueHead'] = "DELETE FROM `ly_sms_data_tmp` WHERE `id`='{$email_data['id']}';";
+    $sql['delQueueHead'] = "DELETE FROM `ly_sms_data_tmp_new` WHERE `id`='{$email_data['id']}';";
     $db->query($sql['delQueueHead']);
 }
 $params = unserialize($email_data['params_json']);
-$mobiles =$params['to'];
-foreach ($mobiles as $k=>$v){
-    $mobile = $v['mobile'];
-    $from = $v['from_name'];
-    sendSmsali($mobile,$params['template_body'],$from);
-    $times=date('Y-m-d H:i:s',time());
-    $sql['insert_log'] = 'INSERT INTO `ly_send_sms_log` (`mobile`,`addtime`,`template_id`,`template_body`,`from_name`,`uid`) VALUES ';
-    $sql['insert_log'] .= "('{$mobile}','{$times}','{$params['template_id']}','{$params['template_body']}','{$from}','{$params['uid']}');";
-    $insert_log = $db->query($sql['insert_log']);
-}
-echo 'success';
+$uid = $params['uid'];
+$phone=serialize($params['phone']);
+$params['phone'] = implode(',', $params['phone']);
+unset($params['uid']);
+//$params= http_build_query($params);
+$post_url = 'http://api2.nxcloud.com/api/sms/mtsend';
+$result = make_curl($post_url, $params);
+$params['status'] = $result['code'];
+$params['remarks'] = $result['messageid'];
+$sql['insert_log'] = 'INSERT INTO `ly_send_sms_log_new` (`mobile`,`template_body`,`from_name`,`uid`,`status`,`remarks`) VALUES ';
+$sql['insert_log'] .= "('{$phone}','{$params['content']}','{$params['source_address']}','{$uid}','{$params['status']}','{$params['remarks']}');";
+$insert_log = $db->query($sql['insert_log']);