123456789101112131415161718192021222324252627282930313233343536373839404142 |
- <?php
- require_once 'DB_PDO.class.php';
- require_once 'TBK.class.php';
- require_once 'conf.class.php';
- define("KEYURL","https://item.taobao.com/item.htm?id=");
- /**
- * 更新收藏商品到期时间
- */
- #设置时区
- date_default_timezone_set('PRC');
- $_PDO=DB_PDO::getInstance( conf::$DB_CONF );
- $sql = " SELECT distinct goods_id FROM `tbk`.`user_favorites` where `create_at` >'2018-07-01 00:00:00' and create_at<='2018-08-15 00:00:00' and `is_coupon` =1 and `coupon_end_time` is null ; ";
- $stmt = $_PDO->prepare($sql);
- $stmt->execute();
- $goods = $stmt->fetchAll(PDO::FETCH_ASSOC);
- $total_num = 0;
- $update_num = 0;
- foreach( $goods as $k=>$v ){
- $total_num++;
- $keyword = KEYURL.$v['goods_id'];
- $result = TBK::search( $keyword );
- if( !isset($result->coupon_end_time) ) continue;
- $coupon_end_time = $result->coupon_end_time;
- $coupon_start_time = $result->coupon_start_time;
- $sql = " update user_favorites set coupon_end_time = :coupon_end_time,coupon_start_time=:coupon_start_time where goods_id = :goods_id ";
- $stmt = $_PDO->prepare($sql);
- $stmt->execute(array(':coupon_end_time'=>$coupon_end_time,':coupon_start_time'=>$coupon_start_time,':goods_id'=>$v['goods_id']));
- $res = $stmt->rowCount();
- if($res){
- var_dump($v['goods_id']);
- $update_num++;
- echo "\n更新成功:".$res;
- }
- //if($total_num == 3) break;
- }
- echo "\n总共".$total_num."条数据";
- echo "\n成功更新".$update_num."条数据";
|