添加网站文件
This commit is contained in:
509
application/admin/controller/Orderautomatic.php
Normal file
509
application/admin/controller/Orderautomatic.php
Normal file
@@ -0,0 +1,509 @@
|
||||
<?php
|
||||
namespace app\admin\controller;
|
||||
use app\admin\logic\OrderautoLogic;
|
||||
use app\admin\logic\OrderchanelLogic;
|
||||
use app\admin\logic\{ LeaveLogic};
|
||||
use app\admin\logic\GoodsCategoryLogic;
|
||||
use app\admin\logic\StaffLogic;
|
||||
use app\admin\logic\UserLogic;
|
||||
use app\common\server\WeChatServer;
|
||||
use app\common\model\NoticeSetting;
|
||||
use EasyWeChat\Factory;
|
||||
use think\Db;
|
||||
class Orderautomatic extends AdminBase
|
||||
{
|
||||
|
||||
/**
|
||||
* 等待预排
|
||||
* @return mixed
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
if ($this->request->isAjax()) {
|
||||
$get = $this->request->get();
|
||||
$this->_success('获取成功', OrderautoLogic::lists($get));
|
||||
}
|
||||
$type = \app\common\model\Ad::getAdTypeDesc(true);
|
||||
$this->assign('ordertypelist',OrderchanelLogic::infolist());
|
||||
$admin=Db::name('admin')->select();
|
||||
$this->assign('admin', $admin);
|
||||
$this->assign('type', $type);
|
||||
return $this->fetch();
|
||||
}
|
||||
/**
|
||||
* 增加预排的订单
|
||||
* @return mixed
|
||||
*/
|
||||
public function add(){
|
||||
if ($this->request->isAjax()) {
|
||||
$post = $this->request->post();
|
||||
$admin=$this->admin_id;
|
||||
$list= OrderautoLogic::add($post,$admin);
|
||||
if($list==3){
|
||||
$this->_error('预排参数错误');
|
||||
}
|
||||
$this->_success('增加预排订单成功',$list);
|
||||
|
||||
}
|
||||
$get=$this->request->get('id');
|
||||
$this->assign('ordertype', OrderchanelLogic::infolist());
|
||||
$this->assign('satff',LeaveLogic::user($get));
|
||||
$this->assign('order_sn', $get);
|
||||
return $this->fetch();
|
||||
}
|
||||
public function userlist(){
|
||||
if ($this->request->isAjax()){
|
||||
$get = $this->request->get();
|
||||
$goods_list = OrderautoLogic::getUserList($get,true);
|
||||
$this->_success('',$goods_list);
|
||||
}
|
||||
return $this->fetch();
|
||||
}
|
||||
/**
|
||||
* 查看预排的订单
|
||||
* @return mixed
|
||||
*/
|
||||
public function infolist(){
|
||||
if ($this->request->isAjax()){
|
||||
$get = $this->request->get();
|
||||
$infolist=OrderautoLogic::infolist($get);
|
||||
$this->_success('',$infolist);
|
||||
}
|
||||
$get = $this->request->get();
|
||||
$this->assign('info', OrderautoLogic::info($get['id']));
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
|
||||
public function edit(){
|
||||
$id= $this->request->get('id');
|
||||
$info = OrderautoLogic::info($id);
|
||||
$this->assign('position_list', OrderautoLogic::infoPosition($info['pid']));
|
||||
$this->assign('info',$info);
|
||||
$this->assign('ordertype', OrderchanelLogic::infolist());
|
||||
$this->assign('satff',LeaveLogic::user());
|
||||
return $this->fetch();
|
||||
}
|
||||
/**
|
||||
* 修改排单的时间
|
||||
* @return mixed
|
||||
*/
|
||||
public function eitdata(){
|
||||
if ($this->request->isAjax()){
|
||||
$id= $this->request->get('id');
|
||||
$post= $this->request->post();
|
||||
$date=Db::name('order_exe')->where('id',$id)->find(); //获取订单的信息
|
||||
$custom=Db::name('order')->where('order_sn',$date['order_sn'])->find(); //获取客户的信息
|
||||
|
||||
if($date['addtime']==1){
|
||||
$timesw="上午";
|
||||
}else{
|
||||
$timesw="下午";
|
||||
}
|
||||
|
||||
$currentTime = date('H');
|
||||
if( $currentTime>17){
|
||||
if($date['staff_id']!=0){
|
||||
$staff=Db::name('staff')->where('id',$date['staff_id'])->find();
|
||||
$openids=Db::name('user_auth')->where('user_id', $staff['user_id'])->find(); //获取用户的ID
|
||||
$timesd=date('Y-m-d',$date['autotime']);
|
||||
$timedd=date('Y-m-d',time());
|
||||
$openid = $openids['openid'];
|
||||
if($post['privilege']==""){
|
||||
$time= date('Y-m-d', strtotime($post['end_time']));
|
||||
if($post['type']==1){
|
||||
$sw="上午";
|
||||
}else{
|
||||
$sw="下午";
|
||||
}
|
||||
|
||||
$data = [
|
||||
'touser'=>$openid,
|
||||
'url'=>'',
|
||||
'template_id'=>'ZTmrioGnhIsZMeK7UElzRyTw-_743VslGvEP5TWopzc', //模板id
|
||||
'data'=>[
|
||||
'character_string1'=>[
|
||||
'value'=>$custom['order_sn']
|
||||
],
|
||||
'time3'=>[
|
||||
'value'=>$time
|
||||
],
|
||||
'thing5'=>[
|
||||
'value'=>$custom['address']
|
||||
],
|
||||
'thing2'=>[
|
||||
'value'=>$sw
|
||||
]
|
||||
]
|
||||
];
|
||||
$config = WeChatServer::getOaConfig();
|
||||
$app = Factory::officialAccount($config);
|
||||
$r = $app->template_message->send($data);
|
||||
|
||||
}
|
||||
|
||||
else{
|
||||
//微信的自己通知
|
||||
$data = [
|
||||
'touser'=>$openid,
|
||||
'url'=>'',
|
||||
'template_id'=>'k1dPNVhKOBTgSWe7Ha4BjZ96yUF11uSfOn0IwBkRx4c', //模板id
|
||||
'data'=>[
|
||||
'thing11'=>[
|
||||
'value'=>$custom['consignee'].$timesw
|
||||
],
|
||||
'phone_number9'=>[
|
||||
'value'=>$custom['mobile']
|
||||
],
|
||||
'thing19'=>[
|
||||
'value'=>$custom['address']
|
||||
],
|
||||
'time18'=>[
|
||||
'value'=>$timesd
|
||||
],
|
||||
|
||||
'time14'=>[
|
||||
'value'=>$timedd
|
||||
//'value'=> $time.$timesw
|
||||
]
|
||||
]
|
||||
];
|
||||
$config = WeChatServer::getOaConfig();
|
||||
$app = Factory::officialAccount($config);
|
||||
$r = $app->template_message->send($data);
|
||||
//通知对方修改的的人
|
||||
$user=Db::name('staff')->where('id',$post['privilege'])->find(); //修改的人员信息
|
||||
$auth=Db::name('user_auth')->where('user_id', $user['user_id'])->find(); //获取用户的openid
|
||||
$goods=Db::name('goods')->where('id', $custom['goods_id'])->find();
|
||||
if($post['type']=1){
|
||||
$ties= '.8:00-12:00';
|
||||
}else{
|
||||
$ties= '.14:00-16:00';
|
||||
}
|
||||
|
||||
//$openid = $openids['openid'];
|
||||
$data = [
|
||||
'touser'=>$auth['openid'],
|
||||
'url'=>'',
|
||||
'template_id'=>'uTFzkTScwMfMJtqQNGTNbpRuItpJwliVtJtMoobfqBQ', //模板id
|
||||
'data'=>[
|
||||
'keyword1'=>[
|
||||
'value'=>$custom['order_sn']
|
||||
],
|
||||
'keyword2'=>[
|
||||
'value'=> $goods['name']
|
||||
],
|
||||
'keyword3'=>[
|
||||
'value'=>$timesd. $ties
|
||||
],
|
||||
'keyword4'=>[
|
||||
'value'=>$custom['mobile']
|
||||
]
|
||||
]
|
||||
];
|
||||
$config = WeChatServer::getOaConfig();
|
||||
$app = Factory::officialAccount($config);
|
||||
$r = $app->template_message->send($data);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
$count=count(explode(',',$post['privilege']));
|
||||
}
|
||||
$list=OrderautoLogic::eittime($id,$post);
|
||||
|
||||
$admins=$this->admin_id;
|
||||
$time=time();
|
||||
$logdate=[
|
||||
'admin_id'=>$admins,
|
||||
'order_sn'=>$id,
|
||||
'show'=>'修改保洁师',
|
||||
'cram_time'=>$time
|
||||
];
|
||||
$log=Db::name('log_orders')->data($logdate)->insert();
|
||||
|
||||
|
||||
|
||||
$this->_success('修改预约时间成功',$list);
|
||||
}
|
||||
$id= $this->request->get('id');
|
||||
$this->assign('info',OrderautoLogic::orderexeinfo($id));
|
||||
$this->assign('satff',LeaveLogic::user());
|
||||
return $this->fetch();
|
||||
}
|
||||
/**
|
||||
* 更换保洁师
|
||||
* @return mixed
|
||||
*/
|
||||
public function staff(){
|
||||
if($this->request->isAjax()){
|
||||
$id= $this->request->get('id');
|
||||
$post= $this->request->post();
|
||||
$list=OrderautoLogic::staff($id,$post);
|
||||
if($list==2){
|
||||
$this->error('只能选择一个保洁师');
|
||||
}else{
|
||||
$this->_success('修改保洁师成功',$list);
|
||||
}
|
||||
}
|
||||
$id= $this->request->get('id');
|
||||
$order=Db::name('order_exe')->where('id',$id)->find();
|
||||
$order_sn=Db::name('order')->where('order_sn',$order['order_sn'])->find();
|
||||
|
||||
$orders=Db::name('order_exe')->where('addtime', $order['addtime'])->where('autotime','>=',$order['autotime'])->where('autotime','<',$order['autotime']+(24 * 3600))->whereNotNull('staff_id')->field('staff_id')->group('staff_id')->select(); //查询有订单的保洁师傅
|
||||
|
||||
|
||||
$oneDimensionalArray = array_column($orders, 'staff_id'); // 根据自己的表格字段名修改'字段名'部分
|
||||
$lent=Db::name('leave')->where('addtime',$order['addtime'])->where('time','>=',$order['autotime'])->where('time','<',$order['autotime']+(24 * 3600))->whereNotNull('user_id')->field('user_id')->group('user_id')->select();
|
||||
$lentuser = array_column($lent,'user_id');
|
||||
|
||||
|
||||
$staff=Db::name('staff')
|
||||
->whereNotIn('id',$oneDimensionalArray) // $array为要比较的数组
|
||||
->whereNotIn('id',$lentuser) // $array为要比较的数组
|
||||
->where('onwork',1)
|
||||
->select();
|
||||
foreach($staff as $item=>$k){
|
||||
$staff[$item]['june']=number_format(UserLogic::haversine_distance($order_sn['lng'],$order_sn['lat'], $staff[$item]['lng'],$staff[$item]['lat'])/1000,1);
|
||||
}
|
||||
|
||||
$this->assign('satff',$staff);
|
||||
return $this->fetch();
|
||||
}
|
||||
/**
|
||||
* 单次订单暂停服务
|
||||
* @return mixed
|
||||
*/
|
||||
public function dels($id){
|
||||
$admins=$this->admin_id;
|
||||
$time=time();
|
||||
$logdate=[
|
||||
'admin_id'=>$admins,
|
||||
'order_sn'=>$id,
|
||||
'show'=>'订单暂停服务',
|
||||
'cram_time'=>$time
|
||||
];
|
||||
$log=Db::name('log_orders')->data($logdate)->insert();
|
||||
$list=DB::name('order_exe')->where('id',$id)->update(['status'=>3,'staff_id'=>null,'staff_status'=>0]);
|
||||
$this->_success('暂停订单成功');
|
||||
}
|
||||
/**
|
||||
* 取消暂停服务
|
||||
* @return mixed
|
||||
*/
|
||||
public function delsd($id){
|
||||
$admins=$this->admin_id;
|
||||
$time=time();
|
||||
$logdate=[
|
||||
'admin_id'=>$admins,
|
||||
'order_sn'=>$id,
|
||||
'show'=>'订单取消暂停',
|
||||
'cram_time'=>$time
|
||||
];
|
||||
$log=Db::name('log_orders')->data($logdate)->insert();
|
||||
$list=DB::name('order_exe')->where('id',$id)->update(['status'=>0]);
|
||||
$this->_success('取消暂停成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* 主订单暂停服务
|
||||
* @return mixed
|
||||
*/
|
||||
|
||||
public function prent($id){
|
||||
//增加订单的日志
|
||||
$order=Db::name('order')->where('id',$id)->find();
|
||||
$admin=$this->admin_id;
|
||||
$time=time();
|
||||
$logdate=[
|
||||
'admin_id'=>$admin,
|
||||
'order_sn'=>$order['order_sn'],
|
||||
'show'=>'暂停主订单',
|
||||
'cram_time'=>$time
|
||||
];
|
||||
$log=Db::name('log_order')->data($logdate)->insert();
|
||||
$list=OrderautoLogic::prent($id);
|
||||
$this->_success('暂停订单成功');
|
||||
}
|
||||
/**
|
||||
* 取消订单的暂停服务
|
||||
* @return mixed
|
||||
*/
|
||||
public function prentsd($id){
|
||||
//增加订单的日志
|
||||
$order=Db::name('order')->where('id',$id)->find();
|
||||
$admin=$this->admin_id;
|
||||
$time=time();
|
||||
$logdate=[
|
||||
'admin_id'=>$admin,
|
||||
'order_sn'=>$order['order_sn'],
|
||||
'show'=>'取消暂停订单',
|
||||
'cram_time'=>$time
|
||||
];
|
||||
$log=Db::name('log_order')->data($logdate)->insert();
|
||||
$list=OrderautoLogic::prentsd($id);
|
||||
$this->_success('取消暂停成功');
|
||||
}
|
||||
/**
|
||||
* 修改订单的备注
|
||||
* @return mixed
|
||||
*/
|
||||
public function remarks(){
|
||||
// 获取的
|
||||
if ($this->request->isAjax() && $this->request->isGet()){
|
||||
$get = $this->request->get();
|
||||
$detail = OrderautoLogic::remarks($get, 'get');
|
||||
$this->_success('获取成功', $detail);
|
||||
}
|
||||
|
||||
// 提交的
|
||||
if ($this->request->isAjax() && $this->request->isPost()) {
|
||||
$post = $this->request->post();
|
||||
$result = OrderautoLogic::remarks($post, 'post');
|
||||
if ($result) {
|
||||
$this->_success('保存成功');
|
||||
}
|
||||
$this->error('保存失败');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除子订单的排单
|
||||
* @return mixed
|
||||
*/
|
||||
|
||||
public function delss($id){
|
||||
$del=Db::name('order_exe')->where('id',$id)->delete();
|
||||
$this->_success('删除成功');
|
||||
}
|
||||
/**
|
||||
* 修改订单已经完成状态
|
||||
* @return mixed
|
||||
*/
|
||||
|
||||
public function complete($id){
|
||||
$admins=$this->admin_id;
|
||||
$time=time();
|
||||
$logdate=[
|
||||
'admin_id'=>$admins,
|
||||
'order_sn'=>$id,
|
||||
'show'=>'修改订单已完成',
|
||||
'cram_time'=>$time
|
||||
];
|
||||
$log=Db::name('log_orders')->data($logdate)->insert();
|
||||
$del=Db::name('order_exe')->where('id',$id)->update(['status'=>1, 'staff_status'=>3]);
|
||||
$this->_success('订单已完成');
|
||||
}
|
||||
/**
|
||||
*锁定订单
|
||||
* @return mixed
|
||||
*/
|
||||
|
||||
public function lock($id){
|
||||
$admins=$this->admin_id;
|
||||
$time=time();
|
||||
$logdate=[
|
||||
'admin_id'=>$admins,
|
||||
'order_sn'=>$id,
|
||||
'show'=>'锁定订单状态',
|
||||
'cram_time'=>$time
|
||||
];
|
||||
$log=Db::name('log_orders')->data($logdate)->insert();
|
||||
$del=Db::name('order_exe')->where('id',$id)->update(['lock'=>1]);
|
||||
$this->_success('订单锁定成功');
|
||||
}
|
||||
|
||||
/**
|
||||
*解锁订单
|
||||
* @return mixed
|
||||
*/
|
||||
|
||||
public function unlock($id){
|
||||
$admins=$this->admin_id;
|
||||
$time=time();
|
||||
$logdate=[
|
||||
'admin_id'=>$admins,
|
||||
'order_sn'=>$id,
|
||||
'show'=>'取消订单锁定',
|
||||
'cram_time'=>$time
|
||||
];
|
||||
$log=Db::name('log_orders')->data($logdate)->insert();
|
||||
$del=Db::name('order_exe')->where('id',$id)->update(['lock'=>0]);
|
||||
$this->_success('订单锁定成功');
|
||||
}
|
||||
|
||||
|
||||
public function log(){
|
||||
if($this->request->isAjax()){
|
||||
$get= $this->request->get();
|
||||
$lists=OrderautoLogic::log($get);
|
||||
$this->_success('获取数据成功',$lists);
|
||||
}
|
||||
$id= $this->request->get('id');
|
||||
$this->assign('ids',$id);
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
public function orderlog(){
|
||||
if($this->request->isAjax()){
|
||||
$get= $this->request->get();
|
||||
$lists=OrderautoLogic::orderlog($get);
|
||||
|
||||
$this->_success('获取数据成功',$lists);
|
||||
}
|
||||
$id= $this->request->get('id');
|
||||
$this->assign('ids',$id);
|
||||
return $this->fetch();
|
||||
}
|
||||
/**
|
||||
*订单进入异常
|
||||
* @return mixed
|
||||
*/
|
||||
|
||||
public function abnormal($id){
|
||||
$admins=$this->admin_id;
|
||||
$time=time();
|
||||
$logdate=[
|
||||
'admin_id'=>$admins,
|
||||
'order_sn'=>$id,
|
||||
'show'=>'设置订单进入异常',
|
||||
'cram_time'=>$time
|
||||
];
|
||||
$log=Db::name('log_orders')->data($logdate)->insert();
|
||||
$del=Db::name('order_exe')->where('id',$id)->update(['abnormal'=>1]);
|
||||
$this->_success('订单异常成功');
|
||||
}
|
||||
/**
|
||||
*订单进入异常
|
||||
* @return mixed
|
||||
*/
|
||||
|
||||
public function notabnormal($id){
|
||||
$admins=$this->admin_id;
|
||||
$time=time();
|
||||
$logdate=[
|
||||
'admin_id'=>$admins,
|
||||
'order_sn'=>$id,
|
||||
'show'=>'取消订单进入异常',
|
||||
'cram_time'=>$time
|
||||
];
|
||||
$log=Db::name('log_orders')->data($logdate)->insert();
|
||||
$del=Db::name('order_exe')->where('id',$id)->update(['abnormal'=>0]);
|
||||
$this->_success('取消订单异常成功');
|
||||
}
|
||||
|
||||
|
||||
public function orderinfo(){
|
||||
$get= $this->request->get();
|
||||
$info=OrderautoLogic::orderinfo($get);
|
||||
if($info){
|
||||
$this->assign('info',$info);
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user