本文整理汇总了PHP中app\models\Order类的典型用法代码示例。如果您正苦于以下问题:PHP Order类的具体用法?PHP Order怎么用?PHP Order使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Order类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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']);
}
}
示例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;
}
示例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]);
}
示例4: create_cart
private function create_cart()
{
$order = new Order();
$order->user_id = $this->id;
$order->save();
$this->order_id = $order->id;
$this->save();
}
示例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;
}
示例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];
}
示例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'));
}
示例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();
}
示例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'));
}
示例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', 'Ошибка');
}
示例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;
}
示例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';
}
示例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}");
}
}
示例14: getOrders
public function getOrders()
{
//with用法,先不用all查询
$orders = $this->hasMany(Order::className(), array('cid' => 'id'))->asArray();
//->all();
return $orders;
}
示例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;
}