123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- <?php
-
- require_once 'DB_PDO.class.php';
- require_once 'confv2.class.php';
-
- # 定义下载订单时间段
- define("SITEID", 11458219);//打印流程详细信息,如有需要,设为1
- define("ACT_ID", 3);//活动id
- /**
- * 导入及更新 ftxia数据
- */
- #设置时区
- date_default_timezone_set('PRC');
- set_time_limit(0);
- ini_set('memory_limit','1024M');
-
- #初始化pdo
- $_PDO=DB_PDO::getInstance( conf::$DB_CONF );
- //37000条
- $n = 0;
- for($i=1;$i<=1;$i++){
- $offset = ($i-1)*2500;
- $pageSize = 2500;
-
- //$sql = "select adzone_id from adzone where id>32512 order by id asc limit {$offset},{$pageSize}";
- $sql = "select adzone_id from user_adzone where user_id in( select user_id from `user_special_relation` where relation_id='')";
- $stmt = $_PDO->prepare($sql); $stmt->execute();
- $res = $stmt->fetchAll(PDO::FETCH_ASSOC);
- foreach($res as $k=>$v){
- $n++;
- echo "\nAdzoneId:".$v['adzone_id'];
- $ret = gethongbao($v['adzone_id'], SITEID);
- if(!empty($ret)){
- echo " OK";
- $params = array();
- $params['adzone_id'] = $v['adzone_id'];
- $params['pc_url'] = $ret['pc'];
- $params['m_url'] = $ret['mobile'];
- $params['qrcode'] = $ret['qrCodeUrl'];
- $params['taoToken'] = $ret['taoToken'];
- $params['act_id'] = ACT_ID;
-
- $end = setAdzoneHong($params);
- if($end){
- echo " OK ".$n;
- }
- }
- else{
- echo " Fail ".$n;
- exit;
- }
- if($n%20==0){
- sleep(2);
- }
- }
- sleep(8);
- }
-
- function setAdzoneHong($params){
- try{
- $_PDO=DB_PDO::getInstance( conf::$DB_CONF );
- $sql = "insert into adzone_hongbao (adzone_id,pc_url,m_url,qrcode,taoToken,act_id) values(:a,:b,:c,:d,:e,:f)";
- $stmt = $_PDO->prepare($sql);
- $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']));
- $res = $_PDO->lastinsertid();
- }catch(PDOException $e){
- echo $e->getMessage();
- }
- return $res;
- }
-
- # curl调用接口push
- function curl_post($url, $params){
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_HEADER, 0);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($ch, CURLOPT_POST, 1);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
- $response = curl_exec($ch);
- curl_close($ch);
- return $response;
- }
-
- # 下载excel订单文件
- function gethongbao($adzone_id,$siteid){
- $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';
-
- //$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";
- //$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";
-
- $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";
- $ch = curl_init($url);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_COOKIE, $str_cookie); //使用上面获取的cookies
- $response = curl_exec($ch);
- curl_close($ch);
- if( $response ){
- $res = json_decode($response,true);
- if($res['ok']){
- return $res['data'];
- }
- else{
- var_dump($response);
- return false;
- }
- }
- else{
- return false;
- }
- }
-
-
|