添加订单报错
This commit is contained in:
parent
a36fe34eab
commit
c71ca560c8
|
|
@ -13,6 +13,7 @@ use think\Db;
|
||||||
use think\exception\PDOException;
|
use think\exception\PDOException;
|
||||||
use think\exception\ValidateException;
|
use think\exception\ValidateException;
|
||||||
use think\Model;
|
use think\Model;
|
||||||
|
use function Symfony\Component\Clock\now;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 订单列管理
|
* 订单列管理
|
||||||
|
|
@ -374,6 +375,53 @@ class Order extends Backend
|
||||||
$this->success($order['order_no']);
|
$this->success($order['order_no']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function addAbnormal($ids = null){
|
||||||
|
if (false === $this->request->isPost()) {
|
||||||
|
|
||||||
|
$abnormals = model('abnormal')->order('sort','desc')->select();
|
||||||
|
$abnormals_data = [];
|
||||||
|
foreach ($abnormals as $abnormal){
|
||||||
|
$abnormals_data [] = $abnormal->toArray();
|
||||||
|
}
|
||||||
|
$order = model('order')->get($ids);
|
||||||
|
return $this->fetch('abnormal',['row' => $order,'options'=>$abnormals_data]);
|
||||||
|
}
|
||||||
|
$params = $this->request->post('row/a');
|
||||||
|
if (empty($params)) {
|
||||||
|
$this->error(__('Parameter %s can not be empty', ''));
|
||||||
|
}
|
||||||
|
$params = $this->preExcludeFields($params);
|
||||||
|
|
||||||
|
|
||||||
|
$result = false;
|
||||||
|
Db::startTrans();
|
||||||
|
try {
|
||||||
|
$insert = [
|
||||||
|
'order_id' => $params['order_id'],
|
||||||
|
'status' => 0,
|
||||||
|
'abnormal_id' => $params['abnormal_id'],
|
||||||
|
'abnormal_title' => model('abnormal')->get($params['abnormal_id'])->title ?? '',
|
||||||
|
'detail' => $params['detail'],
|
||||||
|
'admin_id' => $this->auth->id,
|
||||||
|
'admin_user' => $this->auth->getUserInfo()['username'] ?? '',
|
||||||
|
'create_time' => now()->format('Y-m-d H:m:s'),
|
||||||
|
'update_time' => now()->format('Y-m-d H:m:s'),
|
||||||
|
];
|
||||||
|
|
||||||
|
$result = \model('order_abnormal')->insert($insert);
|
||||||
|
Db::commit();
|
||||||
|
} catch (ValidateException | PDOException | Exception $e) {
|
||||||
|
Db::rollback();
|
||||||
|
$this->error($e->getMessage());
|
||||||
|
}
|
||||||
|
if ($result === false) {
|
||||||
|
$this->error(__('No rows were inserted'));
|
||||||
|
}
|
||||||
|
$this->success();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private function filterAreaCodes(array $area_codes)
|
private function filterAreaCodes(array $area_codes)
|
||||||
{
|
{
|
||||||
// 提取所有两位区号
|
// 提取所有两位区号
|
||||||
|
|
|
||||||
41
application/admin/view/order/abnormal.html
Normal file
41
application/admin/view/order/abnormal.html
Normal file
|
|
@ -0,0 +1,41 @@
|
||||||
|
<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="{:url('order/addAbnormal')}">
|
||||||
|
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="control-label col-xs-12 col-sm-2">订单编号</label>
|
||||||
|
<div class="col-xs-12 col-sm-8">
|
||||||
|
<input id="c-order_id"
|
||||||
|
disabled
|
||||||
|
class="form-control" type="text" value="{$row->order_no}">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<input type="hidden" name="row[order_id]" value="{$row->id}" >
|
||||||
|
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="control-label col-xs-12 col-sm-2">异常类型:</label>
|
||||||
|
<div class="col-xs-12 col-sm-8">
|
||||||
|
|
||||||
|
<select id="c-coupon" data-live-search="true" title="请选择" data-rule="required" name="row[abnormal_id]" class="form-control selectpicker">
|
||||||
|
{foreach $options as $item}
|
||||||
|
<option value="{$item['id']}">{$item['title']}</option>
|
||||||
|
{/foreach}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="control-label col-xs-12 col-sm-2">异常详情:</label>
|
||||||
|
<div class="col-xs-12 col-sm-8">
|
||||||
|
<textarea id="c-detail" data-rule="required" class="form-control" rows="5" name="row[detail]" cols="50"></textarea>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group layer-footer">
|
||||||
|
<label class="control-label col-xs-12 col-sm-2"></label>
|
||||||
|
<div class="col-xs-12 col-sm-8">
|
||||||
|
<button type="submit" class="btn btn-primary btn-embossed">{:__('OK')}</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
|
@ -18,6 +18,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form','cascader'], function
|
||||||
multi_url: 'order/multi',
|
multi_url: 'order/multi',
|
||||||
import_url: 'order/import',
|
import_url: 'order/import',
|
||||||
push_url: 'order/status',
|
push_url: 'order/status',
|
||||||
|
addabnormal: 'order/addAbnormal',
|
||||||
table: 'order',
|
table: 'order',
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -193,6 +194,16 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form','cascader'], function
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name:"error",
|
||||||
|
text:"订单报错",
|
||||||
|
title:"订单报错",
|
||||||
|
extend: 'data-toggle="tooltip" data-container="body"',
|
||||||
|
classname: 'btn btn-xs btn-warning btn-dialog',
|
||||||
|
icon: 'fa fa-bolt',
|
||||||
|
url: 'order/addAbnormal',
|
||||||
|
refresh:true,
|
||||||
|
},
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
@ -285,6 +296,14 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form','cascader'], function
|
||||||
copy: function () {
|
copy: function () {
|
||||||
Controller.api.bindevent();
|
Controller.api.bindevent();
|
||||||
},
|
},
|
||||||
|
addabnormal: function () {
|
||||||
|
console.log('abnormal');
|
||||||
|
Form.api.bindevent($("#add-form"),null,null,function (data) {
|
||||||
|
Form.api.submit($("#add-form"));
|
||||||
|
// console.log(data);
|
||||||
|
// return false;
|
||||||
|
});
|
||||||
|
},
|
||||||
api: {
|
api: {
|
||||||
bindevent: function () {
|
bindevent: function () {
|
||||||
Form.api.bindevent($("form[role=form]"));
|
Form.api.bindevent($("form[role=form]"));
|
||||||
|
|
@ -292,10 +311,6 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form','cascader'], function
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
function parseAndFill() {
|
|
||||||
// 获取左侧输入框的内容
|
|
||||||
}
|
|
||||||
|
|
||||||
return Controller;
|
return Controller;
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user