123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- <?php
- require_once 'PDO.class.php';
- require_once 'TBK.class.php';
- require_once 'conf.class.php';
- require_once 'RedisClass.php';
- define("KEYURL","https://item.taobao.com/item.htm?id=");
- /**
- * 更新优选商品剩余数量数据
- */
- #设置时区
- date_default_timezone_set('PRC');
- $DB = new PDO_DB(conf::$DB_CONF);
- $rkey = 'KuDian_HomeHotGoodsIds';
- $r_data = RedisModel::get($rkey);
- if( !$r_data ){
- exit('没有数据');
- }
- $goods = json_decode($r_data, true);
- $goods = array_reverse($goods);
- echo "\n 开始处理";
- $total_num = count($goods);
- $update_num = 0;
- foreach( $goods as $goods_id ){
- $keyword = KEYURL.$goods_id;
- $result = TBK::search( $keyword );
- if( !isset( $result->commission_rate ) ){
- continue;
- }
-
- $data = array();
- $data['num_iid'] = $result->num_iid;
- $data['coupon_id'] = $result->coupon_id;
- $data['coupon_info'] = $result->coupon_info;
- if(isset($result->coupon_amount)) $data['coupon_price'] = $result->coupon_amount;
- $data['pict_url'] = $result->pict_url;
- $data['white_image'] = $result->white_image;
- $data['small_images'] = serialize($result->small_images->string);
- $data['seller_id'] = $result->seller_id;
- if(isset($result->coupon_start_time)) $data['coupon_start_time'] = $result->coupon_start_time;
- if(isset($result->coupon_end_time)) $data['coupon_end_time'] = $result->coupon_end_time;
- $data['shop_title'] = $result->shop_title;
- $data['short_title'] = $result->short_title;
- $data['title'] = $result->title;
- $data['zk_final_price'] = $result->zk_final_price;
- $data['live_price'] = $result->zk_final_price;
- $data['reserve_price'] = $result->reserve_price;
- $data['commission_rate'] = $result->commission_rate;
- $data['commission_price'] = Number_format( $result->zk_final_price * $result->commission_rate/10000, 2, '.','');
- $data['tk_total_sales'] = $result->tk_total_sales;
- $data['volume'] = $result->volume;
- $data['coupon_remain_count'] = $result->coupon_remain_count;
- $data['coupon_total_count'] = $result->coupon_total_count;
- $data['user_type'] = $result->user_type;
- $data['url'] = $result->url;
- $data['status'] = 1;
- $rs = $DB->table('kis_hot_sale_goods')->insert($data);
- if($rs){
- $update_num++;
- echo "\n更新:".$update_num;
- }
- }
- echo "\n总共".$total_num."条数据";
- echo "\n成功更新".$update_num."条数据";
|