當前位置: 首頁>>代碼示例>>PHP>>正文


PHP models\Order類代碼示例

本文整理匯總了PHP中common\models\Order的典型用法代碼示例。如果您正苦於以下問題:PHP Order類的具體用法?PHP Order怎麽用?PHP Order使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Order類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: actionIndexadd

 public function actionIndexadd()
 {
     if (Yii::$app->user->isGuest) {
         $model = new LoginForm();
         if ($model->load(Yii::$app->request->post()) && $model->login()) {
             return $this->goBack();
         } else {
             return $this->render('/site/login', ['model' => $model]);
         }
     } else {
         $Order = new Order();
         $Order->user_id = Yii::$app->user->identity->id;
         $Order->date_time = date('Y-m-d H:i:s');
         $Order->status_id = '1';
         $Order->save();
         $Card = new CardList();
         $Products = $Card->getCardAndCardList(Yii::$app->user->identity->id);
         $Ord = new Order();
         $order_id = $Ord->GetOrderId(Yii::$app->user->identity->id);
         for ($i = 0; $i < sizeof($Products); $i++) {
             $Orderlist = new Orderlist();
             $Orderlist->order_id = $order_id[0]['MAX(`order_id`)'];
             $Orderlist->product_id = $Products[$i]['product_id'];
             $Orderlist->quantity = $Products[$i]['quantity'];
             $Orderlist->save();
         }
         $card = new Card();
         $card->DeleteCardId(Yii::$app->user->identity->id);
         $order = $Ord->GetOrdersFromID(Yii::$app->user->identity->id);
         $user = User::find()->where(['id' => Yii::$app->user->identity->id])->one();
         return $this->render('index', ['user' => $user, 'order' => $order]);
     }
 }
開發者ID:przemek207,項目名稱:Nzi_Project,代碼行數:33,代碼來源:AccountController.php

示例2: actionCheckout

 public function actionCheckout()
 {
     if ($postData = Yii::$app->request->post()) {
         $model = new Product();
         $order = new Order();
         $order->shipping_address = $postData['address'];
         $order->city = $postData['city'];
         $order->country = $postData['country'];
         $order->postal_code = $postData['postal_code'];
         $order->status = 0;
         $order->save();
         $order_id = $order->order_id;
         $items = [];
         foreach ($postData['qty'] as $key => $val) {
             $order_detail = new OrderDetail();
             $order_detail->order_id = $order_id;
             $order_detail->prod_id = $postData['prod_id'][$key];
             $order_detail->quantity = $postData['qty'][$key];
             $order_detail->unit_price = $postData['prod_price'][$key];
             $order_detail->unit_sum = $postData['prod_price'][$key] * $order_detail->quantity;
             $order_detail->save();
             $item = new Item();
             $item->setName($postData['prod_name'][$key])->setCurrency('USD')->setQuantity($val)->setPrice($postData['prod_price'][$key]);
             $items[] = $item;
         }
         $itemList = new ItemList();
         $itemList->setItems($items);
         $payment = preparePaypal($itemList);
         print_r($items);
     }
     exit;
 }
開發者ID:syedmaaz,項目名稱:marxmall-,代碼行數:32,代碼來源:CartController.php

示例3: actionOrder

 public function actionOrder()
 {
     $order = new Order();
     /** @var ShoppingCart $cart */
     $cart = \Yii::$app->cart;
     /* @var $products Product[] */
     $products = $cart->getPositions();
     if ($order->load(\Yii::$app->request->post()) && $order->validate()) {
         $transaction = $order->getDb()->beginTransaction();
         $order->save(false);
         // part of the transaction;
         foreach ($products as $product) {
             $orderItem = new OrderItem();
             $orderItem->order_id = $order->id;
             $orderItem->product_id = $product->id;
             $orderItem->title = $product->title;
             $orderItem->price = $product->getPrice();
             $orderItem->quantity = $product->getQuantity();
             if (!$orderItem->save(false)) {
                 $transaction->rollBack();
                 Yii::$app->session->setFlash('error', 'Your order cannot be accepted. Please contact us!');
                 $this->goBack();
             }
         }
         $transaction->commit();
         Yii::$app->cart->removeAll();
         Yii::$app->session->addFlash('message', 'Thanks for your order. We\'ll contact you soon!');
         //            $order->sendEmail();
         $this->redirect('/');
     }
     return $this->render('order', ['order' => $order, 'products' => $products, 'total' => $cart->getCost()]);
 }
開發者ID:Krinnerion,項目名稱:shop,代碼行數:32,代碼來源:CartController.php

示例4: actionOrder

 public function actionOrder()
 {
     $session = Yii::$app->getSession();
     $cart = $session->has('cart') ? $session->get('cart') : [];
     if (!$cart) {
         return $this->redirect(['index']);
     }
     $model = new Order();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         if (is_array($cart)) {
             foreach ($cart as $one_goods) {
                 $order_goods = new OrderGoods();
                 $order_goods->goods_id = $one_goods['id'];
                 $order_goods->count = $one_goods['count'];
                 $order_goods->order_id = $model->id;
                 $order_goods->save();
             }
         }
         Yii::$app->session->remove('cart');
         return $this->redirect(['index']);
     } else {
         $goods_id = ArrayHelper::getColumn($cart, 'id');
         $goods = Goods::find()->where(['id' => $goods_id])->asArray()->indexBy('id')->all();
         $amount = 0;
         foreach ($cart as $one_goods) {
             $amount += $one_goods['count'] * $goods[$one_goods['id']]['price'];
         }
         $model->price = $amount;
         return $this->render('order', ['cart' => $cart, 'model' => $model, 'amount' => $amount]);
     }
 }
開發者ID:RStuffGit,項目名稱:furniture,代碼行數:31,代碼來源:GoodsController.php

示例5: actionCreate

 public function actionCreate()
 {
     $model = new Order();
     $model->send_at = date("Y-m-d H:i:s");
     $model->is_new = 0;
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->render('thank');
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
開發者ID:uraankhayayaal,項目名稱:aic.s-vfu.ru,代碼行數:11,代碼來源:OrderController.php

示例6: saveOrder

 /**
  * Сохраняем наш заказ и отправляем письмо пользователю.
  */
 public function saveOrder($user, $product, $post)
 {
     $order = new Order();
     $order->user_id = $user->id;
     $order->summ = $product['price'];
     $order->created_datetime = date('Y-m-d H:i:s');
     $order->finished_datetime = date('Y-m-d H:i:s');
     if ($order->save(false)) {
         \Yii::$app->mailer->compose(['html' => 'order-html', 'text' => 'order-text'], ['user' => $user, 'product' => $product, 'post' => $post])->setFrom([\Yii::$app->params['supportEmail'] => \Yii::$app->name . ' робот'])->setTo($user->email)->setSubject('Заказ товара - ' . \Yii::$app->name)->send();
         return true;
     }
     return false;
 }
開發者ID:kibercoder,項目名稱:bilious-octo-fibula,代碼行數:16,代碼來源:OrderForm.php

示例7: cancel

 public function cancel($runValidation = true)
 {
     if ($runValidation && !$this->validate()) {
         return false;
     }
     if ($this->_order->status !== Order::STATUS_UNSHIPPED) {
         return false;
     }
     if ($this->_order->payment !== Order::PAYMENT_OFFLINE) {
         return false;
     }
     return $this->_order->cancel($this->msg);
 }
開發者ID:daixianceng,項目名稱:xiaoego.com,代碼行數:13,代碼來源:CancelOrderForm.php

示例8: actionIndex

 public function actionIndex()
 {
     $last15days = [];
     $last6Month = [];
     $numDataOrder = [];
     // 訂單生成數據
     $numDataVolume = [];
     // 營業額數據
     $numDataCompleted = [];
     // 訂單完成數據
     $numDataVolumeMonth = [];
     // 每月營業額
     $today = strtotime("00:00:00");
     $todayEnd = strtotime("23:59:59");
     for ($i = 0; $i < 15; $i++) {
         $timestrap = strtotime('-' . $i . ' days', $today);
         $timestrapEnd = strtotime('-' . $i . ' days', $todayEnd);
         $where = ['and', ['store_id' => Yii::$app->user->identity->store_id], ['>=', 'created_at', $timestrap], ['<=', 'created_at', $timestrapEnd]];
         array_unshift($last15days, date('m/d', $timestrap));
         array_unshift($numDataOrder, Order::find()->where($where)->count());
         $data = OrderVolume::find()->select(['sum(volume) AS volume', 'count(*) AS count'])->where($where)->asArray()->one();
         array_unshift($numDataVolume, $data['volume']);
         array_unshift($numDataCompleted, $data['count']);
     }
     for ($i = 0; $i < 6; $i++) {
         $timestrap = strtotime("first day of -{$i} month", $today);
         $timestrapEnd = strtotime("last day of -{$i} month", $todayEnd);
         $where = ['and', ['store_id' => Yii::$app->user->identity->store_id], ['>=', 'created_at', $timestrap], ['<=', 'created_at', $timestrapEnd]];
         array_unshift($last6Month, date('Y/m', $timestrap));
         array_unshift($numDataVolumeMonth, OrderVolume::find()->where($where)->sum('volume'));
     }
     $data2 = OrderVolume::find()->select(['sum(volume) AS volume', 'count(*) AS count'])->where(['store_id' => Yii::$app->user->identity->store_id])->asArray()->one();
     return $this->render('index', ['model' => Yii::$app->user->identity->store, 'last15days' => $last15days, 'last6Month' => $last6Month, 'numDataOrder' => $numDataOrder, 'numDataVolume' => $numDataVolume, 'numDataCompleted' => $numDataCompleted, 'numDataVolumeMonth' => $numDataVolumeMonth, 'countOrder' => Order::getCountByStoreId(Yii::$app->user->identity->store_id), 'countCompleted' => $data2['count'], 'sumVolume' => $data2['volume']]);
 }
開發者ID:daixianceng,項目名稱:xiaoego.com,代碼行數:34,代碼來源:SiteController.php

示例9: actionIndex

 public function actionIndex()
 {
     $dataProvider = new ActiveDataProvider(['query' => Order::find()->limit(10)->where(['status' => Order::STATUS_NEW])]);
     $productModel = new Product(['scenario' => 'create']);
     $productModel->date = date('Y-m-d H:i');
     return $this->render('index', ['dataProvider' => $dataProvider, 'categoryModel' => new Category(), 'productModel' => $productModel]);
 }
開發者ID:cyanofresh,項目名稱:yii2shop,代碼行數:7,代碼來源:SiteController.php

示例10: actionComplete

 /**
  * 完成超過2小時未收貨的訂單,每小時執行一次
  * 
  * @return string
  */
 public function actionComplete()
 {
     $transaction = Yii::$app->db->beginTransaction();
     try {
         $twelveHoursAgo = time() - 3600 * 2;
         $orders = Order::find()->where(['and', ['status' => Order::STATUS_SHIPPED], ['<=', 'created_at', $twelveHoursAgo]])->all();
         $count1 = 0;
         $count2 = 0;
         foreach ($orders as $key => $order) {
             if ($order->complete()) {
                 $count1++;
             } else {
                 $count2++;
             }
             unset($orders[$key]);
         }
         $transaction->commit();
         echo "{$count1} of orders affected by the execution, {$count2} fails.\n";
         return static::EXIT_CODE_NORMAL;
     } catch (\Exception $e) {
         $transaction->rollBack();
         echo $e->getMessage();
         return static::EXIT_CODE_ERROR;
     }
 }
開發者ID:daixianceng,項目名稱:xiaoego.com,代碼行數:30,代碼來源:OrderController.php

示例11: __construct

 /**
  * Creates a form model given an order id.
  *
  * @param  string                          $id
  * @param  array                           $config name-value pairs that will be used to initialize the object properties
  * @throws \yii\base\InvalidParamException if order id is not valid
  */
 public function __construct($id, $config = [])
 {
     $this->_order = Order::find()->where(['and', ['id' => $id], ['user_id' => Yii::$app->user->id], ['<>', 'status', Order::STATUS_DELETED]])->one();
     if (!$this->_order) {
         throw new InvalidParamException('您沒有該訂單!');
     }
     parent::__construct($config);
 }
開發者ID:shunzi250,項目名稱:xiaoego.com,代碼行數:15,代碼來源:PayOrderForm.php

示例12: findModel

 /**
  * Finds the Post model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Post the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Order::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
開發者ID:huynhtuvinh87,項目名稱:cms,代碼行數:15,代碼來源:OrderController.php

示例13: actionSelect

 public function actionSelect($id, $hallid)
 {
     $res = Order::find()->select('session_id')->where(['session_id' => $id])->one();
     if (!empty($res)) {
         \Yii::$app->db->createCommand("UPDATE `order` SET `seats`=:status WHERE `session_id`=:id")->bindValue(':id', $id)->bindValue(':status', $hallid)->execute();
     } else {
         \Yii::$app->db->createCommand()->insert('order', ['session_id' => $id, 'seats' => $hallid])->execute();
     }
 }
開發者ID:saqbest,項目名稱:advanced,代碼行數:9,代碼來源:SessionController.php

示例14: actionIndex

 public function actionIndex()
 {
     $orders = Order::find()->where(['user_id' => Yii::$app->user->id])->limit(2)->all();
     $productIds = ArrayHelper::map(Favorite::find()->where(['user_id' => Yii::$app->user->id])->orderBy(['id' => SORT_DESC])->asArray()->all(), 'product_id', 'product_id');
     if (count($productIds)) {
         $favorites = Product::find()->where(['id' => $productIds])->limit(5)->all();
     }
     $coupons = Coupon::find()->where(['and', 'user_id = ' . Yii::$app->user->id, 'used_at = 0', 'ended_at >= ' . time()])->all();
     return $this->render('index', ['orders' => $orders, 'favorites' => isset($favorites) ? $favorites : null, 'coupons' => $coupons]);
 }
開發者ID:liangdabiao,項目名稱:funshop,代碼行數:10,代碼來源:UserController.php

示例15: actionIndex

 public function actionIndex()
 {
     $model = new OrderForm();
     if ($model->load(Yii::$app->request->post()) && $model->makeOrder()) {
         $model->good_id++;
         // create a new order
         $order = new Order();
         // set total price
         $model->total_price = Good::findAll($model->good_id)[0]->price * $model->goods_count;
         // fill order props
         foreach ($model as $key => $value) {
             $order->setAttribute($key, $value);
         }
         // save the order
         $order->save();
         return $this->redirect('/index.php?r=order%2Forders');
     }
     return $this->render('index', ['model' => $model, 'good_names' => HelperComponent::array_pluck('name', Good::find()->select('name')->all())]);
 }
開發者ID:viktornord,項目名稱:gh-php-project,代碼行數:19,代碼來源:OrderController.php


注:本文中的common\models\Order類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。