优惠券订单及其他脚本

hongbao.php 4.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <?php
  2. require_once 'DB_PDO.class.php';
  3. require_once 'confv2.class.php';
  4. # 定义下载订单时间段
  5. define("SITEID", 11458219);//打印流程详细信息,如有需要,设为1
  6. define("ACT_ID", 3);//活动id
  7. /**
  8. * 导入及更新 ftxia数据
  9. */
  10. #设置时区
  11. date_default_timezone_set('PRC');
  12. set_time_limit(0);
  13. ini_set('memory_limit','1024M');
  14. #初始化pdo
  15. $_PDO=DB_PDO::getInstance( conf::$DB_CONF );
  16. //37000条
  17. $n = 0;
  18. for($i=1;$i<=1;$i++){
  19. $offset = ($i-1)*2500;
  20. $pageSize = 2500;
  21. //$sql = "select adzone_id from adzone where id>32512 order by id asc limit {$offset},{$pageSize}";
  22. $sql = "select adzone_id from user_adzone where user_id in( select user_id from `user_special_relation` where relation_id='')";
  23. $stmt = $_PDO->prepare($sql); $stmt->execute();
  24. $res = $stmt->fetchAll(PDO::FETCH_ASSOC);
  25. foreach($res as $k=>$v){
  26. $n++;
  27. echo "\nAdzoneId:".$v['adzone_id'];
  28. $ret = gethongbao($v['adzone_id'], SITEID);
  29. if(!empty($ret)){
  30. echo " OK";
  31. $params = array();
  32. $params['adzone_id'] = $v['adzone_id'];
  33. $params['pc_url'] = $ret['pc'];
  34. $params['m_url'] = $ret['mobile'];
  35. $params['qrcode'] = $ret['qrCodeUrl'];
  36. $params['taoToken'] = $ret['taoToken'];
  37. $params['act_id'] = ACT_ID;
  38. $end = setAdzoneHong($params);
  39. if($end){
  40. echo " OK ".$n;
  41. }
  42. }
  43. else{
  44. echo " Fail ".$n;
  45. exit;
  46. }
  47. if($n%20==0){
  48. sleep(2);
  49. }
  50. }
  51. sleep(8);
  52. }
  53. function setAdzoneHong($params){
  54. try{
  55. $_PDO=DB_PDO::getInstance( conf::$DB_CONF );
  56. $sql = "insert into adzone_hongbao (adzone_id,pc_url,m_url,qrcode,taoToken,act_id) values(:a,:b,:c,:d,:e,:f)";
  57. $stmt = $_PDO->prepare($sql);
  58. $stmt->execute(array(':a'=>$params['adzone_id'],':b'=>$params['pc_url'],':c'=>$params['m_url'],':d'=>$params['qrcode'],':e'=>$params['taoToken'],':f'=>$params['act_id']));
  59. $res = $_PDO->lastinsertid();
  60. }catch(PDOException $e){
  61. echo $e->getMessage();
  62. }
  63. return $res;
  64. }
  65. # curl调用接口push
  66. function curl_post($url, $params){
  67. $ch = curl_init();
  68. curl_setopt($ch, CURLOPT_URL, $url);
  69. curl_setopt($ch, CURLOPT_HEADER, 0);
  70. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  71. curl_setopt($ch, CURLOPT_POST, 1);
  72. curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
  73. $response = curl_exec($ch);
  74. curl_close($ch);
  75. return $response;
  76. }
  77. # 下载excel订单文件
  78. function gethongbao($adzone_id,$siteid){
  79. $str_cookie = 'cna=gGnDEwQLQAACATqEyYplpj5I; account-path-guide-s1=true; 209580064_yxjh-filter-1=true; undefined_yxjh-filter-1=true; t=8c549c3cedcac7891a2c3c7f36ca91f4; cookie2=14f49386013cc2ad04bb88477ca5a92a; _tb_token_=fede8bbad6a53; v=0; alimamapwag=TW96aWxsYS81LjAgKFdpbmRvd3MgTlQgMTAuMDsgV2luNjQ7IHg2NCkgQXBwbGVXZWJLaXQvNTM3LjM2IChLSFRNTCwgbGlrZSBHZWNrbykgQ2hyb21lLzY5LjAuMzQ5Ny4xMDAgU2FmYXJpLzUzNy4zNg%3D%3D; cookie32=2d2dbd51714bd91fa4e604f2e1050dd6; alimamapw=FnABFCAlFCZcQ3dVHXF2FncCFnF5FCAlFCFWQ3YjHXBxFnAEFnF7FCEgFCFXQ3BRHXFxFnd3FnEB%0AFCIhFCYmQ3YkMQICVwcEUgQPAQFWBlxWBVJRWwEAAABQAgQJV1dSVQAG; cookie31=OTk1MDYxNzMsJUU0JUI4JThBJUU5JUE1JUI2JUU1JUI4JTgyJUU1JTkwJTg4JUU0JUI4JTgwJUU3JUE3JTkxJUU2JThBJTgwJUU2JTlDJTg5JUU5JTk5JTkwJUU1JTg1JUFDJUU1JThGJUI4LGppYW5nbmFuQGZhbnRvdXRpYW8uY29tLFRC; login=UIHiLt3xD8xYTw%3D%3D; apush848645ac0bf07b717f88c18a7e296d1e=%7B%22ts%22%3A1551430382566%2C%22heir%22%3A1551428739677%2C%22parentId%22%3A1551423816200%7D; l=bBEoP2SHvN8ix_zFKOfZVuIJckbtidRbfsPzw4TZDICPOo6VeStCWZaO_o-yC3GVa6GpR3Wc5ILQBmTskPaOh; isg=BHl5MYj3ARA1xdrAcN5VbqFIiOWTLnnbuVA-FpuicqDxIoS049QjCrG0pGZxmgVw';
  80. //$url = "https://pub.alimama.com/superCoupon/getUrlNew.json?adzoneid=$adzone_id&siteid=$siteid&eventId=1&pwdText=%E3%80%8E%E6%B7%98%E5%AE%9D12.12%E4%BA%BA%E6%B0%91%E7%9A%84%E6%80%BB%E5%86%B3%E9%80%89%E3%80%8F%E8%B6%85%E7%BA%A7%E7%BA%A2%E5%8C%85&t=1544154089036&pvid=&_tb_token_=e0351ee7d530a&_input_charset=utf-8";
  81. //$url = "https://pub.alimama.com/superCoupon/getUrlNew.json?adzoneid=$adzone_id&siteid=$siteid&eventId=1&pwdText=%E5%A4%A9%E7%8C%AB%E3%80%8E%E5%B9%B4%E8%B4%A7%E5%90%88%E5%AE%B6%E6%AC%A2%E3%80%8F%E8%B6%85%E7%BA%A7%E7%BA%A2%E5%8C%85&t=1546931999597&pvid=&_tb_token_=f81536ef33d36&_input_charset=utf-8";
  82. $url = "https://pub.alimama.com/superCoupon/getUrlNew.json?adzoneid=$adzone_id&siteid=$siteid&eventId=1&pwdText=%E5%A4%A9%E7%8C%AB%E3%80%8E3.8%E5%A5%B3%E7%8E%8B%E8%8A%82%E3%80%8F%E8%B6%85%E7%BA%A7%E7%BA%A2%E5%8C%85&t=1551430556689&pvid=&_tb_token_=fede8bbad6a53&_input_charset=utf-8";
  83. $ch = curl_init($url);
  84. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  85. curl_setopt($ch, CURLOPT_COOKIE, $str_cookie); //使用上面获取的cookies
  86. $response = curl_exec($ch);
  87. curl_close($ch);
  88. if( $response ){
  89. $res = json_decode($response,true);
  90. if($res['ok']){
  91. return $res['data'];
  92. }
  93. else{
  94. var_dump($response);
  95. return false;
  96. }
  97. }
  98. else{
  99. return false;
  100. }
  101. }