employee->root_id; if (!$request->isAjax()) { $list = RenovatePrice::where([['root_id','=',$root_id],['status','=',0]])->order('sort desc')->select()->toArray(); View::assign('list',$list); return View::fetch(); } } /** * 套餐项目列表 */ public function package_itemlist() { $request = request(); $root_id = request()->employee->root_id; $param = $this->request->only(['id']); if (!$request->isAjax()) { return View::fetch(); } $list = RenovatePriceItem::where([['pid','=',$param['id']],['root_id','=',$root_id]])->select()->toArray(); return json(['code'=>0,'msg'=>'获取成功','data'=>$list]); } /** * 添加报价套餐 */ public function add_renovate_package() { $request = request(); $root_id = request()->employee->root_id; $param = $this->request->only(['id'=>'','package_name','service_price','devise_price']); if (!$request->isAjax()) { if(!empty($param['id'])){ $packdata = RenovatePrice::where([['root_id','=',$root_id],['id','=',$param['id']]])->find(); View::assign('packdata',$packdata); } View::assign('id',$param['id']); return View::fetch(); } $add = [ 'package_name'=>$param['package_name'], 'root_id' => $root_id, 'service_price' => $param['service_price'], 'devise_price' => $param['devise_price'] ]; $ms = RenovatePrice::insertGetId($add); if($ms){ return json(['code' => 0, 'msg' => '添加成功']); }else{ return json(['code' => 1, 'msg' => '添加失败']); } } /** * 添加套餐的项目 */ public function add_package_item() { $request = request(); $root_id = request()->employee->root_id; $param = $this->request->only(['id'=>'','name','rule','price','remark','pid'=>'','discount_price']); if (!$request->isAjax()) { if(!empty($param['id'])){ $itemdata = RenovatePriceItem::where([['root_id','=',$root_id],['id','=',$param['id']]])->find(); View::assign('itemdata',$itemdata); } View::assign('pid',$param['pid']); View::assign('id',$param['id']); //var_dump($param['id']);exit; return View::fetch(); } if(empty($param['pid'])) return json(['code'=>1,'msg'=>'参数错误']); $check = RenovatePrice::where([['root_id','=',$root_id],['id','=',$param['pid']]])->find(); if(empty($check)) return json(['code'=>1,'msg'=>'套餐不存在']); $add = [ 'name' => $param['name'], 'rule' => $param['rule'], 'price' => $param['price'], 'pid' => $param['pid'], 'remark' => $param['remark'], 'root_id' => $root_id, 'discount_price' => $param['discount_price'] ]; $ms = RenovatePriceItem::insertGetId($add); if($ms){ return json(['code' => 0, 'msg' => '添加成功']); }else{ return json(['code' => 1, 'msg' => '添加失败']); } } /** * 修改套餐 */ public function edit_package() { $request = request(); $root_id = request()->employee->root_id; $param = $this->request->only(['id','package_name','service_price','devise_price','remark'=>'']); if (!$request->isAjax()) { //View::assign('source_list',$source_list); return View::fetch(); } $pkdata = RenovatePrice::where([['root_id','=',$root_id],['id','=',$param['id']]])->find(); if(empty($pkdata)) return json(['code'=>1,'msg'=>'数据不存在']); $pkdata->package_name = $param['package_name']; $pkdata->service_price = $param['service_price']; $pkdata->devise_price = $param['devise_price']; $pkdata->remark = $param['remark']; $pkdata->save(); return json(['code' => 0, 'msg' => '修改成功']); } /** * 修改套餐项目 */ public function edit_packitem() { $request = request(); $root_id = request()->employee->root_id; $param = $this->request->only(['id','name','rule','price','pid','remark','discount_price']); if (!$request->isAjax()) { return View::fetch(); } $itdata = RenovatePriceItem::where([['root_id','=',$root_id],['id','=',$param['id']]])->find(); if(empty($itdata)) return json(['code'=>1,'msg'=>'数据不存在']); $itdata->name = $param['name']; $itdata->rule = $param['rule']; $itdata->price = $param['price']; $itdata->remark = $param['remark']; $itdata->discount_price = $param['discount_price']; $itdata->save(); return json(['code' => 0, 'msg' => '修改成功']); } /** * 删除套餐 */ public function del_package() { $request = request(); $root_id = request()->employee->root_id; $param = $this->request->only(['id']); $pkdata = RenovatePrice::where([['root_id','=',$root_id],['id','=',$param['id']]])->find(); if(empty($pkdata)) return json(['code'=>1,'msg'=>'数据不存在']); $item = RenovatePriceItem::where([['root_id','=',$root_id],['pid','=',$param['id']]])->count(); if(!empty($item)) return json(['code'=>1,'msg'=>'请先删除套餐下面的项目']); $pkdata->delete(); return json(['code' => 0, 'msg' => '删除成功']); } /** * 删除套餐下的项目 */ public function del_packitem() { $request = request(); $root_id = request()->employee->root_id; $param = $this->request->only(['id']); $pkdata = RenovatePriceItem::where([['root_id','=',$root_id],['id','=',$param['id']]])->find(); if(empty($pkdata)) return json(['code'=>1,'msg'=>'数据不存在']); $pkdata->delete(); return json(['code' => 0, 'msg' => '删除成功']); } }