优惠券订单及其他脚本

nologin_user_insert.php 1.0KB

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. require_once 'DB_PDO.class.php';
  3. require_once 'TBK.class.php';
  4. require_once 'conf.class.php';
  5. #设置时区
  6. date_default_timezone_set('PRC');
  7. $_PDO=DB_PDO::getInstance( conf::$DB_CONF );
  8. $sql = " select u.user_id,uw.union_id from users u left join user_weixin uw on uw.user_id=u.id where (u.login_num=0 or (u.login_num=1 and uw.source in(3001,3000))) and u.origin=0 and uw.is_login=0 and uw.union_id like 'ovn%' ";
  9. $stmt = $_PDO->prepare($sql);
  10. $stmt->execute();
  11. $userIds = $stmt->fetchAll(PDO::FETCH_ASSOC);
  12. foreach($userIds as $k=>$v){
  13. $sql = " select id from red_user_mission where type=1 and user_id={$v['user_id']} ";
  14. $stmt = $_PDO->prepare($sql);
  15. $stmt->execute();
  16. $red_mission = $stmt->fetch(PDO::FETCH_ASSOC);
  17. $user_id = $v['user_id'];
  18. $union_id = $v['union_id'];
  19. $is_mission = 0;
  20. if(!empty($red_mission)) $is_mission = 1;
  21. $sql = "insert into red_nologin_users (user_id, union_id, is_mission) values({$user_id},'{$union_id}',{$is_mission}) ";
  22. $stmt = $_PDO->prepare($sql);
  23. $stmt->execute();
  24. }