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


PHP Model_Order::generateSn方法代碼示例

本文整理匯總了PHP中Model_Order::generateSn方法的典型用法代碼示例。如果您正苦於以下問題:PHP Model_Order::generateSn方法的具體用法?PHP Model_Order::generateSn怎麽用?PHP Model_Order::generateSn使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Model_Order的用法示例。


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

示例1: bookingAction

    public function bookingAction()
    {
        $this->view->activeMenu = 'booking';
        $this->view->vehicleTypes = (new Model_VehicleType())->fetchPagedList(1, 999999)['rows'];
        if (!$this->_request->isPost()) {
            return;
        }
        $arp = new AjaxResponse();
        $arp->setStatus(AjaxResponse::STATUS_FAILED);
        $availableParams = array('forwho', 'city', 'contact-name', 'contact-email', 'contact-phone', 'passenger-names', 'passenger-phone', 'passenger-num', 'when', 'pickup-address', 'dropoff-address', 'vehicle', 'payment-method', 'notes');
        $via = $this->_getParam('via-address', array());
        $viaToSave = array();
        if (is_array($via)) {
            foreach ($via as $k => $v) {
                if (!empty(trim($v))) {
                    $viaToSave[] = trim($v);
                }
            }
        }
        $via = json_encode($viaToSave);
        $sn = Model_Order::generateSn();
        $order = new Model_Order();
        $order->set('sn', $sn);
        $order->set('user_id', $this->user->get('id'));
        foreach ($availableParams as $paramName) {
            $value = trim($this->getParam($paramName, ''));
            $colName = str_replace('-', '_', $paramName);
            $order->set($colName, $value);
        }
        $order->set('via', $via);
        $order->set('created_time', time());
        $order->save();
        //Mail it.
        $time = date('Y-m-d H:i', $order->get('created_time'));
        $mailBody = <<<EOT
<!DOCTYPE html>
<html lang="en">
<head>
\t<meta charset="UTF-8">
\t<title>新訂單</title>
</head>
<body>
<style>
dt {
\tfont-weight:bold;
\tfont-size:12px;
}
dd {
\tfont-size:14px;
}
</style>
<h2>新訂單:{$order->get('sn')}</h2>
<dl>
<dt>下單時間</dt><dd>{$time}</dd>
<dt>下單人</dt><dd>{$order->get('contact_name')}</dd>
<dt>乘客</dt><dd>{$order->get('passenger_names')}</dd>
<dt>時間</dt><dd>{$order->get('when')}</dd>
<dt>城市</dt><dd>{$order->get('city')}</dd>
<dt>起始地</dt><dd>{$order->get('pickup_address')}</dd>
<dt>終點</dt><dd>{$order->get('dropoff_address')}</dd>
</dl>
<p><a href="http://www.carrentalsbeijing.com/private-car-management/order-detail?sn={$order->get('sn')}" target="_blank">查看訂單詳情</a></p>
✉
</body>
</html>
EOT;
        $mailSubject = "新訂單 {$order->get('passenger_names')}從{$order->get('pickup_address')}到{$order->get('dropoff_address')}";
        $mailRecipients = Application::getConfig()['order_mail_recipients'];
        $mailQueue = new Model_MailQueue();
        $mailQueue->set('to', $mailRecipients);
        $mailQueue->set('subject', $mailSubject);
        $mailQueue->set('message', $mailBody);
        $mailQueue->set('created_time', time());
        $mailQueue->save();
        $arp->setStatus(AjaxResponse::STATUS_OK);
        $arp->setMessage($sn);
        $this->json($arp);
    }
開發者ID:RobertCar,項目名稱:RobertCarrential,代碼行數:78,代碼來源:PrivateCarController.php


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