本文整理汇总了PHP中app\models\Order类的典型用法代码示例。如果您正苦于以下问题:PHP Order类的具体用法?PHP Order怎么用?PHP Order使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Order类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: actionPayment
public function actionPayment()
{
if (\Yii::$app->session->has('customer')) {
$modelCustomer = new Customer();
$infoCustomer = $modelCustomer->getInformation($_SESSION['customer']);
$modelOrder = new Order();
$modelOrderDetail = new OrderDetail();
$modelProduct = new Product();
$ids = array();
foreach ($_SESSION['cart_items'] as $id => $quantity) {
array_push($ids, $id);
}
$products = $modelProduct->getWithIDs($ids);
if (\Yii::$app->request->post()) {
$modelOrder->load(\Yii::$app->request->post());
$modelOrder->save();
$orderId = $modelOrder->id;
foreach ($_SESSION['cart_items'] as $id => $quantity) {
$unitPrice = $modelProduct->getPrice($id) * $quantity;
\Yii::$app->db->createCommand()->insert('order_detail', ['orderId' => $orderId, 'productId' => $id, 'unitPrice' => $unitPrice, 'quantity' => $quantity])->execute();
}
\Yii::$app->session->remove('cart_items');
return $this->redirect(['cart/index', 'success' => 'Thanh toán thành công! Chúng tôi sẽ liên hệ bạn trong thời gian sớm nhất! Xin cảm ơn!']);
} else {
return $this->render('payment', ['infoCustomer' => $infoCustomer, 'modelOrder' => $modelOrder, 'products' => $products]);
}
} else {
$this->redirect(['customer/login', 'error' => 'Vui lòng đăng nhập trước khi thanh toán']);
}
}
开发者ID:royutoan,项目名称:pianodanang,代码行数:30,代码来源:CartController.php
示例2: generate
function generate()
{
/* INV-ddmmyyyXXXXX (INV-0206201500356) */
// $lastInvoice = "INV-270720150001";
$orders = new Order();
$lastOrder = $orders->orderBy('created_at', 'desc')->first();
if ($lastOrder) {
$lastInvoice = $lastOrder->invoice_no;
}
# date configuration
$date = Date('d');
$month = Date('m');
$year = Date('Y');
$newInvoice = "";
if (!$lastOrder || !$lastInvoice) {
$newInvoice = "INV-" . $date . $month . $year . "0001";
} else {
#get the month of the lastInvoice
$last_inv_month = substr($lastInvoice, 6, 2);
if (!$last_inv_month == $month) {
$increment = "0001";
} else {
#get last four digit of last invoice number
$zeroDigits = "";
$invoice_length = strlen($lastInvoice);
$last_increment = intval(substr($lastInvoice, $lastInvoice - 4, 4));
for ($c = 0; $c < 4 - $last_increment; $c++) {
$zeroDigits = $zeroDigits . "0";
}
$new_increment = strval($last_increment + 1);
$newInvoice = "INV-" . $date . $month . $year . $zeroDigits . $new_increment;
}
}
return $newInvoice;
}
开发者ID:ardiqghenatya,项目名称:koptel2,代码行数:35,代码来源:InvoiceHelper.php
示例3: actionOrder
public function actionOrder()
{
$order = new Order();
$products = $this->_cart->getPositions();
$total = $this->_cart->getCost();
if ($order->load(\Yii::$app->request->post()) && $order->validate()) {
$order->user_id = 1;
$order->cart_id = "text";
if ($order->save(false)) {
foreach ($products as $product) {
$orderItem = new OrderItem();
$orderItem->order_id = $order->id;
$orderItem->product_id = $product->id;
$orderItem->price = $product->getPrice();
$orderItem->quantity = $product->getQuantity();
if (!$orderItem->save(false)) {
\Yii::$app->session->addFlash('error', 'Cannot place your order. Please contact us.');
return $this->redirect('site/index');
}
}
}
$this->_cart->removeAll();
\Yii::$app->session->addFlash('success', 'Thanks for your order. We\'ll contact you soon.');
//$order->sendEmail();
return $this->redirect('site/index');
}
return $this->render('order', ['order' => $order, 'products' => $products, 'total' => $total]);
}
开发者ID:absol3112,项目名称:sonneboutique,代码行数:28,代码来源:CartController.php
示例4: create_cart
private function create_cart()
{
$order = new Order();
$order->user_id = $this->id;
$order->save();
$this->order_id = $order->id;
$this->save();
}
开发者ID:nkiermaier,项目名称:laravel_ecommerce,代码行数:8,代码来源:User.php
示例5: proceedToCheckout
public function proceedToCheckout($total)
{
$order = new Order();
$userId = Yii::$app->user->identity->id;
$order->user_id = $userId;
$order->address = $this->address;
$order->phone_number = $this->phoneNumber;
$order->total = $total;
return $order->save(false) && !$this->hasErrors() ? $order : null;
}
开发者ID:andrey3,项目名称:shop,代码行数:10,代码来源:CheckoutForm.php
示例6: feedback
public function feedback(Request $request)
{
$text = view('email.feedback', $request->all())->render();
$email = Config::get('mail.from')['address'];
$order = new Order();
$order->save();
$number = $order->id;
$result = mail($email, "[kolizej.ru] обращение №{$number}", $text, "Content-type: text/html; charset=utf-8\r\n");
return ['success' => $result ? true : false, 'number' => $number];
}
开发者ID:pechatny,项目名称:kolizej,代码行数:10,代码来源:PagesController.php
示例7: actionIndex
public function actionIndex()
{
//todo redis?
$user = Yii::$app->session->get('user');
if (empty($user)) {
$this->goHome();
}
$user = User::findOne($user->id);
if ($user->account < Yii::$app->params['auctionDeposit']) {
$order = Order::find()->where(['type' => Order::TYPE_AUCTION, 'user_id' => $user->id, 'status' => Order::STATUS_CREATED])->one();
if (empty($order)) {
$order = new Order();
$order->user_id = $user->id;
$order->serial_no = Util::composeOrderNumber(Order::TYPE_AUCTION);
$order->money = Yii::$app->params['auctionDeposit'];
$auction = Auction::find()->where('end_time > NOW()')->orderBy('start_time, end_time')->limit(1)->one();
$order->auction_id = $auction->id;
$order->status = Order::STATUS_CREATED;
$order->type = Order::TYPE_AUCTION;
$order->save();
}
$this->redirect('/pay/index?order_id=' . $order->serial_no);
}
$auctions = Auction::find()->where('end_time > NOW()')->orderBy('start_time, type')->limit(3)->all();
$auctionIds = [];
foreach ($auctions as $auction) {
array_push($auctionIds, $auction->id);
}
$topOffers = $this->getTopOfferHash($auctionIds);
$myOffers = $this->getMyTopOfferHash($user->id, $auctionIds);
foreach ($topOffers as $tmpId => $tmpOffer) {
if (!array_key_exists($tmpId, $myOffers)) {
$myTmpOffer = [];
$myTmpOffer['auction_id'] = $tmpId;
$myTmpOffer['top'] = 0;
$myOffers[$tmpId] = $myTmpOffer;
}
list($myOffers[$tmpId]['rank'], $myOffers[$tmpId]['class'], $myOffers[$tmpId]['message']) = $this->composeRankInfo($tmpId, $myOffers[$tmpId]['top']);
}
$isInAuction = $this->isInAuction();
$hasNextAuction = $this->hasNextAuction();
$startTime = isset($auctions[0]) ? $auctions[0]->start_time : '';
$endTime = isset($auctions[0]) ? $auctions[0]->end_time : '';
$countDownTime = str_replace(' ', 'T', $isInAuction ? $endTime : $startTime);
$priceStep = Yii::$app->params['auctionStep'];
$lang = Util::getLanguage();
$view = $lang == 'en' ? 'auction' : 'auction-cn';
Util::setLanguage($lang);
return $this->render($view, compact('auctions', 'topOffers', 'myOffers', 'startTime', 'endTime', 'isInAuction', 'hasNextAuction', 'countDownTime', 'priceStep'));
}
开发者ID:diaosj,项目名称:trivial-php-logic,代码行数:50,代码来源:AuctionController.php
示例8: store
/**
* 提交支付表单
*
* @return Response
*/
public function store(Request $request)
{
//验证input信息
$this->validate($request, ['gateway' => 'required']);
//创建订单...
$orderSn = Order::createOrderSn();
$out_trade_no = $orderSn;
//保存订单
//TODO
//订单数据,暂时使用测试数据
$data = ['out_trade_no' => $out_trade_no, 'subject' => $out_trade_no . '号订单产品', 'total_fee' => '0.1', 'quantity' => 1, 'defaultBank' => 'CCB'];
//保证金额正确性, 订单号,主题,支付金额由订单决定
$data = $data + Input::all();
//创建payway
$gateway = Input::get('gateway');
Omnipay::setGateway($gateway);
//数据对接-按配置参数重组数组
//如果符合则加入进新数组
$gateway = Omnipay::getGateway();
$purchaseParamKeys = Config::get('laravel-omnipay.gateways')[$gateway]['purchaseParamKeys'];
$parameters = createNewKeyArray($data, $purchaseParamKeys);
//获取request
$resquest = Omnipay::purchase($parameters);
//获取respond并跳转到第三方支付平台
$response = $resquest->send();
$response->redirect();
}
开发者ID:Zachary-Leung,项目名称:wine_platform,代码行数:32,代码来源:PaymentsController.php
示例9: run
public function run()
{
DB::table('orders')->delete();
Order::create(array('id' => '1', 'user_id' => '1', 'total' => '4000', 'comment' => 'Позвоните мне.', 'delivery_price' => '1200', 'weight' => '40', 'distance' => '168', 'volume' => '50'));
Order::create(array('id' => '2', 'user_id' => '1', 'total' => '7200', 'comment' => 'Есть в наличие?', 'delivery_price' => '1200', 'weight' => '80', 'distance' => '568', 'volume' => '50'));
Order::create(array('id' => '3', 'user_id' => '1', 'total' => '1000', 'comment' => 'Когда отправите?', 'delivery_price' => '1200', 'distance' => '269', 'weight' => '50', 'volume' => '50'));
}
开发者ID:artyomich,项目名称:laravel,代码行数:7,代码来源:OrdersTableSeeder.php
示例10: create_payment
private function create_payment($order_id)
{
$order = Order::find($order_id);
if ($order) {
$user = $order->user_id;
$sum = $order->sum;
$mrh_login = env('ROBOKASSA_LOGIN');
$mrh_pass1 = env('ROBOKASSA_PASSWORD');
$invoice_id = mt_rand();
$inv_desc = 'Пополнение баланса';
$crc = md5($mrh_login . ":" . $sum . ":" . $invoice_id . ":" . $mrh_pass1);
if ($sum != 0) {
try {
DB::beginTransaction();
$payment = new Payment();
$payment->uid = $invoice_id;
$payment->order_id = $order_id;
$payment->user_id = $user;
$payment->sum = $sum;
$payment->description = $inv_desc;
$payment->operation = '+';
$payment->payment_type = $order->payment_type;
$payment->save();
DB::commit();
} catch (\PDOException $e) {
print $e->getMessage();
DB::connection()->getPdo()->rollBack();
}
}
$redirect_url = "https://auth.robokassa.ru/Merchant/Index.aspx?MrchLogin={$mrh_login}&OutSum={$sum}&InvId={$invoice_id}&Desc={$inv_desc}&SignatureValue={$crc}&IsTest=1";
return $redirect_url;
}
return Redirect::to('/')->with('message', 'Ошибка');
}
开发者ID:venomir,项目名称:tc,代码行数:34,代码来源:OrderController.php
示例11: handle
/**
* Execute the command.
*
// * @return void
*/
public function handle()
{
$documents = Config::get('documents');
$whereAreClientDocuments = $documents['documents_folder'];
//client_{id}
if (!Storage::disk('local')->exists($whereAreClientDocuments . DIRECTORY_SEPARATOR . 'client_' . $this->order->user_id)) {
Storage::makeDirectory($whereAreClientDocuments . DIRECTORY_SEPARATOR . 'client_' . $this->order->user_id);
}
//paymentDocs
if (!Storage::disk('local')->exists($whereAreClientDocuments . DIRECTORY_SEPARATOR . 'client_' . $this->order->user_id . DIRECTORY_SEPARATOR . Order::getDocTypeName($this->docType))) {
Storage::makeDirectory($whereAreClientDocuments . DIRECTORY_SEPARATOR . 'client_' . $this->order->user_id . DIRECTORY_SEPARATOR . Order::getDocTypeName($this->docType));
}
$clientFolder = $whereAreClientDocuments . DIRECTORY_SEPARATOR . 'client_' . $this->order->user_id . DIRECTORY_SEPARATOR . Order::getDocTypeName($this->docType);
//(torg12/schetfactura)_{orderID}_{depoName}_date_{currentDate}
$fileNameTemplate = $this->documentFor == Order::DOCUMENT_FOR_SERVICE ? $documents['client_service_document_template'] : $documents['client_document_template'];
$fileNameTemplate = Utils::mb_str_replace('{docType}', Order::getDocTypeName($this->docType), $fileNameTemplate);
$fileNameTemplate = Utils::mb_str_replace('{orderID}', $this->order->id, $fileNameTemplate);
if ($this->documentFor == Order::DOCUMENT_FOR_SPARE_PART) {
$depoName = $this->order->products_in_order[0]->stantion_name;
$depoName = Utils::mb_str_replace(' ', '', $depoName);
$depoName = Utils::translit($depoName);
$fileNameTemplate = Utils::mb_str_replace('{depoName}', $depoName, $fileNameTemplate);
}
$fileNameTemplate = Utils::mb_str_replace('{currentDate}', time(), $fileNameTemplate);
$extension = $this->file->getClientOriginalExtension();
try {
Storage::disk('local')->put($clientFolder . DIRECTORY_SEPARATOR . $fileNameTemplate . '.' . $extension, File::get($this->file));
} catch (Exception $e) {
Log::error('Ошибка загрузки файла ' . $fileNameTemplate . ' message - ' . $e->getMessage());
return false;
}
return storage_path() . DIRECTORY_SEPARATOR . 'app' . $clientFolder . DIRECTORY_SEPARATOR . $fileNameTemplate . '.' . $extension;
}
开发者ID:kostik34,项目名称:trains.shop,代码行数:38,代码来源:UploadDocument.php
示例12: notify
public function notify(Request $request)
{
\Log::debug('payment_notify', ['request' => $request]);
$input = XML::parse($request->getContent());
if ($input['return_code'] == 'SUCCESS') {
$order = Order::where('wx_out_trade_no', $input['out_trade_no'])->firstOrFail();
$address_id = $order->address_id;
# 当前订单收货地址id
if ($order->isPaid()) {
return 'FAIL';
}
$order->update(['wx_transaction_id' => $input['transaction_id'], 'cash_payment' => floatval($input['total_fee']) / 100.0]);
$order->paid();
/* 发送消息提醒 */
$default_address = Address::where(['id' => $address_id])->first();
$phone = $default_address->phone;
$msg = '尊敬的顾客您好!您的订单已经收到,易康商城将尽快为您安排发货,如有任何问题可以拨打客服电话400-1199-802进行咨询,感谢您的惠顾!';
\MessageSender::sendMessage($phone, $msg);
// if ($phone = env('ORDER_ADMIN_PHONE')) {
// \Log::error($phone);
// \MessageSender::sendMessage($phone, $order->toOrderMessageString());
// }
$result = \Wechat::paymentNotify();
return $result;
}
return 'FAIL';
}
开发者ID:whplay,项目名称:ohmate-shop,代码行数:27,代码来源:PaymentController.php
示例13: createPayment
public function createPayment(Request $request)
{
Auth::user();
$order_id = session('order_id');
$order = Order::find($order_id);
if ($order) {
$user = $order->id;
$sum = $order->sum;
$mrh_login = env('ROBOKASSA_LOGIN');
$mrh_pass1 = env('ROBOKASSA_PASSWORD');
$invoice_id = mt_rand();
$inv_desc = 'Пополнение баланса';
$crc = md5($mrh_login . ":" . $sum . ":" . $invoice_id . ":" . $mrh_pass1);
if ($sum != 0) {
try {
DB::beginTransaction();
$payment = new Payment();
$payment->uid = $invoice_id;
$payment->user_id = $user;
$payment->balance = $sum;
$payment->description = $inv_desc;
$payment->operation = '+';
$payment->save();
DB::commit();
} catch (\PDOException $e) {
print $e->getMessage();
DB::connection()->getPdo()->rollBack();
}
}
echo 'ok';
return 1;
header("Location: https://auth.robokassa.ru/Merchant/Index.aspx?MrchLogin={$mrh_login}&OutSum={$sum}&InvId={$invoice_id}&Desc={$inv_desc}&SignatureValue={$crc}");
}
}
开发者ID:venomir,项目名称:tc,代码行数:34,代码来源:PaymentController.php
示例14: getOrders
public function getOrders()
{
//with用法,先不用all查询
$orders = $this->hasMany(Order::className(), array('cid' => 'id'))->asArray();
//->all();
return $orders;
}
开发者ID:huangsen0912,项目名称:yii2,代码行数:7,代码来源:Customer.php
示例15: unFinishOrder
/**
* Put an order from finished to unfinished
*
* @param $id
* @return mixed
*/
public function unFinishOrder($id)
{
$order = Order::find($id);
$order->finished = null;
$order->save();
return $order;
}
开发者ID:FomKiosk,项目名称:API-Laravel,代码行数:13,代码来源:OrderRepository.php
示例16: request_post
public function request_post()
{
$post = Input::all();
$rules = ['name' => 'required', 'phone' => 'required', 'aid' => 'required'];
$validator = Validator::make($post, $rules);
if ($validator->fails()) {
return redirect()->back()->with('error', $validator->errors()->all())->withInput();
}
$order = new Order();
$order->name = $post['name'];
$order->phone = $post['phone'];
$order->aid = $post['aid'];
$order->type = $post['type'];
$order->save();
return redirect()->back()->with('success', trans('message.message_success_send'));
}
开发者ID:andriy-sa,项目名称:laravel,代码行数:16,代码来源:DefaultController.php
示例17: getSales
public function getSales()
{
$from = Input::get('from');
$to = Input::get('to');
$all_orders = Order::where(function ($q) use($from, $to) {
if ($from) {
$q->where('created_at', '>=', Carbon::parse($from));
}
if ($to) {
$q->where('created_at', '<=', Carbon::parse($to));
}
})->get();
$paid_orders = Order::where(function ($q) use($from, $to) {
$q->where('state', '1');
if ($from) {
$q->where('created_at', '>=', Carbon::parse($from));
}
if ($to) {
$q->where('created_at', '<=', Carbon::parse($to));
}
})->get();
$total_summ_paid_orders = 0;
foreach ($paid_orders as $order) {
$total_summ_paid_orders += $order->sum;
}
$period = ['from' => $from, 'to' => $to, 'text' => $this->period_text($from, $to)];
return view('admin.stat.sales', ['paid_orders' => $paid_orders, 'orders' => $all_orders, 'total_summ_paid_orders' => number_format($total_summ_paid_orders, 2, ',', ' '), 'period' => $period]);
}
开发者ID:venomir,项目名称:tc,代码行数:28,代码来源:StatisticController.php
示例18: edit
/**
* Edit a customer.
*
* @param string $id
*
* @return Response
*/
public function edit($id)
{
$customer = User::find($id);
$addresses = Address::where('customer_id', '=', $customer->id)->get();
$orders = Order::where('customer_id', '=', $customer->id)->get();
return view('admin/customers/edit', ['customer' => $customer, 'addresses' => $addresses, 'orders' => $orders]);
}
开发者ID:kudosagency,项目名称:kudos-php,代码行数:14,代码来源:CustomersController.php
示例19: getTodayVotessCountAttribute
public function getTodayVotessCountAttribute()
{
$order = Order::today();
if ($order == null) {
return '0';
}
return Vote::where('order_id', '=', $order->id)->where('place_id', '=', $this->id)->count();
}
开发者ID:codeforest,项目名称:nisam,代码行数:8,代码来源:Place.php
示例20: storeNewOrder
protected function storeNewOrder(array $data)
{
$id = Auth::user()->id_user;
$data['advPay'] = isset($data['advPay']) ? 1 : 0;
Log::info('User: ' . $id . ' submitted new order, destination: ' . $data['orderDestination'] . ', departure: ' . $data['dateFrom'] . ', arrival: ' . $data['dateFrom'] . 'advPay: ' . $data['advPay']);
// LOG
$order = Order::create(['destination' => $data['orderDestination'], 'date_departure' => $data['dateFrom'], 'date_arrival' => $data['dateTo'], 'adv_pay' => $data['advPay'], 'user_id_user' => $id]);
}
开发者ID:rexDeorum,项目名称:TrEx,代码行数:8,代码来源:UserController.php
注:本文中的app\models\Order类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论