当前位置: 首页>>代码示例>>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;未经允许,请勿转载。