123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744 |
- <?php
- namespace app\api\controller\v1;
- use app\api\controller\Base;
- use app\common\model\Config;
- use app\hander\HelpHander;
- use think\App;
- use think\Db;
- use think\Exception;
- use think\exception\Handle;
- class Orders extends Base {
- public function __construct(App $app = null) {
- parent::__construct($app);
- $this->model = new \app\common\model\Orders();
- }
- public function lists() {
- $page = input('page', 1);
- $size = input('size', 10);
- $type = input('curOrderMode', 0);
- $list = $this->model->lists($page, $size, $type, $this->userId, $this->orgId);
- HelpHander::success($list);
- }
- public function detail() {
- $orderId = input('orderId', 0);
- $info = $this->model->detail($orderId);
- HelpHander::success($info);
- }
- //获取部门
- public function getDep() {
- $list = model('dep')->getList($this->orgId);
- HelpHander::success($list);
- }
- //发起订单
- public function add() {
- $json = [
- 'user_id'=>$this->userId,
- 'org_id'=>$this->orgId,
- 'dep_id'=>input('depId/d',0),
- 'images'=>input('images',''),
- 'videos'=>input('videos',''),
- 'voices'=>input('voices',''),
- 'content'=>input('content',''),
- 'work_type_mode'=>input('workTypeMode/d',1),
- 'source_type'=>input('sourceType/d',1),
- 'type_id'=>input('typeId/d',0),
- 'address_id'=>input('addressId/d',0),
- 'start'=>input('start',''),
- 'end'=>input('end',''),
- 'xq_time'=>input('xqTime',''),
- 'ywc_time'=>input('ywcTime',''),
- 'type'=>input('type',''),
- 'device_id'=>input('deviceId',''),
- 'priority'=>input('priority',''),
- 'bed_number'=>input('bedNumber',''),
- 'ba_number'=>input('baNumber',''),
- 'p_name'=>input('pName',''),
- 'gender'=>input('gender',''),
- 'back'=>input('back',''),
- 'name'=>input('name',''),
- 'phone'=>input('phone',''),
- 'isSpontaneous'=>input('isSpontaneous',0),
- 'repair_priority'=>input('repairPriority',2),
- ];
- $res = $this->model->addSave($json);
- if (!$res) {
- HelpHander::error($this->model->getError());
- }
- HelpHander::success('操作成功');
- }
- //调度发单
- public function dispatchAdd() {
- $json = [
- 'user_id'=>$this->userId,
- 'org_id'=>$this->orgId,
- 'dep_id'=>input('depId/d',0),
- 'images'=>input('images',''),
- 'videos'=>input('videos',''),
- 'voices'=>input('voices',''),
- 'content'=>input('content',''),
- 'work_type_mode'=>input('workTypeMode/d',1),
- 'userType'=>input('userType/d',0),
- 'to_user_id'=>input('toUserId',''),
- 'to_roles_id'=>input('toRolesId/d',0),
- 'type_id'=>input('typeId/d',0),
- 'address_id'=>input('addressId/d',0),
- 'source_type'=>input('sourceType/d',1),
- 'todo_content'=>input('todoContent',''),
- 'start'=>input('start',''),
- 'end'=>input('end',''),
- 'xq_time'=>input('xqTime',''),
- 'ywc_time'=>input('ywcTime',''),
- 'type'=>input('type',''),
- 'device_id'=>input('deviceId',''),
- 'priority'=>input('priority',''),
- 'bed_number'=>input('bedNumber',''),
- 'ba_number'=>input('baNumber',''),
- 'p_name'=>input('pName',''),
- 'gender'=>input('gender',''),
- 'back'=>input('back',''),
- 'name'=>input('name',''),
- 'phone'=>input('phone',''),
- 'daily_record_id'=>input('dailyRecordId/d',0), // 品质整改,日常工作记录id
- 'repair_priority'=>input('repairPriority',1),
- 'quality_type'=>input('qualityType/d',0),
- 'quality_cate'=>input('qualityCate/d',0),
- 'informer_user'=>input('informerUser/d',0),
- ];
- $res = $this->model->addSave($json, 1);
- if (!$res) {
- HelpHander::error($this->model->getError());
- }
- HelpHander::success('操作成功');
- }
- //分配订单
- public function send(){
- $json = [
- 'org_id'=>$this->orgId,
- 'id'=>input('id/d',0),
- 'userType'=>input('userType/d',0),
- 'to_user_id'=>input('toUserId',''),
- 'to_roles_id'=>input('toRolesId/d',0),
- 'type_id'=>input('typeId/d',0),
- 'address_id'=>input('addressId/d',0),
- 'todo_content'=>input('todoContent',''),
- 'work_type_mode'=>input('workTypeMode/d',-1),
- 'ba_number'=>input('baNumber','','trim'),
- 'back'=>input('back/d',0),
- 'bed_number'=>input('bedNumber','','trim'),
- 'device_id'=>input('deviceId/d',0),
- 'start'=>input('start/d',0),
- 'end'=>input('end/d',0),
- 'gender'=>input('gender/d',0),
- 'name'=>input('name','','trim'),
- 'phone'=>input('phone','','trim'),
- 'p_name'=>input('pName','','trim'),
- 'priority'=>input('priority/d',0),
- 'type'=>input('type/d',0),
- 'xq_time'=>input('xqTime','','trim'),
- 'ywc_time'=>input('ywcTime','','trim'),
- 'repair_priority'=>input('repairPriority','','trim'),
- ];
- $res = model('orders')->send($json['id'],$this->userId,$json);
- if(!$res){
- HelpHander::error(model('orders')->getError());
- }
- HelpHander::success('操作成功');
- }
- //转单分配订单
- public function zdSend(){
- $json = [
- 'org_id'=>$this->orgId,
- 'id'=>input('id/d',0),
- 'type_id'=>input('typeId/d',0),
- 'address_id'=>input('addressId/d',0),
- 'todo_content'=>input('todoContent',''),
- 'work_type_mode'=>input('workTypeMode/d',-1),
- 'ba_number'=>input('baNumber','','trim'),
- 'back'=>input('back/d',0),
- 'bed_number'=>input('bedNumber','','trim'),
- 'device_id'=>input('deviceId/d',0),
- 'start'=>input('start/d',0),
- 'end'=>input('end/d',0),
- 'gender'=>input('gender/d',0),
- 'name'=>input('name','','trim'),
- 'phone'=>input('phone','','trim'),
- 'p_name'=>input('pName','','trim'),
- 'priority'=>input('priority/d',0),
- 'type'=>input('type/d',0),
- 'xq_time'=>input('xqTime','','trim'),
- 'ywc_time'=>input('ywcTime','','trim'),
- 'repair_priority'=>input('repairPriority','','trim'),
- ];
- $res = model('orders')->zd_send($json['id'],$json);
- if(!$res){
- HelpHander::error(model('orders')->getError());
- }
- HelpHander::success('操作成功');
- }
- //任务栏工单列表
- public function queryOrderList() {
- $page = input('page', 1);
- $size = input('size', 10);
- $offset = ($page-1)*$size;
- $task = Db::name('task')
- ->where('user_id', $this->userId)
- ->where('org_id', $this->orgId)
- ->where('type', 1)
- ->limit($offset,$size)
- ->order(['priority'=>'desc','id'=>'desc'])
- ->select();
- $workType = [
- 1 => '报修工单',
- 2 => '保洁工单',
- 3 => '运送工单',
- 4 => '应急工单',
- 15 => '品质整改',
- 0 => '一键呼叫',
- ];
- $patrolStatus = [
- 0 => '未执行',
- 1 => '执行中',
- 2 => '已完成',
- 3 => '未完成',
- 5 => '中断',
- ];
- $list = [];
- foreach ($task as $k => $value) {
- if ($value['type'] == 1) {//工单
- $todoInfo = Db::name('todo')
- ->where('id', $value['bus_id'])
- ->where('del',0)
- ->find();
- if (!empty($todoInfo)) {
- $data['sn'] = $todoInfo['sn'];
- $data['title'] = $workType[$todoInfo['work_type_mode']];
- $data['realName'] = Db::name('user')
- ->where('id', $todoInfo['create_user_id'])
- ->value('real_name');
- $data['create_time'] = $todoInfo['create_time'];
- $data['status_txt'] = Db::name('todo_mode')
- ->where('id', $todoInfo['todo_mode'])
- ->value('out_content');
- $data['start_time'] = "";
- $data['end_time'] = "";
- $data['type'] = 1;
- $data['bus_id'] = $value['bus_id'];
- $orderInfo = Db::name('orders')
- ->where('id',$todoInfo['order_id'])
- ->find();
- if($orderInfo['from'] > 0){
- $from = '';
- if($orderInfo['from'] == 1){
- $from = '一键呼叫';
- }else if($orderInfo['from'] == 2){
- $from = '隐患预警';
- }else if($orderInfo['from'] == 3){
- $from = '投诉';
- }
- $data['title'] = $data['title'].'('.$from.')';
- }
- $data['patrol_mode'] = 0;
- $data['status'] = $todoInfo['todo_mode'];
- $data['work_type_mode'] = $orderInfo['work_type_mode'];
- if($data['work_type_mode'] == 1 && $todoInfo['todo_mode'] == 2 && $todoInfo['pause'] == 1){ //维修,检查是否挂起
- $data['status_txt'] = '已挂起';
- }
- $data['addressTitle'] = "";
- $data['typeName'] = "";
- $data['content'] = $orderInfo['content']?$orderInfo['content']:'';
- $data['startName'] = "";
- $data['endName'] = "";
- if($orderInfo['work_type_mode']==1){
- $typeInfo = (new \app\common\model\OrderType())
- ->getTypeByOrderId($orderInfo['id']);
- if($typeInfo){
- $order_type = $typeInfo && isset($typeInfo['title']) ? $typeInfo['title'] : '';
- $order_type_matter = $typeInfo && isset($typeInfo['child_title']) ? $typeInfo['child_title'] : '';
- $data['typeName'] = $order_type.'/'.$order_type_matter;
- $data['addressTitle'] = $typeInfo ? $typeInfo['address_title'] : '';
- }
- }
- if($orderInfo['work_type_mode']==3){
- $oc = Db::name('order_convey')
- ->where('order_id', $orderInfo['id'])
- ->find();
- if($oc){
- $start_name = Db::name('address')->where('id',$oc['start'])
- ->value('title');
- $end_name = Db::name('address')->where('id',$oc['end'])
- ->value('title');
- $data['startName'] = $start_name?$start_name:"";
- $data['endName'] = $end_name?$end_name:"";
- }
- }
- $data['priority'] = $value['priority'];
- $list[] = $data;
- }
- } elseif($value['type'] == 2) {//巡更巡检
- $patrolInfo = Db::name('patrol_task')
- ->where('id', $value['bus_id'])
- ->find();
- if (!empty($patrolInfo)) {
- $title = Db::name('patrol_mode')
- ->where('id', $patrolInfo['patrol_mode'])
- ->value('name');
- $data['title'] = $patrolInfo['title']?$title.'-'.$patrolInfo['title']:$title;
- $data['realName'] = "";
- $data['create_time'] = $patrolInfo['create_time'];
- $data['status_txt'] = $patrolStatus[$patrolInfo['status']];
- $data['start_time'] = $patrolInfo['start_time'];
- $data['end_time'] = $patrolInfo['end_time'];
- $data['bus_id'] = $value['bus_id'];
- $data['type'] = 2;
- $data['work_type_mode'] = 0;
- $data['patrol_mode'] = $patrolInfo['patrol_mode'];
- $data['status'] = $patrolInfo['status'];
- $data['addressTitle'] = "";
- $data['typeName'] = "";
- $data['content'] = '';
- $data['startName'] = "";
- $data['endName'] = "";
- $data['priority'] = $value['priority'];
- $list[] = $data;
- }
- }elseif ($value['type'] == 3){ // 日常工作
- $dailyInfo = Db::name('daily_task')
- ->where('id', $value['bus_id'])
- ->find();
- if (!empty($dailyInfo)) {
- $data['title'] = '日常工作';
- $data['realName'] = "";
- $data['create_time'] = $dailyInfo['create_time'];
- $data['status_txt'] = $patrolStatus[$dailyInfo['status']];
- $data['start_time'] = $dailyInfo['start_time'];
- $data['end_time'] = $dailyInfo['end_time'];
- $data['bus_id'] = $value['bus_id'];
- $data['type'] = 3;
- $data['work_type_mode'] = 0;
- $data['patrol_mode'] = 0;
- $data['status'] = $dailyInfo['status'];
- $data['addressTitle'] = "";
- $data['typeName'] = "";
- $data['content'] = '';
- $data['startName'] = "";
- $data['endName'] = "";
- $data['priority'] = $value['priority'];
- $list[] = $data;
- }
- }elseif ($value['type'] == 4){ // 设备台账
- $deviceInfo = Db::name('device_task')
- ->where('id', $value['bus_id'])
- ->find();
- if (!empty($deviceInfo)) {
- $data['title'] = $deviceInfo['title']? '设备维保'.'-'.$deviceInfo['title']:'设备维保';
- $data['realName'] = "";
- $data['create_time'] = $deviceInfo['create_time'];
- $data['status_txt'] = $patrolStatus[$deviceInfo['status']];
- $data['start_time'] = $deviceInfo['start_time'];
- $data['end_time'] = $deviceInfo['end_time'];
- $data['bus_id'] = $value['bus_id'];
- $data['type'] = 4;
- $data['work_type_mode'] = 0;
- $data['patrol_mode'] = 0;
- $data['status'] = $deviceInfo['status'];
- $data['addressTitle'] = "";
- $data['typeName'] = "";
- $data['content'] = '';
- $data['startName'] = "";
- $data['endName'] = "";
- $data['priority'] = $value['priority'];
- $list[] = $data;
- }
- }
- }
- $orgGrabOrder = getOrgGrabOrder($this->userId,$this->orgId);
- $r = [
- 'list' => $list,
- 'count' => count($list),
- 'org_grab_order'=>$orgGrabOrder?(int)$orgGrabOrder:0
- ];
- HelpHander::success($r);
- }
- //抢单列表
- public function queryGrabOrders(){
- $page = input('page', 1);
- $size = input('size', 10);
- $list = $this->model->queryGrabOrders($page,$size,$this->userId,$this->orgId);
- HelpHander::success($list);
- }
- // 抢单
- public function grabOrders(){
- $orderId = input('orderId');
- $orderType = input('orderType/d',0);
- $addressId = input('addressId/d',0);
- $order = Db::name('orders')
- ->where('id',$orderId)
- ->where('org_id',$this->orgId)
- ->find();
- if($order['work_type_mode']==1 && empty($orderType)){
- HelpHander::error('报修事项不能为空');
- }
- if(!$order || $order['del'] == 1){
- HelpHander::error('订单不存在');
- }
- if($order['order_mode'] != 1){
- HelpHander::error('订单已被处理');
- }
- $off = (new Config())->getConfig('org_grab_order'.$order['work_type_mode'],$this->orgId);
- if($off !=1){
- HelpHander::error('抢单模式未开启');
- }
- $ret = $this->model->grabOrdersEdit($order,$this->userId,$orderType,$addressId);
- if(!$ret){
- HelpHander::error($this->model->getError());
- }
- HelpHander::success([],'操作成功');
- }
- // 扫标本
- public function scanSample(){
- $orderId = input('orderId/d',0);
- $barcode = input('barcode');
- $addrId = input('addrId/d',0);
- if(!$barcode ){
- HelpHander::error('未传标本码');
- }
- if(!$orderId&&!$addrId){
- HelpHander::error('参数错误');
- }
- if($orderId > 0){
- $orderConvey = Db::name('order_convey')
- ->where('order_id',$orderId)
- ->find();
- $addrId = $orderConvey['start'];
- }
- $res = Db::name('order_convey_lis')
- ->where('org_id',$this->orgId)
- ->where('order_id',$orderId)
- ->where('barcode',$barcode)
- ->where('user_id',$this->userId)
- ->where('addr_id',$addrId)
- ->find();
- Db::startTrans();
- try{
- if($res){
- $res = Db::name('order_convey_lis')
- ->where('id',$res['id'])->update([
- 'create_time' => date('Y-m-d H:i:s')
- ]);
- }else{
- $res = Db::name('order_convey_lis')
- ->insert([
- 'order_id' => $orderId,
- 'barcode' => $barcode,
- 'user_id' => $this->userId,
- 'create_time' => date('Y-m-d H:i:s'),
- 'org_id' => $this->orgId,
- 'addr_id' => $addrId
- ]);
- }
- if(!$res){
- exception('操作失败');
- }
- Db::commit();
- HelpHander::success([],'操作成功');
- }catch (Exception $e){
- Db::rollback();
- HelpHander::error($e->getMessage());
- }
- }
- //用户订单列表
- public function queryUserOrdersByMode(){
- $page = input('page', 1);
- $size = input('size', 10);
- $mode = input('mode', 0);
- $type = input('type', 0);
- $ret=$this->model->userOrdersByMode($page,$size,$this->userId,$mode,$type,$this->orgId);
- HelpHander::success($ret);
- }
- //用户取消订单
- public function updateOrderModeByUser(){
- $orderId = input('orderId', 0);
- $reason = input('reason', '','trim');
- $ret=$this->model->cancel($orderId,$this->userId,1,$reason);
- $ret?HelpHander::success([],'操作成功'):HelpHander::error($this->model->getError());
- }
- //调度取消订单
- public function updateOrderModeByDispatch(){
- $orderId = input('orderId', 0);
- $reason = input('reason', '');
- if(!$reason){
- HelpHander::error('请填写取消原因');
- }
- $ret=$this->model->cancel($orderId,$this->userId,2,$reason);
- $ret?HelpHander::success([],'操作成功'):HelpHander::error($this->model->getError());
- }
- //调度完成订单
- public function finishOrder(){
- $orderId = input('orderId', 0);
- $ret=$this->model->finish($orderId);
- $ret?HelpHander::success([],'操作成功'):HelpHander::error($this->model->getError());
- }
- //所有订单
- public function queryAllOrder(){
- $page = input('page', 1);
- $size = input('size', 10);
- $workTypeMode = input('workTypeMode/d',-1);
- $currOrderMode = input('currOrderMode');
- $beginTime = input('beginTime');
- $endTime = input('endTime');
- $list = $this->model->queryAllOrder($this->orgId,$page,$size,$workTypeMode,$currOrderMode,$beginTime,$endTime);
- HelpHander::success($list);
- }
- // 工人添加下一站地址
- public function addConveyEnd(){
- $orderId = input('orderId/d',0);
- $addrId = input('addrId/d',0);
- $ret = $this->model->addConveyEnd($this->orgId,$orderId,$addrId);
- if(!$ret){
- HelpHander::error($this->model->getError());
- }
- HelpHander::success([],'成功');
- }
- // 支付运送病人
- public function pay(){
- $id = input('id/d',0);
- $remark = input('remark','','trim');
- $info = Db::name('order_convey_pay')->where('id',$id)->find();
- if(!$info){
- HelpHander::error('订单不存在');
- }
- if($info['status'] == 1){
- HelpHander::error('订单已支付');
- }
- $res = Db::name('order_convey_pay')->where('id',$id)->update([
- 'type' => 1,
- 'status' => 1,
- 'remark' => $remark,
- 'pay_time' => date('Y-m-d H:i:s')
- ]);
- if($res){
- HelpHander::success([],'操作成功');
- }else{
- HelpHander::error('操作失败');
- }
- }
- // 扫途径地点
- public function sweepCode(){
- $code = input('code');
- $id = input('id/d',0);
- $ret = model('Orders')->sweepCode($code,$id);
- if(!$ret){
- HelpHander::error(model('Orders')->getError());
- }
- HelpHander::success([],'操作成功');
- }
- //获取可转单类型
- public function orderTransferType(){
- $user = Db::name('user')->where('id',$this->userId)->find();
- $config = model('Config')->getConfig('web_order_transfer_type');
- $modes = $config?explode('|',$config):[];
- if($user['type'] != 1){ // 不是总公司人员
- $roles = Db::name('user_roles')
- ->alias('a')
- ->join('roles b','b.id = a.roles_id')
- ->where('a.user_id',$this->userId)
- ->value('work_type_mode');
- if($roles){
- $modes = explode(',',$roles);
- }
- }
- $map[] = ['type','=',1];
- if($modes){
- $map[] = ['id','in',$modes];
- }else{
- $map[] = ['id','=',-1];
- }
- $workType = Db::name('work_type_mode')
- ->where($map)
- ->field('id,name as title')
- ->select();
- HelpHander::success($workType?$workType:[]);
- }
- //获取待处理已完成已评价订单数量
- public function getOrdersCount(){
- $map[] = ['user_id','=',$this->userId];
- $map[] = ['org_id','=',$this->orgId];
- $map[] = ['del','=',0];
- $a1 = Db::name('orders')
- ->where($map)
- ->where('order_mode',1)
- ->count();
- $dcl = $a1?$a1:0;
- $a2 = Db::name('orders')
- ->where($map)
- ->where('order_mode',5)
- ->count();
- $ywc = $a2?$a2:0;
- $a3 = Db::name('orders')
- ->where($map)
- ->where('order_mode',6)
- ->count();
- $ypj = $a3?$a3:0;
- $data = [
- 'dcl'=>$dcl,
- 'ywc'=>$ywc,
- 'ypj'=>$ypj,
- ];
- HelpHander::success($data);
- }
- //被驳回的数量
- public function rejectCount(){
- $map[] = ['org_id', '=', $this->orgId];
- $map[] = ['del', '=', 0];
- $map2[] = ['todo_mode', '=', 4];
- $auth = get_dispatch_auth($this->userId);
- if (empty($auth)) {
- $map[] = ['work_type_mode', '=', -1];
- }
- else {
- $map[] = ['work_type_mode', 'in', $auth];
- }
- $org_two_dispatch = (new Config())->getConfig('org_two_dispatch',$this->orgId);
- if($org_two_dispatch==0){//二级调度开关关闭
- }else{
- if (check_two_dispatch($this->userId) == 1) {//二级调度角色
- $roles_id = Db::name('user_roles')
- ->where('user_id',$this->userId)
- ->value('roles_id');
- $ids = Db::name('dispatch_log')
- ->where('roles_id', $roles_id)
- ->whereOr('to_user_id', $this->userId)
- ->column('order_id');
- if (empty($ids)) {
- $map2[] = ['order_id', '=', -1];
- }else {
- $map2[] = ['order_id', 'in', $ids];
- }
- }
- }
- $count = Db::name('todo_view')
- ->where($map)
- ->where($map2)
- ->count();
- HelpHander::success($count);
- }
- //优先级
- public function repair_priority(){
- $a = [
- ['id'=>1,'title'=>"可延缓的"],
- ['id'=>2,'title'=>"普通"],
- ['id'=>3,'title'=>"紧急"],
- ];
- HelpHander::success($a);
- }
- public function userQualityLists() {
- $page = input('page', 1);
- $size = input('size', 10);
- $list = $this->model->userQualityLists($page, $size, $this->userId, $this->orgId);
- HelpHander::success($list);
- }
- public function informerQualityLists() {
- $page = input('page', 1);
- $size = input('size', 10);
- $list = $this->model->informerQualityLists($page, $size, $this->userId, $this->orgId);
- HelpHander::success($list);
- }
- //巡更巡视..一键呼叫发送给自己转成报修单;
- public function addBxOrders(){
- $data = [
- 'user_id'=>$this->userId,
- 'org_id'=>$this->orgId,
- 'dep_id'=>input('depId/d',0),
- 'images'=>input('images',''),
- 'videos'=>input('videos',''),
- 'voices'=>input('voices',''),
- 'content'=>input('content',''),
- 'work_type_mode'=>input('workTypeMode/d',1),
- 'source_type'=>input('sourceType/d',4),
- 'type_id'=>input('typeId',0),
- 'address_id'=>input('addressId',0),
- 'repair_priority'=>input('repairPriority',0),
- ];
- $res = model('Orders')->addBxOrders($data);
- if (!$res) {
- HelpHander::error(model('Orders')->getError());
- }
- HelpHander::success([],'操作成功');
- }
- public function withdraw(){
- $id = input('id');
- $info = Db::name('orders')
- ->where('id',$id)
- ->where('del',0)
- ->where('order_mode',4)
- ->find();
- if(!$info){
- HelpHander::error('参数错误');
- }
- $saveOrder = Db::name('orders')
- ->where('id',$id)
- ->update(['order_mode'=>1,'withdraw_time'=>getTime()]);
- Db::name('todo')->where('order_id',$id)->update(['del'=>1]);
- $todoIds = Db::name('todo')
- ->where('order_id',$id)
- ->where('todo_mode',1)
- ->column('id');
- Db::name('task')
- ->where('type',1)
- ->whereIn('bus_id',$todoIds)
- ->delete();
- if(!$saveOrder){
- HelpHander::error('操作失败');
- }
- HelpHander::success('操作成功');
- }
- }
|