You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

37 lines
1.1 KiB

  1. <?php
  2. namespace console\controllers;
  3. use common\models\MBaseUnique;
  4. use common\models\MHotel;
  5. use common\util\CurlInterface;
  6. use yii\console\Controller;
  7. use common\util\Util;
  8. class HotelController extends Controller
  9. {
  10. /**
  11. * Function Description:同步酒店数据到mongoDB
  12. * Function Name: actionCacheHotel
  13. *
  14. *
  15. * @author 娄梦宁
  16. */
  17. public function actionCacheHotel()
  18. {
  19. $curlInterface = new CurlInterface();
  20. $siteConfig = Util::getSiteConfig();
  21. $url=$siteConfig['adm_host1'].'/hotel/api/get-hotel-list-cache';
  22. $result = $curlInterface->execute($url);
  23. if($result['code']==0){
  24. $mHotel=new MHotel();
  25. $mBaseUnique=new MBaseUnique();
  26. $new_time_stamp=$result['data'][0]['time_stamp'];
  27. $collection=$mHotel->getCollection();
  28. foreach($result['data'] as $val){
  29. $collection->insert($val);
  30. }
  31. $mBaseUnique::updateAll(['time_stamp'=>$new_time_stamp],['type'=>1]);
  32. $mHotel->deleteAll(['!=','time_stamp',$new_time_stamp]);
  33. }
  34. }
  35. }