| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 | 
							- <?php
 
- namespace app\api\controller\company;
 
- use app\common\controller\Apic;
 
- use think\Db;
 
- /**
 
-  * 套餐管理
 
-  */
 
- class Package extends Apic
 
- {
 
-     protected $noNeedLogin = [];
 
-     protected $noNeedRight = '*';
 
-     //列表
 
-     public function lists(){
 
-         $status = input('status',1);
 
-         $keyword = input('keyword','');
 
-         $where = [
 
-             'p.company_id' => $this->auth->company_id,
 
-             'p.status'     => $status,
 
-         ];
 
-         if(!empty($keyword)){
 
-             $where['p.title|p.info'] = ['LIKE','%'.$keyword.'%'];
 
-         }
 
-         $list = Db::name('package')->alias('p')
 
-             ->field('p.*,type.title as servicetype_title')
 
-             ->join('servicetype type','p.servicetype_id = type.id','LEFT')
 
-             ->where($where)->order('p.id desc')->autopage()->select();
 
-         $list = list_domain_image($list,['images','content_images']);
 
-         $this->success(1,$list);
 
-     }
 
-     //新增
 
-     public function add(){
 
-         //验证
 
-         if($this->auth->type != 1){
 
-             $this->error('只有门店老板才能设置');
 
-         }
 
-         $field = ['title','info','servicetype_id','images','price','oldprice','content','content_images'];
 
-         $data = request_post_hub($field);
 
-         $data['company_id'] = $this->auth->company_id;
 
-         $data['createtime'] = time();
 
-         $data['updatetime'] = time();
 
-         $data['status'] = 1;
 
-         Db::name('package')->insertGetId($data);
 
-         $this->success('添加成功');
 
-     }
 
-     //上下架
 
-     public function changestatus(){
 
-         //验证
 
-         if($this->auth->type != 1){
 
-             $this->error('只有门店老板才能设置');
 
-         }
 
-         $id = input('id',0);
 
-         $status = Db::name('package')->where('id',$id)->value('status');
 
-         $new_status = $status == 1 ? 0 : 1;
 
-         $info = Db::name('package')->where('id',$id)->update(['status'=>$new_status,'updatetime'=>time()]);
 
-         $this->success();
 
-     }
 
-     //详情
 
-     public function info(){
 
-         $id = input('id',0);
 
-         $info = Db::name('package')->alias('p')
 
-             ->field('p.*,type.title as servicetype_title')
 
-             ->join('servicetype type','p.servicetype_id = type.id','LEFT')
 
-             ->where('p.id',$id)->find();
 
-         $info = info_domain_image($info,['images','content_images']);
 
-         $this->success(1,$info);
 
-     }
 
-     //编辑
 
-     public function edit(){
 
-         //验证
 
-         if($this->auth->type != 1){
 
-             $this->error('只有门店老板才能设置');
 
-         }
 
-         $id = input('id','');
 
-         $check = Db::name('package')->where('id',$id)->where('company_id',$this->auth->company_id)->find();
 
-         if(empty($check)){
 
-             $this->error('不存在的套餐');
 
-         }
 
-         //
 
-         $field = ['title','info','servicetype_id','images','price','oldprice','content','content_images'];
 
-         $data = request_post_hub($field);
 
-         $data['updatetime'] = time();
 
-         Db::name('package')->where('id',$id)->update($data);
 
-         $this->success('编辑成功');
 
-     }
 
-     //删除
 
-     public function delete(){
 
-         //验证
 
-         if($this->auth->type != 1){
 
-             $this->error('只有门店老板才能设置');
 
-         }
 
-         $id = input('id','');
 
-         $check = Db::name('package')->where('id',$id)->where('company_id',$this->auth->company_id)->find();
 
-         if(empty($check)){
 
-             $this->error('不存在的套餐');
 
-         }
 
-         Db::name('package')->where('id',$id)->delete();
 
-         $this->success('删除成功');
 
-     }
 
- }
 
 
  |