/**
  * Creates a new Collection model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Collection();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
 /**
  * Creates a new Collection model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Collection();
     if ($model->load(Yii::$app->request->post())) {
         // set the time
         if ($model->time) {
             date_default_timezone_set("Asia/ShangHai");
             $model->time .= "  " . date("H:i:s");
         }
         $model->save();
         // add the money to customer
         $customer = $model->customer;
         $customer->payed += $model->money;
         $customer->unpay -= $model->money;
         $customer->save();
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
Пример #3
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     // $url = 'http://map.naver.com/search2/local.nhn?query='. urlencode('서울특별시+중구+애견호텔');
     //     $job = (new CollectionLocal($url));
     //     dispatch($job);
     // return;
     $this->comment("Collector job staring...");
     $collect_local_main = '';
     $collect_local_sub = '';
     $collect_ord = 1;
     $collect_url = array();
     $collection = Collection::orderby('id', 'desc')->first();
     if (empty($collection->id)) {
         $local = Local::where('ord', 1)->first();
         $collect_local_main = $local->main;
         $collect_local_sub = $local->sub;
     } else {
         $local = Local::where('ord', '>', $collection->ord)->first();
         if (empty($local->id)) {
             $local = Local::where('ord', 1)->first();
         }
         $collect_local_main = $local->main;
         $collect_local_sub = $local->sub;
         $collect_ord = $local->ord;
     }
     //2분단위로 데이터 가져오기 실행
     $keywordSets = Keyword::orderby('ord', 'asc')->get();
     foreach ($keywordSets as $k => $value) {
         $url = 'http://map.naver.com/search2/local.nhn?query=' . urlencode($collect_local_main . '+' . $collect_local_sub . '+' . $value->keyword);
         $job = (new CollectionLocal($url))->delay($k * 120);
         dispatch($job);
     }
     $collection = new Collection();
     $collection->local_main = $collect_local_main;
     $collection->local_sub = $collect_local_sub;
     $collection->ord = $collect_ord;
     $collection->save();
     $this->comment("Collector : [" . $collect_local_main . "/" . $collect_local_sub . "]");
 }
 public function actionCollected()
 {
     if (Yii::$app->request->get('rejected')) {
         return $this->render('collected_failed');
     }
     $collection = new Collection();
     $collection->login = Yii::$app->getSession()->get('collection.login');
     $collection->is_fulfilled = true;
     $collection->sum = Collection::calculateSum();
     $collection->save();
     return $this->render('collected');
 }