|
@@ -121,4 +121,62 @@ class Maintain extends Backend
|
|
|
$this->success();
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 总部指派
|
|
|
+ * 复制pc端的指派,稍作调整
|
|
|
+ */
|
|
|
+ public function zhipai()
|
|
|
+ {
|
|
|
+ $id = input('id',0);
|
|
|
+ $row = Db::name('maintain')->where('id',$id)->find();
|
|
|
+ if(!$this->request->isPost()){
|
|
|
+ $this->view->assign('row', $row);
|
|
|
+ return $this->view->fetch();
|
|
|
+ }
|
|
|
+
|
|
|
+ //检查师傅
|
|
|
+ $worker_id = input('worker_id',0);
|
|
|
+
|
|
|
+ $worker = Db::name('worker')->where('id',$worker_id)->where('status',1)->where('company_id',1)->find();
|
|
|
+ if(empty($worker)){
|
|
|
+ $this->error('没找到该师傅');
|
|
|
+ }
|
|
|
+
|
|
|
+ //检查订单
|
|
|
+ $id = input('id',0);
|
|
|
+
|
|
|
+ Db::startTrans();
|
|
|
+ $info = Db::name('maintain')->where('id',$id)->lock(true)->find();
|
|
|
+ if(empty($info)){
|
|
|
+ Db::rollback();
|
|
|
+ $this->error('没找到该信息,请刷新重试');
|
|
|
+ }
|
|
|
+
|
|
|
+ if(!in_array($info['status'],[0,20,22,30,40])){
|
|
|
+ Db::rollback();
|
|
|
+ $this->error('当前订单状态,不能指派师傅');
|
|
|
+ }
|
|
|
+
|
|
|
+ if(!empty($info['worker_id'])){
|
|
|
+ Db::rollback();
|
|
|
+ $this->error('已经指派了师傅');
|
|
|
+ }
|
|
|
+
|
|
|
+ //
|
|
|
+ $update = [
|
|
|
+ 'worker_id' => $worker_id,
|
|
|
+ 'status' => 50,
|
|
|
+ 'updatetime' => time(),
|
|
|
+ ];
|
|
|
+ $rs_update = Db::name('maintain')->where('id',$id)->update($update);
|
|
|
+ if($rs_update === false){
|
|
|
+ Db::rollback();
|
|
|
+ $this->error('指派失败,请重试');
|
|
|
+ }
|
|
|
+
|
|
|
+ //
|
|
|
+ Db::commit();
|
|
|
+ $this->success();
|
|
|
+ }
|
|
|
+
|
|
|
}
|