예제 #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = EOrder::find()->orderBy(['paid_time' => SORT_DESC]);
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['status' => $this->status, 'ebay_id' => $this->ebay_id, 'sale_record_number' => $this->sale_record_number]);
     $query->andFilterWhere(['like', 'ebay_order_id', $this->ebay_order_id])->andFilterWhere(['like', 'buyer_id', $this->buyer_id])->andFilterWhere(['like', 'total', $this->total])->andFilterWhere(['like', 'recipient_name', $this->recipient_name]);
     // ->andFilterWhere(['like', 'recipient_phone', $this->recipient_phone])
     // ->andFilterWhere(['like', 'recipient_address1', $this->recipient_address1])
     // ->andFilterWhere(['like', 'recipient_address2', $this->recipient_address2])
     // ->andFilterWhere(['like', 'recipient_city', $this->recipient_city])
     // ->andFilterWhere(['like', 'recipient_state', $this->recipient_state])
     // ->andFilterWhere(['like', 'recipient_postcode', $this->recipient_postcode])
     // ->andFilterWhere(['like', 'checkout_message', $this->checkout_message]);
     // if ($this->fetched_at && $fetchedDateRange = explode(" - ",$this->fetched_at)) {
     //     if(isset($fetchedDateRange[0])&&isset($fetchedDateRange[1])){
     //       $query->andFilterWhere(['between','fetched_at',$fetchedDateRange[0],$fetchedDateRange[1]]);
     //     }
     // }
     if ($this->created_time && ($dateRange = explode(" - ", $this->created_time))) {
         if (isset($dateRange[0]) && isset($dateRange[1])) {
             $startDate = new \DateTime($dateRange[0], new \DateTimeZone('Australia/Sydney'));
             $endDate = new \DateTime($dateRange[1], new \DateTimeZone('Australia/Sydney'));
             $startDate->setTimezone(new \DateTimeZone('GMT'))->format('Y-m-d H:i:s');
             $startDate = $startDate->format('Y-m-d H:i:s');
             $endDate->setTimezone(new \DateTimeZone('GMT'))->format('Y-m-d H:i:s');
             $endDate = $endDate->format('Y-m-d H:i:s');
             $query->andFilterWhere(['between', 'created_time', $startDate, $endDate]);
         }
     }
     if ($this->paid_time && ($dateRange = explode(" - ", $this->paid_time))) {
         if (isset($dateRange[0]) && isset($dateRange[1])) {
             $startDate = new \DateTime($dateRange[0], new \DateTimeZone('Australia/Sydney'));
             $endDate = new \DateTime($dateRange[1], new \DateTimeZone('Australia/Sydney'));
             $startDate->setTimezone(new \DateTimeZone('GMT'))->format('Y-m-d H:i:s');
             $startDate = $startDate->format('Y-m-d H:i:s');
             $endDate->setTimezone(new \DateTimeZone('GMT'))->format('Y-m-d H:i:s');
             $endDate = $endDate->format('Y-m-d H:i:s');
             $query->andFilterWhere(['between', 'paid_time', $startDate, $endDate]);
         }
     }
     if ($this->shipped_time && ($dateRange = explode(" - ", $this->shipped_time))) {
         if (isset($dateRange[0]) && isset($dateRange[1])) {
             $startDate = new \DateTime($dateRange[0], new \DateTimeZone('Australia/Sydney'));
             $endDate = new \DateTime($dateRange[1], new \DateTimeZone('Australia/Sydney'));
             $startDate->setTimezone(new \DateTimeZone('GMT'))->format('Y-m-d H:i:s');
             $startDate = $startDate->format('Y-m-d H:i:s');
             $endDate->setTimezone(new \DateTimeZone('GMT'))->format('Y-m-d H:i:s');
             $endDate = $endDate->format('Y-m-d H:i:s');
             $query->andFilterWhere(['between', 'shipped_time', $startDate, $endDate]);
         }
     }
     return $dataProvider;
 }
예제 #2
0
 protected function findOrderModel($id)
 {
     if (($model = EOrder::findOne($id)) !== null && Yii::$app->user->can('ebaycontrol', ['userID' => $model->user_id])) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
예제 #3
0
파일: EbayAccount.php 프로젝트: sea129/kbay
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getEbayOrders()
 {
     return $this->hasMany(EOrder::className(), ['ebay_id' => 'id']);
 }