当前位置: 首页>>代码示例>>PHP>>正文


PHP Order::model方法代码示例

本文整理汇总了PHP中Order::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Order::model方法的具体用法?PHP Order::model怎么用?PHP Order::model使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Order的用法示例。


在下文中一共展示了Order::model方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: processCheckout

 public function processCheckout(Payment $payment, CHttpRequest $request)
 {
     $payler = new Payler($payment);
     $order = Order::model()->findByUrl($payler->getOrderIdFromHash($request));
     if ($order === null) {
         Yii::log(Yii::t('PaylerModule.payler', 'The order doesn\'t exist.'), CLogger::LEVEL_ERROR);
         return false;
     }
     if ($order->isPaid()) {
         Yii::log(Yii::t('PaylerModule.payler', 'The order #{n} is already payed.', $order->getPrimaryKey()), CLogger::LEVEL_ERROR);
         return false;
     }
     if ($payler->getPaymentStatus($request) === 'Charged' && $order->pay($payment)) {
         Yii::log(Yii::t('PaylerModule.payler', 'The order #{n} has been payed successfully.', $order->getPrimaryKey()), CLogger::LEVEL_INFO);
         //Yii::app()->controller->redirect(['/order/order/view', 'url' => $order->url]);
         // return true;
         return $order;
     } else {
         Yii::log(Yii::t('PaylerModule.payler', 'An error occurred when you pay the order #{n}.', $order->getPrimaryKey()), CLogger::LEVEL_ERROR);
         //Customer was made 5 (6?) mistakes, we tell him about it...
         Yii::app()->getUser()->setFlash(yupe\widgets\YFlashMessages::ERROR_MESSAGE, Yii::t('PaylerModule.payler', 'Payment Fail'));
         //...and give another chance to pay
         //Yii::app()->controller->redirect(['/order/order/view', 'url' => $order->url]);
         //return false;
         return $order;
     }
 }
开发者ID:real-gear-plex,项目名称:yupe-payler,代码行数:27,代码来源:PaylerPaymentSystem.php

示例2: actionTest

 public function actionTest()
 {
     $start = time();
     Yii::app()->cache->flush();
     Yii::app()->db->createCommand()->truncateTable(Buy::model()->tableName());
     Yii::app()->db->createCommand()->truncateTable(Sell::model()->tableName());
     Yii::app()->db->createCommand()->truncateTable(Order::model()->tableName());
     Yii::app()->db->createCommand()->truncateTable(Balance::model()->tableName());
     // Тест на 10 000 руб.
     Status::setParam('balance', 10000);
     Status::setParam('balance_btc', 0);
     $exs = Exchange::getAllByDt('btc_rur', '2013-12-16', '2014-01-06');
     $cnt = 0;
     foreach ($exs as $exchange) {
         $obj = new stdClass();
         $obj->dtm = $exchange['dt'];
         $obj->buy = $exchange['buy'];
         $obj->sell = $exchange['sell'];
         $cnt++;
         $bot = new Bot($obj);
         $bot->run();
     }
     $end = time();
     echo '<b>Elapsed time: ' . ($end - $start) / 60 . ' min.<br/>';
     echo '<b>Steps count: ' . $cnt . '<br/>';
 }
开发者ID:HotAttack,项目名称:btcbot,代码行数:26,代码来源:CronCommand.php

示例3: update

 public function update($id)
 {
     $transaction = Yii::app()->db->beginTransaction();
     try {
         $order = Order::model()->findByAttributes(array('id' => $id));
         $order->status = 1;
         $ordercompanyproduct = OrderCompany::model()->findAllByAttributes(array('orderId' => $id));
         if ($ordercompanyproduct) {
             foreach ($ordercompanyproduct as &$value) {
                 $code = Code::model()->findByAttributes(array('ordercompanyproductId' => $value->id));
                 $code->status = 1;
                 $value->status = 1;
                 if (!$value->save() || !$code->save()) {
                     throw new Exception("Error Processing Request", 1);
                 }
             }
         }
         $order->save();
         $transaction->commit();
     } catch (Exception $e) {
         $transaction->rollback();
         Yii::log('update fail', CLogger::LEVEL_ERROR, 'updatedb');
         return array('code' => 500, 'mes' => 'update fail');
     }
     return array('code' => 200, 'mes' => 'success');
 }
开发者ID:itliuchang,项目名称:test,代码行数:26,代码来源:COrder.php

示例4: createReservation

 public function createReservation($data)
 {
     $result = new Reservations();
     $result->createTime = date('Y-m-d H:i:s', time());
     foreach ($data as $k => $v) {
         $result->{$k} = $v;
     }
     $type = User::model()->findByAttributes(array('id' => $data['userId']));
     if ($data['type'] == 1 && $type == 1) {
         $orderid = Order::model()->findAllByAttributes(array('status' => 1, 'userId' => Yii::app()->user->id, 'type' => 1));
         if ($orderid) {
             $now = date('Ymd', strtotime(substr($data['startTime'], 0, 10)));
             foreach ($orderid as $list) {
                 $dp = OrderProduct::model()->find('endDate>=' . $now . ' and orderId=' . $list['id'] . ' and startDate<=' . $now);
                 if ($dp) {
                     break;
                 }
             }
             $dp->usedTimes++;
             $dp->save();
             $result->orderId = $dp['orderId'];
             $result->save();
         }
     }
     if ($result->save()) {
         $data = array('code' => 200, 'message' => 'SUCCESS');
     }
     return $data;
 }
开发者ID:itliuchang,项目名称:test,代码行数:29,代码来源:CReservation.php

示例5: process

 public function process()
 {
     $model = \Order::model();
     foreach ($this->orders as $order) {
         $model->saveItem($order);
     }
 }
开发者ID:xamin123,项目名称:code-example,代码行数:7,代码来源:PopulateOrdersTask.php

示例6: actionAdditem

 /**
  * Displays a particular model.
  * @param integer $id the ID of the model to be displayed
  */
 public function actionAdditem($item_id)
 {
     $user_id = Yii::app()->user->id;
     // find the users cart
     $user = User::model()->find(array('condition' => 'id=:user_id', 'params' => array(':user_id' => $user_id)));
     // find the users cart
     $cart = Cart::model()->find(array('condition' => 'cart_owner=:cart_owner', 'params' => array(':cart_owner' => $user_id)));
     // find the item being reffered to by item_id
     $item = Item::model()->find(array('condition' => 'id=:item_id', 'params' => array(':item_id' => $item_id)));
     if (is_null($cart)) {
         // if the cart is not found. create a cart for the user.
         $cart = new Cart();
         $cart->cart_owner = $user->id;
         $cart->save();
     }
     // check if the same order was already made & increment else, create new
     $order = Order::model()->find(array('condition' => 'item_id=:item_id AND cart_id=:cart_id AND order_by=:order_by', 'params' => array(':item_id' => $item_id, ':cart_id' => $cart->id, ':order_by' => $user->id)));
     if (is_null($order)) {
         $order = new Order();
         $order->create_time = time();
         $order->quantity = 1;
         $order->item_id = $item->id;
         $order->cart_id = $cart->id;
         $order->order_by = $user->id;
     } else {
         $order->quantity = 1 + $order->quantity;
         $order->update_time = time();
     }
     $order->save();
     // find all orders by this user.
     $orders = Order::model()->findAll('cart_id=:cart_id AND order_by=:order_by', array(':cart_id' => $cart->id, ':order_by' => $user->id));
     $return = array('success' => true, 'data' => $orders);
     echo CJavaScript::jsonEncode($return);
     Yii::app()->end();
 }
开发者ID:iusedtobecat,项目名称:sweetparticles,代码行数:39,代码来源:CartController.php

示例7: testCreateOrder

 /**
  * Check creating new orders
  */
 public function testCreateOrder()
 {
     $microTime = microtime();
     $comment = 'test comment ' . $microTime;
     // Find any active product
     $product = StoreProduct::model()->active()->findByAttributes(array('use_configurations' => 0));
     $this->assertTrue($product instanceof StoreProduct);
     // Open product page and add to cart
     $this->open(Yii::app()->createUrl('/store/frontProduct/view', array('url' => $product->url)));
     $this->click("//input[@id='buyButton']");
     $this->open('cart');
     $this->assertTrue($this->isTextPresent($product->name));
     $this->click('css=label.radio > span');
     $this->type('id=OrderCreateForm_name', 'Tester Name');
     $this->type('id=OrderCreateForm_email', 'tester@localhost.loc');
     $this->type('id=OrderCreateForm_phone', '0990000000');
     $this->type('id=OrderCreateForm_address', 'test address');
     $this->type('id=OrderCreateForm_comment', $comment);
     $this->clickAtAndWait('name=create');
     // Check if order successfully saved
     $order = Order::model()->findByAttributes(array('user_comment' => $comment));
     $this->assertTrue($order instanceof Order);
     // Check of ordered products
     $this->assertTrue($order->getOrderedProducts() instanceof CActiveDataProvider);
     $this->assertTrue($order->getOrderedProducts()->getTotalItemCount() > 0);
 }
开发者ID:kolbensky,项目名称:rybolove,代码行数:29,代码来源:OrdersWebTest.php

示例8: processCheckout

 /**
  * @param Payment $payment
  * @param CHttpRequest $request
  */
 public function processCheckout(Payment $payment, CHttpRequest $request)
 {
     $settings = $payment->getPaymentSystemSettings();
     $params = ['action' => $request->getParam('action'), 'orderSumAmount' => $request->getParam('orderSumAmount'), 'orderSumCurrencyPaycash' => $request->getParam('orderSumCurrencyPaycash'), 'orderSumBankPaycash' => $request->getParam('orderSumBankPaycash'), 'shopId' => $settings['shopid'], 'invoiceId' => $request->getParam('invoiceId'), 'customerNumber' => $request->getParam('customerNumber'), 'password' => $settings['password']];
     /* @var $order Order */
     $order = Order::model()->findByPk($request->getParam('orderNumber'));
     if ($order === null) {
         $message = Yii::t('YandexMoneyModule.ymoney', 'The order doesn\'t exist.');
         Yii::log($message, CLogger::LEVEL_ERROR);
         $this->showResponse($params, $message, 200);
     }
     if ($order->isPaid()) {
         $message = Yii::t('YandexMoneyModule.ymoney', 'The order #{n} is already payed.', $order->getPrimaryKey());
         Yii::log($message, CLogger::LEVEL_ERROR);
         $this->showResponse($params, $message, 200);
     }
     if ($this->getOrderCheckSum($params) !== $request->getParam('md5')) {
         $message = Yii::t('YandexMoneyModule.ymoney', 'Wrong checksum');
         Yii::log($message, CLogger::LEVEL_ERROR);
         $this->showResponse($params, $message, 200);
     }
     if ((double) $order->getTotalPriceWithDelivery() !== (double) $params['orderSumAmount']) {
         $message = Yii::t('YandexMoneyModule.ymoney', 'Wrong payment amount');
         Yii::log($message, CLogger::LEVEL_ERROR);
         $this->showResponse($params, $message, 200);
     }
     if ($params['action'] === 'checkOrder') {
         $this->showResponse($params);
     }
     if ($params['action'] === 'paymentAviso' && $order->pay($payment)) {
         Yii::log(Yii::t('YandexMoneyModule.ymoney', 'The order #{n} has been payed successfully.', $order->getPrimaryKey()), CLogger::LEVEL_INFO);
         $this->showResponse($params);
     }
 }
开发者ID:alextravin,项目名称:yupe,代码行数:38,代码来源:YandexMoneyPaymentSystem.php

示例9: run

 public function run($nurser_id, $order_id)
 {
     //throw new RuntimeException($nurser_id);
     $order_model = Order::model()->findByPk($order_id);
     if (!empty($order_model->nurser_id)) {
         $id = $order_model->nurser_id;
         $nurser_model = NurseUser::model()->findByPk($id);
         $nurser_model->status = 0;
         if (!$nurser_model->update()) {
             throw new RuntimeException("数据保存失败");
         }
     }
     //确认护士,并改成护士值班状态
     $order_model->nurser_id = $nurser_id;
     $nurse_model = NurseUser::model()->findBypk($nurser_id);
     //选择后护士状态呈现已安排
     $nurse_model->status = 1;
     //throw new RuntimeException($phone);
     $order_model->order_status = 1;
     if ($order_model->update() && $nurse_model->update()) {
         $flag = 0;
         //$phone = $nurse_model->phone;
         //$message = "橙妈妈用户已下单,请您在30分钟内确认订单...";
         //SmsCode::SendMsgs($phone,$message);
     } else {
         $flag = 1;
     }
     $vars = array('nurser_id' => $nurser_id, 'order_id' => $order_id, 'flag' => $flag);
     $this->controller->success('', $vars);
 }
开发者ID:WalkerDi,项目名称:mama,代码行数:30,代码来源:OkNurseAction.php

示例10: actionCreate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate($id)
 {
     $modelOrder = Order::model()->findByPk($id);
     $model = new SparePartsOrder();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['SparePartsOrder'])) {
         $model->spare_parts_id = $_POST['SparePartsOrder']['spareParts'];
         //            $model->attributes = $_POST['SparePartsOrder'];
         var_dump($model->attributes);
         if ($model->validate()) {
             if (isset($_POST['SparePartsOrder']['spareParts'])) {
                 $arraySpareParts = $_POST['SparePartsOrder']['spareParts'];
                 foreach ($arraySpareParts as $spareParts) {
                     $model = new SparePartsOrder();
                     $model->order_id = $modelOrder->id;
                     $model->spare_parts_id = $spareParts;
                     $model->save(false);
                 }
             }
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('create', array('model' => $model, 'modelOrder' => $modelOrder));
 }
开发者ID:rodespsan,项目名称:LMEC,代码行数:29,代码来源:SparePartsOrderController.php

示例11: processCheckout

 /**
  * @param Payment $payment
  * @param CHttpRequest $request
  * @return bool
  */
 public function processCheckout(Payment $payment, CHttpRequest $request)
 {
     $amount = $request->getParam('OutSum');
     $orderId = (int) $request->getParam('InvId');
     $crc = strtoupper($request->getParam('SignatureValue'));
     $order = Order::model()->findByPk($orderId);
     if (null === $order) {
         Yii::log(Yii::t('RobokassaModule.robokassa', 'Order with id = {id} not found!', ['{id}' => $orderId]), CLogger::LEVEL_ERROR, self::LOG_CATEGORY);
         return false;
     }
     if ($order->isPaid()) {
         Yii::log(Yii::t('RobokassaModule.robokassa', 'Order with id = {id} already payed!', ['{id}' => $orderId]), CLogger::LEVEL_ERROR, self::LOG_CATEGORY);
         return false;
     }
     $settings = $payment->getPaymentSystemSettings();
     $myCrc = strtoupper(md5("{$amount}:{$orderId}:" . $settings['password2']));
     if ($myCrc !== $crc) {
         Yii::log(Yii::t('RobokassaModule.robokassa', 'Error pay order with id = {id}! Bad crc!', ['{id}' => $orderId]), CLogger::LEVEL_ERROR, self::LOG_CATEGORY);
         return false;
     }
     if ($amount != Yii::app()->money->convert($order->total_price, $payment->currency_id)) {
         Yii::log(Yii::t('RobokassaModule.robokassa', 'Error pay order with id = {id}! Incorrect price!', ['{id}' => $orderId]), CLogger::LEVEL_ERROR, self::LOG_CATEGORY);
         return false;
     }
     if ($order->pay($payment)) {
         Yii::log(Yii::t('RobokassaModule.robokassa', 'Success pay order with id = {id}!', ['{id}' => $orderId]), CLogger::LEVEL_INFO, self::LOG_CATEGORY);
         return true;
     } else {
         Yii::log(Yii::t('RobokassaModule.robokassa', 'Error pay order with id = {id}! Error change status!', ['{id}' => $orderId]), CLogger::LEVEL_ERROR, self::LOG_CATEGORY);
         return false;
     }
 }
开发者ID:alextravin,项目名称:yupe,代码行数:37,代码来源:RobokassaPaymentSystem.php

示例12: processPaymentRequest

 /**
  * This method will be triggered after redirection from payment system site.
  * If payment accepted method must return Order model to make redirection to order view.
  * @param StorePaymentMethod $method
  * @return boolean|Order
  */
 public function processPaymentRequest(StorePaymentMethod $method)
 {
     $settings = $this->getSettings($method->id);
     $cr = new CDbCriteria();
     $cr->order = 'created DESC';
     $orders = Order::model()->findAllByAttributes(array('paid' => 0));
     $orders = $this->prepareOrders($orders);
     $xmlResponse = $this->requestStatuses($orders, $settings);
     foreach ($xmlResponse->{'bills-list'}->{'bill'} as $bill) {
         if ((int) $bill->attributes()->{'status'} === 60) {
             $orderId = (string) $bill->attributes()->{'status'};
             if (isset($orders[$orderId])) {
                 $order = Order::model()->findByPk($orderId);
                 if ($order) {
                     $order->paid = true;
                     $order->save(false);
                 }
             }
         }
     }
     if (Yii::app()->request->getQuery('redirect')) {
         Yii::app()->request->redirect(Yii::app()->request->getQuery('redirect'));
     }
     Yii::app()->request->redirect('/');
 }
开发者ID:kolbensky,项目名称:rybolove,代码行数:31,代码来源:QiwiPaymentSystem.php

示例13: processPaymentRequest

 /**
  * This method will be triggered after redirection from payment system site.
  * If payment accepted method must return Order model to make redirection to order view.
  * @param StorePaymentMethod $method
  * @return boolean|Order
  */
 public function processPaymentRequest(StorePaymentMethod $method)
 {
     $request = Yii::app()->request;
     $settings = $this->getSettings($method->id);
     $order = Order::model()->findByAttributes(array('secret_key' => $request->getParam('Shp_orderKey')));
     if ($order->paid) {
         return false;
     }
     $mrh_pass2 = $settings['password2'];
     $shp_order_key = $order->secret_key;
     $shp_payment_id = $method->id;
     $out_sum = $request->getParam("OutSum");
     $inv_id = $request->getParam("InvId");
     $crc = strtoupper($request->getParam("SignatureValue"));
     $my_crc = strtoupper(md5("{$out_sum}:{$inv_id}:{$mrh_pass2}:Shp_orderKey={$shp_order_key}:Shp_pmId={$shp_payment_id}"));
     // Check sum
     if ($out_sum != Yii::app()->currency->convert($order->full_price, $method->currency_id)) {
         return ERROR_SUM;
     }
     // Check sign
     if ($my_crc != $crc) {
         return "bad sign {$out_sum}:{$inv_id}:Shp_orderKey={$shp_order_key}:Shp_pmId={$shp_payment_id}";
     }
     // Set order paid
     $order->paid = 1;
     $order->save();
     // Show answer for Robokassa API service
     if (isset($_REQUEST['getResult']) && $_REQUEST['getResult'] == 'true') {
         exit("OK" . $order->id);
     }
     return $order;
 }
开发者ID:kolbensky,项目名称:rybolove,代码行数:38,代码来源:RobokassaPaymentSystem.php

示例14: actionCheckPostponedOrders

 /**
  * Check for orders without carrier chosen
  *
  * @return int
  */
 public function actionCheckPostponedOrders()
 {
     echo "Finding postponed orders..." . PHP_EOL;
     /** @var Order[] $orders */
     $orders = Order::model()->getPostponedOrders();
     $ordersCount = count($orders);
     Yii::log(sprintf("Found %s delayed %s" . PHP_EOL, $ordersCount, $this->pluralize('order', $ordersCount)), CLogger::LEVEL_ERROR, 'email_notification');
     foreach ($orders as $order) {
         Yii::log(sprintf("Sending notification email about postponed Order #%s to User #%s %s <%s>", $order->id, $order->creator_id, $order->creator->fullname, $order->creator->email), CLogger::LEVEL_INFO, 'email_notification');
         /** @var SwiftMailer $mailer */
         $mailer = Yii::app()->mailer;
         /** @var EmailTemplate $emailTemplateModel */
         $emailTemplateModel = EmailTemplate::model();
         $template = $emailTemplateModel->getEmailTemplateBySlug(EmailTemplate::TEMPLATE_ORDER_DELAYED);
         $replacements = [$order->creator->email => ['{{order}}' => CHtml::link('#' . $order->id, Yii::app()->createAbsoluteUrl('order/view', ['id' => $order->id]))]];
         if ($template) {
             $mailer->setSubject($template->subject)->setBody($template->body)->setTo($order->creator->email)->setDecoratorReplacements($replacements)->send();
         } else {
             Yii::log("Email template not found!", CLogger::LEVEL_ERROR, 'email_notification');
             return 1;
         }
     }
     echo "Done!" . PHP_EOL;
     return 0;
 }
开发者ID:septembermd,项目名称:n1,代码行数:30,代码来源:OrderCommand.php

示例15: actionIndex

 public function actionIndex()
 {
     // total semua pemasukan
     $criteria = new CDbCriteria();
     $criteria->addBetweenCondition('TANGGAL_ORDER', date('Y-m-01', strtotime('this month')), date('Y-m-t', strtotime('this month')));
     $kredit = Order::model()->findAll($criteria);
     $total = 0;
     foreach ($kredit as $k) {
         $total += $k->TOTAL;
     }
     // menghitung total order
     $order_c = Order::model()->count();
     // menghitung total pasien
     $pelanggan_c = Pasien::model()->count();
     // get data order hari ini
     $criteria2 = new CDbCriteria();
     $criteria2->condition = 'date(TANGGAL_ORDER) = date(NOW())';
     $hariini = Order::model()->count($criteria2);
     // get barang yang tanggal expired
     $expired = Item::getExpired();
     // data obat habis
     $criteria = new CDbCriteria();
     $criteria->order = 'TANGGAL_ORDER DESC';
     $criteria->limit = '5';
     $dataProvider = new CActiveDataProvider('Pasien', array('pagination' => false, 'criteria' => $criteria));
     $this->render('index', array('total' => $total, 'order' => $order_c, 'pelanggan' => $pelanggan_c, 'hariini' => $hariini, 'expired' => $expired));
 }
开发者ID:bangphe,项目名称:klinik,代码行数:27,代码来源:DefaultController.php


注:本文中的Order::model方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。