| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 | 
							- <?php
 
- namespace app\api\controller\company;
 
- use app\common\controller\Apic;
 
- use think\Db;
 
- /**
 
-  * 预约管理
 
-  */
 
- class Preorder extends Apic
 
- {
 
-     protected $noNeedLogin = [];
 
-     protected $noNeedRight = '*';
 
-     //列表
 
-     public function lists(){
 
-         $pre_order_status = input('pre_order_status',1);
 
-         $where = [
 
-             'po.company_id' => $this->auth->company_id,
 
-             'po.pre_order_status' => $pre_order_status,
 
-         ];
 
-         $list = Db::name('pre_order')->alias('po')->field('po.*,servicetype.title')
 
-             ->join('servicetype','po.servicetype_id = servicetype.id','LEFT')
 
-             ->where($where)->order('po.id desc')->autopage()->select();
 
-         $this->success(1,$list);
 
-     }
 
-     //取消
 
-     public function cancel(){
 
-         $id = input('pre_order_id',0);
 
-         $cancel_reason = input('cancel_reason','');
 
-         $update = [
 
-             'cancel_reason' => $cancel_reason,
 
-             'cancel_time'   => time(),
 
-             'updatetime'    => time(),
 
-             'pre_order_status' => 0,
 
-         ];
 
-         Db::name('pre_order')->where('id',$id)->where('company_id',$this->auth->company_id)->update($update);
 
-         $this->success('取消成功');
 
-     }
 
-     //详情
 
-     public function info(){
 
-         $id = input('pre_order_id',0);
 
-         $info = Db::name('pre_order')->where('id',$id)->find();
 
-         $this->success(1,$info);
 
-     }
 
-     //预约开单 在线开单
 
-     public function submit_order(){
 
-         $pre_order_id = input('pre_order_id',0); //预约单id
 
-         $data = request_post_hub([
 
-             'user_name','user_car_number','user_mobile','user_address',
 
-             'servicetype_id','server_time','server_info','server_images','pay_fee'
 
-         ]);
 
-         //检查用户
 
-         $user_info = Db::name('user')->where('mobile',$data['user_mobile'])->find();
 
-         if(empty($user_info)){
 
-             $this->error('不存在的用户');
 
-         }
 
-         $data['user_id'] = $user_info['id'];
 
-         //预约单
 
-         $pre_order = [];
 
-         if($pre_order_id > 0){
 
-             $map = ['id'=>$pre_order_id,'company_id'=>$this->auth->company_id,'pre_order_status'=>1];
 
-             $pre_order = Db::name('pre_order')->where($map)->find();
 
-             if(empty($pre_order)){
 
-                 $this->error('不存在的预约单');
 
-             }else{
 
-                 $data['pre_order_id'] = $pre_order_id;
 
-                 //数据一致性
 
-                 if($pre_order['user_id'] != $data['user_id']){
 
-                     $this->error('预约单用户非当前用户');
 
-                 }
 
-             }
 
-             //修改状态
 
-             $update = [
 
-                 'order_time'   => time(),
 
-                 'updatetime'    => time(),
 
-                 'pre_order_status' => 2,
 
-             ];
 
-             Db::name('pre_order')->where('id',$pre_order_id)->update($update);
 
-         }
 
-         //检索car_id,没必要了
 
-         //准备数据
 
-         $data['orderno']    = createUniqueNo('O',$this->auth->id);
 
-         $data['ordertype']    = ($pre_order_id > 0) ? 1 : 2;  //类型:1=预约下单,2=在线下单,3=套餐订单
 
-         $data['company_id'] = $this->auth->company_id;
 
-         $data['staff_id'] = $this->auth->id;
 
-         $data['createtime'] = time();
 
-         $order_id = Db::name('order')->insertGetId($data);
 
-         $this->success('下单完成',$order_id);
 
-     }
 
-     //查看预约单下的订单
 
- }
 
 
  |