zgg 2 月之前
父節點
當前提交
721c37d8a9

+ 2 - 2
.gitignore

@@ -1,6 +1,6 @@
 /.idea
 /.vscode
 *.log
-.env
+.env.example
 .DS_Store
-/.env
+/.env.example

+ 53 - 0
application/admin/controller/PhBalanceWarning.php

@@ -0,0 +1,53 @@
+<?php
+namespace app\admin\controller;
+
+use think\App;
+use think\Db;
+use think\Exception;
+
+class PhBalanceWarning extends Auth
+{
+
+    public function index(){
+        if(request()->isAjax()){
+            //分页参数
+            $length = input('rows',10,'intval');   //每页条数
+            $page = input('page',1,'intval');      //第几页
+            $start = ($page - 1) * $length;     //分页开始位置
+            //排序
+            $sortRow = input('sidx','u.id','trim');      //排序列
+            $sort = input('sord','desc','trim');        //排序方式
+
+            $map[] = ['org_id','=',$this->orgId];
+
+            $b = input('begin','','trim');
+            $e = input('end','','trim');
+            if($b!=''){
+                $map[] = ['end','>=',$b];
+            }
+
+            if($e!=''){
+                $map[] = ['end','<=',$e];
+            }
+
+            $map= empty($map) ? true: $map;
+            //数据查询
+            $list = Db::name('ph_balance_warning')
+                ->where($map)
+                ->limit($start,$length)
+                ->order('id desc')
+                ->select();
+
+            //数据返回
+            $totalCount = Db::name('ph_balance_warning')->where($map)->count();
+            $totalPage = ceil($totalCount/$length);
+            $result['page'] = $page;
+            $result['total'] = $totalPage;
+            $result['records'] = $totalCount;
+            $result['rows'] = $list;
+            return json($result);
+        }else{
+            return $this->fetch();
+        }
+    }
+}

+ 139 - 0
application/admin/controller/PhUser.php

@@ -0,0 +1,139 @@
+<?php
+
+namespace app\admin\controller;
+use app\common\model\WorkerBalance;
+use think\App;
+use think\Db;
+use think\Exception;
+
+class PhUser extends Auth {
+    public function __construct(App $app = null) {
+        parent::__construct($app);
+        $this->model = new \app\common\model\PhUser();
+        $this->table = 'ph_user';
+    }
+    public function index() {
+        if (request()->isAjax()) {
+            //分页参数
+            $length = input('rows',10,'intval');   //每页条数
+            $page = input('page',1,'intval');      //第几页
+            $start = ($page - 1) * $length;     //分页开始位置
+            $name = input('name','','trim');
+            if ($name != '') {
+                $ids =Db::name('user')
+                    ->alias('a')
+                    ->join('user_org b','a.id = b.user_id')
+                    ->where('a.real_name','=',$name)
+                    ->where('b.org_id',$this->orgId)
+                    ->column('a.id');
+                $map[] = ['user','in',$ids];
+            }
+            $map[] = ['org_id','=',$this->orgId];
+            $map[] = ['del','=',0];
+            $map= empty($map) ? true: $map;
+            //数据查询
+            $user= Db::name('user')
+                ->alias('a')
+                ->join('user_org b','a.id = b.user_id')
+                ->where('b.org_id','=',$this->orgId)
+                ->where('a.del','=',0)
+                ->where('a.enable','=',1)
+                ->column('a.real_name','a.id');
+            $dep= Db::name('dep')
+                ->where('org_id','=',$this->orgId)
+                ->where('del','=',0)
+                ->where('enable','=',1)
+                ->column('title','id');
+            $list = Db::name($this->table)->where($map)->limit($start,$length)->order('id desc')->select();
+            foreach ($list as $k=>$v){
+                $list[$k]['userName'] = $user[$v['user']];
+                $depList = explode(',',$v['dep']);
+                foreach ($depList as $k1=>$v1){
+                   $depList[$k1] = $dep[$v1];
+                }
+                $list[$k]['depName'] = implode(',',$depList);
+            }
+            $totalCount = Db::name($this->table)->where($map)->count();
+            $totalPage = ceil($totalCount/$length);
+            $result['page'] = $page;
+            $result['total'] = $totalPage;
+            $result['records'] = $totalCount;
+            $result['rows'] = $list;
+            return json($result);
+        }
+        else {
+            return $this->fetch();
+        }
+    }
+    /**
+     * 新增/编辑
+     */
+    public function add($id = 0) {
+        $model = $this->model;
+        if (request()->isPost()) {
+            $res = $model->updates($this->orgId);
+            if ($res) {
+                $this->success('操作成功', url('index'));
+            }
+            else {
+                $this->error($model->getError());
+            }
+        }
+        else {
+            if ($id) {
+                $info = Db::name($this->table)->where('id',$id)->find();
+                $info['dep'] = explode(',',$info['dep']);
+                $this->assign('info', $info);
+            }
+            $depLisr = model('Dep')->getList();
+            $this->assign('depList', $depLisr);
+            $userList= Db::name('user')
+                ->alias('a')
+                ->join('user_org b','a.id = b.user_id')
+                ->where('b.org_id','=',$this->orgId)
+                ->where('a.del','=',0)
+                ->where('a.enable','=',1)
+                ->field('a.id,a.real_name as title')
+                ->select();
+            $this->assign('userList', $userList);
+            return $this->fetch();
+        }
+    }
+    /**
+     * 删除记录
+     * @param int $id
+     */
+    public function del($id = 0) {
+        if (!$id) {
+            $this->error('参数错误');
+        }
+        $res = db('user')->where('id', $id)->setField('del', 1);
+        if ($res) {
+            $this->success('删除成功');
+        }
+        else {
+            $this->error('删除失败');
+        }
+    }
+    /**
+     * 改变字段值
+     * @param int $fv
+     * @param string $fn
+     * @param int $fv
+     */
+    public function changeField($id = 0, $fn = '', $fv = 0) {
+        if (!$fn || !$id) {
+            $this->error('参数错误');
+        }
+        if ($fn == 'enable') {
+            $res = Db::name($this->table)->where('id', $id)->update([$fn => $fv]);
+        }
+        if ($res) {
+            $this->success('操作成功');
+        }
+        else {
+            $this->error('操作失败');
+        }
+    }
+
+}

+ 46 - 0
application/admin/view/common/multiselect2.html

@@ -0,0 +1,46 @@
+<style>
+
+</style>
+<div id="{$name}">
+    <input type="hidden" id="ele-{$name}" name="{$name}" :value="value.join(',')">
+    <el-select
+        v-model="value"
+        multiple
+        filterable
+        clearable
+        size="small"
+        style="width:100%"
+        placeholder="请选择"
+    >
+        <el-option
+                v-for="item in options"
+                :key="item.id"
+                :label="item.title"
+                :value="item.id.toString()">
+        </el-option>
+    </el-select>
+</div>
+<script>
+    new Vue({
+        el: '#{$name}',
+        data: function() {
+            return {
+                options: {:json_encode($lists)},
+                value: {:json_encode($val)}
+            }
+        },
+        watch: {
+            value: function (newVal, oldVal) {
+               $('#ele-{$name}').val(newVal.join(','));
+            }
+        },
+        created(){
+            const vals = this.value;
+            this.value = [];
+            vals.forEach((item) => {
+                this.value.push(item.toString());
+            })
+            console.log('11111',this.value,this.options);
+        }
+    })
+</script>

+ 49 - 0
application/admin/view/ph_balance_warning/detail.html

@@ -0,0 +1,49 @@
+{extend name="common/common2" /}
+{block name="main"}
+<div class="row">
+    <div class="col-sm-12">
+        <div class="ibox float-e-margins">
+            <div class="ibox-title">
+                <h5>{$meta_title}</h5>
+                <!--<div class="ibox-tools">-->
+                    <!--<a class="toback" href="{:url('index')}">-->
+                        <!--返回上一页-->
+                    <!--</a>-->
+                <!--</div>-->
+                <div class="ibox-tools">
+                    <a class="toback" href="{:url('export')}?id={$id}">
+                        导出
+                    </a>
+                </div>
+            </div>
+            <div class="ibox-content">
+             <table class="table-bordered table">
+                 <tr>
+                     <th>护工</th>
+                     <th>金额</th>
+                     <th>创建时间</th>
+                 </tr>
+                 {foreach $list as $k=>$v}
+                 <tr>
+
+                     <td>{$v.workName}</td>
+
+                     <td style="color: red;">{$v.money}</td>
+
+                     <td>{$v.create_time}</td>
+                 </tr>
+                 {/foreach}
+             </table>
+            </div>
+            <div>
+                {:htmlspecialchars_decode($page)}
+            </div>
+        </div>
+    </div>
+</div>
+{/block}
+{block name="script"}
+<script>
+
+</script>
+{/block}

+ 108 - 0
application/admin/view/ph_balance_warning/index.html

@@ -0,0 +1,108 @@
+{extend name="common/common2" /}
+{block name="main"}
+<div class="ibox">
+    <div class="ibox-content">
+        <div class="row">
+
+            <div class="col-xs-12" style="text-align: right;">
+                <form class="form-inline" id="form-search" action="{:url('index')}">
+                    <div class="input-group">
+                        <input type="text" id="date" readonly class="form-control" name="begin" placeholder="截至开始时间">
+                    </div>
+                    <div class="input-group">
+                        <input type="text" id="date1" readonly class="form-control" name="end" placeholder="截至结束时间">
+                    </div>
+                    <div class="input-group">
+                         <span class="input-group-btn">
+                            <button class="btn-sm btn-primary" type="button" id ="search-btn" ><i class="fa fa-search"></i></button>
+                        </span>
+                        &nbsp;
+                        <span class="input-group-btn">
+                            <button class="btn-sm btn-primary " type="button" id="search-clear"><i class="fa fa-undo"></i></button>
+                        </span>
+
+                    </div>
+                </form>
+            </div>
+        </div>
+
+    </div>
+    <div class="ibox-content">
+        <div class="jqGrid_wrapper">
+            <table id="table" style="border-collapse: collapse"></table>
+            <div id="pager"></div>
+        </div>
+    </div>
+</div>
+<script src="/static/layDate-v5.0.9/laydate.js"></script>
+{/block}
+{block name="script"}
+<script>
+    laydate.render({
+        elem: '#date',
+        //设置开始日期、日期日期的 input 选择器
+        //数组格式为 5.3.0 开始新增,之前版本直接配置 true 或任意分割字符即可
+        trigger: 'click' ,
+        theme: '#3C65F9',
+        type:'datetime'
+    });
+    laydate.render({
+        elem: '#date1',
+        //设置开始日期、日期日期的 input 选择器
+        //数组格式为 5.3.0 开始新增,之前版本直接配置 true 或任意分割字符即可
+        trigger: 'click' ,
+        theme: '#3C65F9',
+        type:'datetime'
+    });
+    $(function () {
+
+        $(window).bind("resize",function(){
+            var width=$(".jqGrid_wrapper").width();
+            $("#table").setGridWidth(width);
+        });
+
+        $.jgrid.defaults.styleUI="Bootstrap";
+        $("#table").jqGrid({
+            url:"{:url('index')}",
+            datatype: "json",
+            colModel:[
+                {label:'序号',name:'id',index:'id', width:30,sortable: false},
+                {label:'订单编号',name:'sn',index:'sn', width:50,sortable: false},
+                {label:'联系人',name:'contact',index:'contact', width:30,sortable: false},
+                {label:'联系电话',name:'phone',index:'phone', width:30,sortable: false},
+                {label:'预收金',name:'pre_money',index:'pre_money',width:30,editable: false,sortable: false},
+                {label:'已花费金额',name:'cost_money',index:'cost_money',width:30,editable: false,sortable: false},
+                {label:'开始时间',name:'start',index:'start',width:60,editable: false,sortable: false},
+                {label:'截至时间',name:'end',index:'end',width:60,editable: false,sortable: false},
+
+                // {label:'操作',width:100,sortable: false,formatter: function (a, b, c) {
+                //     var detail = "{:url('detail',[],'')}/id/"+c.id;
+                //
+                //         var btn = '<a url="'+detail+'" href="javascript:;" data-title="详情" onclick="layer_open(this,1)"><span class="label label-primary" title="详情">详情</span></a>&nbsp;';
+                //
+                //         return btn;
+                // }},
+            ],
+            rowNum:10,
+            rowList:[10,20,30,50,100],
+            pager: '#pager',
+            sortname: 'id',
+            viewrecords: true,
+            autowidth:true,
+            mtype: 'post',
+            height: 'auto',
+            emptyrecords: "暂无数据",
+            sortorder: "desc",
+            caption:"预警记录",
+            loadComplete: function (xhr) {
+                if(xhr.code==0){
+                    layer.msg(xhr.msg);
+                    return false;
+                }
+
+            },
+        });
+    });
+
+</script>
+{/block}

+ 6 - 0
application/admin/view/ph_orders/detail.html

@@ -129,6 +129,7 @@
                         <th>备注</th>
                         <th>状态</th>
                         <th>派发日期</th>
+                        <th>护工签名</th>
                         <th>操作</th>
                     </tr>
                     {volist name="info['todo']" id="v"}
@@ -146,6 +147,11 @@
                         </td>
                         <td>{$v.create_time}</td>
                         <td>
+                            {if condition="$v['sign']"}
+                            <img src="{$v['sign']}" onclick="open_img(this)" style="width: 30px;height: auto" alt="">
+                            {/if}
+                        </td>
+                        <td>
                             {if condition="!in_array($info['status'],[3,4])"}
                             <a href="javascript:;" url="{:url('PhOrders/editTodo',['id'=>$v['id']])}" data-title="编辑" onclick="layer_open(this,2)" class="btn btn-xs btn-warning">编辑</a>
                             {/if}

+ 98 - 0
application/admin/view/ph_user/add.html

@@ -0,0 +1,98 @@
+{extend name="common/common2" /}
+{block name="main"}
+<div class="row">
+    <div class="col-sm-12">
+        <div class="ibox float-e-margins">
+            <div class="ibox-content">
+                <form method="post" action="{:url('add')}" class="form-horizontal">
+                    <input type="hidden" name="id" value="{$info['id']|default='0'}">
+                    <div class="panel-body" style="min-height: 150px">
+                        <div class="form-group">
+                            <label class="col-sm-2 control-label">负责人<span style="color: red">*</span></label>
+                            <div class="col-sm-6">
+                                {:widget('common/select',['name'=>'user','lists'=>$userList,'value'=>isset($info)?$info.user:''])}
+                            </div>
+                        </div>
+                        <div class="form-group">
+                            <label class="col-sm-2 control-label">负责部门<span style="color: red">*</span></label>
+                            <div class="col-sm-6">
+                                {:widget('common/multiselect2',['name'=>'dep','lists'=>$depList,'val'=>isset($info)?$info.dep:[]])}
+                            </div>
+                        </div>
+                    </div>
+
+                    <div class="hr-line-dashed"></div>
+                    <div class="form-group" style="margin: 0 auto">
+                        <div class="col-sm-6 col-sm-offset-2">
+                            <button class="btn btn-primary ajax-post" data-layer_c="1" target-form="form-horizontal" type="submit">确 定</button>
+                            <button  class="btn cancel-btn btn-default" type="button">取 消</button>
+                        </div>
+                    </div>
+                </form>
+            </div>
+        </div>
+    </div>
+</div>
+{/block}
+{block name="script"}
+<script type="text/javascript" src="/static/layDate-v5.0.9/laydate.js"></script>
+
+<script>
+    $(document).ready(function(){
+    });
+    laydate.render({
+        elem: '#date',
+        type:'date',
+        trigger: 'click' ,
+        theme: '#337ab7',
+    });
+    function checkAll() {
+        var checkbox=document.getElementById('allInput');//获取div
+        var checked=checkbox.getElementsByTagName('input');//获取div下的input
+
+        var allCheck=document.getElementById('all');//获取div
+        var allChecked=allCheck.getElementsByTagName('input');//获取div下的input
+        for(i=0;i<checked.length;i++){
+            if(checked[i].className=='check'){
+                checked[i].checked = allChecked[0].checked;
+            }
+        }
+    }
+    $(function () {
+        var checkbox=document.getElementById('allInput');//获取div
+        var checked=checkbox.getElementsByTagName('input');//获取div下的input
+
+        $(document).on('click','.check',function () {
+            var all = false;
+            var count = 0;
+            for(i=0;i<checked.length;i++){
+                if(checked[i].className=='check'){
+                    if(checked[i].checked){
+                        all = true;
+                        count++;
+                    }
+                }
+            }
+
+            var allCheck=document.getElementById('all');//获取div
+            var allChecked=allCheck.getElementsByTagName('input');//获取div下的input
+            if(!all){
+                for(i=0;i<allChecked.length;i++){
+                    allChecked[i].checked = false;
+                }
+            }
+            if(all && parseInt(count)*2===checked.length){
+
+                for(i=0;i<allChecked.length;i++){
+                    allChecked[i].checked = true;
+                }
+            }
+            if(all && parseInt(count)*2!==checked.length){
+                for(i=0;i<allChecked.length;i++){
+                    allChecked[i].checked = false;
+                }
+            }
+        })
+    })
+</script>
+{/block}

+ 96 - 0
application/admin/view/ph_user/index.html

@@ -0,0 +1,96 @@
+{extend name="common/common2" /}
+{block name="main"}
+<div class="ibox">
+    <div class="ibox-content">
+        <div class="row">
+            <div class="col-xs-3">
+                <a href="javascript:;" url="{:url('add')}" data-title="新增" data-width="60%" data-height="60%" onclick="layer_open(this,1)" class="btn btn-sm btn-primary">新增</a>
+            </div>
+            <div class="col-xs-9" style="text-align: right;">
+                <form class="form-inline" id="form-search" action="{:url('index')}">
+                    <div class="input-group">
+                        <input type="text" class="form-control" name="name" placeholder="负责人">
+                    </div>
+                    <div class="input-group">
+                        <span class="input-group-btn">
+                            <button class="btn-sm btn-primary" type="button" id ="search-btn" ><i class="fa fa-search"></i></button>
+                        </span>
+                        &nbsp;
+                        <span class="input-group-btn">
+                            <button class="btn-sm btn-primary " type="button" id="search-clear"><i class="fa fa-undo"></i></button>
+                        </span>
+                    </div>
+                </form>
+            </div>
+        </div>
+
+    </div>
+    <div class="ibox-content">
+        <div class="jqGrid_wrapper">
+            <table id="table" style="border-collapse: collapse"></table>
+            <div id="pager"></div>
+        </div>
+    </div>
+</div>
+{/block}
+{block name="script"}
+<script>
+    $(function () {
+
+        $(window).bind("resize",function(){
+            var width=$(".jqGrid_wrapper").width();
+            $("#table").setGridWidth(width);
+        });
+
+        $.jgrid.defaults.styleUI="Bootstrap";
+        $("#table").jqGrid({
+            url:"{:url('index')}",
+            datatype: "json",
+            colModel:[
+                {label:'ID',name:'id',index:'id', width:30,sortable: false},
+                {label:'负责人',name:'userName',index:'userName',width:60,editable: false,sortable: false},
+                {label:'负责部门',name:'depName',index:'depName',width:600,editable: false,sortable: false},
+                {label:'状态',name:'enable',index:'enable',width:50,editable: false,sortable: false,formatter:function (a,b,c){
+                    if(a == 0){
+                        var url = "{:url('changeField',[],'')}/fn/enable/fv/1/id/"+c.id;
+                        return '<a href="'+url+'" class="ajax-get" data-table="1"><span class="label label-danger" title="禁用">禁用</span></a>';
+                    } else{
+                        var url = "{:url('changeField',[],'')}/fn/enable/fv/0/id/"+c.id;
+                        return '<a href="'+url+'" class="ajax-get" data-table="1"><span class="label label-primary" title="正常">正常</span></a>';
+                    }
+                }},
+                {label:'创建时间',name:'create_time',index:'create_time',width:80,editable: false,sortable: false},
+                {label:'操作',width:180,sortable: false,formatter: function (a, b, c) {
+                    var editurl = "{:url('add',[],'')}/id/"+c.id;
+                    var delurl = "{:url('del',[],'')}/id/"+c.id;
+
+                        var btn = '<a url="'+editurl+'" href="javascript:;" data-title="编辑" data-height="60%" data-width="60%"  onclick="layer_open(this,1)"><span class="label label-primary" title="编辑">编辑</span></a>&nbsp;';
+
+                        btn += '<a {if !btnAuth(session("user_auth.id"),"Worker/del")} style="display:none"{/if} href="'+delurl+'" class="confirm ajax-get" data-confirm="确定要删除此记录吗?" data-table="1"><span class="label label-danger" title="删除">删除</span></a>&nbsp;';
+
+
+                        return btn;
+                }},
+            ],
+            rowNum:10,
+            rowList:[10,20,30,50,100],
+            pager: '#pager',
+            sortname: 'id',
+            viewrecords: true,
+            autowidth:true,
+            mtype: 'post',
+            height: 'auto',
+            emptyrecords: "暂无数据",
+            sortorder: "desc",
+            caption:"管理人员列表",
+            loadComplete: function (xhr) {
+                if(xhr.code==0){
+                    layer.msg(xhr.msg);
+                    return false;
+                }
+            },
+        });
+    });
+
+</script>
+{/block}

+ 9 - 0
application/api/controller/h5/Worker.php

@@ -1,6 +1,7 @@
 <?php
 namespace app\api\controller\h5;
 
+use app\common\util\AppMsg;
 use app\hander\HelpHander;
 use think\Controller;
 use think\Db;
@@ -27,11 +28,19 @@ class Worker extends Base
 
     // 用户下单
     public function order(){
+        $depId = input('depId/d',0);
         $model = new \app\common\model\PhOrders();
         $res = $model->bookOrder();
         if(!$res){
             HelpHander::error($model->getError());
         }
+        $ids = Db::table('ph_user')
+            ->where('org_id',$this->orgId)
+            ->where('','exp',Db::raw("FIND_IN_SET($depId,dep)"))
+            ->column('user');
+        if (!empty($ids)) {
+            send_jpush($ids,AppMsg::PUSH_WORKER_ORDER_SEND,'有一个新的陪护订单,请注意查看',['id'=>$res]);
+        }
         HelpHander::success(['payId'=>$res],'操作成功');
     }
 

+ 54 - 3
application/api/controller/v1/PhOrders.php

@@ -35,7 +35,7 @@ class PhOrders extends Base
         $size = input('size',10);
         $status = input('status/d',-1);
         $model = new \app\common\model\PhOrders();
-        $res = $model->orderList1($this->orgId,$status,$page,$size);
+        $res = $model->orderList1($this->orgId,$this->userId,$status,$page,$size);
         HelpHander::success($res,'操作成功');
 
     }
@@ -43,7 +43,7 @@ class PhOrders extends Base
     public function detail(){
         $id = input('id/d','');
         $model = new \app\common\model\PhOrders();
-        $ret = $model->getInfo($id);
+        $ret = $model->getInfo($id,$this->orgId);
         HelpHander::success($ret,'操作成功');
     }
     //取消订单
@@ -101,11 +101,12 @@ class PhOrders extends Base
         $id = input('id/d',0);
         $remark = input('remark','','trim');
         $money = input('money/f',0);
+        $busType = input('busType/d',0);
         if($money <= 0){
             HelpHander::error('输入金额错误');
         }
 
-        $res = model('PhOrderPay')->addSaveDispatch($this->orgId,$id,$money,$remark);
+        $res = model('PhOrderPay')->addSaveDispatch($this->orgId,$id,$money,$remark,$busType);
         if($res){
             HelpHander::success([],'操作成功');
         }else{
@@ -135,4 +136,54 @@ class PhOrders extends Base
         HelpHander::success($pay,'成功');
     }
 
+    //护工签名
+    public function workerSign(){
+        $todoId = input('id/d',0);
+        $sign = input('img','');
+        if(!$sign){
+            HelpHander::error('未上传签名图');
+        }
+
+        $res = Db::name('ph_todo')
+            ->where('id',$todoId)
+            ->update([
+                'sign'=>$sign
+            ]);
+        if(!$res){
+            HelpHander::error('上传失败');
+        }
+        HelpHander::success([],'上传成功');
+    }
+
+    //员工余额记录
+    public function balanceRecord()
+    {
+        $page = input('page',1);
+        $size = input('size',10);
+        $id = Db::name('worker')
+            ->where('user_id',$this->userId)
+            ->value('id');
+        $list = Db::name('worker_balance')
+            ->where('org_id', $this->orgId)
+            ->where('worker_id', $id)
+            ->order('id', 'desc')
+            ->limit(($page-1)*$size,$size)
+            ->select();
+        foreach ($list as $k => $v) {
+            $list[$k]['userName'] = Db::name('user')
+                ->where('id', $v['user_id'])
+                ->value('real_name');
+            if ($v['type'] == 1) {
+                $list[$k]['type'] = '订单结算';
+            }else if ($v['type'] == 2) {
+                $list[$k]['type'] = '工资结算';
+            }else if ($v['type'] == 3) {
+                $list[$k]['type'] = '管理员增加';
+            }else{
+                $list[$k]['type'] = '管理员减少';
+            }
+        }
+        HelpHander::success($list);
+    }
+
 }

+ 55 - 6
application/common/model/PhOrders.php

@@ -596,7 +596,7 @@ class PhOrders extends Base
         Db::name('ph_orders_log')->insert($data);
     }
 
-    public function getInfo($id){
+    public function getInfo($id,$orgId=0){
         $info = $this->where('id',$id)->find()->toArray();
 
         $off = model('Config')->getConfig('ph_order_cancel_time',cur_org_id());
@@ -677,12 +677,39 @@ class PhOrders extends Base
             $pays = Db::name('ph_order_pay')->where('status',1)->where('bus_type',1)->where('order_id',$id)->select();
             $pays = $pays?$pays:[];
             $info['pays2'] = $pays;
+            $info['serviceFee'] = empty($pays)?0:1;
 
-            // 获取退款记录
-            $refunds = Db::name('ph_order_refund')->where('order_id',$id)->select();
+            // 获取预收金退款记录
+            $refunds = Db::name('ph_order_refund')
+                ->alias('a')
+                ->join('ph_order_pay b','a.pay_id = b.id')
+                ->where('b.status',1)
+                ->where('b.bus_type',0)
+                ->where('b.order_id',$id)
+                ->field('a.*')
+                ->select();
             $refunds = $refunds?$refunds:[];
             $info['refunds'] = $refunds;
 
+            // 获取服务费退款记录
+            $refunds2 = Db::name('ph_order_refund')
+                ->alias('a')
+                ->join('ph_order_pay b','a.pay_id = b.id')
+                ->where('b.status',1)
+                ->where('b.bus_type',1)
+                ->where('b.order_id',$id)
+                ->field('a.*')
+                ->select();
+            $refunds2 = $refunds2?$refunds2:[];
+            $info['refunds2'] = $refunds2;
+
+            //固定服务费金额
+            if ($orgId>0){
+                $serviceMoney = model("Config")->getConfig("web_service_money",$orgId);
+                $serviceMoney = floatval($serviceMoney) > 0? floatval($serviceMoney) : 0;
+                $info['serviceCharge'] = $serviceMoney;
+            }
+
         }
 
         return $info;
@@ -809,7 +836,7 @@ class PhOrders extends Base
 
 
     //调度订单列表
-    public function orderList1($orgId,$status,$page,$size){
+    public function orderList1($orgId,$userId,$status,$page,$size){
         $start = ($page - 1) * $size;
         if($status >= 0){
             if($status==2){
@@ -819,17 +846,38 @@ class PhOrders extends Base
                 $map[] = ['status','=',$status];
             }
         }
+        $depId = Db::name('ph_user')
+            ->where('enable',1)
+            ->where('del',0)
+            ->where('org_id',$orgId)
+            ->where('user',$userId)
+            ->value('dep');
+        $depId = explode(',',$depId);
+        if (!empty($depId)) {
+            $map[] = ['dep_id','in',$depId];
+        }else{
+            $map[] = ['dep_id','=',0];
+        }
         $map[] = ['org_id', '=', $orgId];
         $map[] = ['is_service', '=', 1];
 
         $list = $this->where($map)
             ->limit($start,$size)
-            ->field('id,sn,contact,phone,start,create_time')
+            ->field('id,sn,contact,phone,start,create_time,name,bed,price,dep_id')
             ->order('id','desc')
             ->select();
         $list = $list?$list->toArray():[];
         foreach ($list as $k=>$v){
-
+            $list[$k]['dep'] = Db::name('dep')->where('id',$v['dep_id'])->value('title');
+            $workerId = Db::name('ph_todo')->where('order_id',$v['id'])->column('worker_id');
+            foreach ($workerId as $k1=>$v1){
+                $workerId[$k1] = Db::name('worker')
+                    ->alias('a')
+                    ->join('user b','a.user_id=b.id')
+                    ->where('a.id',$v1)
+                    ->value('b.real_name');
+            }
+            $list[$k]['worker'] = implode(',',$workerId);
         }
         return $list;
     }
@@ -1337,6 +1385,7 @@ class PhOrders extends Base
         $todo['worker_name'] =  Db::name('user')
             ->where('id',$user_id)
             ->value('real_name');
+        $todo['sign'] = $todo['sign']?$todo['sign']:'';
         $orderInfo = $this->getInfo($todo['order_id']);
         unset($orderInfo['todo']);
         $orderInfo['todo'][] = $todo;

+ 48 - 0
application/common/model/PhUser.php

@@ -0,0 +1,48 @@
+<?php
+namespace app\common\model;
+
+use app\hander\HelpHander;
+use think\Db;
+use think\Exception;
+use tools\Idcard;
+
+class PhUser extends Base
+{
+    public function updates($orgId){
+        $data = request()->post();
+        if(!$data['user']){
+            $this->error = '请选择负责人';
+            return false;
+        }
+        if(!$data['dep']){
+            $this->error = '请选择负责部门';
+            return false;
+        }
+        $id = $data['id'];
+        unset($data['id']);
+        Db::startTrans();
+        try{
+            if($id > 0){
+                $res = $this->where('id',$id)
+                    ->update($data);
+                if(!$res){
+                    \exception('更新失败');
+                }
+
+            }else{
+                $data['org_id'] = $orgId;
+                $data['create_time'] = date('Y-m-d H:i:s');
+                $ret = $this->allowField(true)->insert($data);
+                if(!$ret){
+                    \exception('操作失败');
+                }
+            }
+            Db::commit();
+            return true;
+        }catch (Exception $e){
+            Db::rollback();
+            $this->error = $e->getMessage();
+            return false;
+        }
+    }
+}

+ 52 - 0
application/cron/PhBalanceWarning.php

@@ -0,0 +1,52 @@
+<?php
+namespace app\cron;
+
+use think\Db;
+use yunwuxin\cron\Task;
+
+class PhBalanceWarning extends Task
+{
+    public function configure()
+    {
+        $this->dailyAt('00:00'); //每天执行一次
+    }
+
+    /**
+     * 执行任务
+     * @return mixed
+     */
+    protected function execute()
+    {
+        try{
+            $this->record();
+        }catch (\Exception $e){
+            trace($e->getMessage());
+        }
+
+    }
+
+    //生成预警记录
+    public function record(){
+        $list = Db::name('ph_orders')
+            ->where('status',1)
+            ->field('org_id,sn,start,price,pre_money,contact,phone')
+            ->order('id desc')
+            ->select();
+        foreach ($list as $k=>$v){
+            $time = strtotime(date('Y-m-d 00:00:00')) - strtotime($v['start']);
+            $day =  round($time/(60*60*24),1);
+            $costMoney = round($v['price'] * $day,2);
+            $list[$k]['cost_money'] = $costMoney;
+            $list[$k]['end'] = date('Y-m-d 00:00:00');
+            unset($list[$k]['price']);
+        }
+        foreach ($list as $k=>$v){
+            if ($v['cost_money'] > $v['pre_money']){
+                $data[] = $v;
+            }
+        }
+        if (!empty($data)){
+            Db::name('ph_balance_warning')->insertAll($data);
+        }
+    }
+}

+ 1 - 0
config/cron.php

@@ -22,5 +22,6 @@ return [
         \app\cron\ConveyCron::class,
         \app\cron\Wlps::class,
         \app\cron\MateReport::class,
+        \app\cron\PhBalanceWarning::class,
     ]
 ];

+ 2 - 2
thinkphp/library/think/App.php

@@ -180,8 +180,8 @@ class App extends Container
         $this->instance('app', $this);
 
         // 加载环境变量配置文件
-        if (is_file($this->rootPath . '.env')) {
-            $this->env->load($this->rootPath . '.env');
+        if (is_file($this->rootPath . '.env.example')) {
+            $this->env->load($this->rootPath . '.env.example');
         }
 
         $this->configExt = $this->env->get('config_ext', '.php');