```
{include file="../templates/overall/header.html" /}
<div class="layui-container">
<div class="layui-tab-content"></div>
<blockquote class="layui-elem-quote">订单创建后请在6小时内付款,否则订单将会失效。</blockquote>
<form class="layui-form" method="post">
<div class="layui-card">
<!-- 分区开始 -->
<div class="layui-card">
<div class="layui-card-header">创建订单</div>
<div class="layui-card-body">
<!-- 表单开始 -->
<div class="layui-form-item">
<label class="layui-form-label">产品名称</label>
<div class="layui-form-mid layui-word-aux">
<a style="color:#999;" href="/phpwczyxx/index/yjz_pcsj/" target="_blank">{$goods['title']}</a>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">产品单价</label>
<div class="layui-form-mid layui-word-aux">
<span style="color:#ff5722;">{$goods['price']} 元 / 年</span>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">选择机房</label>
<div class="layui-input-block">
<input type="radio" title="国内(需备案)" name="jifang" value="1" checked >
<input type="radio" title="海外(免备案)" name="jifang" value="2">
</div>
<div class="layui-form-mid layui-word-aux">如果业务不着急上线建议选择国内机房,网站备案一般只需要3~7个工作日。</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">购买时长</label>
<div class="layui-input-block">
<input type="radio" title="1年" name="number" value="1" checked >
<input type="radio" title="2年" name="number" value="2">
<input type="radio" title="3年" name="number" value="3">
<input type="radio" title="5年" name="number" value="5">
</div>
<div class="layui-form-mid layui-word-aux">优惠说明:买2年9折,3年8折,5年7折。</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">附加信息</label>
<div class="layui-input-block">
<input type="text" name="coupon_id" placeholder="可留空" autocomplete="off" class="layui-input">
<div class="layui-form-mid layui-word-aux">若有可填写,否则请忽略。</div>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">备注/留言</label>
<div class="layui-input-block">
<textarea class="layui-textarea" rows="3" name="addition"></textarea>
</div>
</div>
<!-- 表单结束 -->
</div>
</div>
<!-- 分区结束 -->
</div>
<div class="layui-form-item layer-footer">
<div class="layui-input-block">
<button class="layui-btn" lay-submit lay-filter="*">创建订单</button>
</div>
</div>
</form>
</div>
{include file="../templates/overall/footer_menu.html" /}
```
*****
```
<?php
$sid = $_G['sid'];
if ($sid){
$goods = Db::name('goods')->where(['id' => $sid])->find();
}
if ($this->request->isPost()) {
// 自动生成订单号
include_once ROOT_PATH."application/order/include/order_id.php";
$params_data = [
'jifang' => $_G['jifang'], //所选机房
];
$params = serialize($params_data); //序列化数组
$adddata = [
'order_id' => $order_id, //订单号
'uid' => $_W['mc_uid'], //创建人UID
'module' => $_W['module'], //所属模块
'title' => $goods['title'], //产品名称
'surl' => "/phpwczyxx/index/yjz_pcsj/", //产品URL
'univalence' => $goods['price'], //产品单价(元)
'number' => $_G['number'], //订单数量
'coupon_id' => $_G['coupon_id'], //优惠码
'params' => $params, //附加参数
'addition' => $_G['addition'], //用户备注
'create_time' => time(), //创建时间
];
$sqlczjg = Db::name('order')->strict(false)->insert($adddata);
if ($sqlczjg) {
$this->redirect("/abt/index/pay_order/?order_id={$order_id}");
}else{
$this -> error('创建失败');
}
}
$seo = [
'title' => "创建订单 - {$_W['q_set']['web_site_xtname']}", //SEO标题
'keyword' => "", //SEO关键词
'description' => "", //SEO描述
];
// 模版赋值
$this->assign([
'_W' => $_W, //全局变量
'_G' => $_G, //URL地址中的参数
'SEO' => $seo, //SEO标题
'goods' => $goods, // 产品信息
]);
$htmlmbmc = "{$_W['ismobile']}/{$_W['controller']}/{$_W['action']}"; //模版目录
// 调试
//Print_r("ID:{$_G['sid']}"); // 打印变量
```