Files
duolamaojiazhen/application/admin/logic/ControlLogic.php
2025-12-22 13:59:40 +08:00

258 lines
9.2 KiB
PHP

<?php
namespace app\admin\Logic;
use app\common\server\UrlServer;
use think\Db;
class ControlLogic{
public static function lists($get){
$where = [];
//查询
//根据员工编号查询
if(isset($get['order_id']) && $get['order_id'] != ''){
$where[] = ['order_id','=',$get['order_id']];
}
if(isset($get['staff_id']) && $get['staff_id'] != ''){
$where[] = ['staff_id','=',$get['staff_id']];
}
if(isset($get['name']) && $get['name'] != ''){
$where[] = ['name', 'like', '%' . $get['name'] . '%'];
}
if(isset($get['phone']) && $get['phone'] != ''){
$where[] = ['phone', 'like', '%' . $get['phone'] . '%'];
}
//增加时间
if(isset($get['start_score']) && $get['start_score']!=''){
$where[] = ['score','>=',$get['start_score']];
}
if(isset($get['end_score']) && $get['end_score']!=''){
$where[] = ['score','<=',$get['end_score']];
}
//增加时间
if(isset($get['start_time']) && $get['start_time']!=''){
$where[] = ['createtime','>=',strtotime($get['start_time'])];
}
if(isset($get['end_time']) && $get['end_time']!=''){
$where[] = ['createtime','<=',strtotime($get['end_time'])];
}
$count = Db::name('order_trace')
->where($where)
->count();
$lists = Db::name('order_trace')
->where($where)
->page($get['page'],$get['limit'])
->order('id desc')
->select();
foreach ($lists as &$item){
$item['createtime']=date('Y-m-d H:i:s',$item['createtime']);
$order_info=Db::name('order_exe')->where('id',$item['order_id'])->find(); //获取子订单信息
$staffinfo=Db::name('staff')->where('id',$order_info['staff_id'])->find();
$item['staff_name']=$staffinfo['name'];
$item['start_time']=date('Y-m-d H:i:s', $order_info['start_time']);
$item['timeout']=date('Y-m-d H:i:s', $order_info['timeout']);
$item['add']=$order_info['add'];
$order=Db::name('order')->where('order_sn',$order_info['order_sn'])->find();
$item['adderss']=$order['address'];
$goods=Db::name('goods')->where('id',$order['goods_id'])->find();
$item['goods_name']=$goods['name'];
}
return ['count'=>$count , 'lists'=>$lists];
}
public static function info($id){
return Db::name('order_trace')->where('id',$id)->find();
}
public static function edit($post){
$data=[
'score' => $post['score'],
'ptance' =>$post['ptance'],
'storaged' =>$post['storaged'],
'leanin' => $post['leanin'],
'munity'=>$post['munity'],
'advise' => $post['advise'],
'profound' => $post['profound'],
'adjust'=>$post['adjust']
];
return Db::name('order_trace')->where('id',$post['id'])->data($data)->update();
}
public static function sale_add($post){
$order=Db::name('order_exe')->where('id',$post['id'])->find();
$data=[
'name'=>$order['name'],
'phone'=>$order['phone'],
'problem'=>$post['problem'],
'autotime'=>$order['autotime'],
'staff_id'=>$order['staff_id'],
'status' =>0,
'adjust'=>$post['adjust'],
'order_id'=>$post['id'],
'goods_images'=>$post['goods_images'],
'video' =>$post['video'],
'time' =>time(),
];
return Db::name('order_sale')->data($data)->insert();
}
public static function visit_order($get){
$where=[];
if(isset($get['name']) && $get['name'] != ''){
$where[] = ['name', 'like', '%' . $get['name'] . '%'];
}
if(isset($get['phone']) && $get['phone'] != ''){
$where[] = ['phone', 'like', '%' . $get['phone'] . '%'];
}
//增加时间
if(isset($get['start_time']) && $get['start_time']!=''){
$where[] = ['time','>=',strtotime($get['start_time'])];
}
if(isset($get['end_time']) && $get['end_time']!=''){
$where[] = ['time','<=',strtotime($get['end_time'])];
}
$count = Db::name('order_sale')
->where($where)
->count();
$lists = Db::name('order_sale')
->where($where)
->page($get['page'],$get['limit'])
->order('id desc')
->select();
foreach ($lists as &$item){
$item['autotime']=date('Y-m-d', $item['autotime']);
$staff=Db::name('staff')->where('id',$item['staff_id'])->find();
if($staff){
$item['staff_name']= $staff['name'];
$item['staff_phone']= $staff['mobile'];
}
$item['time']=date('Y-m-d:H:i:s', $item['time']);
}
return ['count'=>$count , 'lists'=>$lists];
}
public static function sale_info($id){
return Db::name('order_sale')->where('id',$id)->find();
}
public static function sale_edit($post){
return Db::name('order_sale')->where('id',$post['id'])->update(['problem'=>$post['problem'],'adjust'=>$post['adjust']]);
}
public static function sale_status($id){
return Db::name('order_sale')->where('id',$id)->update(['status'=>1]);
}
public static function sale_del($id){
return Db::name('order_sale')->where('id',$id)->delete();
}
public static function follow($get){
return $get;
}
public static function abnormal_lists($get){
$where=[];
if(isset($get['name']) && $get['name'] != ''){
$where[] = ['name', 'like', '%' . $get['name'] . '%'];
}
if(isset($get['phone']) && $get['phone'] != ''){
$where[] = ['phone', 'like', '%' . $get['phone'] . '%'];
}
if(isset($get['staff_id']) && $get['staff_id'] != ''){
$where[] = ['staff_id','=',$get['staff_id']];
}
if(isset($get['phone']) && $get['phone'] != ''){
$where[] = ['phone', 'like', '%' . $get['phone'] . '%'];
}
//增加时间
if(isset($get['start_time']) && $get['start_time']!=''){
$where[] = ['create_time','>=',strtotime($get['start_time'])];
}
if(isset($get['end_time']) && $get['end_time']!=''){
$where[] = ['create_time','<=',strtotime($get['end_time'])];
}
$count = Db::name('order_abnormal')
->where($where)
->count();
$lists = Db::name('order_abnormal')
->where($where)
->page($get['page'],$get['limit'])
->order('id desc')
->select();
foreach ($lists as &$item){
$staff=Db::name('staff')->where('id',$item['staff_id'])->find();
$item['staff_name']= $staff['name'];
$item['staff_mobile']= $staff['mobile'];
$coust=Db::name('order_exe')->where('id',$item['order_id'])->find();
if($coust){
$item['coust_name']= $coust['name'];
$item['coust_mobile']= $coust['phone'];
}else{
$item['coust_name']="-";
$item['coust_mobile']="-";
}
$item['create_time']=date('Y-m-d:H:i:s', $item['create_time']);
}
return ['count'=>$count , 'lists'=>$lists];
}
public static function abnormal_info($id){
return Db::name('order_abnormal')->where('id',$id)->find();
}
public static function abnormal_eidt($post){
return Db::name('order_abnormal')->where('id',$post['id'])
->update(['problem'=>$post['problem'],'adjust'=>$post['adjust']]);
}
public static function abnormal_del($id){
return Db::name('order_abnormal')->where('id',$id)->delete();
}
public static function controlimg($post){
$data=Db::name('user_order_imges')->where('order_id',$post)->find();
return $data;
}
//查看投诉图片
public static function images($id){
$data=Db::name('order_sale')->where('order_id',$id)->find();
$array = explode(',', $data['goods_images']);
$datas=[
'images'=>$array,
'video' =>$data['video'],
];
return $datas;
}
//生成处罚单据
public static function punish($id){
Db::name('order_sale')->where('order_id',$id)->update(['punish'=>1]);
$data=Db::name('order_sale')->where('order_id',$id)->find();
$datas=[
'staff_id'=>$data['staff_id'],
'order_id' =>$data['order_id'],
'create_time' =>time()
];
Db::name('fine')->data($datas)->insert();
return;
}
}