优惠券订单及其他脚本

red_newcust_order_push.php 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. require_once 'DB_PDO.class.php';
  3. require_once 'confv2.class.php';
  4. require_once 'YPSM.class.php';
  5. define("ACT_PUSH_URL",'https://tbk.726p.com/api/v2/MessagePush/act_push');//push接口地址
  6. date_default_timezone_set('PRC');
  7. $etime = date("Y-m-d H:i:s",strtotime('-1 day'));
  8. $stime = date("Y-m-d H:i:s",strtotime('-2 day'));
  9. $_PDO=DB_PDO::getInstance( conf::$DB_CONF );
  10. $sql = "select rui.user_id from red_user_info as rui left join user_weixin as uw on uw.user_id=rui.user_id where rui.type=2 and uw.is_login=1 and rui.add_time>='{$stime}' and rui.add_time<'{$etime}' and rui.user_id not in(select distinct user_id from `order` where order_create_at>'{$stime}' and status>0 and user_id>0)";
  11. $stmt = $_PDO->prepare($sql);
  12. $stmt->execute();
  13. $result = $stmt->fetchAll(PDO::FETCH_ASSOC);
  14. foreach($result as $k=>$v){
  15. $params = array();
  16. $params['user_id'] = $v['user_id'];
  17. $params['type'] = 5; //5 提醒新用户下单
  18. $push_res = curl_post( ACT_PUSH_URL, $params);
  19. }
  20. # curl调用接口push
  21. function curl_post($url, $params){
  22. $ch = curl_init();
  23. curl_setopt($ch, CURLOPT_URL, $url);
  24. curl_setopt($ch, CURLOPT_HEADER, 0);
  25. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  26. curl_setopt($ch, CURLOPT_POST, 1);
  27. curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
  28. $response = curl_exec($ch);
  29. curl_close($ch);
  30. return $response;
  31. }