优惠券订单及其他脚本

kis_hot_sale_goods_update.php 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. require_once 'PDO.class.php';
  3. require_once 'TBK.class.php';
  4. require_once 'conf.class.php';
  5. require_once 'RedisClass.php';
  6. define("KEYURL","https://item.taobao.com/item.htm?id=");
  7. /**
  8. * 更新优选商品剩余数量数据
  9. */
  10. #设置时区
  11. date_default_timezone_set('PRC');
  12. $DB = new PDO_DB(conf::$DB_CONF);
  13. $rkey = 'KuDian_HomeHotGoodsIds';
  14. $r_data = RedisModel::get($rkey);
  15. if( !$r_data ){
  16. exit('没有数据');
  17. }
  18. $goods = json_decode($r_data, true);
  19. $goods = array_reverse($goods);
  20. echo "\n 开始处理";
  21. $total_num = count($goods);
  22. $update_num = 0;
  23. foreach( $goods as $goods_id ){
  24. $keyword = KEYURL.$goods_id;
  25. $result = TBK::search( $keyword );
  26. if( !isset( $result->commission_rate ) ){
  27. continue;
  28. }
  29. $data = array();
  30. $data['num_iid'] = $result->num_iid;
  31. $data['coupon_id'] = $result->coupon_id;
  32. $data['coupon_info'] = $result->coupon_info;
  33. if(isset($result->coupon_amount)) $data['coupon_price'] = $result->coupon_amount;
  34. $data['pict_url'] = $result->pict_url;
  35. $data['white_image'] = $result->white_image;
  36. $data['small_images'] = serialize($result->small_images->string);
  37. $data['seller_id'] = $result->seller_id;
  38. if(isset($result->coupon_start_time)) $data['coupon_start_time'] = $result->coupon_start_time;
  39. if(isset($result->coupon_end_time)) $data['coupon_end_time'] = $result->coupon_end_time;
  40. $data['shop_title'] = $result->shop_title;
  41. $data['short_title'] = $result->short_title;
  42. $data['title'] = $result->title;
  43. $data['zk_final_price'] = $result->zk_final_price;
  44. $data['live_price'] = $result->zk_final_price;
  45. $data['reserve_price'] = $result->reserve_price;
  46. $data['commission_rate'] = $result->commission_rate;
  47. $data['commission_price'] = Number_format( $result->zk_final_price * $result->commission_rate/10000, 2, '.','');
  48. $data['tk_total_sales'] = $result->tk_total_sales;
  49. $data['volume'] = $result->volume;
  50. $data['coupon_remain_count'] = $result->coupon_remain_count;
  51. $data['coupon_total_count'] = $result->coupon_total_count;
  52. $data['user_type'] = $result->user_type;
  53. $data['url'] = $result->url;
  54. $data['status'] = 1;
  55. $rs = $DB->table('kis_hot_sale_goods')->insert($data);
  56. if($rs){
  57. $update_num++;
  58. echo "\n更新:".$update_num;
  59. }
  60. }
  61. echo "\n总共".$total_num."条数据";
  62. echo "\n成功更新".$update_num."条数据";