123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- <?php
- require_once 'DB_PDO.class.php';
- require_once 'conf.class.php';
- require_once 'YPSM.class.php';
- /**
- * 提醒新用户
- */
- #设置时区
- date_default_timezone_set('PRC');
- error_reporting(E_ALL);
- echo "\n脚本开始时间:".date("Y-m-d H:i:s");
- $call1 = sendToMsg(1);
- echo "\n1天未登录:\n";
- echo $call1;
- $call2 = sendToMsg(2);
- echo "\n3天未登录:\n";
- echo $call2;
- $call3 = sendToMsg(3);
- echo "\n5天未登录:\n";
- echo $call3;
- function sendToMsg($flag){
- if($flag == 1){
- $etime = date("Y-m-d H:i:s",strtotime('-1 day'));
- $stime = date("Y-m-d H:i:s",strtotime('-2 day'));
- }elseif($flag == 2){
- $etime = date("Y-m-d H:i:s",strtotime('-3 day'));
- $stime = date("Y-m-d H:i:s",strtotime('-4 day'));
- return sendToMsg2($stime, $etime);
- }elseif($flag == 3){
- $etime = date("Y-m-d H:i:s",strtotime('-5 day'));
- $stime = date("Y-m-d H:i:s",strtotime('-6 day'));
- }
- $_PDO=DB_PDO::getInstance( conf::$DB_CONF );
- $sql = "select u.phone,wx.nickname,u.name,u.is_update_name from users as u left join user_weixin wx on wx.user_id = u.id where u.origin=0 and wx.is_login=0 and u.created_at < '{$etime}' and u.created_at >= '{$stime}'";
- $stmt = $_PDO->prepare($sql);
- $stmt->execute();
- $result = $stmt->fetchAll(PDO::FETCH_ASSOC);
- $str = '';
- echo "\n\nSQL:".$sql;
- if(!empty($result)){
- foreach($result as $k=>$v){
- $mobile = $v['phone'];
- $name = (!empty($v['is_update_name']) && !empty($v['name'])) ? $v['name'] : $v['nickname'];
- $res = YPSMS::sendNewRed($mobile, $name, $flag);
- $str .= $mobile.',';
- }
- }
- return trim($str,',');
- }
- function sendToMsg2($stime, $etime){
- $_PDO=DB_PDO::getInstance( conf::$DB_CONF );
- $sql = "select u.phone,wx2.nickname,u2.name,u2.is_update_name from users as u
- left join user_weixin wx on wx.user_id=u.id
- left join users u2 on u2.invite_code=wx.invite_code
- left join user_weixin wx2 on wx2.user_id=u2.id
- where u.origin=0 and wx.is_login=0 and u.created_at < '{$etime}' and u.created_at >= '{$stime}'";
- $stmt = $_PDO->prepare($sql);
- $stmt->execute();
- $result = $stmt->fetchAll(PDO::FETCH_ASSOC);
- $str = '';
- echo "\n\nSQL:".$sql;
- if(!empty($result)){
- foreach($result as $k=>$v){
- $mobile = $v['phone'];
- $name = (!empty($v['is_update_name']) && !empty($v['name'])) ? $v['name'] : $v['nickname'];
- $res = YPSMS::sendNewRed2($mobile, $name);
- $str .= $mobile.',';
- }
- }
- return trim($str,',');
- }
|