1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557 |
- <?php
- namespace app\admin\controller;
- use app\common\model\Config;
- use Overtrue\Pinyin\Pinyin;
- use think\App;
- use think\Db;
- use think\Exception;
- class Orders extends Auth {
- public function __construct(App $app = null) {
- parent::__construct($app);
- $this->model = new \app\common\model\Orders();
- $this->table = $this->model->table;
- }
- //用户订单列表
- public function selfIndex() {
- $mode = input('mode', 1);
- if (request()->isAjax()) {
- //分页参数
- $length = input('rows', 10, 'intval'); //每页条数
- $page = input('page', 1, 'intval'); //第几页
- $start = ($page - 1) * $length; //分页开始位置
- //排序
- $sortRow = input('sidx', 'a.id', 'trim'); //排序列
- $sort = input('sord', 'desc', 'trim'); //排序方式
- $order = $sortRow . ' ' . $sort;
- $map[] = ['a.del', '=', 0];
- $map[] = ['a.org_id', '=', $this->orgId];
- $order_mode = input('order_mode', '', 'trim');
- if ($order_mode != '') {
- $map[] = ['a.order_mode', '=', $order_mode];
- }
- if($mode >0){
- $map[] = ['a.work_type_mode', '=', $mode];
- }else{
- $map[] = ['a.source_type', '=', 4];
- }
- $sn = input('sn', '', 'trim');
- if ($sn) {
- $map[] = ['a.sn', 'like', '%' . $sn . '%'];
- }
- if (!is_admin($this->userId)) {
- $map[] = ['a.user_id', '=', $this->userId];
- }
- $priority = input('priority', '', 'trim');
- if($priority !=''){
- $map[] = ['b.priority', '=',$priority];
- }
- $map = empty($map) ? true : $map;
- //数据查询
- $lists = db($this->table)
- ->alias('a')
- ->leftJoin('order_convey b','a.id=b.order_id')
- ->where($map)
- ->field('a.*,b.priority')
- ->limit($start, $length)
- ->order($order)
- ->select();
- foreach ($lists as $k => $v) {
- $lists[$k] = $this->model->formatOrder($v);
- $lists[$k]['priority'] = isset($this->model->priority[$v['priority']])?$this->model->priority[$v['priority']]:"";
- }
- //数据返回
- $totalCount = db($this->table)
- ->alias('a')
- ->leftJoin('order_convey b','a.id=b.order_id')
- ->where($map)->count();
- $totalPage = ceil($totalCount / $length);
- $result['page'] = $page;
- $result['total'] = $totalPage;
- $result['records'] = $totalCount;
- $result['rows'] = $lists;
- return json($result);
- }
- else {
- $mode_name = $this->getTableField('work_type_mode', ['id' => $mode], 'name');
- if($mode==4){
- $mode_name = '应急';
- }
- $this->assign('m_name', $mode_name);
- $this->assign('mode', $mode);
- $this->assign('priority', model("Orders")->priority);
- $order_mode = Db::name('order_mode')->select();
- $this->assign('order_mode_list', $order_mode);
- $tsDh = model('Config')->getConfig('org_config_ts',$this->orgId);
- $this->assign('tsDh',$tsDh);
- if ($mode == 1) {
- return $this->fetch('selfIndex1');
- }
- else {
- if ($mode == 3) {
- return $this->fetch('selfIndex3');
- }
- else {
- return $this->fetch('selfIndex');
- }
- }
- }
- }
- //用户添加订单
- public function selfAdd($mode = 1) {
- if (request()->isPost()) {
- $data = request()->post();
- $data['user_id'] = $this->userId;
- $data['org_id'] = $this->orgId;
- $data['work_type_mode'] = $mode;
- $data['images'] = isset($data['images']) && !empty($data['images']) ? implode(',', $data['images']) : '';
- $res = $this->model->addSave($data);
- if ($res) {
- $this->success('操作成功');
- }
- else {
- $this->error($this->model->getError());
- }
- }
- else {
- $dep = $this->getTableField('user_dep', ['user_id' => $this->userId], 'dep_id');
- $depList = (new \app\common\model\Dep())->getList();
- $this->assign('dep_id', $dep);
- $this->assign('dep_list', $depList);
- $this->assign('mode', $mode);
- if ($mode == 3) {
- $address = (new \app\common\model\Address())->getListByType(2);
- $conveyCate = (new \app\common\model\ConveyCate());
- $priority = $conveyCate->priority;
- $order_convey = $conveyCate->getList();
- $order_device = (new \app\common\model\ConveyDevice())->getList();
- $this->assign('address', $address);
- $this->assign('priority', $priority);
- $this->assign('order_convey_type', $order_convey);
- $this->assign('order_device', $order_device);
- }
- $user = Db::name('user')
- ->where('id',$this->userId)
- ->find();
- $this->assign('user',$user);
- $tsDh = model('Config')->getConfig('org_config_ts',$this->orgId);
- $this->assign('tsDh',$tsDh);
- if ($mode == 3) {
- return $this->fetch('self_add3');
- }
- else {
- return $this->fetch('self_add');
- }
- }
- }
- public function getAddr(){
- $id = input('id/d',0);
- $info = Db::name('convey_cate')
- ->where('id',$id)
- ->find();
- if(!empty($info['starts'])){
- $st = explode(',',$info['starts']);
- $s = (new \app\common\model\Address())->getListByTypes($st,2);
- }else{
- $s = (new \app\common\model\Address())->getListByType(2);
- }
- if(!empty($info['ends'])){
- $ent = explode(',',$info['ends']);
- $en = (new \app\common\model\Address())->getListByTypes($ent,2);
- }else{
- $en = (new \app\common\model\Address())->getListByType(2);
- }
- $a = [
- 's'=>$s,
- 'e'=>$en,
- ];
- $this->success('','',$a);
- }
- //用户取消订单
- public function cancel($id) {
- $res = $this->model->cancel($id, $this->userId);
- if (!$res) {
- $this->error($this->model->getError());
- }
- $this->success('取消成功');
- }
- //调度取消订单
- public function disCancel($id) {
- if (request()->isGet()) {
- $this->assign('id', $id);
- return $this->fetch();
- }
- else {
- $reason = input('cancel_reason');
- $res = $this->model->cancel($id, $this->userId, 2, $reason);
- if (!$res) {
- $this->error($this->model->getError());
- }
- $this->success('取消成功');
- }
- }
- //延迟订单
- public function batchdelay($id) {
- if (request()->isGet()) {
- $delay_reason = Db::name('delay_reason')
- ->where('org_id', $this->orgId)
- ->where('enable', 1)
- ->where('del', 0)
- ->select();
- $this->assign('delay_reason', $delay_reason);
- $this->assign('id', $id);
- return $this->fetch();
- }
- else {
- $delay_reason_id = input('delay_reason_id');
- if (empty($delay_reason_id)) {
- $this->error('请选择延迟原因');
- }
- $res = $this->model->delay_reason($id, $delay_reason_id);
- if (!$res) {
- $this->error($this->model->getError());
- }
- $this->success('延迟成功');
- }
- }
- //取消延迟订单
- public function batchcanceldelay($id) {
- if (request()->isGet()) {
- $this->assign('id', $id);
- return $this->fetch();
- }
- else {
- $res = $this->model->batchcanceldelay($id);
- if (!$res) {
- $this->error($this->model->getError());
- }
- $this->success('延迟成功');
- }
- }
- //用户查看订单详情
- public function detail($id) {
- if (!$id) {
- $this->error('参数错误');
- }
- $order = Db::name('orders')->where(['id' => $id])->find();
- $order = $this->model->formatOrder($order, 1);
- $order['images'] = !empty($order['images']) ? explode(',', $order['images']) : '';
- if($order['work_type_mode'] == 3){
- // 地点路径
- $conveyends = Db::name('order_convey_end')
- ->alias('a')
- ->join('address b','b.id = a.addr')
- ->where('a.order_id',$id)
- ->order('a.id asc')
- ->field('a.*,b.title')
- ->select();
- $order['ends'] = $conveyends?$conveyends:[];
- }
- $this->assign('info', $order);
- $workTypeName = $this->getTableField('work_type_mode', ['id' => $order['work_type_mode']], 'name');
- $this->assign('meta_title', $workTypeName . '订单详情');
- return $this->fetch();
- }
- //调度订单列表
- public function index() {
- $mode = input('mode', 0);
- $quality_type = input('quality_type','');
- $level1 = check_is_dispatch($this->userId);
- $level2 = check_two_dispatch($this->userId);
- $turnoff = two_dispatch_off($this->orgId);
- if (request()->isAjax()) {
- //分页参数
- $length = input('rows', 10, 'intval'); //每页条数
- $page = input('page', 1, 'intval'); //第几页
- $start = ($page - 1) * $length; //分页开始位置
- //排序
- $sortRow = input('sidx', 'a.id', 'trim'); //排序列
- $sort = input('sord', 'desc', 'trim'); //排序方式
- $order = $sortRow . ' ' . $sort;
- $content = input('content', '', 'trim');
- if ($content) {
- $map[] = ['a.content', 'like', '%' . $content . '%'];
- }
- $dep_id = input('dep_id', '', 'trim');
- if ($dep_id != '') {
- $map[] = ['a.dep_id', '=', $dep_id];
- }
- $dep_cate = input('dep_cate', '', 'trim');
- if ($dep_cate != '') {
- $depIds = Db::name('dep')
- ->where('org_id',$this->orgId)
- ->where('cate_id',$dep_cate)
- ->where('del',0)
- ->column('id');
- if(!empty($depIds)){
- $map[] = ['a.dep_id', 'in', $depIds];
- }else{
- $map[] = ['a.dep_id', '=', -1];
- }
- }
- $order_mode = input('order_mode', '', 'trim');
- $map6 = [];
- if ($order_mode != '') {
- if($level1 && $turnoff && $mode != 15){ // 一级调度且二级调度开关开着,品质整改例外
- if ($order_mode == 1) {
- $map[] = ['a.is_deal', '=', 0];
- }else if ($order_mode == 4) {
- $map6[] = ['a.is_deal', '=', 1];
- }
- }
- if($order_mode==100){//已挂起
- $gq = Db::name('todo')
- ->where('work_type_mode',1)
- ->where('todo_mode',2)
- ->where('pause',1)
- ->column('order_id');
- if(empty($gq)){
- $map[] = ['a.id', '=', -1];
- }else{
- $map[] = ['a.id', 'in', $gq];
- }
- }else{
- $map[] = ['a.order_mode', '=', $order_mode];
- }
- }
- $b = input('start', '', 'trim');
- $e = input('end', '', 'trim');
- if ($b) {
- // $b = date('Ymd', strtotime($b));
- // $map[] = ['a.create_yyyymmdd', '>=', $b];
- $map[] = ['a.create_time', '>=', $b];
- }
- if ($e) {
- // $e = date('Ymd', strtotime($e));
- // $map[] = ['a.create_yyyymmdd', '<=', $e];
- $map[] = ['a.create_time', '<=', $e];
- }
- $map[] = ['a.del', '=', 0];
- $map[] = ['a.org_id', '=', $this->orgId];
- if($mode==-1){
- $map[] = ['a.source_type', '=', 4];
- }
- $type = input('type', '', 'trim');
- $oids = [];
- if ($type != '') {
- $map1[] = ['parent_id', '=', $type];
- $type_id = Db::name('order_type')
- ->where($map1)
- ->where('org_id', $this->orgId)
- ->where('enable', 1)
- ->column('id');
- if (!empty($type_id)) {
- $map3[] = ['type_id', 'in', $type_id];
- $ids = Db::name('order_repair')
- ->where($map3)
- ->column('order_id');
- if (!empty($ids)) {
- $oids = $ids;
- }
- else {
- $oids = [];
- }
- }
- else {
- $oids = [];
- }
- }
- $typeName = input('typeName', '', 'trim');
- if ($typeName != '') {
- $map_11[] = ['a.title', 'like', '%'.$typeName.'%'];
- $typeNameId = Db::name('convey_cate')
- ->alias('a')
- ->join('order_convey b','a.id=b.type')
- ->where($map_11)
- ->where('a.org_id', $this->orgId)
- ->where('a.enable', 1)
- ->where('a.del', 0)
- ->column('b.order_id');
- if (!empty($typeNameId)) {
- $map[] = ['a.id', 'in', $typeNameId];
- }
- else {
- $map[] = ['a.id', '=', -1];
- }
- }
- if($level2 && $turnoff){ // 二级调度
- $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)) {
- $map[] = ['a.id', '=', -1];
- } else {
- if($type != ''){
- $oids = array_intersect($oids,$ids);
- if($oids){
- $map[] = ['a.id', 'in', $oids];
- }else{
- $map[] = ['a.id', '=', -1];
- }
- }else{
- $map[] = ['a.id', 'in', $ids];
- }
- }
- }else{
- if($type != ''){
- if($oids){
- $map[] = ['a.id', 'in', $oids];
- }else{
- $map[] = ['a.id', '=', 0];
- }
- }
- }
- if($mode == 15){ // 品质检查,单独处理
- $map[] = ['a.work_type_mode','=',$mode];
- if($quality_type!=''){
- $map[] = ['a.quality_type','=',$quality_type];
- }
- }else{
- $work_type_mode = input('work_type_mode','','trim');
- if(!is_admin($this->userId)){
- $auth = get_dispatch_auth($this->userId);
- if($auth){
- $map[] = ['a.work_type_mode', 'in', $auth];
- if($mode > 0){
- $map[] = ['a.work_type_mode', '=', $mode];
- }else{
- if($work_type_mode!=''){
- $map[] = ['a.work_type_mode','=',$work_type_mode];
- }
- }
- }else{
- $map[] = ['a.work_type_mode', '=', -1];
- }
- }else{
- if($mode > 0){
- $map[] = ['a.work_type_mode', '=', $mode];
- }else{
- if($work_type_mode!=''){
- $map[] = ['a.work_type_mode','=',$work_type_mode];
- }
- }
- }
- }
- $sn = input('sn', '', 'trim');
- if ($sn) {
- $map[] = ['a.sn', 'like', '%' . $sn . '%'];
- }
- $from = input('from', '', 'trim');
- if ($from) {
- if($from >3){
- $map[] = ['a.from','=',0];
- $map[] = ['a.work_type_mode','=',$from-3];
- }else{
- $map[] = ['a.from','=',$from];
- }
- }
- $priority = input('priority', '', 'trim');
- if($priority !=''){
- $map[] = ['b.priority', '=',$priority];
- }
- $sddr = input('saddr','','trim');
- if($sddr !=''){
- $map[] = ['b.start','=',$sddr];
- }
- $eddr = input('eaddr','','trim');
- if($eddr !=''){
- $map[] = ['b.end','=',$eddr];
- }
- $map = empty($map) ? true : $map;
- //数据查询
- $lists = db($this->table)->where($map)
- ->alias('a')
- ->leftJoin('order_convey b','a.id=b.order_id')
- ->field('a.*,b.priority')
- ->whereOr($map6)
- ->limit($start, $length)->order($order)->select();
- foreach ($lists as $k => $v) {
- $lists[$k] = $this->model->formatOrder($v);
- $lists[$k]['priority'] = isset($this->model->priority[$v['priority']])?$this->model->priority[$v['priority']]:"";
- if ($turnoff && $level1 && $v['order_mode'] == 1 && $v['is_deal'] == 1) {
- $lists[$k]['order_mode_text'] = '已派发';
- }
- $lists[$k]['bh_nums'] = Db::name('todo')->where('order_id',$v['id'])->where('del',0)->where('todo_mode',4)->count();
- $gq = Db::name('todo')
- ->where('order_id',$v['id'])
- ->where('work_type_mode',1)
- ->where('todo_mode',2)
- ->where('pause',1)
- ->find();
- $lists[$k]['gq'] = $gq?'存在挂起':'';
- }
- //数据返回
- $totalCount = db($this->table)
- ->alias('a')
- ->leftJoin('order_convey b','a.id=b.order_id')
- ->where($map)->count();
- $totalPage = ceil($totalCount / $length);
- $result['page'] = $page;
- $result['total'] = $totalPage;
- $result['records'] = $totalCount;
- $result['rows'] = $lists;
- return json($result);
- }
- else {
- if($mode >0){
- $mode_name = $this->getTableField('work_type_mode', ['id' => $mode], 'name');
- }else{
- $mode_name = '';
- }
- if($mode==4){
- $mode_name = '应急';
- }
- $auths = [1,2,3,4,15,0];
- if(!is_admin($this->userId)){
- $auth = get_dispatch_auth($this->userId);
- if($auth){
- $auths = array_intersect($auths,$auth);
- if($mode > 0){
- $auths = array_intersect($auths,[$mode]);
- }
- }else{
- $auths = [];
- }
- }
- $this->assign('auths',$auths);
- $this->assign('priority', model("Orders")->priority);
- $dep_list = (new \app\common\model\Dep())->getList();
- $order_type = (new \app\common\model\OrderType())->list();
- $order_mode = Db::name('order_mode')
- ->select();
- $this->assign('dep_list', $dep_list);
- $this->assign('order_type_list', $order_type);
- $this->assign('m_name', $mode_name);
- $this->assign('mode', $mode);
- $this->assign('order_mode_list', $order_mode);
- $this->assign('dispatch_type', check_two_dispatch($this->userId));
- $this->assign('quality_type',$quality_type);
- $dep_cate = model('DepCate')->getList();
- $this->assign('dep_cate',$dep_cate);
- $addrList = (new \app\common\model\Address())->getListByTypes([],2,$this->orgId);
- $this->assign('addrList',$addrList);
- //抢单开关
- $this->assign('org_grab_order',(new \app\common\model\Config())
- ->getConfig('org_grab_order1',$this->orgId));
- $is = 0;
- if(!isset($_GET['quality_type']) && $mode==15){
- $is = 1;
- }
- $this->assign('is',$is);
- if ($mode == 1) {
- return $this->fetch('index1');
- }
- else {
- if ($mode == 3) {
- return $this->fetch('index3');
- }else if (in_array($mode,[0,-1])) {
- return $this->fetch('index0');
- }
- else {
- return $this->fetch('index');
- }
- }
- }
- }
- //调度删除订单
- public function del($id = 0) {
- if (!$id) {
- $this->error('参数错误');
- }
- $model = (new \app\common\model\Orders());
- $res = $model->del($id, $this->userId);
- if (!$res) {
- $this->error($model->getError());
- }
- $this->success('删除成功');
- }
- //调度添加订单
- public function dispatchAdd($mode = 1) {
- $id = input('id', 0);
- if (request()->isPost()) {
- $data = request()->post();
- $data['user_id'] = $this->userId;
- $data['org_id'] = $this->orgId;
- $data['work_type_mode'] = isset($data['work_type_mode'])?$data['work_type_mode']:$mode;
- $data['images'] = isset($data['images']) && !empty($data['images']) ? implode(',', $data['images']) : '';
- if ($id > 0) {
- // $phoneInfo = Db::name('phone_monitor_record')
- // ->where('id', $id)
- // ->find();
- $data['id'] = $id;
- $data['user_id'] = $this->userId;
- }
- $res = $this->model->addSave($data, 1);
- if ($res) {
- $this->success('操作成功');
- }
- else {
- $this->error($this->model->getError());
- }
- }
- else {
- $tsDh = model('Config')->getConfig('org_config_ts',$this->orgId);
- $this->assign('tsDh',$tsDh);
- $user = Db::name('user')
- ->where('id',$this->userId)
- ->find();
- $this->assign('user',$user);
- if($mode==0){//创建一键呼叫
- $dep = $this->getTableField('user_dep', ['user_id' => $this->userId], 'dep_id');
- $depList = (new \app\common\model\Dep())->getList();
- $this->assign('dep_id', $dep);
- $this->assign('dep_list', $depList);
- $order_type = (new \app\common\model\OrderType())->getList();
- $address = (new \app\common\model\Address())->getListByType(1);
- $this->assign('order_type_list', $order_type);
- $this->assign('address_list', $address);
- $order_repair = Db::name('order_repair')
- ->where('order_id', $id)
- ->find();
- $this->assign('order_repair', $order_repair);
- $workType = Db::name('work_type_mode')
- ->where('type',1)
- ->select();
- $config = Db::name('config')
- ->where('name','web_order_transfer_type')
- ->value('value');
- if(empty($config)){
- $workType = [];
- }else{
- $ll = explode('|',$config);
- foreach ($workType as $kk=>$vv){
- if(!in_array($vv['id'],$ll)){
- unset($workType[$kk]);
- }
- }
- }
- if(!is_admin($this->userId)){
- $auth = get_dispatch_auth($this->userId);
- if(empty($auth)){
- $workType = [];
- }else{
- foreach ($workType as $kk=>$vv){
- if(!in_array($vv['id'],$auth)){
- unset($workType[$kk]);
- }
- }
- }
- }
- foreach ($workType as $k=>$v){
- $this->assign('send_user_num'.$v['id'], $this->model->sendUserNum($v['id'], $this->orgId));
- $this->assign('user_list'.$v['id'], (new \app\common\model\WorkTypeMode())->getRolesUserByNum($v['id'], $this->orgId, 1));
- $two_dispatch_roles = model('user')->get_two_dispatch_role($this->orgId, $v['id']);
- $this->assign('dispatch_roles'.$v['id'], $two_dispatch_roles);
- }
- $this->assign('dispatch_type', check_two_dispatch($this->userId));
- $this->assign('two_dispatch_off', two_dispatch_off($this->orgId));
- $this->assign('workType', $workType);
- $address = (new \app\common\model\Address())->getListByType(2);
- $conveyCate = (new \app\common\model\ConveyCate());
- $priority = $conveyCate->priority;
- $order_convey = $conveyCate->getList();
- $order_device = (new \app\common\model\ConveyDevice())->getList();
- $this->assign('address', $address);
- $this->assign('priority', $priority);
- $this->assign('order_convey_type', $order_convey);
- $this->assign('order_device', $order_device);
- $oCid = Db::name('order_convey')
- ->where('order_id',$id)
- ->find();
- $opt = Db::name('order_convey_patient')
- ->where('order_id',$id)
- ->find();
- $this->assign('ocid',$oCid);
- $this->assign('opt',$opt);
- $this->assign('ps',empty($opt)?1:0);
- $this->assign('id', $id);
- $this->assign('mode', $mode);
- return $this->fetch('yjhj_dispatch_add');
- }else{
- $dep = $this->getTableField('user_dep', ['user_id' => $this->userId], 'dep_id');
- $depList = (new \app\common\model\Dep())->getList();
- $order_type = (new \app\common\model\OrderType())->getList();
- $address = (new \app\common\model\Address())->getListByType(1);
- $this->assign('dep_id', $dep);
- $this->assign('dep_list', $depList);
- $this->assign('order_type_list', $order_type);
- $this->assign('mode', $mode);
- $this->assign('send_user_num', $this->model->sendUserNum($mode, $this->orgId));
- $this->assign('user_list', (new \app\common\model\WorkTypeMode())->getRolesUserByNum($mode, $this->orgId,1));
- $this->assign('address_list', $address);
- $this->assign('address_id', '');
- if ($mode == 3) {
- $address = (new \app\common\model\Address())->getListByType(2);
- $conveyCate = (new \app\common\model\ConveyCate());
- $priority = $conveyCate->priority;
- $order_convey = $conveyCate->getList();
- $order_device = (new \app\common\model\ConveyDevice())->getList();
- $this->assign('address', $address);
- $this->assign('priority', $priority);
- $this->assign('order_convey_type', $order_convey);
- $this->assign('order_device', $order_device);
- }
- if ($id > 0) {
- // $phoneInfo = Db::name('phone_monitor_record')
- // ->where('id', $id)
- // ->find();
- $this->assign('address_id', 0);
- // $depId = Db::name('user_dep')
- // ->where('user_id', $phoneInfo['user_id'])
- // ->value('dep_id');
- $this->assign('dep_id', 0);
- }
- $two_dispatch_roles = model('user')->get_two_dispatch_role($this->orgId, $mode);
- $this->assign('dispatch_roles', $two_dispatch_roles);
- $this->assign('dispatch_type', check_two_dispatch($this->userId));
- $this->assign('two_dispatch_off', two_dispatch_off($this->orgId));
- $this->assign('id', $id);
- if ($mode == 3) {
- return $this->fetch('dispatch_add3');
- }
- else {
- return $this->fetch('dispatch_add');
- }
- }
- }
- }
- //调度查看订单详情
- public function detail2($id) {
- if (!$id) {
- $this->error('参数错误');
- }
- $type = input('type/d',0);
- $this->assign('type', $type);
- $order = Db::name('orders')->where(['id' => $id])->find();
- $order = $this->model->formatOrder($order, 1);
- $order['images'] = !empty($order['images']) ? explode(',', $order['images']) : '';
- $is_ch = 0;
- if($order['order_mode'] == 4){
- $todoInfo = Db::name('todo')->where('order_id',$order['id'])->where('del',0)->where('todo_mode','>',1)->find();
- if(!$todoInfo){
- $is_ch = 1;
- }
- }
- $order['is_ch'] = $is_ch;
- if($order['work_type_mode'] == 3){
- // 地点路径
- $conveyends = Db::name('order_convey_end')
- ->alias('a')
- ->join('address b','b.id = a.addr')
- ->where('a.order_id',$id)
- ->order('a.id asc')
- ->field('a.*,b.title')
- ->select();
- $order['ends'] = $conveyends?$conveyends:[];
- }
- $this->assign('info', $order);
- $workTypeName = $this->getTableField('work_type_mode', ['id' => $order['work_type_mode']], 'name');
- $this->assign('meta_title', $workTypeName . '订单详情');
- $level2 = check_two_dispatch($this->userId);
- $level1 = check_is_dispatch($this->userId);
- $turnoff = two_dispatch_off($this->orgId);
- $this->assign('level1', $level1);
- $this->assign('level2', $level2);
- $this->assign('turnoff', $turnoff);
- $this->assign('dispatch_type', $level2);
- $this->assign('org_auto_send',(new \app\common\model\Config())
- ->getConfig('org_auto_send',$this->orgId));
- return $this->fetch();
- }
- public function zg_detail($id) {
- if (!$id) {
- $this->error('参数错误');
- }
- $type = input('type/d',0);
- $this->assign('type', $type);
- $order = Db::name('orders')->where(['id' => $id])->find();
- $order = $this->model->formatOrder($order, 1);
- $order['images'] = !empty($order['images']) ? explode(',', $order['images']) : '';
- $this->assign('info', $order);
- $workTypeName = $this->getTableField('work_type_mode', ['id' => $order['work_type_mode']], 'name');
- $this->assign('meta_title', $workTypeName . '订单详情');
- $level2 = check_two_dispatch($this->userId);
- $level1 = check_is_dispatch($this->userId);
- $turnoff = two_dispatch_off($this->orgId);
- $this->assign('level1', $level1);
- $this->assign('level2', $level2);
- $this->assign('turnoff', $turnoff);
- $this->assign('dispatch_type', $level2);
- return $this->fetch();
- }
- public function print($id) {
- if (!$id) {
- $this->error('参数错误');
- }
- $type = input('type/d',0);
- $this->assign('type', $type);
- $order = Db::name('orders')->where(['id' => $id])->find();
- $order = $this->model->formatOrder($order, 1);
- $order['images'] = !empty($order['images']) ? explode(',', $order['images']) : '';
- $this->assign('info', $order);
- $workTypeName = $this->getTableField('work_type_mode', ['id' => $order['work_type_mode']], 'name');
- $this->assign('meta_title', $workTypeName . '订单详情');
- $level2 = check_two_dispatch($this->userId);
- $level1 = check_is_dispatch($this->userId);
- $turnoff = two_dispatch_off($this->orgId);
- $this->assign('level1', $level1);
- $this->assign('level2', $level2);
- $this->assign('turnoff', $turnoff);
- $this->assign('dispatch_type', $level2);
- return $this->fetch();
- }
- //派单
- public function send($id, $mode = 1) {
- if (request()->isGet()) {
- $this->assign('id', $id);
- $this->assign('mode', $mode);
- $orders = Db::name('orders')
- ->where('id',$id)
- ->find();
- if($orders['source_type']==4 && $orders['work_type_mode']==0 && $orders['is_deal']==0){//一键呼叫
- $order_type = (new \app\common\model\OrderType())->getList();
- $address = (new \app\common\model\Address())->getListByType(1);
- $this->assign('order_type_list', $order_type);
- $this->assign('address_list', $address);
- $order_repair = Db::name('order_repair')
- ->where('order_id', $id)
- ->find();
- $this->assign('order_repair', $order_repair);
- $workType = Db::name('work_type_mode')
- ->where('type',1)
- ->select();
- $config = Db::name('config')
- ->where('name','web_order_transfer_type')
- ->value('value');
- if(empty($config)){
- $workType = [];
- }else{
- $ll = explode('|',$config);
- foreach ($workType as $kk=>$vv){
- if(!in_array($vv['id'],$ll)){
- unset($workType[$kk]);
- }
- }
- }
- foreach ($workType as $k=>$v){
- $this->assign('send_user_num'.$v['id'], $this->model->sendUserNum($v['id'], $this->orgId));
- $this->assign('user_list'.$v['id'], (new \app\common\model\WorkTypeMode())->getRolesUserByNum($v['id'], $this->orgId, 1));
- $two_dispatch_roles = model('user')->get_two_dispatch_role($this->orgId, $v['id']);
- $this->assign('dispatch_roles'.$v['id'], $two_dispatch_roles);
- }
- $this->assign('dispatch_type', check_two_dispatch($this->userId));
- $this->assign('two_dispatch_off', two_dispatch_off($this->orgId));
- $this->assign('workType', $workType);
- $this->assign('orders', $orders);
- $address = (new \app\common\model\Address())->getListByType(2);
- $conveyCate = (new \app\common\model\ConveyCate());
- $priority = $conveyCate->priority;
- $order_convey = $conveyCate->getList();
- $order_device = (new \app\common\model\ConveyDevice())->getList();
- $this->assign('address', $address);
- $this->assign('priority', $priority);
- $this->assign('order_convey_type', $order_convey);
- $this->assign('order_device', $order_device);
- $oCid = Db::name('order_convey')
- ->where('order_id',$id)
- ->find();
- $opt = Db::name('order_convey_patient')
- ->where('order_id',$id)
- ->find();
- $this->assign('ocid',$oCid);
- $this->assign('opt',$opt);
- $this->assign('ps',empty($opt)?1:0);
- $auths = [1,2,3,4,15,0];
- if(!is_admin($this->userId)){
- $auth = get_dispatch_auth($this->userId);
- if($auth){
- $auths = array_intersect($auths,$auth);
- if($mode > 0){
- $auths = array_intersect($auths,[$mode]);
- }
- }else{
- $auths = [];
- }
- }
- $this->assign('auths',$auths);
- return $this->fetch('yjhj_send');
- }else{
- if ($mode == 1) {
- $order_type = (new \app\common\model\OrderType())->getList();
- $address = (new \app\common\model\Address())->getListByType(1);
- $this->assign('order_type_list', $order_type);
- $this->assign('address_list', $address);
- $order_repair = Db::name('order_repair')
- ->where('order_id', $id)
- ->find();
- $this->assign('order_repair', $order_repair);
- }
- $this->assign('send_user_num', $this->model->sendUserNum($mode, $this->orgId));
- $this->assign('user_list', (new \app\common\model\WorkTypeMode())->getRolesUserByNum($mode, $this->orgId, 1));
- $two_dispatch_roles = model('user')->get_two_dispatch_role($this->orgId, $mode);
- $this->assign('dispatch_roles', $two_dispatch_roles);
- $this->assign('dispatch_type', check_two_dispatch($this->userId));
- $this->assign('two_dispatch_off', two_dispatch_off($this->orgId));
- return $this->fetch();
- }
- }
- else {
- $data = request()->post();
- $data['org_id'] = $this->orgId;
- $res = $this->model->send($id, $this->userId, $data);
- if (!$res) {
- $this->error($this->model->getError());
- }
- $this->success('操作成功');
- }
- }
- //转单
- public function zd_send($id, $mode = 1) {
- if (request()->isGet()) {
- $this->assign('id', $id);
- $this->assign('mode', $mode);
- $orders = Db::name('orders')
- ->where('id',$id)
- ->find();
- if($orders['source_type']==4 && $orders['is_deal']==0){//一键呼叫
- $order_type = (new \app\common\model\OrderType())->getList();
- $address = (new \app\common\model\Address())->getListByType(1);
- $this->assign('order_type_list', $order_type);
- $this->assign('address_list', $address);
- $order_repair = Db::name('order_repair')
- ->where('order_id', $id)
- ->find();
- $this->assign('order_repair', $order_repair);
- $workType = Db::name('work_type_mode')
- ->where('type',1)
- ->select();
- $config = Db::name('config')
- ->where('name','web_order_transfer_type')
- ->value('value');
- if(empty($config)){
- $workType = [];
- }else{
- $ll = explode('|',$config);
- foreach ($workType as $kk=>$vv){
- if(!in_array($vv['id'],$ll)){
- unset($workType[$kk]);
- }
- }
- }
- foreach ($workType as $k=>$v){
- $this->assign('send_user_num'.$v['id'], $this->model->sendUserNum($v['id'], $this->orgId));
- $this->assign('user_list'.$v['id'], (new \app\common\model\WorkTypeMode())->getRolesUser($v['id'], $this->orgId, 1));
- $two_dispatch_roles = model('user')->get_two_dispatch_role($this->orgId, $v['id']);
- $this->assign('dispatch_roles'.$v['id'], $two_dispatch_roles);
- }
- $this->assign('dispatch_type', check_two_dispatch($this->userId));
- $this->assign('two_dispatch_off', two_dispatch_off($this->orgId));
- $this->assign('workType', $workType);
- $this->assign('orders', $orders);
- $address = (new \app\common\model\Address())->getListByType(2);
- $conveyCate = (new \app\common\model\ConveyCate());
- $priority = $conveyCate->priority;
- $order_convey = $conveyCate->getList();
- $order_device = (new \app\common\model\ConveyDevice())->getList();
- $this->assign('address', $address);
- $this->assign('priority', $priority);
- $this->assign('order_convey_type', $order_convey);
- $this->assign('order_device', $order_device);
- $oCid = Db::name('order_convey')
- ->where('order_id',$id)
- ->find();
- $opt = Db::name('order_convey_patient')
- ->where('order_id',$id)
- ->find();
- $this->assign('ocid',$oCid);
- $this->assign('opt',$opt);
- $this->assign('ps',empty($opt)?1:0);
- $auths = [1,2,3,4,15,0];
- if(!is_admin($this->userId)){
- $auth = get_dispatch_auth($this->userId);
- if($auth){
- $auths = array_intersect($auths,$auth);
- if($mode > 0){
- $auths = array_intersect($auths,[$mode]);
- }
- }else{
- $auths = [];
- }
- }
- $this->assign('auths',$auths);
- return $this->fetch('yjhj_zd_send');
- }
- }
- else {
- $data = request()->post();
- $data['org_id'] = $this->orgId;
- $res = $this->model->zd_send($id, $data);
- if (!$res) {
- $this->error($this->model->getError());
- }
- $this->success('操作成功');
- }
- }
- //批量派单
- public function batchsend($id, $mode = 1) {
- if (request()->isGet()) {
- $this->assign('id', $id);
- $this->assign('mode', $mode);
- if ($mode == 1) {
- $order_type = (new \app\common\model\OrderType())->getList();
- $address = (new \app\common\model\Address())->getListByType(1);
- $this->assign('order_type_list', $order_type);
- $this->assign('address_list', $address);
- $order_repair = Db::name('order_repair')
- ->where('order_id', $id)
- ->find();
- $this->assign('order_repair', $order_repair);
- }
- $user = (new \app\common\model\WorkTypeMode())->getRolesUser($mode, $this->orgId, 1);
- $newUser = [];
- $pinyin = new Pinyin();
- foreach ($user as $k => $v) {
- foreach ($v['user'] as $k1 => $v1) {
- $v1['pinyin'] = $pinyin->abbr($v1['real_name'],PINYIN_KEEP_ENGLISH); //只保留汉字首字母 和 字母的首字母 //例如:'汉字sszz11' = hzs
- $newUser[] = $v1;
- }
- }
- $newUser = arraySequence($newUser,'pinyin');
- $mm = new \app\common\model\User();
- foreach ($newUser as $key => $value) {
- $nums = Db::name('todo')
- ->where(['to_user_id' => $value['id'], 'work_type_mode' => 3])
- ->where('create_yyyymmdd', date('Ymd'))
- ->where('todo_mode', 'in', [1, 2, 3])
- ->count();
- $newUser[$key]['nums'] = $nums;
- $addr = Db::name('order_convey')
- ->alias('cpr')
- ->join('todo os', 'cpr.order_id = os.order_id')
- ->join('orders ods', 'cpr.order_id = ods.id')
- ->join('address ca', 'ca.id = cpr.start')
- ->join('address cad', 'cad.id = cpr.end')
- ->field('os.todo_mode,ca.title as start_name,cad.title as end_name,os.create_time')
- ->where('os.to_user_id', $value['id'])
- ->where('os.del', 0)
- ->where('ods.del', 0)
- ->order('os.id desc')
- ->find();
- $newUser[$key]['title'] = '';
- $newUser[$key]['addr_time'] = '';
- if($addr){
- if(in_array($addr['todo_mode'],[1,2])){
- $newUser[$key]['title'] = $addr['start_name'];
- }else{
- $newUser[$key]['title'] = $addr['end_name'];
- }
- $newUser[$key]['addr_time'] = $addr['create_time'];
- }
- $u = Db::name('user')
- ->where('id',$value['id'])
- ->value('sex');
- $newUser[$key]['sex_name'] = isset($mm->sex[$u])?$mm->sex[$u]:"";
- }
- if($this->orgId==3){
- // echo "<pre/>";
- // print_r($newUser);
- // die();
- }
- $this->assign('user_list', $newUser);
- return $this->fetch();
- }
- else {
- $data = request()->post();
- $data['org_id'] = $this->orgId;
- if (empty($data['to_user_id'])) {
- $this->error('请选择执行人');
- }
- $data['to_user_id'] = implode(',', $data['to_user_id']);
- $res = $this->model->batchsend($id, $this->userId, $data);
- if (!$res) {
- $this->error($this->model->getError());
- }
- $this->success('操作成功');
- }
- }
- public function onesend($id, $mode = 1) {
- $data = request()->post();
- $data['org_id'] = $this->orgId;
- if (empty($data['to_user_id'])) {
- $this->error('请选择执行人');
- }
- // $data['to_user_id'] = implode(',', $data['to_user_id']);
- $res = $this->model->batchsend($id, $this->userId, $data);
- if (!$res) {
- $this->error($this->model->getError());
- }
- $this->success('操作成功');
- }
- //完成订单
- public function finish($id) {
- $res = $this->model->finish($id);
- if (!$res) {
- $this->error($this->model->getError());
- }
- $this->success('操作成功');
- }
- //批量完成订单
- public function batchfinish($id) {
- $res = $this->model->batchfinish($id);
- if (!$res) {
- $this->error($this->model->getError());
- }
- $this->success('操作成功');
- }
- //评价
- public function comment() {
- $id = input('id');
- $score = input('score');
- $content = input('content');
- if ($score <= 0 || $score > 5) {
- $this->error('参数错误');
- }
- $res = $this->model->addComment($id, $score, $content, $this->userId, $this->orgId);
- if (!$res) {
- $this->error($this->model->getError());
- }
- $this->success('操作成功');
- }
- public function phone() {
- $phone = input('phone','','trim');
- $fp = input('fp','','trim');
- $id = input('id/d',0,'trim');
- if($phone){
- $fp = $fp?base64_decode($fp):'';
- $md5 = md5($this->orgId.'|'.$fp);
- $ret = Db::name('phone_monitor_record')->where('md5',$md5)->find();
- if(!$ret){
- $id = Db::name('phone_monitor_record')->insertGetId([
- 'org_id' => $this->orgId,
- 'phone' => $phone,
- 'path' => $fp,
- 'md5' => $md5,
- 'create_time' => date('Y-m-d H:i:s')
- ]);
- }else{
- $id = $ret['id'];
- }
- }
- $worktype = [
- ['id' => 1, 'title' => '报修'],
- ['id' => 2, 'title' => '保洁'],
- ['id' => 3, 'title' => '运送'],
- ['id' => 4, 'title' => '应急'],
- ];
- $info = Db::name('phone_monitor_record')->where('id',$id)->find();
- if(!$info){
- halt('数据存储失败');
- }
- $this->assign('worktype', $worktype);
- $this->assign('info', $info);
- $this->assign('id', $id);
- return $this->fetch();
- }
- public function phoneAdd() {
- $id = input('id');
- $worktype = [
- ['id' => 1, 'title' => '报修'],
- ['id' => 2, 'title' => '保洁'],
- ['id' => 3, 'title' => '运送'],
- ['id' => 4, 'title' => '应急'],
- ];
- $info = Db::name('phone_monitor')
- ->where('id', $id)->find();
- if (!$info) {
- echo '负责人不存在', exit();
- }
- $info['real_name'] = Db::name('user')
- ->where('id', $info['user_id'])
- ->value('real_name');
- $info['dep'] = Db::name('user_dep')
- ->alias('a')
- ->join('dep b', 'a.dep_id=b.id')
- ->where('a.user_id', $info['user_id'])
- ->value('b.title');
- $this->assign('worktype', $worktype);
- $this->assign('info', $info);
- $this->assign('id', $id);
- return $this->fetch();
- }
- //运送调度订单列表
- public function convey() {
- set_time_limit(0);
- ini_set("memory_limit","1024M");
- $mode = input('mode', 1);
- if (request()->isAjax()) {
- //分页参数
- $length = input('rows', 10, 'intval'); //每页条数
- $page = input('page', 1, 'intval'); //第几页
- $start = ($page - 1) * $length; //分页开始位置
- //排序
- $sortRow = input('sidx', 'id', 'trim'); //排序列
- $sort = input('sord', 'desc', 'trim'); //排序方式
- $order = $sortRow . ' ' . $sort;
- $content = input('content', '', 'trim');
- if ($content) {
- $map[] = ['o.content', 'like', '%' . $content . '%'];
- }
- $dep_id = input('dep_id', '', 'trim');
- if ($dep_id != '') {
- $map[] = ['o.dep_id', '=', $dep_id];
- }
- $priority = input('priority', '', 'trim');
- if ($priority) {
- $map[] = ['oc.priority', '=', $priority];
- }
- $s = input('start', '', 'trim');
- $end = input('end', '', 'trim');
- if ($s) {
- $map[] = ['oc.start', '=', $start];
- }
- if ($end) {
- $map[] = ['oc.end', '=', $end];
- }
- $type = input('type', '', 'trim');
- if ($type) {
- $map[] = ['oc.type', '=', $type];
- }
- $xqtime = input('xqtime', '', 'trim');
- $ywctime = input('ywctime', '', 'trim');
- if ($xqtime) {
- $xqtimes = explode(' - ', $xqtime);
- $x1 = date('Ymd', strtotime($xqtimes[0]));
- $x2 = date('Ymd', strtotime($xqtimes[1]));
- $map[] = ['oc.xq_time', '>=', $x1];
- $map[] = ['oc.xq_time', '<=', $x2];
- }
- if ($ywctime) {
- $ywctimes = explode(' - ', $ywctime);
- $y1 = date('Ymd', strtotime($ywctimes[0]));
- $y2 = date('Ymd', strtotime($ywctimes[1]));
- $map[] = ['oc.ywc_time', '>=', $y1];
- $map[] = ['oc.ywc_time', '<=', $y2];
- }
- $map[] = ['o.del', '=', 0];
- $map[] = ['o.org_id', '=', $this->orgId];
- $map[] = ['o.work_type_mode', '=', 3];
- $map[] = ['o.order_mode', 'in', [1, 4]];
- $status = input('status', '', 'trim');
- $ysName = input('ysname', '');
- if ($ysName) {
- $orders = Db::name('todo')
- ->alias('t')
- ->where('t.org_id', $this->orgId)
- ->where('t.del', 0)
- ->where('t.work_type_mode', 3)
- ->where('t.todo_mode', [1, 2, 4])
- ->where('u.real_name', 'like', '%' . $ysName . '%')
- ->join('orders o', 'o.id = t.order_id')
- ->join('user u', 't.to_user_id = u.id')
- ->group('o.id')
- ->column('o.id');
- if ($orders) {
- $map[] = ['o.id', 'in', $orders];
- }
- else {
- $map[] = ['o.id', '=', 0];
- }
- }
- $map = empty($map) ? true : $map;
- //数据查询
- $lists = db($this->table)->alias('o')
- ->join('order_convey oc', 'oc.order_id=o.id')
- ->field('o.*,oc.type,oc.start,oc.end,oc.xq_time,oc.ywc_time,oc.device_id,oc.name,oc.phone,oc.priority')
- ->where($map)
- ->order(['o.order_mode' => 'asc', 'oc.xq_time' => 'desc'])
- ->select();
- $newret = [];
- $newret1 = [];
- $newret2 = [];
- $newret3 = [];
- $newret4 = [];
- foreach ($lists as $k => $v) {
- $v = $this->model->formatOrder($v);
- $v['bed_number'] = '';
- $ocp = Db::name('order_convey_patient')
- ->where('order_id', $v['id'])
- ->find();
- $v['bed_number'] = !empty($ocp)?$ocp['bed_number']:'';
- $todo = Db::name('todo')
- ->alias('t')
- ->where('t.order_id', $v['id'])
- ->join('user u', 'u.id = t.to_user_id')
- ->where('t.todo_mode', 'in', [1, 2, 3, 4])
- ->where('t.del', 0)
- ->field('u.real_name,t.create_time,t.confirm_time')
- ->order('t.id asc')
- ->select();
- $users = [];
- $confirmtime = '';
- foreach ($todo as $kk => $vv) {
- $users[] = $vv['real_name'];
- if (!$confirmtime && $vv['confirm_time']) {
- $confirmtime = $vv['confirm_time'];
- }
- else {
- if ($confirmtime && $vv['confirm_time'] && $vv['confirm_time'] < $confirmtime) {
- $confirmtime = $vv['confirm_time'];
- }
- }
- }
- $v['real_names'] = implode(',', $users);
- $v['confirm_time'] = $confirmtime;
- $last = strtotime($v['ywc_time']) - time();
- $v['last_time'] = $last > 0 ? round($last / 60) : 0;
- //是否有延时
- $v['delay'] = 0; // 0=未延迟 1=延迟
- $v['delay_diff'] = 0;
- $v['delay_reason'] = '';
- $delays = Db::name('order_delay')
- ->where('order_id', $v['id'])
- ->select();
- $delays = $delays ? $delays : [];
- foreach ($delays as $vv) {
- if ($vv['status'] == 0) {
- $v['delay'] = 1;
- $v['delay_reason'] = $this->gettablefield('delay_reason', ['id' => $vv['delay_reason_id']], 'title');
- $vv['diff'] = time() - strtotime($vv['start_time']);
- }
- $v['delay_diff'] += $vv['diff'];
- }
- $v['delay_diff'] = round($v['delay_diff'] / 60);
- if ($v['delay'] == 1) {
- $v['status'] = 3;
- } else {
- if ($v['order_mode'] == 1) {
- $v['status'] = 1;
- } else {
- $v['status'] = 2;
- }
- }
- $convey = Db::name('convey_cate')
- ->alias('oc')
- ->join('time ot', 'ot.id = oc.time_id')
- ->where('oc.id', $v['type'])
- ->field('ot.*')
- ->find();
- $createtime = strtotime($v['create_time']);
- $curtime = time();
- $ct = round(($curtime - $createtime) / 60);
- if ($ct < $convey['yy_time']) {
- $ss = 0;
- }
- else {
- if ($ct >= $convey['yy_time'] && $ct < $convey['bz_time']) {
- $ss = 1;
- }
- else {
- if ($ct >= $convey['bz_time'] && $ct < $convey['jg_time']) {
- $ss = 2;
- }
- else {
- if ($ct >= $convey['jg_time'] && $ct < $convey['wjjg_time']) {
- $ss = 3;
- }
- else {
- $ss = 4;
- }
- }
- }
- }
- $v['ss'] = $ss;
- $v['xtime'] = date('H:i', strtotime($v['xq_time']));
- $v['stime'] = $v['send_time'] ? date('H:i', strtotime($v['send_time'])) : "";
- $v['ctime'] = $v['confirm_time'] ? date('H:i', strtotime($v['confirm_time'])) : "";
- $v['priorityName'] = isset($this->model->priority[$v['priority']])?$this->model->priority[$v['priority']]:'';
- if ($status == 3 && $v['delay'] == 1) { //延时任务
- $newret[] = $v;
- $newret1[] = $v;
- }
- if ($status == 1 && $v['order_mode'] == 1) { //新任务
- $newret[] = $v;
- $newret2[] = $v;
- }
- if ($status == 2 && $v['order_mode'] == 4) { // 进行中
- $newret[] = $v;
- $newret3[] = $v;
- }
- if (!$status || !in_array($status, [1, 2, 3])) {
- $newret[] = $v;
- $newret4[] = $v;
- }
- $lists[$k] = $v;
- }
- if(!empty($newret)){
- //$newret = arraySequence($newret,'status');//返回数组中指定的一列
- // $newret1 = $newret1?arraySequence($newret1,'xtime','SORT_DESC'):[];
- // $newret3 = $newret3?arraySequence($newret3,'xtime','SORT_DESC'):[];
- // $newret4 = $newret4?arraySequence($newret4,'xtime','SORT_DESC'):[];
- // $newret = array_merge($newret2,$newret3,$newret4,$newret1);
- $all = [];
- $newret2 = $newret2?arraySequence($newret2,'status'):[];
- $newret3 = $newret3?arraySequence($newret3,'status'):[];
- //$newret4 = $newret4?arraySequence($newret4,'status'):[];
- $newret1 = $newret1?arraySequence($newret1,'status'):[];
- $newret2 = $newret2?arraySequence($newret2,'xtime','SORT_DESC'):[];
- $newret3 = $newret3?arraySequence($newret3,'xtime','SORT_DESC'):[];
- // $newret4 = $newret4?arraySequence($newret4,'xtime','SORT_DESC'):[];
- $newret1 = $newret1?arraySequence($newret1,'xtime','SORT_DESC'):[];
- foreach ($newret2 as $k=>$v){
- $all[] = $v;
- }
- foreach ($newret3 as $k=>$v){
- $all[] = $v;
- }
- foreach ($newret1 as $k=>$v){
- $all[] = $v;
- }
- $a1 = $a2 = $a3 = [];
- foreach ($newret4 as $k=>$v){
- if ($v['status'] == 3) { //延时任务
- $a1[] = $v;
- }
- if ($v['status'] == 1) { //新任务
- $a2[] = $v;
- }
- if ($v['status'] == 2) { // 进行中
- $a3[] = $v;
- }
- }
- $a1 = $a1?arraySequence($a1,'status'):[];
- $a2 = $a2?arraySequence($a2,'status'):[];
- $a3 = $a3?arraySequence($a3,'status'):[];
- $a1 = $a1?arraySequence($a1,'xtime','SORT_DESC'):[];
- $a2 = $a2?arraySequence($a2,'xtime','SORT_DESC'):[];
- $a3 = $a3?arraySequence($a3,'xtime','SORT_DESC'):[];
- // 预约类型-取15分钟后之前的订单
- $curtime15 = $curtime+60*15;
- foreach ($a2 as $k=>$v){
- if($v['priority'] !=4 && $v['xq_time'] < date('Y-m-d H:i:s',$curtime15) ){
- $all[] = $v;
- }
- }
- foreach ($a3 as $k=>$v){
- if($v['priority'] !=4 && $v['xq_time'] < date('Y-m-d H:i:s',$curtime15) ){
- $all[] = $v;
- }
- }
- foreach ($a1 as $k=>$v){
- if($v['priority'] !=4 && $v['xq_time'] < date('Y-m-d H:i:s',$curtime15) ){
- $all[] = $v;
- }
- }
- $newret= $all;
- }
- $sdd[] =['org_id','=',$this->orgId];
- $sdd[] =['del','=',0];
- $sdd[] =['work_type_mode','=',3];
- $sdd[] =['create_yyyymmdd','=',date('Ymd')];
- $dcl = Db::name('orders')
- ->where($sdd)
- ->where('order_mode',1)
- ->count();
- $ypf = Db::name('orders')
- ->where($sdd)
- ->where('order_mode',4)
- ->count();
- $ywc = Db::name('orders')
- ->where($sdd)
- ->where('order_mode','in',[5,6])
- ->count();
- $yqx = Db::name('orders')
- ->where($sdd)
- ->where('order_mode','in',[2,3])
- ->count();
- //数据返回
- $totalCount = count($newret);
- $totalPage = ceil($totalCount / $length);
- $result['dcl'] = $dcl;
- $result['ypf'] = $ypf;
- $result['ywc'] = $ywc;
- $result['yqx'] = $yqx;
- $result['page'] = $page;
- $result['total'] = $totalPage;
- $result['records'] = $totalCount;
- $result['rows'] = $newret;
- return json($result);
- }
- else {
- $mode_name = $this->getTableField('work_type_mode', ['id' => $mode], 'name');
- $order_type = (new \app\common\model\ConveyCate())->getList();
- $order_mode = Db::name('order_mode')
- ->select();
- $this->assign('order_type_list', $order_type);
- $this->assign('m_name', $mode_name);
- $this->assign('mode', $mode);
- $this->assign('order_mode_list', $order_mode);
- $this->assign('dispatch_type', check_two_dispatch($this->userId));
- $address = (new \app\common\model\Address())->getListByType(2);
- $this->assign('address', $address);
- $count = Db::name('todo')
- ->where('org_id', $this->orgId)
- ->where('del', 0)
- ->where('work_type_mode', 3)
- ->where('todo_mode', 4)
- ->count();
- $this->assign('count', $count);
- $info = Db::name('config')->where('name','org_order_refresh')
- ->find();
- $orgConfig = Db::name('config_org')
- ->where('config_id',$info['id'])
- ->where('org_id',$this->orgId)
- ->find();
- $value = $orgConfig?$orgConfig['value']:0;
- $this->assign('refresh',$value);
- $sxJg = (new Config())->getConfig('ys_auto_sx',$this->orgId);
- $this->assign('sxJg',$sxJg?$sxJg:30);
- return $this->fetch();
- }
- }
- //运送员状态
- public function conveystatus($id='') {
- if (request()->isAjax()) {
- //分页参数
- $length = input('rows', 10, 'intval'); //每页条数
- $page = input('page', 1, 'intval'); //第几页
- $start = ($page - 1) * $length; //分页开始位置
- //排序
- $sortRow = input('sidx', 'id', 'trim'); //排序列
- $sort = input('sord', 'desc', 'trim'); //排序方式
- $order = $sortRow . ' ' . $sort;
- $real_name = input('real_name', '');
- $map8 = [];
- if ($real_name) {
- $map8[] = ['real_name', 'like', '%'.$real_name.'%'];
- }
- $work = input('work', '');
- if ($work!='') {
- $map8[] = ['work', '=',$work];
- }
- $user = (new \app\common\model\WorkTypeMode())->getRolesUser(3, $this->orgId);
- $newUser = [];
- foreach ($user as $k => $v) {
- foreach ($v['user'] as $k1 => $v1) {
- $newUser[] = $v1['id'];
- }
- }
- $userIds1 = [];
- if($id){
- $ids = explode(',', $id);
- $map[] = ['order_id', 'in', $ids];
- $map[] = ['del', '=', 0];
- $map[] = ['org_id', '=', $this->orgId];
- $map[] = ['work_type_mode', '=', 3];
- $userIds = Db::name('todo')->where($map)->column('to_user_id');
- $userIds1 = $userIds?$userIds:[];
- $newUser = array_intersect($userIds1,$newUser);
- }
- if(empty($newUser)){
- $map8[] = ['id','=',0];
- }else{
- $map8[] = ['id','in',$newUser];
- }
- $mm = [];
- $group = input('group', '');
- if ($group) {
- $uid = Db::name('user_group_user')
- ->where('group_id',$group)
- ->column('user_id');
- if(!empty($uid)){
- $mm[] = ['id','in',$uid];
- }else{
- $mm[] = ['id','in',[-1]];
- }
- }
- $lists = db('user')
- ->where($mm)
- ->where($map8)
- ->limit($start, $length)
- ->order($order)
- ->select();
- foreach ($lists as $key => $value) {
- $lists[$key]['user_group_title'] = Db::name('user_group')
- ->alias('ug')
- ->join('user_group_user ugu','ugu.group_id=ug.id')
- ->where('ugu.user_id',$value['id'])
- ->value('ug.title');
- $nums = Db::name('todo')
- ->where(['to_user_id' => $value['id'], 'work_type_mode' => 3])
- ->where('create_yyyymmdd', date('Ymd'))
- ->where('todo_mode', 'in', [1, 2, 3])
- ->count();
- $lists[$key]['nums'] = $nums;
- $addr = Db::name('order_convey')
- ->alias('cpr')
- ->join('todo os', 'cpr.order_id = os.order_id')
- ->join('orders ods', 'cpr.order_id = ods.id')
- ->join('address ca', 'ca.id = cpr.start')
- ->join('address cad', 'cad.id = cpr.end')
- ->field('os.todo_mode,ca.title as start_name,cad.title as end_name,os.create_time')
- ->where('os.to_user_id', $value['id'])
- ->where('os.del', 0)
- ->where('ods.del', 0)
- ->order('os.id desc')
- ->find();
- $lists[$key]['title'] = '';
- $lists[$key]['addr_time'] = '';
- if($addr){
- if(in_array($addr['todo_mode'],[1,2])){
- $lists[$key]['title'] = $addr['start_name'];
- }else{
- $lists[$key]['title'] = $addr['end_name'];
- }
- $lists[$key]['addr_time'] = $addr['create_time'];
- }
- $lists[$key]['worktxt'] = $value['work'] == 1 ? '上班' : '下班';
- $lists[$key]['stationtxt'] = $value['station'] == 1 ? '驻守' : '取消驻守';
- }
- //数据返回
- // $totalCount = db('user')
- // ->where($map1)->count();
- $totalCount = db('user')
- ->where($map8)->count();
- $totalPage = ceil($totalCount / $length);
- $result['page'] = $page;
- $result['total'] = $totalPage;
- $result['records'] = $totalCount;
- $result['rows'] = $lists;
- return json($result);
- }
- else {
- $group = model('UserGroup')->getList();
- $this->assign('group', $group);
- $this->assign('id', $id);
- return $this->fetch();
- }
- }
- //上下班
- public function work($id) {
- $user = Db::name('user')
- ->where('id', $id)
- ->find();
- $value = $user['work'] == 1 ? 0 : 1;
- $res = Db::name('user')
- ->where('id', $id)
- ->update(['work' => $value, 'update_time' => getTime()]);
- $res ? $this->success('操作成功') : $this->error('操作失败');
- }
- //驻守
- public function station($id) {
- $user = Db::name('user')
- ->where('id', $id)
- ->find();
- $value = $user['station'] == 1 ? 0 : 1;
- $res = Db::name('user')
- ->where('id', $id)
- ->update(['station' => $value, 'update_time' => getTime()]);
- $res ? $this->success('操作成功') : $this->error('操作失败');
- }
- //驳回工单列表
- public function bhTodoList() {
- if (request()->isAjax()) {
- $length = input('rows', 10, 'intval'); //每页条数
- $page = input('page', 1, 'intval'); //第几页
- $start = ($page - 1) * $length; //分页开始位置
- $map[] = ['todo.org_id', '=', $this->orgId];
- $map[] = ['todo.del', '=', 0];
- $map[] = ['todo.todo_mode', '=', 4];
- $map[] = ['todo.work_type_mode', '=', 3];
- $totalCount = Db::name('todo')
- ->alias('todo')
- ->join('orders orders', 'orders.id = todo.order_id')
- ->join('order_convey oc', 'oc.order_id = orders.id')
- ->join('user u', 'u.id = todo.to_user_id')
- ->where($map)
- ->count();
- $totalPage = ceil($totalCount / $length);
- $ret = Db::name('todo')
- ->alias('todo')
- ->join('orders orders', 'orders.id = todo.order_id')
- ->join('order_convey oc', 'oc.order_id = orders.id')
- ->join('user u', 'u.id = todo.to_user_id')
- ->field('orders.*,u.real_name as to_real_name,oc.type,oc.start,oc.end,oc.xq_time,oc.ywc_time,oc.device_id,oc.name,oc.phone,oc.priority,todo.nodo_reason,todo.id,todo.reject_time')
- ->order('oc.xq_time', 'desc')
- ->where($map)
- ->limit($start, $length)
- ->select();
- foreach ($ret as $k => $v) {
- $ret[$k]['start_name'] = $this->gettablefield('address', array('id' => $v['start']), 'title');
- $ret[$k]['end_name'] = $this->gettablefield('address', array('id' => $v['end']), 'title');
- $ret[$k]['type_name'] = $this->gettablefield('convey_cate', array('id' => $v['type']), 'title');
- $ret[$k]['real_name'] = $this->gettablefield('user', array('id' => $v['user_id']), 'real_name');
- $ret[$k]['device_name'] = '';
- if ($v['device_id'] > 0) {
- $ret[$k]['device_name'] = $this->gettablefield('convey_device', array('id' => $v['device_id']), 'title');
- }
- $last = strtotime($v['ywc_time']) - time();
- $ret[$k]['last_time'] = $last > 0 ? round($last / 60) : 0;
- $ret[$k]['reject_time'] = $v['reject_time'] ? date('Y-m-d h:i', strtotime($v['reject_time'])) : '';
- }
- $result['page'] = $page;
- $result['total'] = $totalPage;
- $result['records'] = $totalCount;
- $result['rows'] = $ret;
- return json($result);
- }
- else {
- return $this->fetch();
- }
- }
- //excel导出
- public function export($mode) {
- set_time_limit(0);
- ini_set("memory_limit", "1024M");
- $meta_title = '订单列表';
- if ($mode == 1) {
- $meta_title = '报修' . $meta_title;
- }
- elseif ($mode == 2) {
- $meta_title = '保洁' . $meta_title;
- }
- elseif ($mode == 3) {
- $meta_title = '运送' . $meta_title;
- }
- elseif ($mode == 4) {
- $meta_title = '应急' . $meta_title;
- }
- elseif ($mode == 15) {
- $meta_title = '品质整改' . $meta_title;
- }elseif ($mode == -1) {
- $meta_title = '一键呼叫' . $meta_title;
- }
- $level1 = check_is_dispatch($this->userId);
- $level2 = check_two_dispatch($this->userId);
- $turnoff = two_dispatch_off($this->orgId);
- $quality_type = input('quality_type','');
- if (request()->isGet()) {
- //排序
- $sortRow = input('sidx', 'a.id', 'trim'); //排序列
- $sort = input('sord', 'desc', 'trim'); //排序方式
- $order = $sortRow . ' ' . $sort;
- $content = input('content', '', 'trim');
- if ($content) {
- $map[] = ['a.content', 'like', '%' . $content . '%'];
- }
- $dep_id = input('dep_id', '', 'trim');
- if ($dep_id != '') {
- $map[] = ['a.dep_id', '=', $dep_id];
- }
- $order_mode = input('order_mode', '', 'trim');
- $map6 = [];
- if ($order_mode != '') {
- if($level1 && $turnoff && $mode != 15){ // 一级调度且二级调度开关开着,品质整改例外
- if ($order_mode == 1) {
- $map[] = ['a.is_deal', '=', 0];
- }else if ($order_mode == 4) {
- $map6[] = ['a.is_deal', '=', 1];
- }
- }
- if($order_mode==100){//已挂起
- $gq = Db::name('todo')
- ->where('work_type_mode',1)
- ->where('todo_mode',2)
- ->where('pause',1)
- ->column('order_id');
- if(empty($gq)){
- $map[] = ['a.id', '=', -1];
- }else{
- $map[] = ['a.id', 'in', $gq];
- }
- }else{
- $map[] = ['a.order_mode', '=', $order_mode];
- }
- }
- $b = input('start', '', 'trim');
- $e = input('end', '', 'trim');
- if ($b) {
- // $b = date('Ymd', strtotime($b));
- // $map[] = ['a.create_yyyymmdd', '>=', $b];
- $map[] = ['a.create_time', '>=', $b];
- }
- if ($e) {
- // $e = date('Ymd', strtotime($e));
- // $map[] = ['a.create_yyyymmdd', '<=', $e];
- $map[] = ['a.create_time', '<=', $e];
- }
- $map[] = ['a.del', '=', 0];
- $map[] = ['a.org_id', '=', $this->orgId];
- if($mode==-1){
- $map[] = ['a.source_type', '=', 4];
- }
- $type = input('type', '', 'trim');
- $oids = [];
- if ($type != '') {
- $map1[] = ['parent_id', '=', $type];
- $type_id = Db::name('order_type')
- ->where($map1)
- ->where('org_id', $this->orgId)
- ->where('enable', 1)
- ->column('id');
- if (!empty($type_id)) {
- $map3[] = ['type_id', 'in', $type_id];
- $ids = Db::name('order_repair')
- ->where($map3)
- ->column('order_id');
- if (!empty($ids)) {
- $oids = $ids;
- }
- else {
- $oids = [];
- }
- }
- else {
- $oids = [];
- }
- }
- $typeName = input('typeName', '', 'trim');
- if ($typeName != '') {
- $map_11[] = ['a.title', 'like', '%'.$typeName.'%'];
- $typeNameId = Db::name('convey_cate')
- ->alias('a')
- ->join('order_convey b','a.id=b.type')
- ->where($map_11)
- ->where('a.org_id', $this->orgId)
- ->where('a.enable', 1)
- ->where('a.del', 0)
- ->column('b.order_id');
- if (!empty($typeNameId)) {
- $map[] = ['a.id', 'in', $typeNameId];
- }
- else {
- $map[] = ['a.id', '=', -1];
- }
- }
- if($level2 && $turnoff){ // 二级调度
- $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)) {
- $map[] = ['a.id', '=', -1];
- } else {
- if($type != ''){
- $oids = array_intersect($oids,$ids);
- if($oids){
- $map[] = ['a.id', 'in', $oids];
- }else{
- $map[] = ['a.id', '=', -1];
- }
- }else{
- $map[] = ['a.id', 'in', $ids];
- }
- }
- }else{
- if($type != ''){
- if($oids){
- $map[] = ['a.id', 'in', $oids];
- }else{
- $map[] = ['a.id', '=', 0];
- }
- }
- }
- if($mode == 15){ // 品质检查,单独处理
- $map[] = ['a.work_type_mode','=',$mode];
- if($quality_type !=''){
- $map[] = ['a.quality_type','=',$quality_type];
- }
- }else{
- $work_type_mode = input('work_type_mode','','trim');
- if(!is_admin($this->userId)){
- $auth = get_dispatch_auth($this->userId);
- if($auth){
- $map[] = ['a.work_type_mode', 'in', $auth];
- if($mode > 0){
- $map[] = ['a.work_type_mode', '=', $mode];
- }else{
- if($work_type_mode!=''){
- $map[] = ['a.work_type_mode','=',$work_type_mode];
- }
- }
- }else{
- $map[] = ['a.work_type_mode', '=', -1];
- }
- }else{
- if($mode > 0){
- $map[] = ['a.work_type_mode', '=', $mode];
- }else{
- if($work_type_mode!=''){
- $map[] = ['a.work_type_mode','=',$work_type_mode];
- }
- }
- }
- }
- $sn = input('sn', '', 'trim');
- if ($sn) {
- $map[] = ['a.sn', 'like', '%' . $sn . '%'];
- }
- $from = input('from', '', 'trim');
- if ($from) {
- if($from >3){
- $map[] = ['a.from','=',0];
- $map[] = ['a.work_type_mode','=',$from-3];
- }else{
- $map[] = ['a.from','=',$from];
- }
- }
- $dep_cate = input('dep_cate', '', 'trim');
- if ($dep_cate != '') {
- $depIds = Db::name('dep')
- ->where('org_id',$this->orgId)
- ->where('cate_id',$dep_cate)
- ->where('del',0)
- ->column('id');
- if(!empty($depIds)){
- $map[] = ['a.dep_id', 'in', $depIds];
- }else{
- $map[] = ['a.dep_id', '=', -1];
- }
- }
- $priority = input('priority', '', 'trim');
- if($priority !=''){
- $map[] = ['b.priority', '=',$priority];
- }
- $sddr = input('saddr','','trim');
- if($sddr !=''){
- $map[] = ['b.start','=',$sddr];
- }
- $eddr = input('eaddr','','trim');
- if($eddr !=''){
- $map[] = ['b.end','=',$eddr];
- }
- $map = empty($map) ? true : $map;
- //数据查询
- if($mode==3){
- $lists = db($this->table)->where($map)
- ->alias('a')
- ->leftJoin('order_convey b','a.id=b.order_id')
- ->leftJoin('address ad','b.start=ad.id')
- ->leftJoin('address ade','b.end=ade.id')
- ->leftJoin('convey_cate cc','b.type=cc.id')
- ->leftJoin('convey_device cd','b.device_id=cd.id')
- ->leftJoin('dep dp','a.dep_id=dp.id')
- // ->leftJoin('dep_cate dc','dp.cate_id=dc.id')
- ->leftJoin('order_mode om','a.order_mode=om.id')
- ->field('a.*,om.in_content as order_mode_text,dp.title as dep,cd.title as device_name,cc.title as type_name,b.priority,ad.title as start_name,ade.title as end_name')
- ->whereOr($map6)
- ->order($order)->select();
- foreach ($lists as $k => $v) {
- // $lists[$k] = $this->model->newFormatOrder($v);
- $lists[$k]['priority'] = isset($this->model->priority[$v['priority']])?$this->model->priority[$v['priority']]:"";
- $lists[$k]['task_priority'] = $v['priority']==3?2:0;
- $lists[$k]['source_type_text'] =$v['from']>0? isset($this->model->source_type[$v['from']])?$this->model->source_type[$v['from']]:'':$this->getTableField('work_type_mode', ['id' => $v['work_type_mode']], 'name');
- if ($turnoff && $level1 && $v['order_mode'] == 1 && $v['is_deal'] == 1) {
- $lists[$k]['order_mode_text'] = '已派发';
- }
- }
- }else{
- $lists = db($this->table)->where($map)
- ->alias('a')
- ->leftJoin('order_convey b','a.id=b.order_id')
- ->field('a.*,b.priority')
- ->whereOr($map6)
- ->order($order)->select();
- foreach ($lists as $k => $v) {
- $lists[$k] = $this->model->newFormatOrder($v);
- $lists[$k]['priority'] = isset($this->model->priority[$v['priority']])?$this->model->priority[$v['priority']]:"";
- if ($turnoff && $level1 && $v['order_mode'] == 1 && $v['is_deal'] == 1) {
- $lists[$k]['order_mode_text'] = '已派发';
- }
- }
- }
- include_once env('root_path') . '/extend/phpexcel/Classes/PHPExcel.php';
- //实例化PHPExcel类
- $objPHPExcel = new \PHPExcel();
- //激活当前的sheet表
- $objPHPExcel->setActiveSheetIndex(0);
- //设置表格头(即excel表格的第一行)
- if ($mode == 1) {
- $objPHPExcel->setActiveSheetIndex(0)
- ->setCellValue('A1', '编号')
- ->setCellValue('B1', '申请时间')
- ->setCellValue('C1', '内容')
- ->setCellValue('D1', '所在科室/部门')
- ->setCellValue('E1', '报修类型')
- ->setCellValue('F1', '状态')
- ->setCellValue('G1', '紧急程度')
- ->setCellValue('H1', '来源');
- }
- else {
- if ($mode == 3) {
- $objPHPExcel->setActiveSheetIndex(0)
- ->setCellValue('A1', '编号')
- ->setCellValue('B1', '申请时间')
- ->setCellValue('C1', '开始地点')
- ->setCellValue('D1', '结束地点')
- ->setCellValue('E1', '运送类型')
- ->setCellValue('F1', '任务备注')
- ->setCellValue('G1', '所在科室/部门')
- ->setCellValue('H1', '状态')
- ->setCellValue('I1', '来源')
- ->setCellValue('J1', '优先级');
- }
- else {
- if($mode==0){
- $objPHPExcel->setActiveSheetIndex(0)
- ->setCellValue('A1', '编号')
- ->setCellValue('B1', '申请时间')
- ->setCellValue('C1', '内容')
- ->setCellValue('D1', '所在科室/部门')
- ->setCellValue('E1', '状态')
- ->setCellValue('F1', '订单类型')
- ->setCellValue('G1', '来源');
- }else{
- if($mode==15){
- $objPHPExcel->setActiveSheetIndex(0)
- ->setCellValue('A1', '编号')
- ->setCellValue('B1', '申请时间')
- ->setCellValue('C1', '内容')
- ->setCellValue('D1', '所在科室/部门')
- ->setCellValue('E1', '状态')
- ->setCellValue('F1', '来源')
- ->setCellValue('H1', '部门分类');
- }else{
- $objPHPExcel->setActiveSheetIndex(0)
- ->setCellValue('A1', '编号')
- ->setCellValue('B1', '申请时间')
- ->setCellValue('C1', '内容')
- ->setCellValue('D1', '所在科室/部门')
- ->setCellValue('E1', '状态')
- ->setCellValue('F1', '来源');
- }
- }
- }
- }
- // 设置表格头水平居中
- $objPHPExcel->setActiveSheetIndex(0)->getStyle('A1')->getAlignment()
- ->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
- $objPHPExcel->setActiveSheetIndex(0)->getStyle('B1')->getAlignment()
- ->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
- $objPHPExcel->setActiveSheetIndex(0)->getStyle('C1')->getAlignment()
- ->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
- $objPHPExcel->setActiveSheetIndex(0)->getStyle('D1')->getAlignment()
- ->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
- $objPHPExcel->setActiveSheetIndex(0)->getStyle('E1')->getAlignment()
- ->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
- $objPHPExcel->setActiveSheetIndex(0)->getStyle('F1')->getAlignment()
- ->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
- $objPHPExcel->setActiveSheetIndex(0)->getStyle('G1')->getAlignment()
- ->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
- $objPHPExcel->setActiveSheetIndex(0)->getStyle('H1')->getAlignment()
- ->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
- //设置列水平居中
- $objPHPExcel->setActiveSheetIndex(0)->getStyle('A')->getAlignment()
- ->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
- $objPHPExcel->setActiveSheetIndex(0)->getStyle('B')->getAlignment()
- ->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
- $objPHPExcel->setActiveSheetIndex(0)->getStyle('C')->getAlignment()
- ->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
- $objPHPExcel->setActiveSheetIndex(0)->getStyle('D')->getAlignment()
- ->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
- $objPHPExcel->setActiveSheetIndex(0)->getStyle('E')->getAlignment()
- ->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
- $objPHPExcel->setActiveSheetIndex(0)->getStyle('F')->getAlignment()
- ->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
- $objPHPExcel->setActiveSheetIndex(0)->getStyle('G')->getAlignment()
- ->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
- $objPHPExcel->setActiveSheetIndex(0)->getStyle('H')->getAlignment()
- ->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
- //设置单元格宽度
- $objPHPExcel->setActiveSheetIndex(0)->getColumnDimension('A')->setWidth(10);
- $objPHPExcel->setActiveSheetIndex(0)->getColumnDimension('B')->setWidth(20);
- $objPHPExcel->setActiveSheetIndex(0)->getColumnDimension('C')->setWidth(20);
- $objPHPExcel->setActiveSheetIndex(0)->getColumnDimension('D')->setWidth(20);
- $objPHPExcel->setActiveSheetIndex(0)->getColumnDimension('E')->setWidth(20);
- $objPHPExcel->setActiveSheetIndex(0)->getColumnDimension('F')->setWidth(50);
- $objPHPExcel->setActiveSheetIndex(0)->getColumnDimension('G')->setWidth(20);
- $objPHPExcel->setActiveSheetIndex(0)->getColumnDimension('H')->setWidth(20);
- //循环刚取出来的数组,将数据逐一添加到excel表格。
- if ($mode == 1) {
- for ($i = 0; $i < count($lists); $i++) {
- $objPHPExcel->getActiveSheet()->setCellValue('A' . ($i + 2), $lists[$i]['sn']);
- $objPHPExcel->getActiveSheet()->setCellValue('B' . ($i + 2), $lists[$i]['create_time']);
- $objPHPExcel->getActiveSheet()->setCellValue('C' . ($i + 2), $lists[$i]['content']);
- $objPHPExcel->getActiveSheet()->setCellValue('D' . ($i + 2), $lists[$i]['dep']);
- $objPHPExcel->getActiveSheet()->setCellValue('E' . ($i + 2), $lists[$i]['order_type']);
- $objPHPExcel->getActiveSheet()->setCellValue('F' . ($i + 2), $lists[$i]['order_mode_text']);
- $objPHPExcel->getActiveSheet()->setCellValue('G' . ($i + 2), $lists[$i]['repair_priority']);
- $objPHPExcel->getActiveSheet()->setCellValue('H' . ($i + 2), $lists[$i]['source_type_text']);
- }
- }
- else {
- if ($mode == 3) {
- for ($i = 0; $i < count($lists); $i++) {
- $objPHPExcel->getActiveSheet()->setCellValue('A' . ($i + 2), $lists[$i]['sn']);
- $objPHPExcel->getActiveSheet()->setCellValue('B' . ($i + 2), $lists[$i]['create_time']);
- $objPHPExcel->getActiveSheet()->setCellValue('C' . ($i + 2), $lists[$i]['start_name']);
- $objPHPExcel->getActiveSheet()->setCellValue('D' . ($i + 2), $lists[$i]['end_name']);
- $objPHPExcel->getActiveSheet()->setCellValue('E' . ($i + 2), $lists[$i]['type_name']);
- $objPHPExcel->getActiveSheet()->setCellValue('F' . ($i + 2), $lists[$i]['content']);
- $objPHPExcel->getActiveSheet()->setCellValue('G' . ($i + 2), $lists[$i]['dep']);
- $objPHPExcel->getActiveSheet()->setCellValue('H' . ($i + 2), $lists[$i]['order_mode_text']);
- $objPHPExcel->getActiveSheet()->setCellValue('I' . ($i + 2), $lists[$i]['source_type_text']);
- $objPHPExcel->getActiveSheet()->setCellValue('J' . ($i + 2), $lists[$i]['priority']);
- }
- }
- else {
- if($mode==0){
- for ($i = 0; $i < count($lists); $i++) {
- $objPHPExcel->getActiveSheet()->setCellValue('A' . ($i + 2), $lists[$i]['sn']);
- $objPHPExcel->getActiveSheet()->setCellValue('B' . ($i + 2), $lists[$i]['create_time']);
- $objPHPExcel->getActiveSheet()->setCellValue('C' . ($i + 2), $lists[$i]['content']);
- $objPHPExcel->getActiveSheet()->setCellValue('D' . ($i + 2), $lists[$i]['dep']);
- $objPHPExcel->getActiveSheet()->setCellValue('E' . ($i + 2), $lists[$i]['order_mode_text']);
- $objPHPExcel->getActiveSheet()->setCellValue('F' . ($i + 2), $lists[$i]['work_type_mode_text']);
- $objPHPExcel->getActiveSheet()->setCellValue('G' . ($i + 2), $lists[$i]['source_type_text']);
- }
- }else{
- if($mode==15){
- for ($i = 0; $i < count($lists); $i++) {
- $objPHPExcel->getActiveSheet()->setCellValue('A' . ($i + 2), $lists[$i]['sn']);
- $objPHPExcel->getActiveSheet()->setCellValue('B' . ($i + 2), $lists[$i]['create_time']);
- $objPHPExcel->getActiveSheet()->setCellValue('C' . ($i + 2), $lists[$i]['content']);
- $objPHPExcel->getActiveSheet()->setCellValue('D' . ($i + 2), $lists[$i]['dep']);
- $objPHPExcel->getActiveSheet()->setCellValue('E' . ($i + 2), $lists[$i]['order_mode_text']);
- $objPHPExcel->getActiveSheet()->setCellValue('F' . ($i + 2), $lists[$i]['source_type_text']);
- $objPHPExcel->getActiveSheet()->setCellValue('G' . ($i + 2), $lists[$i]['quality_cate_name']);
- }
- }else{
- for ($i = 0; $i < count($lists); $i++) {
- $objPHPExcel->getActiveSheet()->setCellValue('A' . ($i + 2), $lists[$i]['sn']);
- $objPHPExcel->getActiveSheet()->setCellValue('B' . ($i + 2), $lists[$i]['create_time']);
- $objPHPExcel->getActiveSheet()->setCellValue('C' . ($i + 2), $lists[$i]['content']);
- $objPHPExcel->getActiveSheet()->setCellValue('D' . ($i + 2), $lists[$i]['dep']);
- $objPHPExcel->getActiveSheet()->setCellValue('E' . ($i + 2), $lists[$i]['order_mode_text']);
- $objPHPExcel->getActiveSheet()->setCellValue('F' . ($i + 2), $lists[$i]['source_type_text']);
- }
- }
- }
- }
- }
- //设置保存的Excel表格名称
- $filename = $meta_title . '_' . date('YmdHis', time()) . '.xls';
- //设置当前激活的sheet表格名称
- $objPHPExcel->getActiveSheet()->setTitle($meta_title);
- //设置浏览器窗口下载表格
- ob_end_clean();
- header("Content-Type: application/force-download");
- header("Content-Type: application/octet-stream");
- header("Content-Type: application/download");
- header('Content-Disposition:inline;filename="' . $filename);
- //生成excel文件
- $objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
- //下载文件在浏览器窗口
- return $objWriter->save('php://output');
- }
- }
- public function rejectTodoList(){
- $orderId = input('orderId',0);
- if (request()->isAjax()) {
- $length = input('rows', 10, 'intval'); //每页条数
- $page = input('page', 1, 'intval'); //第几页
- $start = ($page - 1) * $length; //分页开始位置
- $map[] = ['org_id','=',$this->orgId];
- $map[] = ['del','=',0];
- $map[] = ['todo_mode','=',4];
- $map[] = ['order_id','=',$orderId];
- $lists = Db::name('todo')
- ->where($map)
- ->limit($start,$length)
- ->order('id desc')
- ->select();
- $workTypeMode = [
- '0'=>'一键呼叫',
- '1'=>'报修',
- '2'=>'保洁',
- '3'=>'运送',
- '4'=>'应急',
- ];
- foreach ($lists as $k=>$v){
- $lists[$k]['to_user_name'] = Db::name('user')->where('id',$v['to_user_id'])->value('real_name');
- $lists[$k]['work_type_mode_text'] = $workTypeMode[$v['work_type_mode']];
- $lists[$k]['todo_mode_in_content'] = Db::name('todo_mode')->where('id',$v['todo_mode'])->value('in_content');
- $lists[$k]['todo_mode_color'] = Db::name('todo_mode')->where('id',$v['todo_mode'])->value('color');
- }
- $totalCount = Db::name('todo')
- ->where($map)
- ->count();
- $totalPage = ceil($totalCount / $length);
- $result['page'] = $page;
- $result['total'] = $totalPage;
- $result['records'] = $totalCount;
- $result['rows'] = $lists;
- return json($result);
- }
- else {
- $this->assign('orderId',$orderId);
- return $this->fetch();
- }
- }
- public function orderRefreshOff(){
- $info = Db::name('config')->where('name','org_order_refresh')
- ->find();
- $orgConfig = Db::name('config_org')
- ->where('config_id',$info['id'])
- ->where('org_id',$this->orgId)
- ->find();
- if($orgConfig){
- $value = $orgConfig['value']==1?0:1;
- $res = Db::name('config_org')
- ->where('config_id',$info['id'])
- ->where('org_id',$this->orgId)
- ->update(['value'=>$value]);
- }else{
- $value = 1;
- $res = Db::name('config_org')
- ->insertGetId([
- 'config_id'=>$info['id'],
- 'org_id'=>$this->orgId,
- 'value'=>$value,
- ]);
- }
- $res?$this->success('操作成功','',['status'=>$value]):$this->error('操作失败');
- }
- public function print1($id){
- $order = Db::name('orders')->where(['id' => $id])->find();
- $depName = Db::name('dep')
- ->where('id',$order['dep_id'])
- ->value('title');
- $info['depName'] = $depName;
- $info['create_time'] = $order['create_time'];
- $users = Db::name('todo')
- ->alias('t')
- ->join('user u','u.id=t.to_user_id')
- ->where('t.order_id',$order['id'])
- ->column('u.real_name');
- $info['users'] = $users?implode(',',$users):'';
- $info['content'] = $order['content'];
- $info['cons'] = [];
- $tList = Db::name('todo')
- ->where('order_id',$order['id'])
- ->select();
- $total = $totalPrice = 0;
- $signs = [];
- foreach ($tList as $k=>$v){
- if($v['sign']){
- $signs[] = $v['sign'];
- }
- $mate = Db::name('todo_mate_item')
- ->alias('tmi')
- ->join('todo_mate tm','tmi.todo_mate_id = tm.id')
- ->join('mate_goods mg','mg.id = tmi.items_id')
- ->field('tmi.items_id,tmi.total,tmi.money,tmi.total_money,mg.title')
- ->where('tm.todo_id',$v['id'])
- ->select();
- if(!empty($mate)){
- foreach ($mate as $kk=>$todo_mate){
- $info['cons'][] = [
- 'title' =>$todo_mate['title'],
- 'total' =>$todo_mate['total'],
- 'money' =>$todo_mate['money'],
- 'total_money' =>$todo_mate['total_money'],
- ];
- $total +=$todo_mate['total'];
- $totalPrice +=$todo_mate['total_money'];
- }
- }
- }
- $aa = [
- 'title'=>'',
- 'total'=>'',
- 'money'=>'',
- 'total_money'=>'',
- ];
- if(empty($info['cons'])){
- for ($i=1;$i<=4;$i++){
- $info['cons'][] = $aa;
- }
- }elseif (count($info['cons']) <4){
- $ii = 4-count($info['cons']);
- for ($i=1;$i<=$ii;$i++){
- $info['cons'][] = $aa;
- }
- }
- $info['total'] = $total;
- $info['totalPrice'] = round($totalPrice,2);
- $info['signs'] = $signs;
- $this->assign('info', $info);
- return $this->fetch();
- }
- public function withdraw(){
- $id = input('id');
- $info = Db::name('orders')
- ->where('id',$id)
- ->where('del',0)
- ->where('order_mode',4)
- ->find();
- if(!$info){
- $this->error('参数错误');
- }
- $saveOrder = Db::name('orders')
- ->where('id',$id)
- ->update(['order_mode'=>1,'withdraw_time'=>getTime()]);
- $saveTodo = Db::name('todo')
- ->where('order_id',$id)
- ->update(['del'=>1]);
- $todoIds = Db::name('todo')
- ->where('order_id',$id)
- ->where('todo_mode',1)
- ->column('id');
- $task = Db::name('task')
- ->where('type',1)
- ->whereIn('bus_id',$todoIds)
- ->delete();
- if($info['work_type_mode'] == 3){
- Db::name('order_convey_end')->where('order_id',$info['id'])->setField('del',0);
- }
- if(!$saveOrder){
- $this->error('操作失败');
- }
- $this->success('操作成功');
- }
- public function autoSend($id,$form=0) {
- if(request()->isGet() && $form==0){
- $order_type = (new \app\common\model\OrderType())->getList();
- $order_repair = Db::name('order_repair')
- ->where('order_id', $id)
- ->find();
- $this->assign('order_repair', $order_repair);
- $this->assign('order_type_list',$order_type);
- $this->assign('id',$id);
- return $this->fetch();
- }else{
- $type_id = input('type_id/d','');
- if(!empty($type_id)){
- $old = Db::name('order_repair')
- ->where('order_id', $id)
- ->find();
- $rData['type_id'] = $type_id;
- if ($old) {
- $rData['update_time'] = getTime();
- Db::name('order_repair')
- ->where('order_id', $id)
- ->update($rData);
- }
- else {
- $rData['order_id'] = $id;
- Db::name('order_repair')
- ->insert($rData);
- }
- }
- $res = $this->model->autoSend($id);
- if (!$res) {
- $this->error($this->model->getError());
- }
- $this->success('操作成功');
- }
- }
- public function setType($id) {
- if(request()->isGet()){
- $order_type = (new \app\common\model\OrderType())->getList();
- $order_repair = Db::name('order_repair')
- ->where('order_id', $id)
- ->find();
- $this->assign('order_repair', $order_repair);
- $this->assign('order_type_list',$order_type);
- $this->assign('id',$id);
- return $this->fetch();
- }else{
- $type_id = input('type_id/d','');
- if(empty($type_id)){
- $this->error('请选择报修事项');
- }
- $old = Db::name('order_repair')
- ->where('order_id', $id)
- ->find();
- $rData['type_id'] = $type_id;
- if ($old) {
- $rData['update_time'] = getTime();
- $r = Db::name('order_repair')
- ->where('order_id', $id)
- ->update($rData);
- }
- else {
- $rData['order_id'] = $id;
- $r = Db::name('order_repair')
- ->insert($rData);
- }
- $r?$this->success('操作成功'):$this->error('操作失败');
- }
- }
- public function batchSb(){
- $id = input('ids',[]);
- if(!$id){
- $this->error('参数错误');
- }
- $res = db('user')->where('id','in',$id)->setField('work',1);
- if($res){
- $this->success('操作成功');
- }else{
- $this->error('操作失败');
- }
- }
- public function batchXb(){
- $id = input('ids',[]);
- if(!$id){
- $this->error('参数错误');
- }
- $res = db('user')->where('id','in',$id)->setField('work',0);
- if($res){
- $this->success('操作成功');
- }else{
- $this->error('操作失败');
- }
- }
- public function getTime(){
- $type = input('type');
- $start = input('start');
- $v = Db::name('convey_cate')
- ->where('id',$type)
- ->where('enable',1)
- ->where('del',0)
- ->find();
- if($v['time_id'] > 0){
- $time = Db::name('time')
- ->where('id',$v['time_id'])
- ->find();
- $v['xq_time'] = $start?$start:date('Y-m-d H:i');
- $v['ywc_time'] = date('Y-m-d H:i',strtotime($v['xq_time']) + 60*$time['bz_time']);
- }else{
- $v['xq_time'] = $start?$start:date('Y-m-d H:i');
- $v['ywc_time'] = '';
- }
- $this->success('','',$v);
- }
- }
|