Accept Merge Request #189: (feature/hant -> develop)
Merge Request: 修复问题 Created By: @todayswind Accepted By: @todayswind URL: https://g-bcrc3009.coding.net/p/allocatr/d/allocatr/git/merge/189?initial=true
This commit is contained in:
commit
23a2b60c9f
|
|
@ -28,12 +28,11 @@ class AutoDispatchLogic
|
||||||
if (!$worker_id) {
|
if (!$worker_id) {
|
||||||
$area_id = substr($order->area_id, 0, 4);
|
$area_id = substr($order->area_id, 0, 4);
|
||||||
$res_worker = Admin::where('area_ids', 'like', '%' . $area_id . '%')
|
$res_worker = Admin::where('area_ids', 'like', '%' . $area_id . '%')
|
||||||
|
|
||||||
->column('id');
|
->column('id');
|
||||||
|
|
||||||
$dispatch_admin = AuthGroupAccess::where('group_id', 6)
|
$dispatch_admin = AuthGroupAccess::where('group_id', 6)
|
||||||
->column('uid');
|
->column('uid');
|
||||||
$res_worker = array_values(array_diff($res_worker,$dispatch_admin));
|
$res_worker = array_values(array_intersect($res_worker,$dispatch_admin));
|
||||||
$res_admin = AuthGroupAccess::whereIn('group_id', [1,11])
|
$res_admin = AuthGroupAccess::whereIn('group_id', [1,11])
|
||||||
->column('uid');
|
->column('uid');
|
||||||
$res = array_values(array_unique(array_merge($res_worker,$res_admin)));
|
$res = array_values(array_unique(array_merge($res_worker,$res_admin)));
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ namespace app\admin\controller;
|
||||||
use app\admin\addresmart\Address;
|
use app\admin\addresmart\Address;
|
||||||
use app\admin\controller\orders\DispatchLogic;
|
use app\admin\controller\orders\DispatchLogic;
|
||||||
use app\admin\model\Admin;
|
use app\admin\model\Admin;
|
||||||
|
use app\admin\model\AuthGroupAccess;
|
||||||
use app\admin\model\Item;
|
use app\admin\model\Item;
|
||||||
use app\admin\model\Message;
|
use app\admin\model\Message;
|
||||||
use app\admin\model\order\Invoice;
|
use app\admin\model\order\Invoice;
|
||||||
|
|
@ -156,8 +157,6 @@ class Order extends Backend
|
||||||
return $this->selectpage();
|
return $this->selectpage();
|
||||||
}
|
}
|
||||||
|
|
||||||
$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
|
||||||
->field(['id', 'order_no', 'admin_id', 'customer', 'tel', 'status', 'area_id', 'address',
|
->field(['id', 'order_no', 'admin_id', 'customer', 'tel', 'status', 'area_id', 'address',
|
||||||
|
|
@ -203,15 +202,6 @@ class Order extends Backend
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($type == 1) {
|
|
||||||
$build->where('status', '>=', 0);
|
|
||||||
} elseif ($type == 2) {
|
|
||||||
$build->where('status', '<', 0);
|
|
||||||
} elseif ($type == 3) {
|
|
||||||
$build->where('status', '>=', \app\admin\model\Order::STATUS_DISPATCHING)
|
|
||||||
->where('create_time', '<=', (new Carbon())->subMinutes(20)
|
|
||||||
->format('Y-m-d H:i:s'));
|
|
||||||
}
|
|
||||||
if ($group == 2 ) {
|
if ($group == 2 ) {
|
||||||
$build->where('admin_id',$user->id);
|
$build->where('admin_id',$user->id);
|
||||||
}elseif ($group == 6){
|
}elseif ($group == 6){
|
||||||
|
|
@ -564,8 +554,14 @@ class Order extends Backend
|
||||||
|
|
||||||
$res = Admin::where('area_ids', 'like', '%' . $area_id . '%')
|
$res = Admin::where('area_ids', 'like', '%' . $area_id . '%')
|
||||||
->column('id');
|
->column('id');
|
||||||
$message = $params['detail'] ?? '';
|
|
||||||
|
|
||||||
|
$dispatch_admin = AuthGroupAccess::where('group_id', 6)
|
||||||
|
->column('uid');
|
||||||
|
$res = array_values(array_intersect($res,$dispatch_admin));
|
||||||
|
|
||||||
|
$message = $params['detail'] ?? '';
|
||||||
|
$abnormals = model('abnormal')->where('type', 3)
|
||||||
|
->where('id',$params['abnormal_id'])->find();
|
||||||
|
|
||||||
$insert = [];
|
$insert = [];
|
||||||
foreach ($res as $re) {
|
foreach ($res as $re) {
|
||||||
|
|
@ -573,7 +569,7 @@ class Order extends Backend
|
||||||
'to_id' => $re,
|
'to_id' => $re,
|
||||||
'type' => 1,
|
'type' => 1,
|
||||||
'title' => '订单内容变更',
|
'title' => '订单内容变更',
|
||||||
'content' => '【订单内容变更】您有一条订单信息被修改,修改内容为:【' . $message . '】,请注意查收。'
|
'content' => '【订单内容变更】您有一条订单'.$order->order_no.'信息被修改,异常类型【'.$abnormals->title.'】,备注:【' . $message . '】,请注意查收。'
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
$build = new Message();
|
$build = new Message();
|
||||||
|
|
|
||||||
|
|
@ -38,9 +38,12 @@ ORDER BY distance;",[$order->lng,$order->lat]);
|
||||||
|
|
||||||
$worker_ids = array_column($worker_info,'id');
|
$worker_ids = array_column($worker_info,'id');
|
||||||
|
|
||||||
|
$items = model('item')->getAll();
|
||||||
|
$ids = $this->getParentIdsFromArray($order->item_id,$items);
|
||||||
|
|
||||||
|
|
||||||
$worker_items_ids = (new WorkerItem())
|
$worker_items_ids = (new WorkerItem())
|
||||||
->where('item_id', $order->item_id)
|
->whereIn('item_id', $ids)
|
||||||
->whereIn('worker_id', $worker_ids)
|
->whereIn('worker_id', $worker_ids)
|
||||||
->column('worker_id');
|
->column('worker_id');
|
||||||
|
|
||||||
|
|
@ -312,4 +315,19 @@ ORDER BY distance;",[$order->lng,$order->lat]);
|
||||||
}
|
}
|
||||||
return $val;
|
return $val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getParentIdsFromArray($id, $items) {
|
||||||
|
$map = [];
|
||||||
|
foreach ($items as $item) {
|
||||||
|
$map[$item['id']] = $item['pid'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = [];
|
||||||
|
while (isset($map[$id]) && $map[$id] != 0) {
|
||||||
|
$id = $map[$id];
|
||||||
|
$result[] = $id;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ class Worker extends Backend
|
||||||
* Worker模型对象
|
* Worker模型对象
|
||||||
* @var \app\admin\model\Worker
|
* @var \app\admin\model\Worker
|
||||||
*/
|
*/
|
||||||
protected $model = null;
|
protected $model = null,$items;
|
||||||
|
|
||||||
public function _initialize()
|
public function _initialize()
|
||||||
{
|
{
|
||||||
|
|
@ -37,7 +37,7 @@ class Worker extends Backend
|
||||||
|
|
||||||
|
|
||||||
$items = model('item')->getAll();
|
$items = model('item')->getAll();
|
||||||
|
$this->items = $items;
|
||||||
Tree::instance()->init($items)->icon = [' ', ' ', ' '];
|
Tree::instance()->init($items)->icon = [' ', ' ', ' '];
|
||||||
// dd($ruleList);
|
// dd($ruleList);
|
||||||
$res = Tree::instance()->getTreeList(Tree::instance()->getTreeArray(0), 'title');
|
$res = Tree::instance()->getTreeList(Tree::instance()->getTreeArray(0), 'title');
|
||||||
|
|
@ -304,7 +304,9 @@ class Worker extends Backend
|
||||||
$build->where('area_id', 'like', $code . '%');
|
$build->where('area_id', 'like', $code . '%');
|
||||||
}
|
}
|
||||||
if ($item_id) {
|
if ($item_id) {
|
||||||
$worker_ids = WorkerItem::where('item_id',$item_id)->column('worker_id');
|
$ids = $this->getParentIdsFromArray($item_id,$this->items);
|
||||||
|
|
||||||
|
$worker_ids = WorkerItem::whereIn('item_id',$ids)->column('worker_id');
|
||||||
$build->whereIn('id',$worker_ids);
|
$build->whereIn('id',$worker_ids);
|
||||||
}
|
}
|
||||||
$list = $build
|
$list = $build
|
||||||
|
|
@ -315,6 +317,20 @@ class Worker extends Backend
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getParentIdsFromArray($id, $items) {
|
||||||
|
$map = [];
|
||||||
|
foreach ($items as $item) {
|
||||||
|
$map[$item['id']] = $item['pid'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = [];
|
||||||
|
while (isset($map[$id]) && $map[$id] != 0) {
|
||||||
|
$id = $map[$id];
|
||||||
|
$result[] = $id;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public function dispatchMapList()
|
public function dispatchMapList()
|
||||||
|
|
@ -342,8 +358,11 @@ ORDER BY distance;",[$order->lng,$order->lat]);
|
||||||
|
|
||||||
$worker_ids = array_column($worker_distance,'id');
|
$worker_ids = array_column($worker_distance,'id');
|
||||||
|
|
||||||
|
|
||||||
|
$ids = $this->getParentIdsFromArray($order->item_id,$this->items);
|
||||||
|
|
||||||
$worker_items_ids = (new WorkerItem())
|
$worker_items_ids = (new WorkerItem())
|
||||||
->where('item_id', $order->item_id)
|
->whereIn('item_id', $ids)
|
||||||
->whereIn('worker_id', $worker_ids)
|
->whereIn('worker_id', $worker_ids)
|
||||||
->column('worker_id');
|
->column('worker_id');
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user