0 and ul.parent_user_id is null and ul.regist_at < '{$etime}' and ul.regist_at >= '{$stime}'"; $stmt = $_PDO->prepare($sql); $stmt->execute(); $result = $stmt->fetchAll(PDO::FETCH_ASSOC); $n = 0; $m = 0; $str = ''; $fstr = ''; echo "\n\nSQL:".$sql; if(!empty($result)){ foreach($result as $k=>$v){ $mobile = $v['phone']; $res = sendMsg($mobile); if($res && $res['code'] == 0){ $n++; $str .= $mobile.'|'; $inres = insertRecall( $v ); } else{ $m++; $fstr .= $mobile.'|'; } } } echo "\n成功发送{$n}条,失败{$m}条"; echo "\n成功:".trim($str,'|'); echo "\n失败:".trim($fstr,'|'); function sendMsg ($mobile){ $params = array(); $params['mobile'] = $mobile; $n = mt_rand(0,1); //阿里测试 $params['SignName'] = '猎豆优选'; $params['tpl_id'] = 'SMS_152805117'; $result = SendMsg::AliSendMsg($params); return $result; //天瑞测试 /* $params['SignName'] = '猎豆优选'; $params['tpl_id'] = '30290'; //$params['extra']['code'] = '111256'; //$params['extra']['minutes'] = 2; $result = SendMsg::TruiSendMsg($params); var_dump($result);exit; //云片测试 $params['tpl_id'] = '2619986'; //$params['extra']['code'] = '9000'; //$params['extra']['minutes'] = 2; $params['extra'] = array(); $result = SendMsg::YpianSendMsg($params); print_r($result); return $result; */ } function insertRecall($userInfo){ $user_id = $userInfo['id']; $nick = $userInfo['nickname']; $phone = $userInfo['phone']; $regist_at = $userInfo['regist_at']; $today_date = date("Y-m-d"); $_PDO=DB_PDO::getInstance( conf::$DB_CONF ); $sql = "insert into `user_recall_log` (user_id, nickname, phone, regist_at, today_date) values ({$user_id},'{$nick}', '{$phone}','{$regist_at}','{$today_date}')"; $stmt = $_PDO->prepare($sql); $stmt->execute(); return $_PDO->lastinsertid(); }