Example #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;
 }
Example #2
0
 /**
  * 去ebay更新下过单却没有付款的订单,这些订单已经存在数据库中,但状态是-1,意思是没有付款
  */
 public function actionUpdateNotPaid()
 {
     if (Yii::$app->request->isAjax) {
         Yii::$app->response->format = Response::FORMAT_JSON;
         $post = Yii::$app->request->post();
         $notPaidOrders = EOrder::find()->select(['ebay_order_id'])->where(['status' => EOrder::STATUS_NOT_PAID, 'paid_time' => null, 'ebay_id' => $post['ebayID']])->asArray()->all();
         //$notPaidOrders = EOrder::find()->select(['ebay_order_id'])->where(['status'=>EOrder::STATUS_NOT_PAID,'ebay_id'=>$post['ebayID']])->asArray()->all();
         $notPaidOrderIDArr = ArrayHelper::getColumn($notPaidOrders, 'ebay_order_id');
         $ebayOrderApi = new EbayOrder($post['ebayID']);
         $result = $ebayOrderApi->getOrdersByID($notPaidOrderIDArr, $post['pageNum']);
         if (isset($result['Error'])) {
             return $result;
         }
         //update unpaid orders
         if ($result['Error'] = $this->saveOrders($result['orders'], $post['ebayID'])) {
             return $result;
         }
         return ['moreOrders' => $result['moreOrders']];
     } else {
         // $notPaidOrders = EOrder::find()->select(['ebay_order_id'])->where(['status'=>EOrder::STATUS_NOT_PAID,'paid_time'=>null,'ebay_id'=>3])->asArray()->all();
         // $notPaidOrderIDArr = ArrayHelper::getColumn($notPaidOrders,'ebay_order_id');
         // $ebayOrderApi = new EbayOrder(3);
         // $result = $ebayOrderApi->getOrdersByID($notPaidOrderIDArr,1);
         // echo "<pre>";
         // echo print_r($result);
         // echo "</pre>";
         return false;
     }
 }