优惠券订单及其他脚本

recall_new_cust.php 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?php
  2. require_once 'DB_PDO.class.php';
  3. require_once 'conf.class.php';
  4. require_once 'YPSM.class.php';
  5. /**
  6. * 提醒新用户
  7. */
  8. #设置时区
  9. date_default_timezone_set('PRC');
  10. error_reporting(E_ALL);
  11. echo "\n脚本开始时间:".date("Y-m-d H:i:s");
  12. $call1 = sendToMsg(1);
  13. echo "\n1天未登录:\n";
  14. echo $call1;
  15. $call2 = sendToMsg(2);
  16. echo "\n3天未登录:\n";
  17. echo $call2;
  18. $call3 = sendToMsg(3);
  19. echo "\n5天未登录:\n";
  20. echo $call3;
  21. function sendToMsg($flag){
  22. if($flag == 1){
  23. $etime = date("Y-m-d H:i:s",strtotime('-1 day'));
  24. $stime = date("Y-m-d H:i:s",strtotime('-2 day'));
  25. }elseif($flag == 2){
  26. $etime = date("Y-m-d H:i:s",strtotime('-3 day'));
  27. $stime = date("Y-m-d H:i:s",strtotime('-4 day'));
  28. return sendToMsg2($stime, $etime);
  29. }elseif($flag == 3){
  30. $etime = date("Y-m-d H:i:s",strtotime('-5 day'));
  31. $stime = date("Y-m-d H:i:s",strtotime('-6 day'));
  32. }
  33. $_PDO=DB_PDO::getInstance( conf::$DB_CONF );
  34. $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}'";
  35. $stmt = $_PDO->prepare($sql);
  36. $stmt->execute();
  37. $result = $stmt->fetchAll(PDO::FETCH_ASSOC);
  38. $str = '';
  39. echo "\n\nSQL:".$sql;
  40. if(!empty($result)){
  41. foreach($result as $k=>$v){
  42. $mobile = $v['phone'];
  43. $name = (!empty($v['is_update_name']) && !empty($v['name'])) ? $v['name'] : $v['nickname'];
  44. $res = YPSMS::sendNewRed($mobile, $name, $flag);
  45. $str .= $mobile.',';
  46. }
  47. }
  48. return trim($str,',');
  49. }
  50. function sendToMsg2($stime, $etime){
  51. $_PDO=DB_PDO::getInstance( conf::$DB_CONF );
  52. $sql = "select u.phone,wx2.nickname,u2.name,u2.is_update_name from users as u
  53. left join user_weixin wx on wx.user_id=u.id
  54. left join users u2 on u2.invite_code=wx.invite_code
  55. left join user_weixin wx2 on wx2.user_id=u2.id
  56. where u.origin=0 and wx.is_login=0 and u.created_at < '{$etime}' and u.created_at >= '{$stime}'";
  57. $stmt = $_PDO->prepare($sql);
  58. $stmt->execute();
  59. $result = $stmt->fetchAll(PDO::FETCH_ASSOC);
  60. $str = '';
  61. echo "\n\nSQL:".$sql;
  62. if(!empty($result)){
  63. foreach($result as $k=>$v){
  64. $mobile = $v['phone'];
  65. $name = (!empty($v['is_update_name']) && !empty($v['name'])) ? $v['name'] : $v['nickname'];
  66. $res = YPSMS::sendNewRed2($mobile, $name);
  67. $str .= $mobile.',';
  68. }
  69. }
  70. return trim($str,',');
  71. }