123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- <?php
- require_once 'DB_PDO.class.php';
- require_once 'TBK.class.php';
- require_once 'confv2.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 num_iid as goods_id from special_sale_goods order by id desc limit 200";
- $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_id) && !empty($result->coupon_id)){
- $coupon_id = $result->coupon_id;
- $coupon_info = $result->coupon_info;
- $coupon_start_time = $result->coupon_start_time;
- $coupon_end_time = $result->coupon_end_time;
- $coupon_remain_count = $result->coupon_remain_count;
- }else{
- $coupon_id = '';
- $coupon_info = '';
- $coupon_start_time = '';
- $coupon_end_time = '';
- $coupon_remain_count = 0;
- }
- $sql = " update special_sale_goods set coupon_id = :coupon_id,coupon_info = :coupon_info,coupon_start_time = :coupon_start_time,coupon_end_time = :coupon_end_time,coupon_remain_count = :coupon_remain_count where num_iid = :goods_id ";
- $stmt = $_PDO->prepare($sql);
- $stmt->execute(array(':coupon_id'=>$coupon_id,':coupon_info'=>$coupon_info,':coupon_start_time'=>$coupon_start_time,':coupon_end_time'=>$coupon_end_time,':coupon_remain_count'=>$coupon_remain_count,':goods_id'=>$v['goods_id']));
- $res = $stmt->rowCount();
- if($res){
- $update_num++;
- echo "\n\n更新成功:".$res;
- var_dump($v['goods_id']);
- }
- //if($total_num == 3) break;
- }
- echo "\n总共".$total_num."条数据";
- echo "\n成功更新".$update_num."条数据";
|