优惠券订单及其他脚本

red_user_mission.php 1.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. require_once 'DB_PDO.class.php';
  3. require_once 'TBK.class.php';
  4. require_once 'confv2.class.php';
  5. /**
  6. * 判断新手任务是否完成,更新状态
  7. */
  8. #设置时区
  9. date_default_timezone_set('PRC');
  10. $_PDO=DB_PDO::getInstance( conf::$DB_CONF );
  11. $sql = "select user_id from red_user_mission where type=2 and status=0";
  12. $stmt = $_PDO->prepare($sql);
  13. $stmt->execute();
  14. $users = $stmt->fetchAll(PDO::FETCH_ASSOC);
  15. $total_num = 0;
  16. $update_num = 0;
  17. $isUps = '';
  18. foreach( $users as $k=>$v ){
  19. $total_num++;
  20. $sql = "select * from `order` where user_id={$v['user_id']} limit 1";
  21. $stmt = $_PDO->prepare($sql);
  22. $stmt->execute();
  23. $res = $stmt->fetch(PDO::FETCH_ASSOC);
  24. if(!empty($res)){
  25. $isUps .= $v['user_id'].',';
  26. }
  27. }
  28. if($isUps != ''){
  29. $isUps = rtrim($isUps, ',');
  30. $sql = " update red_user_mission set status=1 where user_id in({$isUps}) ";
  31. $stmt = $_PDO->prepare($sql);
  32. $stmt->execute();
  33. $update_num = $stmt->rowCount();
  34. }
  35. echo "\n总共".$total_num."条数据";
  36. echo "\n成功更新".$update_num."条数据";