处理错误
This commit is contained in:
parent
abdfa0bc28
commit
fe115b963e
|
|
@ -34,11 +34,11 @@ class Test extends Command
|
||||||
|
|
||||||
protected function execute(Input $input, Output $output)
|
protected function execute(Input $input, Output $output)
|
||||||
{
|
{
|
||||||
|
dd(config('system_id'));
|
||||||
|
|
||||||
$order = Order::where('id',140)->find();
|
$order = Order::where('id',140)->find();
|
||||||
AutoDispatchLogic::autoDispatch($order);
|
AutoDispatchLogic::autoDispatch($order);
|
||||||
dd(2);
|
|
||||||
|
|
||||||
$hookParams = [
|
$hookParams = [
|
||||||
'dispatch' => (new OrderDispatch())->where('id', 144)->find(),
|
'dispatch' => (new OrderDispatch())->where('id', 144)->find(),
|
||||||
|
|
|
||||||
|
|
@ -29,8 +29,8 @@ class AutoDispatchLogic
|
||||||
}
|
}
|
||||||
//$admin = Admin::where('id',$order->admin_id)->find();
|
//$admin = Admin::where('id',$order->admin_id)->find();
|
||||||
$insert = [
|
$insert = [
|
||||||
'admin_id' => 1,
|
'admin_id' => config('system_id'),
|
||||||
'admin_user' => '系统',
|
'admin_user' => config('system_name'),
|
||||||
'order_id' => $order->id,
|
'order_id' => $order->id,
|
||||||
'type' => 2,
|
'type' => 2,
|
||||||
'worker_id' => $worker_id,
|
'worker_id' => $worker_id,
|
||||||
|
|
@ -48,6 +48,7 @@ class AutoDispatchLogic
|
||||||
$order->dispatch_admin_id = 1;
|
$order->dispatch_admin_id = 1;
|
||||||
$order->dispatch_admin_user = '系统';
|
$order->dispatch_admin_user = '系统';
|
||||||
$order->worker_id = $worker_id;
|
$order->worker_id = $worker_id;
|
||||||
|
$order->dispatch_type = 2;
|
||||||
$order->save();
|
$order->save();
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -120,7 +120,7 @@ class Order extends Backend
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
$this->request->filter(['strip_tags', 'trim']);
|
$this->request->filter(['strip_tags', 'trim']);
|
||||||
$group = \model('auth_group_access')->where('uid',$this->auth->id)->find()->group_id ?? 0;
|
$group = \model('auth_group_access')->where('uid', $this->auth->id)->find()->group_id ?? 0;
|
||||||
$user = \model('admin')->find($this->auth->id);
|
$user = \model('admin')->find($this->auth->id);
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -132,7 +132,7 @@ class Order extends Backend
|
||||||
return $this->selectpage();
|
return $this->selectpage();
|
||||||
}
|
}
|
||||||
|
|
||||||
$type = request()->get('type',1);
|
$type = request()->get('type', 1);
|
||||||
|
|
||||||
[$where, $sort, $order, $offset, $limit] = $this->buildparams();
|
[$where, $sort, $order, $offset, $limit] = $this->buildparams();
|
||||||
$build = $this->model
|
$build = $this->model
|
||||||
|
|
@ -148,25 +148,25 @@ class Order extends Backend
|
||||||
$filter = (array)json_decode(input()['filter'] ?? '', true);
|
$filter = (array)json_decode(input()['filter'] ?? '', true);
|
||||||
$admin_filter = $filter['user.nickname'] ?? false;
|
$admin_filter = $filter['user.nickname'] ?? false;
|
||||||
|
|
||||||
if ($admin_filter){
|
if ($admin_filter) {
|
||||||
$admin_ids = Admin::where('nickname','like','%'.$admin_filter.'%')->column('id');
|
$admin_ids = Admin::where('nickname', 'like', '%' . $admin_filter . '%')->column('id');
|
||||||
$build->whereIn('admin_id',$admin_ids);
|
$build->whereIn('admin_id', $admin_ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($type == 1){
|
if ($type == 1) {
|
||||||
$build->where('status','>=', 0);
|
$build->where('status', '>=', 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($type == 2){
|
if ($type == 2) {
|
||||||
$build->where('status','<', 0);
|
$build->where('status', '<', 0);
|
||||||
}
|
}
|
||||||
if ($group == 2 || $group == 6) {
|
if ($group == 2 || $group == 6) {
|
||||||
// 生成 SQL 语句
|
// 生成 SQL 语句
|
||||||
$ids = $user->area_ids??'';
|
$ids = $user->area_ids ?? '';
|
||||||
if ($ids == ''){
|
if ($ids == '') {
|
||||||
return ['total' => 0, 'rows' => []];
|
return ['total' => 0, 'rows' => []];
|
||||||
}
|
}
|
||||||
$ids = explode(',',$ids);
|
$ids = explode(',', $ids);
|
||||||
$area_codes = $this->filterAreaCodes($ids);
|
$area_codes = $this->filterAreaCodes($ids);
|
||||||
|
|
||||||
$build->where(function ($q) use ($area_codes) {
|
$build->where(function ($q) use ($area_codes) {
|
||||||
|
|
@ -185,15 +185,15 @@ class Order extends Backend
|
||||||
$q->field('id,area_code,merge_name');
|
$q->field('id,area_code,merge_name');
|
||||||
}, 'phone' => function ($q) {
|
}, 'phone' => function ($q) {
|
||||||
$q->field('id,model');
|
$q->field('id,model');
|
||||||
},'coupon' => function ($q) {
|
}, 'coupon' => function ($q) {
|
||||||
$q->field('id,code,description');
|
$q->field('id,code,description');
|
||||||
}])
|
}])
|
||||||
->order($sort, $order)
|
->order($sort, $order)
|
||||||
->paginate($limit);
|
->paginate($limit);
|
||||||
|
|
||||||
foreach ($list as &$item){
|
foreach ($list as &$item) {
|
||||||
$item->aftersale_btn = false;
|
$item->aftersale_btn = false;
|
||||||
if($item->aftersale_id==0 && $this->auth->check('aftersales/aftersale/add') && $item->status == \app\admin\model\Order::STATUS_FINISHED){ //$item->status == \app\admin\model\Order::STATUS_FINISHED &&
|
if ($item->aftersale_id == 0 && $this->auth->check('aftersales/aftersale/add') && $item->status == \app\admin\model\Order::STATUS_FINISHED) { //$item->status == \app\admin\model\Order::STATUS_FINISHED &&
|
||||||
$item->aftersale_btn = true;
|
$item->aftersale_btn = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -248,7 +248,7 @@ class Order extends Backend
|
||||||
$result = $this->model->allowField(true)->save($params);
|
$result = $this->model->allowField(true)->save($params);
|
||||||
|
|
||||||
if ($params['dispatch_type'] == 2) {
|
if ($params['dispatch_type'] == 2) {
|
||||||
AutoDispatchLogic::autoDispatch($this->model,$this->auth);
|
AutoDispatchLogic::autoDispatch($this->model, $this->auth);
|
||||||
}
|
}
|
||||||
Db::commit();
|
Db::commit();
|
||||||
} catch (ValidateException | PDOException | Exception $e) {
|
} catch (ValidateException | PDOException | Exception $e) {
|
||||||
|
|
@ -361,9 +361,6 @@ class Order extends Backend
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function smart()
|
public function smart()
|
||||||
{
|
{
|
||||||
$this->success(data: Address::smart(request()->get('str')));
|
$this->success(data: Address::smart(request()->get('str')));
|
||||||
|
|
@ -466,12 +463,13 @@ class Order extends Backend
|
||||||
$result = false;
|
$result = false;
|
||||||
Db::startTrans();
|
Db::startTrans();
|
||||||
try {
|
try {
|
||||||
|
$abnormal_title = model('abnormal')->get($params['abnormal_id'])->title ?? '';
|
||||||
$insert = [
|
$insert = [
|
||||||
'order_id' => $params['order_id'],
|
'order_id' => $params['order_id'],
|
||||||
'status' => 0,
|
'status' => 0,
|
||||||
'level' => $params['level'],
|
'level' => $params['level'],
|
||||||
'abnormal_id' => $params['abnormal_id'],
|
'abnormal_id' => $params['abnormal_id'],
|
||||||
'abnormal_title' => model('abnormal')->get($params['abnormal_id'])->title ?? '',
|
'abnormal_title' => $abnormal_title,
|
||||||
'detail' => $params['detail'],
|
'detail' => $params['detail'],
|
||||||
'admin_id' => $this->auth->id,
|
'admin_id' => $this->auth->id,
|
||||||
'admin_user' => $this->auth->getUserInfo()['nickname'] ?? '',
|
'admin_user' => $this->auth->getUserInfo()['nickname'] ?? '',
|
||||||
|
|
@ -479,16 +477,59 @@ class Order extends Backend
|
||||||
'update_time' => now()->format('Y-m-d H:m:s'),
|
'update_time' => now()->format('Y-m-d H:m:s'),
|
||||||
];
|
];
|
||||||
|
|
||||||
Message::create([
|
|
||||||
'to_id' => $order->admin_id,
|
if ($params['abnormal_id'] == 2 || $params['abnormal_id'] == 3) {
|
||||||
'type' => 1,
|
|
||||||
'title' => '订单报错通知',
|
$order->status = \app\admin\model\Order::STATUS_CANCEL;
|
||||||
'content' => '【订单报错通知】您有一条订单号为' . $order->order_no . '的订单订单信息录入错误,请前往报错订单界面进行查看,并立即处理!'
|
$order->save();
|
||||||
]);
|
if (!empty($order->dispatch->id)) {
|
||||||
|
$orderLogic = new OrderLogic();
|
||||||
|
$orderLogic->cancelOrderDispatch($order->dispatch, $this->auth, '订单被取消', false);
|
||||||
|
//日志
|
||||||
|
$hookparams['order'] = $order;
|
||||||
|
$hookparams['role'] = 1;
|
||||||
|
$hookparams['auth'] = $this->auth;
|
||||||
|
$hookparams['remark'] = $params['remark'] ?? '';
|
||||||
|
Hook::listen('order_change', $hookparams);
|
||||||
|
}
|
||||||
|
|
||||||
|
$insert['deal_type'] = 2;
|
||||||
|
$insert['handle_detail'] = '系统取消订单';
|
||||||
|
$insert['handle_admin_user'] = config('system_name');
|
||||||
|
$insert['handle_admin_id'] = config('system_id');
|
||||||
|
$insert['handle_time'] = now()->format('Y-m-d H:i:s');
|
||||||
|
$insert['status'] = 1;
|
||||||
|
|
||||||
|
} else if ($params['abnormal_id'] == 5 || $params['abnormal_id'] == 15) {
|
||||||
|
|
||||||
|
$order->status = \app\admin\model\Order::STATUS_DISPATCHING;
|
||||||
|
$order->save();
|
||||||
|
if (!empty($order->dispatch->id)) {
|
||||||
|
$OrderLogic = new OrderLogic();
|
||||||
|
$OrderLogic->noWorkerCanGetIt($order->dispatch, '系统取消' . $abnormal_title);
|
||||||
|
AutoDispatchLogic::autoDispatch($order);
|
||||||
|
}
|
||||||
|
|
||||||
|
$insert['deal_type'] = 3;
|
||||||
|
$insert['handle_detail'] = '系统重新派单';
|
||||||
|
$insert['handle_admin_user'] = config('system_name');
|
||||||
|
$insert['handle_admin_id'] = config('system_id');
|
||||||
|
$insert['handle_time'] = now()->format('Y-m-d H:i:s');
|
||||||
|
$insert['status'] = 1;
|
||||||
|
} else {
|
||||||
|
Message::create([
|
||||||
|
'to_id' => $order->admin_id,
|
||||||
|
'type' => 1,
|
||||||
|
'title' => '订单报错通知',
|
||||||
|
'content' => '【订单报错通知】您有一条订单号为' . $order->order_no . '的订单订单信息录入错误,请前往报错订单界面进行查看,并立即处理!'
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$result = \model('order_abnormal')->insert($insert);
|
$result = \model('order_abnormal')->insert($insert);
|
||||||
Db::commit();
|
Db::commit();
|
||||||
} catch (ValidateException | PDOException | Exception $e) {
|
} catch (ValidateException | PDOException | Exception $e) {
|
||||||
|
throw $e;
|
||||||
Db::rollback();
|
Db::rollback();
|
||||||
$this->error($e->getMessage());
|
$this->error($e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
@ -536,11 +577,11 @@ class Order extends Backend
|
||||||
|
|
||||||
if (!empty($order->dispatch->id)) {
|
if (!empty($order->dispatch->id)) {
|
||||||
$orderLogic = new OrderLogic();
|
$orderLogic = new OrderLogic();
|
||||||
$orderLogic->cancelOrderDispatch($order->dispatch, $this->auth, '订单被取消', false);
|
$orderLogic->cancelOrderDispatch($order->dispatch, null, '订单被取消', false);
|
||||||
//日志
|
//日志
|
||||||
$hookparams['order'] = $order;
|
$hookparams['order'] = $order;
|
||||||
$hookparams['role'] = 1;
|
$hookparams['role'] = 1;
|
||||||
$hookparams['auth'] = $this->auth;
|
$hookparams['auth'] = null;
|
||||||
$hookparams['remark'] = $params['remark'] ?? '';
|
$hookparams['remark'] = $params['remark'] ?? '';
|
||||||
Hook::listen('order_change', $hookparams);
|
Hook::listen('order_change', $hookparams);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
namespace app\admin\controller\orders;
|
namespace app\admin\controller\orders;
|
||||||
|
|
||||||
|
use app\admin\controller\AutoDispatchLogic;
|
||||||
use app\admin\model\Order;
|
use app\admin\model\Order;
|
||||||
use app\common\controller\Backend;
|
use app\common\controller\Backend;
|
||||||
use app\common\Logic\OrderLogic;
|
use app\common\Logic\OrderLogic;
|
||||||
|
|
@ -130,10 +131,7 @@ class Abnormal extends Backend
|
||||||
|
|
||||||
|
|
||||||
if ($params['abnormal_id'] == 2 || $params['abnormal_id'] == 3){
|
if ($params['abnormal_id'] == 2 || $params['abnormal_id'] == 3){
|
||||||
|
|
||||||
$order->status = Order::STATUS_CANCEL;
|
$order->status = Order::STATUS_CANCEL;
|
||||||
$order->abnormal_id = $params['abnormal_id'];
|
|
||||||
$order->abnormal_title = $abnormal_title;
|
|
||||||
$order->save();
|
$order->save();
|
||||||
if (!empty($order->dispatch->id)) {
|
if (!empty($order->dispatch->id)) {
|
||||||
$orderLogic = new OrderLogic();
|
$orderLogic = new OrderLogic();
|
||||||
|
|
@ -146,8 +144,27 @@ class Abnormal extends Backend
|
||||||
Hook::listen('order_change', $hookparams);
|
Hook::listen('order_change', $hookparams);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$params['deal_type'] = 2;
|
||||||
|
$params['handle_detail'] = '系统取消订单';
|
||||||
|
$params['handle_admin_user'] = config('system_name');
|
||||||
|
$params['handle_admin_id'] = config('system_id');
|
||||||
|
$params['status'] = 1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($params['abnormal_id'] == 5 || $params['abnormal_id'] == 15){
|
||||||
|
if (!empty($order->dispatch->id)) {
|
||||||
|
$OrderLogic = new OrderLogic();
|
||||||
|
$OrderLogic->noWorkerCanGetIt($order->dispatch,'系统取消'.$abnormal_title);
|
||||||
|
AutoDispatchLogic::autoDispatch($order);
|
||||||
|
}
|
||||||
|
|
||||||
|
$params['deal_type'] =3;
|
||||||
|
$params['handle_detail'] = '系统重新派单';
|
||||||
|
$params['handle_admin_user'] = config('system_name');
|
||||||
|
$params['handle_admin_id'] = config('system_id');
|
||||||
|
$params['status'] = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$result = $this->model->allowField(true)->save($params);
|
$result = $this->model->allowField(true)->save($params);
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@
|
||||||
|
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="control-label col-xs-12 col-sm-2">{:__('Source')}:</label>
|
<label class="control-label col-xs-12 col-sm-2">处理方式:</label>
|
||||||
<div class="col-xs-12 col-sm-8">
|
<div class="col-xs-12 col-sm-8">
|
||||||
<select id="c-source" data-live-search="true" title="请选择" data-rule="required" name="row[source]" class="form-control show-tick">
|
<select id="c-source" data-live-search="true" title="请选择" data-rule="required" name="row[source]" class="form-control show-tick">
|
||||||
<option value="0"> 无</option>
|
<option value="0"> 无</option>
|
||||||
|
|
|
||||||
|
|
@ -92,11 +92,13 @@ class OrderLogic
|
||||||
* 师傅超时未接单的处理逻辑
|
* 师傅超时未接单的处理逻辑
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function noWorkerCanGetIt(OrderDispatch $dispatch)
|
public function noWorkerCanGetIt(OrderDispatch $dispatch,$remark = null)
|
||||||
{//超过三次,直接取消
|
{//超过三次,直接取消
|
||||||
Db::startTrans();
|
Db::startTrans();
|
||||||
try {
|
try {
|
||||||
$remark = '师傅超时未接单,任务取消';
|
if (is_null($remark)){
|
||||||
|
$remark = '师傅超时未接单,任务取消';
|
||||||
|
}
|
||||||
$this->cancelOrderDispatch($dispatch,null,$remark);
|
$this->cancelOrderDispatch($dispatch,null,$remark);
|
||||||
Db::commit();
|
Db::commit();
|
||||||
}catch (Exception $exception){
|
}catch (Exception $exception){
|
||||||
|
|
@ -121,7 +123,7 @@ class OrderLogic
|
||||||
if(!empty($auth)){
|
if(!empty($auth)){
|
||||||
$dispatch->admin_user = '管理员:'.$auth->nickname;
|
$dispatch->admin_user = '管理员:'.$auth->nickname;
|
||||||
}else{
|
}else{
|
||||||
$dispatch->admin_user = 'sys';
|
$dispatch->admin_user = config('system_name');
|
||||||
}
|
}
|
||||||
$hookParams = [
|
$hookParams = [
|
||||||
'dispatch' => $dispatch,
|
'dispatch' => $dispatch,
|
||||||
|
|
|
||||||
|
|
@ -324,5 +324,7 @@ return [
|
||||||
'mini_program' => [
|
'mini_program' => [
|
||||||
'app_id' => Env::get('mini_program.app_id', ''),
|
'app_id' => Env::get('mini_program.app_id', ''),
|
||||||
'secret' => Env::get('mini_program.secret', ''),
|
'secret' => Env::get('mini_program.secret', ''),
|
||||||
]
|
],
|
||||||
|
'system_id' => 100,
|
||||||
|
'system_name' => '系统',
|
||||||
];
|
];
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,9 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
||||||
{field: 'abnormal_id', title: __('Abnormal_id'),visible:false},
|
{field: 'abnormal_id', title: __('Abnormal_id'),visible:false},
|
||||||
{field: 'abnormal_title', title: __('Abnormal_title'), operate: false},
|
{field: 'abnormal_title', title: __('Abnormal_title'), operate: false},
|
||||||
{field: 'status', title: __('Status'), searchList: {"0":__('Status 0'),"1":__('Status 1'),"-1":__('Status -1')}, formatter: Table.api.formatter.status},
|
{field: 'status', title: __('Status'), searchList: {"0":__('Status 0'),"1":__('Status 1'),"-1":__('Status -1')}, formatter: Table.api.formatter.status},
|
||||||
|
{field: 'deal_type', title: '处理方式', operate: false,
|
||||||
|
searchList: {"1": '修改订单', "2": '取消订单', '3': '重新派单','0':'无'},
|
||||||
|
formatter: Table.api.formatter.label,},
|
||||||
//{field: 'order.customer', title: __('Order.customer'), operate: 'LIKE'},
|
//{field: 'order.customer', title: __('Order.customer'), operate: 'LIKE'},
|
||||||
//{field: 'order.tel', title: __('Order.tel'), operate: 'LIKE'},
|
//{field: 'order.tel', title: __('Order.tel'), operate: 'LIKE'},
|
||||||
// {field: 'order.worker_name', title: __('Order.worker_name'), operate: 'LIKE'},
|
// {field: 'order.worker_name', title: __('Order.worker_name'), operate: 'LIKE'},
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user