本文整理汇总了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);
}