添加网站文件
This commit is contained in:
340
application/api/controller/Webmaster.php
Normal file
340
application/api/controller/Webmaster.php
Normal file
@@ -0,0 +1,340 @@
|
||||
<?php
|
||||
namespace app\api\controller;
|
||||
use app\api\logic\WebmasterLogic;
|
||||
use app\common\server\UrlServer;
|
||||
use think\Db;
|
||||
class Webmaster extends ApiBase
|
||||
{
|
||||
public $like_not_need_login = ['staffList','Leaveapproval','leavethroug','leavethroug','reject','punishlists','punishthroug','punishreject','material','materialthroug','materialreject','Scheduling','occupy','occupy_del'];
|
||||
|
||||
/**
|
||||
* note 获取站长下面的员工
|
||||
* create_time 2020/10/21 19:05
|
||||
*/
|
||||
|
||||
public function staffList(){
|
||||
$param = $this->request->get();
|
||||
$data = Db::name('staff')
|
||||
->alias('s1')
|
||||
->field('s1.*, s2.*')
|
||||
->where('s1.id', $param['id'])
|
||||
->where('s2.onwork',1)
|
||||
->join('staff s2', 's1.grouping_id = s2.grouping_id')
|
||||
->select();
|
||||
$this->_success('获取数据成功', $data);
|
||||
}
|
||||
/**
|
||||
* note 请假审批
|
||||
* create_time 2020/10/21 19:05
|
||||
*/
|
||||
public function Leaveapproval(){
|
||||
$param = $this->request->get();
|
||||
$data = Db::name('staff')
|
||||
->alias('s1')
|
||||
->field('s1.*, s2.*')
|
||||
->where('s1.id', $param['id'])
|
||||
->where('s2.onwork',1)
|
||||
->join('staff s2', 's1.grouping_id = s2.grouping_id')
|
||||
->select();
|
||||
if($data){
|
||||
$ids = array_column($data, 'id');
|
||||
$leave=Db::name('leavesd')
|
||||
->whereIN('staff_id',$ids)
|
||||
->where('status',$param['status'])
|
||||
->order('id', 'asc')
|
||||
->page($param['page'], $param['limt'])
|
||||
->select();
|
||||
|
||||
foreach ($leave as &$item){
|
||||
$item['time']=date('Y-m-d',$item['time']);
|
||||
$item['create_time']=date('Y-m-d H:i:s',$item['create_time']);
|
||||
|
||||
}
|
||||
$this->_success('获取数据成功', $leave);
|
||||
}else{
|
||||
$this->_error('获取数据失败');
|
||||
}
|
||||
}
|
||||
/**
|
||||
* note 请假审批通过
|
||||
* create_time 2020/10/21 19:05
|
||||
*/
|
||||
public function leavethroug(){
|
||||
$param = $this->request->post();
|
||||
$data=Db::name('leavesd')->where('id',$param['id'])->update(['status'=>1]);
|
||||
$this->_success('审批成功');
|
||||
}
|
||||
/**
|
||||
* note 驳回请假
|
||||
* create_time 2020/10/21 19:05
|
||||
*/
|
||||
public function reject(){
|
||||
$param = $this->request->post();
|
||||
$data=Db::name('leavesd')->where('id',$param['id'])->update(['status'=>2,'refuse'=>$param['refuse']]);
|
||||
$this->_success('修改成功');
|
||||
}
|
||||
/**
|
||||
* note 处罚的列表
|
||||
* create_time 2020/10/21 19:05
|
||||
*/
|
||||
public function punishlists(){
|
||||
$param = $this->request->get();
|
||||
$data = Db::name('staff')
|
||||
->alias('s1')
|
||||
->field('s1.*, s2.*')
|
||||
->where('s1.id', $param['id'])
|
||||
->where('s2.onwork',1)
|
||||
->join('staff s2', 's1.grouping_id = s2.grouping_id')
|
||||
->select();
|
||||
if($data){
|
||||
$ids = array_column($data, 'id');
|
||||
$punish=Db::name('fine')
|
||||
->whereIN('staff_id',$ids)
|
||||
->where('status',$param['status'])
|
||||
->order('id', 'asc')
|
||||
->page($param['page'], $param['limt'])
|
||||
->select();
|
||||
foreach($punish as &$item){
|
||||
$item['create_time']=date("Y-m-d H:i:s");
|
||||
$user=Db::name('order_exe')->where('id',$item['order_id'])->find();
|
||||
$item['user_name']=$user['name'];
|
||||
$item['user_phone']=$user['phone'];
|
||||
$order=Db::name('order')->where('order_sn',$user['order_sn'])->find();
|
||||
$item['user_adder']=$order['address'];
|
||||
$staff=Db::name('staff')->where('id',$item['staff_id'])->find();
|
||||
$item['staff_name']= $staff['name'];
|
||||
$item['staff_phone']= $staff['mobile'];
|
||||
|
||||
}
|
||||
$this->_success('获取数据成功', $punish);
|
||||
}else{
|
||||
$this->_error('网络错误');
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* note 审批处罚通过
|
||||
* create_time 2020/10/21 19:05
|
||||
*/
|
||||
public function punishthroug(){
|
||||
$param = $this->request->post();
|
||||
$data=Db::name('fine')->where('id',$param['id'])->update(['status'=>1]);
|
||||
$this->_success('审批成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* note 驳回处罚的审核
|
||||
* create_time 2020/10/21 19:05
|
||||
*/
|
||||
public function punishreject(){
|
||||
$param = $this->request->post();
|
||||
$data=Db::name('fine')->where('id',$param['id'])->update(['status'=>2]);
|
||||
$this->_success('修改成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* note 物料的申请列表
|
||||
* create_time 2020/10/21 19:05
|
||||
*/
|
||||
public function material(){
|
||||
$param = $this->request->post();
|
||||
$param = $this->request->get();
|
||||
$data = Db::name('staff')
|
||||
->alias('s1')
|
||||
->field('s1.*, s2.*')
|
||||
->where('s1.id', $param['id'])
|
||||
->where('s2.onwork',1)
|
||||
->join('staff s2', 's1.grouping_id = s2.grouping_id')
|
||||
->select();
|
||||
if($data){
|
||||
$ids = array_column($data, 'id');
|
||||
$material=Db::name('erp_staff')
|
||||
->whereIN('staff_id',$ids)
|
||||
->where('status',$param['status'])
|
||||
->order('id', 'asc')
|
||||
->page($param['page'], $param['limt'])
|
||||
->select();
|
||||
foreach ($material as &$item){
|
||||
$erp_goods=Db::name('epr')->where('id',$item['goods_id'])->find();
|
||||
if($erp_goods){
|
||||
$item['goods_name']= $erp_goods['name'];
|
||||
$item['goods_img']=UrlServer::getFileUrl($erp_goods['abs_avatar']);
|
||||
|
||||
}else{
|
||||
$item['goods_name']='-';
|
||||
$item['goods_img']='-';
|
||||
}
|
||||
|
||||
}
|
||||
$this->_success('获取数据成功', $material);
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* note 无聊审批通过
|
||||
* create_time 2020/10/21 19:05
|
||||
*/
|
||||
public function materialthroug(){
|
||||
$param = $this->request->post();
|
||||
$data=Db::name('erp_staff')->where('id',$param['id'])->update(['status'=>2]);
|
||||
$this->_success('审批成功');
|
||||
}
|
||||
/**
|
||||
* note 物料驳回申请
|
||||
* create_time 2020/10/21 19:05
|
||||
*/
|
||||
public function materialreject(){
|
||||
$param = $this->request->post();
|
||||
$data=Db::name('erp_staff')->where('id',$param['id'])->update(['status'=>3,'reason'=>$param['reason']]);
|
||||
$this->_success('修改成功');
|
||||
}
|
||||
/**
|
||||
* note 员工排班
|
||||
* create_time 2020/10/21 19:05
|
||||
*/
|
||||
public function Scheduling(){
|
||||
$param = $this->request->get();
|
||||
if (!isset($param['id']) || empty($param['id'])) {
|
||||
throw new Exception('员工ID不能为空');
|
||||
}
|
||||
$where=[];
|
||||
//判断检索框
|
||||
$selval = trim($param['selval'] ?? '');
|
||||
if (!empty($selval)) {
|
||||
if (preg_match('/^1[3-9]\d{9}$/', $selval)) {
|
||||
$where[] = ['s2.mobile', '=', $selval];
|
||||
} else {
|
||||
$where[] = ['s2.name', 'LIKE', '%' . $selval . '%'];
|
||||
}
|
||||
} else {
|
||||
$where = [];
|
||||
}
|
||||
//判断时间的检索
|
||||
if($param['startDate']){
|
||||
$startTime = strtotime($param['startDate']); //开始时间
|
||||
$endTime = strtotime($param['startDate'] . ' 23:59:59'); //结束时间
|
||||
}else{
|
||||
$startTime = strtotime(date('Y-m-d'));
|
||||
$endTime = strtotime(date('Y-m-d') . ' 23:59:59');
|
||||
}
|
||||
|
||||
$data = Db::name('staff')
|
||||
->alias('s1')
|
||||
->field('s1.*, s2.*')
|
||||
->where('s1.id', $param['id'])
|
||||
->where('s2.onwork',1)
|
||||
->where($where)
|
||||
->join('staff s2', 's1.grouping_id = s2.grouping_id')
|
||||
->select();
|
||||
foreach ($data as &$item){
|
||||
$item['sw_order']=Db::name('order_exe')
|
||||
->where('staff_id',$item['id'])
|
||||
->whereBetween('autotime', [$startTime, $endTime])
|
||||
->field('id')
|
||||
->where('addtime',1)
|
||||
->find();
|
||||
$item['xw_order']=Db::name('order_exe')
|
||||
->where('staff_id',$item['id'])
|
||||
->whereBetween('autotime', [$startTime, $endTime])
|
||||
->field('id')
|
||||
->where('addtime',2)
|
||||
->find();
|
||||
$item['sw_zy']=Db::name('leave')
|
||||
->where('user_id',$item['id'])
|
||||
->whereBetween('time', [$startTime, $endTime])
|
||||
->field('id')
|
||||
->where('addtime',1)
|
||||
->find();
|
||||
$item['xw_zy']=Db::name('leave')
|
||||
->where('user_id',$item['id'])
|
||||
->whereBetween('time', [$startTime, $endTime])
|
||||
->field('id')
|
||||
->where('addtime',2)
|
||||
->find();
|
||||
$item['sw_qj']=Db::name('leavesd')
|
||||
->where('staff_id',$item['id'])
|
||||
->whereBetween('time', [$startTime, $endTime])
|
||||
->where('status',1)
|
||||
->where('addtime',1)
|
||||
->field('id')
|
||||
->find();
|
||||
$item['xw_qj']=Db::name('leavesd')
|
||||
->where('staff_id',$item['id'])
|
||||
->whereBetween('time', [$startTime, $endTime])
|
||||
->field('id')
|
||||
->where('status',1)
|
||||
->where('addtime',2)
|
||||
->find();
|
||||
}
|
||||
|
||||
$this->_success('获取数据成功',$data);
|
||||
}
|
||||
|
||||
/**
|
||||
* note 员工占用列表
|
||||
* create_time 2020/10/21 19:05
|
||||
*/
|
||||
public function occupy(){
|
||||
$param = $this->request->get();
|
||||
if (!isset($param['id']) || empty($param['id'])) {
|
||||
throw new Exception('站长ID不能为空');
|
||||
}
|
||||
$where=[];
|
||||
$selval = trim($param['selval'] ?? '');
|
||||
if (!empty($selval)) {
|
||||
if (preg_match('/^1[3-9]\d{9}$/', $selval)) {
|
||||
$where[] = ['phone','=',$selval];
|
||||
} else {
|
||||
$where[] = ['name', 'LIKE', '%' . $selval . '%'];
|
||||
}
|
||||
} else {
|
||||
$where = [];
|
||||
}
|
||||
//检索框
|
||||
$data = Db::name('staff')
|
||||
->alias('s1')
|
||||
->field('s1.*, s2.*')
|
||||
->where('s1.id', $param['id'])
|
||||
->where('s2.onwork',1)
|
||||
->join('staff s2', 's1.grouping_id = s2.grouping_id')
|
||||
->select();
|
||||
if($data){
|
||||
$ids = array_column($data, 'id');
|
||||
$occupy=Db::name('leave')
|
||||
->whereIN('user_id',$ids)
|
||||
->where($where)
|
||||
->order('id', 'desc')
|
||||
->page($param['page'], $param['limt'])
|
||||
->select();
|
||||
foreach ($occupy as &$item){
|
||||
$item['time']=date('Y-m-d',$item['time']);
|
||||
$item['create_time']=date('Y-m-d H:i:s',$item['create_time']);
|
||||
$admin=Db::name('admin')->where('id',$item['admin_id'])->find();
|
||||
if($admin){
|
||||
$item['admin_name']=$admin['name'];
|
||||
}else{
|
||||
$item['admin_name']='-';
|
||||
}
|
||||
$type=Db::name('leave_statype')->where('id',$item['type'])->find();
|
||||
if($type){
|
||||
$item['type_name']=$type['name'];
|
||||
}else{
|
||||
$item['type_name']='-';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
$this->_success('修改成功', $occupy);
|
||||
}
|
||||
/**
|
||||
* note 删除占用数据
|
||||
* create_time 2020/10/21 19:05
|
||||
*/
|
||||
public function occupy_del(){
|
||||
$param = $this->request->get();
|
||||
$data=Db::name('leave')->where('id',$param['id'])->delete();
|
||||
$this->_success('删除数据成功');
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user