@@ -2,7 +2,12 @@ | |||||
namespace app\admin\controller; | namespace app\admin\controller; | ||||
use app\admin\dao\GroupDao; | |||||
use app\common\controller\Backend; | use app\common\controller\Backend; | ||||
use think\Db; | |||||
use think\Exception; | |||||
use think\exception\PDOException; | |||||
use think\exception\ValidateException; | |||||
/** | /** | ||||
* 渠道配置 | * 渠道配置 | ||||
@@ -11,7 +16,7 @@ use app\common\controller\Backend; | |||||
*/ | */ | ||||
class CfChannelInfo extends Backend | class CfChannelInfo extends Backend | ||||
{ | { | ||||
protected $noNeedRight = ['getList']; | |||||
/** | /** | ||||
* CfChannelInfo模型对象 | * CfChannelInfo模型对象 | ||||
* @var \app\admin\model\CfChannelInfo | * @var \app\admin\model\CfChannelInfo | ||||
@@ -35,7 +40,53 @@ class CfChannelInfo extends Backend | |||||
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑 | * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑 | ||||
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改 | * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改 | ||||
*/ | */ | ||||
/** | |||||
* 添加 | |||||
*/ | |||||
public function add() | |||||
{ | |||||
if ($this->request->isPost()) { | |||||
$params = $this->request->post("row/a"); | |||||
if ($params) { | |||||
$params = $this->preExcludeFields($params); | |||||
if ($this->dataLimit && $this->dataLimitFieldAutoFill) { | |||||
$params[$this->dataLimitField] = $this->auth->id; | |||||
} | |||||
$result = false; | |||||
Db::startTrans(); | |||||
try { | |||||
//是否采用模型验证 | |||||
if ($this->modelValidate) { | |||||
$name = str_replace("\\model\\", "\\validate\\", get_class($this->model)); | |||||
$validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : $name) : $this->modelValidate; | |||||
$this->model->validateFailException(true)->validate($validate); | |||||
} | |||||
$params['create_id']=$this->auth->id; | |||||
$groupDao = new GroupDao(); | |||||
$params['group_id'] = $groupDao->getTopGroup($this->auth->getGroupId()); | |||||
$result = $this->model->allowField(true)->save($params); | |||||
Db::commit(); | |||||
} catch (ValidateException $e) { | |||||
Db::rollback(); | |||||
$this->error($e->getMessage()); | |||||
} catch (PDOException $e) { | |||||
Db::rollback(); | |||||
$this->error($e->getMessage()); | |||||
} catch (Exception $e) { | |||||
Db::rollback(); | |||||
$this->error($e->getMessage()); | |||||
} | |||||
if ($result !== false) { | |||||
$this->success(); | |||||
} else { | |||||
$this->error(__('No rows were inserted')); | |||||
} | |||||
} | |||||
$this->error(__('Parameter %s can not be empty', '')); | |||||
} | |||||
return $this->view->fetch(); | |||||
} | |||||
/** | /** | ||||
* 查看 | * 查看 | ||||
@@ -49,10 +100,12 @@ class CfChannelInfo extends Backend | |||||
if ($this->request->request('keyField')) { | if ($this->request->request('keyField')) { | ||||
return $this->selectpage(); | return $this->selectpage(); | ||||
} | } | ||||
$groupDao = new GroupDao(); | |||||
$group_id = $groupDao->getTopGroup($this->auth->getGroupId()); | |||||
list($where, $sort, $order, $offset, $limit) = $this->buildparams(); | list($where, $sort, $order, $offset, $limit) = $this->buildparams(); | ||||
$list = $this->model | $list = $this->model | ||||
->where($where) | ->where($where) | ||||
->where("group_id",'=',$group_id) | |||||
->order($sort, $order) | ->order($sort, $order) | ||||
->paginate($limit); | ->paginate($limit); | ||||
@@ -68,12 +121,15 @@ class CfChannelInfo extends Backend | |||||
$name=$this->request->post('name'); | $name=$this->request->post('name'); | ||||
$keyValue=$this->request->post('keyValue'); | $keyValue=$this->request->post('keyValue'); | ||||
$this->model->field('id,channel_name as name,commission_rate'); | $this->model->field('id,channel_name as name,commission_rate'); | ||||
$groupDao = new GroupDao(); | |||||
$group_id = $groupDao->getTopGroup($this->auth->getGroupId()); | |||||
$where = ["group_id"=>$group_id]; | |||||
if($keyValue){ | if($keyValue){ | ||||
$this->model->where(['id'=>$keyValue]); | |||||
$where = ['id'=>$keyValue,"group_id"=>$group_id]; | |||||
}elseif($name){ | }elseif($name){ | ||||
$this->model->where(['channel_name'=>['like','%'.$name.'%']]); | |||||
$where = ['channel_name'=>['like','%'.$name.'%',"group_id"=>$group_id]]; | |||||
} | } | ||||
$result= $this->model->select(); | |||||
$result= $this->model->where($where)->select(); | |||||
if($keyValue){ | if($keyValue){ | ||||
return json(['list' => $result]); | return json(['list' => $result]); | ||||
} | } | ||||
@@ -2,6 +2,7 @@ | |||||
namespace app\admin\controller; | namespace app\admin\controller; | ||||
use app\admin\dao\GroupDao; | |||||
use app\admin\model\Area; | use app\admin\model\Area; | ||||
use app\admin\service\CfHotelInfoService; | use app\admin\service\CfHotelInfoService; | ||||
use app\common\controller\Backend; | use app\common\controller\Backend; | ||||
@@ -17,6 +18,7 @@ use think\exception\ValidateException; | |||||
class CfHotelInfo extends Backend | class CfHotelInfo extends Backend | ||||
{ | { | ||||
protected $noNeedRight = ['getHotelList',"getList","save","delAll"]; | |||||
/** | /** | ||||
* CfHotelInfo模型对象 | * CfHotelInfo模型对象 | ||||
* @var \app\admin\model\CfHotelInfo | * @var \app\admin\model\CfHotelInfo | ||||
@@ -44,7 +46,10 @@ class CfHotelInfo extends Backend | |||||
public function getHotelList(){ | public function getHotelList(){ | ||||
$name=$this->request->post('name'); | $name=$this->request->post('name'); | ||||
$keyValue=$this->request->post('keyValue'); | $keyValue=$this->request->post('keyValue'); | ||||
$result= $this->model->getList($name,$keyValue); | |||||
$params['create_id']=$this->auth->id; | |||||
$groupDao = new GroupDao(); | |||||
$params['group_id'] = $groupDao->getTopGroup($this->auth->getGroupId()); | |||||
$result= $this->model->getList($name,$keyValue,$params); | |||||
if($keyValue){ | if($keyValue){ | ||||
return json(['list' => $result]); | return json(['list' => $result]); | ||||
} | } | ||||
@@ -58,6 +63,9 @@ class CfHotelInfo extends Backend | |||||
*/ | */ | ||||
public function getList(){ | public function getList(){ | ||||
$params=$this->request->post(); | $params=$this->request->post(); | ||||
$params['create_id']=$this->auth->id; | |||||
$groupDao = new GroupDao(); | |||||
$params['group_id'] = $groupDao->getTopGroup($this->auth->getGroupId()); | |||||
$service = new CfHotelInfoService(); | $service = new CfHotelInfoService(); | ||||
return json($service->getList($params)); | return json($service->getList($params)); | ||||
} | } | ||||
@@ -69,7 +77,8 @@ class CfHotelInfo extends Backend | |||||
public function save(){ | public function save(){ | ||||
$params=$this->request->post(); | $params=$this->request->post(); | ||||
$params['create_id']=$this->auth->id; | $params['create_id']=$this->auth->id; | ||||
$params['group_id']=$this->auth->getGroupId(); | |||||
$groupDao = new GroupDao(); | |||||
$params['group_id'] = $groupDao->getTopGroup($this->auth->getGroupId()); | |||||
$service = new CfHotelInfoService(); | $service = new CfHotelInfoService(); | ||||
return json($service->save($params)); | return json($service->save($params)); | ||||
} | } | ||||
@@ -2,6 +2,7 @@ | |||||
namespace app\admin\controller; | namespace app\admin\controller; | ||||
use app\admin\dao\GroupDao; | |||||
use app\admin\model\Area; | use app\admin\model\Area; | ||||
use app\admin\service\CfItemService; | use app\admin\service\CfItemService; | ||||
use app\common\controller\Backend; | use app\common\controller\Backend; | ||||
@@ -16,7 +17,7 @@ use think\exception\ValidateException; | |||||
*/ | */ | ||||
class CfItem extends Backend | class CfItem extends Backend | ||||
{ | { | ||||
protected $noNeedRight = ['list',"save","delAll","getList"]; | |||||
/** | /** | ||||
* CfItem模型对象 | * CfItem模型对象 | ||||
* @var \app\admin\model\CfItem | * @var \app\admin\model\CfItem | ||||
@@ -60,16 +61,10 @@ class CfItem extends Backend | |||||
->join('hbp_admin d','a.purchase_user_id = d.id','left') | ->join('hbp_admin d','a.purchase_user_id = d.id','left') | ||||
->field("a.*,d.nickname") | ->field("a.*,d.nickname") | ||||
->where($where); | ->where($where); | ||||
if ($group_id){ | |||||
$list = $list | |||||
->where("group_id","=",$group_id) | |||||
->order($sort, $order) | |||||
->paginate($limit); | |||||
}else{ | |||||
$list = $list | |||||
->order($sort, $order) | |||||
->paginate($limit); | |||||
} | |||||
$list = $list | |||||
->where("group_id","=",$group_id) | |||||
->order($sort, $order) | |||||
->paginate($limit); | |||||
$config = \think\Config::get("site.item_category"); | $config = \think\Config::get("site.item_category"); | ||||
$config = json_decode($config,true); | $config = json_decode($config,true); | ||||
@@ -214,11 +209,13 @@ class CfItem extends Backend | |||||
$name=$this->request->post('name'); | $name=$this->request->post('name'); | ||||
$keyValue=$this->request->post('keyValue'); | $keyValue=$this->request->post('keyValue'); | ||||
$this->model->field('id,item_name as name,item_unit,item_type,item_memo,purchase_user_id'); | $this->model->field('id,item_name as name,item_unit,item_type,item_memo,purchase_user_id'); | ||||
$where = ["del_flag"=>0]; | |||||
$groupDao = new GroupDao(); | |||||
$group_id = $groupDao->getTopGroup($this->auth->getGroupId()); | |||||
$where = ["del_flag"=>0,"group_id"=>$group_id]; | |||||
if($keyValue){ | if($keyValue){ | ||||
$where = ['id'=>$keyValue,"del_flag"=>0]; | |||||
$where = ['id'=>$keyValue,"del_flag"=>0,"group_id"=>$group_id]; | |||||
}elseif($name){ | }elseif($name){ | ||||
$where = ['item_name'=>['like','%'.$name.'%'],"del_flag"=>0]; | |||||
$where = ['item_name'=>['like','%'.$name.'%'],"del_flag"=>0,"group_id"=>$group_id]; | |||||
} | } | ||||
$result= $this->model->where($where)->select()->toArray(); | $result= $this->model->where($where)->select()->toArray(); | ||||
@@ -245,6 +242,9 @@ class CfItem extends Backend | |||||
*/ | */ | ||||
public function list(){ | public function list(){ | ||||
$params=$this->request->post(); | $params=$this->request->post(); | ||||
$params['create_id']=$this->auth->id; | |||||
$groupDao = new GroupDao(); | |||||
$params['group_id'] = $groupDao->getTopGroup($this->auth->getGroupId()); | |||||
$service = new CfItemService(); | $service = new CfItemService(); | ||||
return json($service->getList($params)); | return json($service->getList($params)); | ||||
} | } | ||||
@@ -256,7 +256,8 @@ class CfItem extends Backend | |||||
public function save(){ | public function save(){ | ||||
$params=$this->request->post(); | $params=$this->request->post(); | ||||
$params['create_id']=$this->auth->id; | $params['create_id']=$this->auth->id; | ||||
$params['group_id']=$this->auth->getGroupId(); | |||||
$groupDao = new GroupDao(); | |||||
$params['group_id'] = $groupDao->getTopGroup($this->auth->getGroupId()); | |||||
$service = new CfItemService(); | $service = new CfItemService(); | ||||
return json($service->save($params)); | return json($service->save($params)); | ||||
} | } | ||||
@@ -2,6 +2,7 @@ | |||||
namespace app\admin\controller; | namespace app\admin\controller; | ||||
use app\admin\dao\GroupDao; | |||||
use app\admin\model\Area; | use app\admin\model\Area; | ||||
use app\common\controller\Backend; | use app\common\controller\Backend; | ||||
use think\Db; | use think\Db; | ||||
@@ -15,6 +16,7 @@ use think\exception\ValidateException; | |||||
*/ | */ | ||||
class CfRoomInfo extends Backend | class CfRoomInfo extends Backend | ||||
{ | { | ||||
protected $noNeedRight = ['getRoomList',"getList"]; | |||||
/** | /** | ||||
* CfRoomInfo模型对象 | * CfRoomInfo模型对象 | ||||
@@ -53,21 +55,18 @@ class CfRoomInfo extends Backend | |||||
} | } | ||||
list($where, $sort, $order, $offset, $limit) = $this->buildparams(); | list($where, $sort, $order, $offset, $limit) = $this->buildparams(); | ||||
$group_id=$this->auth->getGroupId(); | $group_id=$this->auth->getGroupId(); | ||||
$groupDao = new GroupDao(); | |||||
$group_id = $groupDao->getTopGroup($group_id); | |||||
$list = $this->model | $list = $this->model | ||||
->alias('a') | ->alias('a') | ||||
->join('hbp_cf_hotel_info b','a.hotel_id = b.id','left') | ->join('hbp_cf_hotel_info b','a.hotel_id = b.id','left') | ||||
->join('hbp_admin c','a.create_id = c.id','left') | ->join('hbp_admin c','a.create_id = c.id','left') | ||||
->field("a.id,a.hotel_id,a.room_name,a.room_memo,b.hotel_name,a.create_time,a.update_time,c.nickname") | ->field("a.id,a.hotel_id,a.room_name,a.room_memo,b.hotel_name,a.create_time,a.update_time,c.nickname") | ||||
->where($where); | ->where($where); | ||||
if ($group_id){ | |||||
$list = $list | |||||
->where("group_id","=",$group_id) | |||||
->order($sort, $order) | |||||
->paginate($limit); | |||||
}else{ | |||||
$list= $list->order($sort, $order) | |||||
->paginate($limit); | |||||
} | |||||
$list = $list | |||||
->where("a.group_id","=",$group_id) | |||||
->order($sort, $order) | |||||
->paginate($limit); | |||||
$result = array("total" => $list->total(), "rows" => $list->items()); | $result = array("total" => $list->total(), "rows" => $list->items()); | ||||
return json($result); | return json($result); | ||||
@@ -100,7 +99,8 @@ class CfRoomInfo extends Backend | |||||
$this->model->validateFailException(true)->validate($validate); | $this->model->validateFailException(true)->validate($validate); | ||||
} | } | ||||
$params['create_id']=$this->auth->id; | $params['create_id']=$this->auth->id; | ||||
$params['group_id']=$this->auth->getGroupId(); | |||||
$groupDao = new GroupDao(); | |||||
$params['group_id'] = $groupDao->getTopGroup($this->auth->getGroupId()); | |||||
$result = $this->model->allowField(true)->save($params); | $result = $this->model->allowField(true)->save($params); | ||||
Db::commit(); | Db::commit(); | ||||
} catch (ValidateException $e) { | } catch (ValidateException $e) { | ||||
@@ -2,6 +2,7 @@ | |||||
namespace app\admin\controller; | namespace app\admin\controller; | ||||
use app\admin\dao\GroupDao; | |||||
use app\admin\model\Area; | use app\admin\model\Area; | ||||
use app\common\controller\Backend; | use app\common\controller\Backend; | ||||
use think\Db; | use think\Db; | ||||
@@ -15,7 +16,7 @@ use think\exception\ValidateException; | |||||
*/ | */ | ||||
class CfRoomPlan extends Backend | class CfRoomPlan extends Backend | ||||
{ | { | ||||
protected $noNeedRight = ['getList']; | |||||
/** | /** | ||||
* CfRoomPlan模型对象 | * CfRoomPlan模型对象 | ||||
* @var \app\admin\model\CfRoomPlan | * @var \app\admin\model\CfRoomPlan | ||||
@@ -49,14 +50,16 @@ class CfRoomPlan extends Backend | |||||
public function getList(){ | public function getList(){ | ||||
$groupDao = new GroupDao(); | |||||
$group_id = $groupDao->getTopGroup($this->auth->getGroupId()); | |||||
$name=$this->request->post('name'); | $name=$this->request->post('name'); | ||||
$keyValue=$this->request->post('keyValue'); | $keyValue=$this->request->post('keyValue'); | ||||
$this->model->field('id,plan_name as name,purchase_user_id,plan_memo'); | $this->model->field('id,plan_name as name,purchase_user_id,plan_memo'); | ||||
$where = ["del_flag"=>0]; | |||||
$where = ["del_flag"=>0,"group_id"=>$group_id]; | |||||
if($keyValue){ | if($keyValue){ | ||||
$where = ['id'=>$keyValue,"del_flag"=>0]; | |||||
$where = ['id'=>$keyValue,"del_flag"=>0,"group_id"=>$group_id]; | |||||
}elseif($name){ | }elseif($name){ | ||||
$where = ['plan_name'=>['like','%'.$name.'%'],"del_flag"=>0]; | |||||
$where = ['plan_name'=>['like','%'.$name.'%'],"del_flag"=>0,"group_id"=>$group_id]; | |||||
} | } | ||||
$roomId =$this->request->get('room_id'); | $roomId =$this->request->get('room_id'); | ||||
if ($roomId){ | if ($roomId){ | ||||
@@ -82,7 +85,8 @@ class CfRoomPlan extends Backend | |||||
return $this->selectpage(); | return $this->selectpage(); | ||||
} | } | ||||
list($where, $sort, $order, $offset, $limit) = $this->buildparams(); | list($where, $sort, $order, $offset, $limit) = $this->buildparams(); | ||||
$group_id=$this->auth->getGroupId(); | |||||
$groupDao = new GroupDao(); | |||||
$group_id = $groupDao->getTopGroup($this->auth->getGroupId()); | |||||
$list = $this->model | $list = $this->model | ||||
->alias("a") | ->alias("a") | ||||
->join('hbp_admin','a.purchase_user_id = hbp_admin.id','left') | ->join('hbp_admin','a.purchase_user_id = hbp_admin.id','left') | ||||
@@ -90,16 +94,10 @@ class CfRoomPlan extends Backend | |||||
->join('hbp_cf_hotel_info f','a.hotel_id = f.id','left') | ->join('hbp_cf_hotel_info f','a.hotel_id = f.id','left') | ||||
->field("a.*,hbp_admin.nickname,e.room_name,f.hotel_name") | ->field("a.*,hbp_admin.nickname,e.room_name,f.hotel_name") | ||||
->where($where); | ->where($where); | ||||
if ($group_id){ | |||||
$list = $list | |||||
->where("group_id","=",$group_id) | |||||
->order($sort, $order) | |||||
->paginate($limit); | |||||
}else{ | |||||
$list = $list | |||||
->order($sort, $order) | |||||
->paginate($limit); | |||||
} | |||||
$list = $list | |||||
->where("a.group_id","=",$group_id) | |||||
->order($sort, $order) | |||||
->paginate($limit); | |||||
$result = $list->items(); | $result = $list->items(); | ||||
foreach ($result as $k=>$item){ | foreach ($result as $k=>$item){ | ||||
$result[$k]["continuity_type"]=$this->continuity_type[$item["continuity_type"]]; | $result[$k]["continuity_type"]=$this->continuity_type[$item["continuity_type"]]; | ||||
@@ -134,8 +132,9 @@ class CfRoomPlan extends Backend | |||||
$validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : $name) : $this->modelValidate; | $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : $name) : $this->modelValidate; | ||||
$this->model->validateFailException(true)->validate($validate); | $this->model->validateFailException(true)->validate($validate); | ||||
} | } | ||||
$groupDao = new GroupDao(); | |||||
$params['create_id']=$this->auth->id; | $params['create_id']=$this->auth->id; | ||||
$params['group_id']=$this->auth->getGroupId(); | |||||
$params['group_id']=$groupDao->getTopGroup($this->auth->getGroupId()); | |||||
$result = $this->model->allowField(true)->save($params); | $result = $this->model->allowField(true)->save($params); | ||||
Db::commit(); | Db::commit(); | ||||
} catch (ValidateException $e) { | } catch (ValidateException $e) { | ||||
@@ -2,7 +2,12 @@ | |||||
namespace app\admin\controller; | namespace app\admin\controller; | ||||
use app\admin\dao\GroupDao; | |||||
use app\common\controller\Backend; | use app\common\controller\Backend; | ||||
use think\Db; | |||||
use think\Exception; | |||||
use think\exception\PDOException; | |||||
use think\exception\ValidateException; | |||||
/** | /** | ||||
* 供应商配置 | * 供应商配置 | ||||
@@ -11,7 +16,7 @@ use app\common\controller\Backend; | |||||
*/ | */ | ||||
class CfSuplierInfo extends Backend | class CfSuplierInfo extends Backend | ||||
{ | { | ||||
protected $noNeedRight = ['getList']; | |||||
/** | /** | ||||
* CfSuplierInfo模型对象 | * CfSuplierInfo模型对象 | ||||
* @var \app\admin\model\CfSuplierInfo | * @var \app\admin\model\CfSuplierInfo | ||||
@@ -36,14 +41,97 @@ class CfSuplierInfo extends Backend | |||||
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改 | * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改 | ||||
*/ | */ | ||||
/** | |||||
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法 | |||||
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑 | |||||
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改 | |||||
*/ | |||||
/** | |||||
* 添加 | |||||
*/ | |||||
public function add() | |||||
{ | |||||
if ($this->request->isPost()) { | |||||
$params = $this->request->post("row/a"); | |||||
if ($params) { | |||||
$params = $this->preExcludeFields($params); | |||||
if ($this->dataLimit && $this->dataLimitFieldAutoFill) { | |||||
$params[$this->dataLimitField] = $this->auth->id; | |||||
} | |||||
$result = false; | |||||
Db::startTrans(); | |||||
try { | |||||
//是否采用模型验证 | |||||
if ($this->modelValidate) { | |||||
$name = str_replace("\\model\\", "\\validate\\", get_class($this->model)); | |||||
$validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : $name) : $this->modelValidate; | |||||
$this->model->validateFailException(true)->validate($validate); | |||||
} | |||||
$params['create_id']=$this->auth->id; | |||||
$groupDao = new GroupDao(); | |||||
$params['group_id'] = $groupDao->getTopGroup($this->auth->getGroupId()); | |||||
$result = $this->model->allowField(true)->save($params); | |||||
Db::commit(); | |||||
} catch (ValidateException $e) { | |||||
Db::rollback(); | |||||
$this->error($e->getMessage()); | |||||
} catch (PDOException $e) { | |||||
Db::rollback(); | |||||
$this->error($e->getMessage()); | |||||
} catch (Exception $e) { | |||||
Db::rollback(); | |||||
$this->error($e->getMessage()); | |||||
} | |||||
if ($result !== false) { | |||||
$this->success(); | |||||
} else { | |||||
$this->error(__('No rows were inserted')); | |||||
} | |||||
} | |||||
$this->error(__('Parameter %s can not be empty', '')); | |||||
} | |||||
return $this->view->fetch(); | |||||
} | |||||
/** | |||||
* 查看 | |||||
*/ | |||||
public function index() | |||||
{ | |||||
//设置过滤方法 | |||||
$this->request->filter(['strip_tags', 'trim']); | |||||
if ($this->request->isAjax()) { | |||||
//如果发送的来源是Selectpage,则转发到Selectpage | |||||
if ($this->request->request('keyField')) { | |||||
return $this->selectpage(); | |||||
} | |||||
$groupDao = new GroupDao(); | |||||
$group_id = $groupDao->getTopGroup($this->auth->getGroupId()); | |||||
list($where, $sort, $order, $offset, $limit) = $this->buildparams(); | |||||
$list = $this->model | |||||
->where($where) | |||||
->where("group_id",'=',$group_id) | |||||
->order($sort, $order) | |||||
->paginate($limit); | |||||
$result = array("total" => $list->total(), "rows" => $list->items()); | |||||
return json($result); | |||||
} | |||||
return $this->view->fetch(); | |||||
} | |||||
public function getList(){ | public function getList(){ | ||||
$name=$this->request->post('name'); | $name=$this->request->post('name'); | ||||
$keyValue=$this->request->post('keyValue'); | $keyValue=$this->request->post('keyValue'); | ||||
$this->model->field('id,supplier_name as name'); | $this->model->field('id,supplier_name as name'); | ||||
$groupDao = new GroupDao(); | |||||
$group_id = $groupDao->getTopGroup($this->auth->getGroupId()); | |||||
if($keyValue){ | if($keyValue){ | ||||
$this->model->where(['id'=>$keyValue]); | |||||
$this->model->where(['id'=>$keyValue,"group_id"=>$group_id]); | |||||
}elseif($name){ | }elseif($name){ | ||||
$this->model->where(['supplier_name'=>['like','%'.$name.'%']]); | |||||
$this->model->where(['supplier_name'=>['like','%'.$name.'%'],"group_id"=>$group_id]); | |||||
} | } | ||||
$result= $this->model->select(); | $result= $this->model->select(); | ||||
if($keyValue){ | if($keyValue){ | ||||
@@ -58,7 +58,7 @@ class Deposit extends Backend | |||||
->where($where); | ->where($where); | ||||
if ($group_id){ | if ($group_id){ | ||||
$list = $list | $list = $list | ||||
->where("group_id","=",$group_id) | |||||
->where("a.group_id","=",$group_id) | |||||
->order($sort, $order) | ->order($sort, $order) | ||||
->paginate($limit); | ->paginate($limit); | ||||
}else{ | }else{ | ||||
@@ -2,7 +2,12 @@ | |||||
namespace app\admin\controller; | namespace app\admin\controller; | ||||
use app\admin\dao\GroupDao; | |||||
use app\common\controller\Backend; | use app\common\controller\Backend; | ||||
use think\Db; | |||||
use think\Exception; | |||||
use think\exception\PDOException; | |||||
use think\exception\ValidateException; | |||||
/** | /** | ||||
* 订单-酒店订单子管理 | * 订单-酒店订单子管理 | ||||
@@ -11,7 +16,7 @@ use app\common\controller\Backend; | |||||
*/ | */ | ||||
class OrderHotel extends Backend | class OrderHotel extends Backend | ||||
{ | { | ||||
/** | /** | ||||
* OrderHotel模型对象 | * OrderHotel模型对象 | ||||
* @var \app\admin\model\OrderHotel | * @var \app\admin\model\OrderHotel | ||||
@@ -35,6 +40,49 @@ class OrderHotel extends Backend | |||||
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑 | * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑 | ||||
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改 | * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改 | ||||
*/ | */ | ||||
/** | |||||
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法 | |||||
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑 | |||||
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改 | |||||
*/ | |||||
/** | |||||
* 添加 | |||||
*/ | |||||
public function add() | |||||
{ | |||||
if ($this->request->isPost()) { | |||||
$this->error(__('不可新增', '')); | |||||
} | |||||
return $this->view->fetch(); | |||||
} | |||||
/** | |||||
* 查看 | |||||
*/ | |||||
public function index() | |||||
{ | |||||
//设置过滤方法 | |||||
$this->request->filter(['strip_tags', 'trim']); | |||||
if ($this->request->isAjax()) { | |||||
//如果发送的来源是Selectpage,则转发到Selectpage | |||||
if ($this->request->request('keyField')) { | |||||
return $this->selectpage(); | |||||
} | |||||
$groupDao = new GroupDao(); | |||||
$group_id = $groupDao->getTopGroup($this->auth->getGroupId()); | |||||
list($where, $sort, $order, $offset, $limit) = $this->buildparams(); | |||||
$list = $this->model | |||||
->where($where) | |||||
->where("group_id",'=',$group_id) | |||||
->order($sort, $order) | |||||
->paginate($limit); | |||||
$result = array("total" => $list->total(), "rows" => $list->items()); | |||||
return json($result); | |||||
} | |||||
return $this->view->fetch(); | |||||
} | |||||
} | } |
@@ -2,7 +2,12 @@ | |||||
namespace app\admin\controller; | namespace app\admin\controller; | ||||
use app\admin\dao\GroupDao; | |||||
use app\common\controller\Backend; | use app\common\controller\Backend; | ||||
use think\Db; | |||||
use think\Exception; | |||||
use think\exception\PDOException; | |||||
use think\exception\ValidateException; | |||||
/** | /** | ||||
* 订单-附加项目子订单 | * 订单-附加项目子订单 | ||||
@@ -35,6 +40,49 @@ class OrderItem extends Backend | |||||
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑 | * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑 | ||||
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改 | * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改 | ||||
*/ | */ | ||||
/** | |||||
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法 | |||||
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑 | |||||
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改 | |||||
*/ | |||||
/** | |||||
* 添加 | |||||
*/ | |||||
public function add() | |||||
{ | |||||
if ($this->request->isPost()) { | |||||
$this->error(__('不可新增', '')); | |||||
} | |||||
return $this->view->fetch(); | |||||
} | |||||
/** | |||||
* 查看 | |||||
*/ | |||||
public function index() | |||||
{ | |||||
//设置过滤方法 | |||||
$this->request->filter(['strip_tags', 'trim']); | |||||
if ($this->request->isAjax()) { | |||||
//如果发送的来源是Selectpage,则转发到Selectpage | |||||
if ($this->request->request('keyField')) { | |||||
return $this->selectpage(); | |||||
} | |||||
$groupDao = new GroupDao(); | |||||
$group_id = $groupDao->getTopGroup($this->auth->getGroupId()); | |||||
list($where, $sort, $order, $offset, $limit) = $this->buildparams(); | |||||
$list = $this->model | |||||
->where($where) | |||||
->where("group_id",'=',$group_id) | |||||
->order($sort, $order) | |||||
->paginate($limit); | |||||
$result = array("total" => $list->total(), "rows" => $list->items()); | |||||
return json($result); | |||||
} | |||||
return $this->view->fetch(); | |||||
} | |||||
} | } |
@@ -2,6 +2,7 @@ | |||||
namespace app\admin\controller; | namespace app\admin\controller; | ||||
use app\admin\dao\GroupDao; | |||||
use app\admin\model\Area; | use app\admin\model\Area; | ||||
use app\admin\service\OrderMainService; | use app\admin\service\OrderMainService; | ||||
use app\common\controller\Backend; | use app\common\controller\Backend; | ||||
@@ -17,6 +18,7 @@ use think\Loader; | |||||
*/ | */ | ||||
class OrderMain extends Backend | class OrderMain extends Backend | ||||
{ | { | ||||
protected $noNeedRight = ['getOrderList',"save","delSubOrder","subOrderSave","getShowInfo","newAdd","insertOrderMain"]; | |||||
/** | /** | ||||
* OrderMain模型对象 | * OrderMain模型对象 | ||||
* @var \app\admin\model\OrderMain | * @var \app\admin\model\OrderMain | ||||
@@ -43,375 +45,14 @@ class OrderMain extends Backend | |||||
/** | /** | ||||
* 查看 | |||||
*/ | |||||
public function index() | |||||
{ | |||||
//设置过滤方法 | |||||
$this->request->filter(['strip_tags', 'trim']); | |||||
if ($this->request->isAjax()) { | |||||
//如果发送的来源是Selectpage,则转发到Selectpage | |||||
if ($this->request->request('keyField')) { | |||||
return $this->selectpage(); | |||||
} | |||||
list($where, $sort, $order, $offset, $limit) = $this->buildparams(); | |||||
$group_id=$this->auth->getGroupId(); | |||||
$list = $this->model | |||||
->alias("order_main") | |||||
->join('hbp_cf_channel_info b','order_main.channel_id = b.id','left') | |||||
->join('hbp_admin','order_main.create_id = hbp_admin.id','left') | |||||
->field("order_main.*,b.channel_name,hbp_admin.nickname") | |||||
->where($where); | |||||
if ($group_id){ | |||||
$list = $list | |||||
->where("group_id","=",$group_id) | |||||
->order($sort, $order) | |||||
->paginate($limit); | |||||
}else{ | |||||
$list = $list | |||||
->order($sort, $order) | |||||
->paginate($limit); | |||||
} | |||||
$result = $list->items(); | |||||
foreach ($result as $k=>$item){ | |||||
switch ($item["order_status"]){ | |||||
case 0: | |||||
$result[$k]["order_status"]="待处理"; | |||||
break; | |||||
case 1: | |||||
$result[$k]["order_status"]="已确认"; | |||||
break; | |||||
case 2: | |||||
$result[$k]["order_status"]="部分取消"; | |||||
break; | |||||
case 10: | |||||
$result[$k]["order_status"]="已完成"; | |||||
break; | |||||
case 11: | |||||
$result[$k]["order_status"]="已取消"; | |||||
break; | |||||
} | |||||
$result[$k]["hbp_admin.nickname"] = $item["nickname"]; | |||||
} | |||||
$result = array("total" => $list->total(), "rows" =>$result); | |||||
return json($result); | |||||
} | |||||
return $this->view->fetch(); | |||||
} | |||||
/** | |||||
* 生成查询所需要的条件,排序方式 | |||||
* @param mixed $searchfields 快速查询的字段 | |||||
* @param boolean $relationSearch 是否关联查询 | |||||
* @return array | |||||
*/ | |||||
protected function buildparams($searchfields = null, $relationSearch = null) | |||||
{ | |||||
$searchfields = is_null($searchfields) ? $this->searchFields : $searchfields; | |||||
$relationSearch = is_null($relationSearch) ? $this->relationSearch : $relationSearch; | |||||
$search = $this->request->get("search", ''); | |||||
$filter = $this->request->get("filter", ''); | |||||
$op = $this->request->get("op", '', 'trim'); | |||||
$sort = $this->request->get("sort", !empty($this->model) && $this->model->getPk() ? $this->model->getPk() : 'id'); | |||||
$order = $this->request->get("order", "DESC"); | |||||
$offset = $this->request->get("offset/d", 0); | |||||
$limit = $this->request->get("limit/d", 999999); | |||||
//新增自动计算页码 | |||||
$page = $limit ? intval($offset / $limit) + 1 : 1; | |||||
if ($this->request->has("page")) { | |||||
$page = $this->request->get("page/d", 1); | |||||
} | |||||
$this->request->get([config('paginate.var_page') => $page]); | |||||
$filter = (array)json_decode($filter, true); | |||||
$op = (array)json_decode($op, true); | |||||
$filter = $filter ? $filter : []; | |||||
$where = []; | |||||
$alias = []; | |||||
$bind = []; | |||||
$name = ''; | |||||
$aliasName = ''; | |||||
if (!empty($this->model) && $this->relationSearch) { | |||||
$name = $this->model->getTable(); | |||||
$alias[$name] = Loader::parseName(basename(str_replace('\\', '/', get_class($this->model)))); | |||||
$aliasName = $alias[$name] . '.'; | |||||
} | |||||
$sortArr = explode(',', $sort); | |||||
foreach ($sortArr as $index => & $item) { | |||||
$item = stripos($item, ".") === false ? $aliasName . trim($item) : $item; | |||||
} | |||||
unset($item); | |||||
$sort = implode(',', $sortArr); | |||||
$adminIds = $this->getDataLimitAdminIds(); | |||||
if (is_array($adminIds)) { | |||||
$where[] = [$aliasName . $this->dataLimitField, 'in', $adminIds]; | |||||
} | |||||
if ($search) { | |||||
$searcharr = is_array($searchfields) ? $searchfields : explode(',', $searchfields); | |||||
foreach ($searcharr as $k => &$v) { | |||||
$v = stripos($v, ".") === false ? $aliasName . $v : $v; | |||||
} | |||||
unset($v); | |||||
$where[] = [implode("|", $searcharr), "LIKE", "%{$search}%"]; | |||||
} | |||||
$index = 0; | |||||
foreach ($filter as $k => $v) { | |||||
if (!preg_match('/^[a-zA-Z0-9_\-\.]+$/', $k)) { | |||||
continue; | |||||
} | |||||
$sym = isset($op[$k]) ? $op[$k] : '='; | |||||
if (stripos($k, ".") === false) { | |||||
$k = $aliasName . $k; | |||||
} | |||||
$v = !is_array($v) ? trim($v) : $v; | |||||
$sym = strtoupper(isset($op[$k]) ? $op[$k] : $sym); | |||||
//null和空字符串特殊处理 | |||||
if (!is_array($v)) { | |||||
if (in_array(strtoupper($v), ['NULL', 'NOT NULL'])) { | |||||
$sym = strtoupper($v); | |||||
} | |||||
if (in_array($v, ['""', "''"])) { | |||||
$v = ''; | |||||
$sym = '='; | |||||
} | |||||
} | |||||
switch ($sym) { | |||||
case '=': | |||||
case '<>': | |||||
$where[] = [$k, $sym, (string)$v]; | |||||
break; | |||||
case 'LIKE': | |||||
case 'NOT LIKE': | |||||
case 'LIKE %...%': | |||||
case 'NOT LIKE %...%': | |||||
$where[] = [$k, trim(str_replace('%...%', '', $sym)), "%{$v}%"]; | |||||
break; | |||||
case '>': | |||||
case '>=': | |||||
case '<': | |||||
case '<=': | |||||
$where[] = [$k, $sym, intval($v)]; | |||||
break; | |||||
case 'FINDIN': | |||||
case 'FINDINSET': | |||||
case 'FIND_IN_SET': | |||||
$v = is_array($v) ? $v : explode(',', str_replace(' ', ',', $v)); | |||||
$findArr = array_values($v); | |||||
foreach ($findArr as $idx => $item) { | |||||
$bindName = "item_" . $index . "_" . $idx; | |||||
$bind[$bindName] = $item; | |||||
$where[] = "FIND_IN_SET(:{$bindName}, `" . str_replace('.', '`.`', $k) . "`)"; | |||||
} | |||||
break; | |||||
case 'IN': | |||||
case 'IN(...)': | |||||
case 'NOT IN': | |||||
case 'NOT IN(...)': | |||||
$where[] = [$k, str_replace('(...)', '', $sym), is_array($v) ? $v : explode(',', $v)]; | |||||
break; | |||||
case 'BETWEEN': | |||||
case 'NOT BETWEEN': | |||||
$arr = array_slice(explode(',', $v), 0, 2); | |||||
if (stripos($v, ',') === false || !array_filter($arr)) { | |||||
continue 2; | |||||
} | |||||
//当出现一边为空时改变操作符 | |||||
if ($arr[0] === '') { | |||||
$sym = $sym == 'BETWEEN' ? '<=' : '>'; | |||||
$arr = $arr[1]; | |||||
} elseif ($arr[1] === '') { | |||||
$sym = $sym == 'BETWEEN' ? '>=' : '<'; | |||||
$arr = $arr[0]; | |||||
} | |||||
$where[] = [$k, $sym, $arr]; | |||||
break; | |||||
case 'RANGE': | |||||
case 'NOT RANGE': | |||||
$v = str_replace(' - ', ',', $v); | |||||
$arr = array_slice(explode(',', $v), 0, 2); | |||||
if (stripos($v, ',') === false || !array_filter($arr)) { | |||||
continue 2; | |||||
} | |||||
//当出现一边为空时改变操作符 | |||||
if ($arr[0] === '') { | |||||
$sym = $sym == 'RANGE' ? '<=' : '>'; | |||||
$arr = $arr[1]; | |||||
} elseif ($arr[1] === '') { | |||||
$sym = $sym == 'RANGE' ? '>=' : '<'; | |||||
$arr = $arr[0]; | |||||
} | |||||
$tableArr = explode('.', $k); | |||||
if (count($tableArr) > 1 && $tableArr[0] != $name && !in_array($tableArr[0], $alias) && !empty($this->model)) { | |||||
//修复关联模型下时间无法搜索的BUG | |||||
$relation = Loader::parseName($tableArr[0], 1, false); | |||||
$alias[$this->model->$relation()->getTable()] = $tableArr[0]; | |||||
} | |||||
$where[] = [$k, str_replace('RANGE', 'BETWEEN', $sym) . ' TIME', $arr]; | |||||
break; | |||||
case 'NULL': | |||||
case 'IS NULL': | |||||
case 'NOT NULL': | |||||
case 'IS NOT NULL': | |||||
$where[] = [$k, strtolower(str_replace('IS ', '', $sym))]; | |||||
break; | |||||
default: | |||||
break; | |||||
} | |||||
$index++; | |||||
} | |||||
if (!empty($this->model)) { | |||||
$this->model->alias($alias); | |||||
} | |||||
$model = $this->model; | |||||
$where = function ($query) use ($where, $alias, $bind, &$model) { | |||||
if (!empty($model)) { | |||||
$model->alias($alias); | |||||
$model->bind($bind); | |||||
} | |||||
foreach ($where as $k => $v) { | |||||
if (is_array($v)) { | |||||
call_user_func_array([$query, 'where'], $v); | |||||
} else { | |||||
$query->where($v); | |||||
} | |||||
} | |||||
}; | |||||
return [$where, $sort, $order, $offset, $limit, $page, $alias, $bind]; | |||||
} | |||||
/** | |||||
* 添加 | |||||
*/ | |||||
public function add() | |||||
{ | |||||
if ($this->request->isPost()) { | |||||
$params = $this->request->post("row/a"); | |||||
if ($params) { | |||||
$params = $this->preExcludeFields($params); | |||||
if ($this->dataLimit && $this->dataLimitFieldAutoFill) { | |||||
$params[$this->dataLimitField] = $this->auth->id; | |||||
} | |||||
$result = false; | |||||
Db::startTrans(); | |||||
try { | |||||
//是否采用模型验证 | |||||
if ($this->modelValidate) { | |||||
$name = str_replace("\\model\\", "\\validate\\", get_class($this->model)); | |||||
$validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : $name) : $this->modelValidate; | |||||
$this->model->validateFailException(true)->validate($validate); | |||||
} | |||||
$params['create_id']=$this->auth->id; | |||||
$params['group_id']=$this->auth->getGroupId(); | |||||
$result = $this->model->allowField(true)->save($params); | |||||
Db::commit(); | |||||
} catch (ValidateException $e) { | |||||
Db::rollback(); | |||||
$this->error($e->getMessage()); | |||||
} catch (PDOException $e) { | |||||
Db::rollback(); | |||||
$this->error($e->getMessage()); | |||||
} catch (Exception $e) { | |||||
Db::rollback(); | |||||
$this->error($e->getMessage()); | |||||
} | |||||
if ($result !== false) { | |||||
$this->success(); | |||||
} else { | |||||
$this->error(__('No rows were inserted')); | |||||
} | |||||
} | |||||
$this->error(__('Parameter %s can not be empty', '')); | |||||
} | |||||
return $this->view->fetch(); | |||||
} | |||||
/** | |||||
* 编辑 | |||||
*/ | |||||
public function edit($ids = null) | |||||
{ | |||||
$row = $this->model->get($ids); | |||||
if (!$row) { | |||||
$this->error(__('No Results were found')); | |||||
} | |||||
$adminIds = $this->getDataLimitAdminIds(); | |||||
if (is_array($adminIds)) { | |||||
if (!in_array($row[$this->dataLimitField], $adminIds)) { | |||||
$this->error(__('You have no permission')); | |||||
} | |||||
} | |||||
if ($this->request->isPost()) { | |||||
$params = $this->request->post("row/a"); | |||||
if ($params) { | |||||
$params = $this->preExcludeFields($params); | |||||
$result = false; | |||||
Db::startTrans(); | |||||
try { | |||||
//是否采用模型验证 | |||||
if ($this->modelValidate) { | |||||
$name = str_replace("\\model\\", "\\validate\\", get_class($this->model)); | |||||
$validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate; | |||||
$row->validateFailException(true)->validate($validate); | |||||
} | |||||
$result = $row->allowField(true)->save($params); | |||||
Db::commit(); | |||||
} catch (ValidateException $e) { | |||||
Db::rollback(); | |||||
$this->error($e->getMessage()); | |||||
} catch (PDOException $e) { | |||||
Db::rollback(); | |||||
$this->error($e->getMessage()); | |||||
} catch (Exception $e) { | |||||
Db::rollback(); | |||||
$this->error($e->getMessage()); | |||||
} | |||||
if ($result !== false) { | |||||
$this->success(); | |||||
} else { | |||||
$this->error(__('No rows were updated')); | |||||
} | |||||
} | |||||
$this->error(__('Parameter %s can not be empty', '')); | |||||
} | |||||
$this->view->assign("row", $row); | |||||
return $this->view->fetch(); | |||||
} | |||||
public function newEdit($id =null){ | |||||
$orderMain = $this->model->find($id); | |||||
if (!$orderMain){ | |||||
return null; | |||||
} | |||||
$orderHotelList=(new \app\admin\model\OrderHotel()) | |||||
->where("order_id","=",$id) | |||||
->find(); | |||||
$orderItemList=(new \app\admin\model\OrderItem()) | |||||
->where("order_id","=",$id) | |||||
->find(); | |||||
$result = [ | |||||
"orderMain"=>$orderMain, | |||||
"hotel"=>$orderHotelList, | |||||
"item"=>$orderItemList | |||||
]; | |||||
return json($result); | |||||
} | |||||
/** | |||||
* 订单页面保存接口 | * 订单页面保存接口 | ||||
* @return \think\response\Json | * @return \think\response\Json | ||||
*/ | */ | ||||
public function save(){ | public function save(){ | ||||
$params=$this->request->post(); | $params=$this->request->post(); | ||||
$params['create_id']=$this->auth->id; | $params['create_id']=$this->auth->id; | ||||
$params['group_id']=$this->auth->getGroupId(); | |||||
$groupDao = new GroupDao(); | |||||
$params['group_id'] = $groupDao->getTopGroup($this->auth->getGroupId()); | |||||
$orderMainService = new OrderMainService(); | $orderMainService = new OrderMainService(); | ||||
Db::startTrans(); | Db::startTrans(); | ||||
$result = $orderMainService->saveOrder($params); | $result = $orderMainService->saveOrder($params); | ||||
@@ -430,7 +71,8 @@ class OrderMain extends Backend | |||||
public function subOrderSave(){ | public function subOrderSave(){ | ||||
$params=$this->request->post(); | $params=$this->request->post(); | ||||
$params['create_id']=$this->auth->id; | $params['create_id']=$this->auth->id; | ||||
$params['group_id']=$this->auth->getGroupId(); | |||||
$groupDao = new GroupDao(); | |||||
$params['group_id'] = $groupDao->getTopGroup($this->auth->getGroupId()); | |||||
$orderMainService = new OrderMainService(); | $orderMainService = new OrderMainService(); | ||||
Db::startTrans(); | Db::startTrans(); | ||||
$result = $orderMainService->subOrderSave($params); | $result = $orderMainService->subOrderSave($params); | ||||
@@ -484,6 +126,8 @@ class OrderMain extends Backend | |||||
*/ | */ | ||||
public function getOrderList(){ | public function getOrderList(){ | ||||
$params=$this->request->post(); | $params=$this->request->post(); | ||||
$groupDao = new GroupDao(); | |||||
$params['group_id'] = $groupDao->getTopGroup($this->auth->getGroupId()); | |||||
$orderMainService = new OrderMainService(); | $orderMainService = new OrderMainService(); | ||||
$result = $orderMainService->getOrderList($params); | $result = $orderMainService->getOrderList($params); | ||||
return json($result); | return json($result); | ||||
@@ -2,6 +2,7 @@ | |||||
namespace app\admin\controller; | namespace app\admin\controller; | ||||
use app\admin\dao\GroupDao; | |||||
use app\admin\service\PaymentOrderService; | use app\admin\service\PaymentOrderService; | ||||
use app\common\controller\Backend; | use app\common\controller\Backend; | ||||
@@ -12,7 +13,7 @@ use app\common\controller\Backend; | |||||
*/ | */ | ||||
class PaymentOrder extends Backend | class PaymentOrder extends Backend | ||||
{ | { | ||||
protected $noNeedRight = ['save',"getList","setStatus","addOrderMain","removeOrderMain","getSubOrderList","delAll"]; | |||||
/** | /** | ||||
* PaymentOrder模型对象 | * PaymentOrder模型对象 | ||||
* @var \app\admin\model\PaymentOrder | * @var \app\admin\model\PaymentOrder | ||||
@@ -44,7 +45,8 @@ class PaymentOrder extends Backend | |||||
public function save(){ | public function save(){ | ||||
$params=$this->request->post(); | $params=$this->request->post(); | ||||
$params['create_id']=$this->auth->id; | $params['create_id']=$this->auth->id; | ||||
$params['group_id']=$this->auth->getGroupId(); | |||||
$groupDao = new GroupDao(); | |||||
$params['group_id'] = $groupDao->getTopGroup($this->auth->getGroupId()); | |||||
$service = new PaymentOrderService(); | $service = new PaymentOrderService(); | ||||
$result = $service->save($params); | $result = $service->save($params); | ||||
return json($result); | return json($result); | ||||
@@ -56,6 +58,8 @@ class PaymentOrder extends Backend | |||||
*/ | */ | ||||
public function getList(){ | public function getList(){ | ||||
$params=$this->request->post(); | $params=$this->request->post(); | ||||
$groupDao = new GroupDao(); | |||||
$params['group_id'] = $groupDao->getTopGroup($this->auth->getGroupId()); | |||||
$service = new PaymentOrderService(); | $service = new PaymentOrderService(); | ||||
$result = $service->getList($params); | $result = $service->getList($params); | ||||
return json($result); | return json($result); | ||||
@@ -101,6 +105,8 @@ class PaymentOrder extends Backend | |||||
*/ | */ | ||||
public function getSubOrderList(){ | public function getSubOrderList(){ | ||||
$params=$this->request->post(); | $params=$this->request->post(); | ||||
$groupDao = new GroupDao(); | |||||
$params['group_id'] = $groupDao->getTopGroup($this->auth->getGroupId()); | |||||
$service = new PaymentOrderService(); | $service = new PaymentOrderService(); | ||||
$result = $service->getSubOrderList($params); | $result = $service->getSubOrderList($params); | ||||
return json($result); | return json($result); | ||||
@@ -2,6 +2,7 @@ | |||||
namespace app\admin\controller; | namespace app\admin\controller; | ||||
use app\admin\dao\GroupDao; | |||||
use app\admin\service\ReceiptOrderDao; | use app\admin\service\ReceiptOrderDao; | ||||
use app\admin\service\ReceiptOrderService; | use app\admin\service\ReceiptOrderService; | ||||
use app\common\controller\Backend; | use app\common\controller\Backend; | ||||
@@ -16,7 +17,7 @@ use think\exception\ValidateException; | |||||
*/ | */ | ||||
class ReceiptOrder extends Backend | class ReceiptOrder extends Backend | ||||
{ | { | ||||
protected $noNeedLogin = ['getOrderMainList',"getList"]; | |||||
protected $noNeedRight = ['save',"getList","setStatus","addOrderMain","removeOrderMain","getOrderMainList","delAll"]; | |||||
/** | /** | ||||
* ReceiptOrder模型对象 | * ReceiptOrder模型对象 | ||||
* @var \app\admin\model\ReceiptOrder | * @var \app\admin\model\ReceiptOrder | ||||
@@ -41,152 +42,6 @@ class ReceiptOrder extends Backend | |||||
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改 | * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改 | ||||
*/ | */ | ||||
/** | |||||
* 查看 | |||||
*/ | |||||
public function index() | |||||
{ | |||||
//设置过滤方法 | |||||
$this->request->filter(['strip_tags', 'trim']); | |||||
if ($this->request->isAjax()) { | |||||
//如果发送的来源是Selectpage,则转发到Selectpage | |||||
if ($this->request->request('keyField')) { | |||||
return $this->selectpage(); | |||||
} | |||||
list($where, $sort, $order, $offset, $limit) = $this->buildparams(); | |||||
$group_id=$this->auth->getGroupId(); | |||||
$list = $this->model | |||||
->alias("a") | |||||
->join('hbp_admin c','a.create_id = c.id','left') | |||||
->field("a.*,c.nickname") | |||||
->where($where); | |||||
if ($group_id){ | |||||
$list = $list | |||||
->where("group_id","=",$group_id) | |||||
->order($sort, $order) | |||||
->paginate($limit); | |||||
}else{ | |||||
$list = $list | |||||
->order($sort, $order) | |||||
->paginate($limit); | |||||
} | |||||
$res = $list->items(); | |||||
foreach ($res as $k=>$item){ | |||||
switch ($item["status"]){ | |||||
case 0: | |||||
$res[$k]["status"]="未付款"; | |||||
break; | |||||
case 1: | |||||
$res[$k]["status"]="已付款"; | |||||
break; | |||||
} | |||||
} | |||||
$result = array("total" => $list->total(), "rows" => $list->items()); | |||||
return json($result); | |||||
} | |||||
return $this->view->fetch(); | |||||
} | |||||
/** | |||||
* 添加 | |||||
*/ | |||||
public function add() | |||||
{ | |||||
if ($this->request->isPost()) { | |||||
$params = $this->request->post("row/a"); | |||||
if ($params) { | |||||
$params = $this->preExcludeFields($params); | |||||
if ($this->dataLimit && $this->dataLimitFieldAutoFill) { | |||||
$params[$this->dataLimitField] = $this->auth->id; | |||||
} | |||||
$result = false; | |||||
Db::startTrans(); | |||||
try { | |||||
//是否采用模型验证 | |||||
if ($this->modelValidate) { | |||||
$name = str_replace("\\model\\", "\\validate\\", get_class($this->model)); | |||||
$validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : $name) : $this->modelValidate; | |||||
$this->model->validateFailException(true)->validate($validate); | |||||
} | |||||
$params['create_id']=$this->auth->id; | |||||
$params['group_id']=$this->auth->getGroupId(); | |||||
$result = $this->model->allowField(true)->save($params); | |||||
Db::commit(); | |||||
} catch (ValidateException $e) { | |||||
Db::rollback(); | |||||
$this->error($e->getMessage()); | |||||
} catch (PDOException $e) { | |||||
Db::rollback(); | |||||
$this->error($e->getMessage()); | |||||
} catch (Exception $e) { | |||||
Db::rollback(); | |||||
$this->error($e->getMessage()); | |||||
} | |||||
if ($result !== false) { | |||||
$this->success(); | |||||
} else { | |||||
$this->error(__('No rows were inserted')); | |||||
} | |||||
} | |||||
$this->error(__('Parameter %s can not be empty', '')); | |||||
} | |||||
return $this->view->fetch(); | |||||
} | |||||
/** | |||||
* 编辑 | |||||
*/ | |||||
public function edit($ids = null) | |||||
{ | |||||
$row = $this->model->get($ids); | |||||
if (!$row) { | |||||
$this->error(__('No Results were found')); | |||||
} | |||||
$adminIds = $this->getDataLimitAdminIds(); | |||||
if (is_array($adminIds)) { | |||||
if (!in_array($row[$this->dataLimitField], $adminIds)) { | |||||
$this->error(__('You have no permission')); | |||||
} | |||||
} | |||||
if ($this->request->isPost()) { | |||||
$params = $this->request->post("row/a"); | |||||
if ($params) { | |||||
$params = $this->preExcludeFields($params); | |||||
$result = false; | |||||
Db::startTrans(); | |||||
try { | |||||
//是否采用模型验证 | |||||
if ($this->modelValidate) { | |||||
$name = str_replace("\\model\\", "\\validate\\", get_class($this->model)); | |||||
$validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate; | |||||
$row->validateFailException(true)->validate($validate); | |||||
} | |||||
$result = $row->allowField(true)->save($params); | |||||
Db::commit(); | |||||
} catch (ValidateException $e) { | |||||
Db::rollback(); | |||||
$this->error($e->getMessage()); | |||||
} catch (PDOException $e) { | |||||
Db::rollback(); | |||||
$this->error($e->getMessage()); | |||||
} catch (Exception $e) { | |||||
Db::rollback(); | |||||
$this->error($e->getMessage()); | |||||
} | |||||
if ($result !== false) { | |||||
$this->success(); | |||||
} else { | |||||
$this->error(__('No rows were updated')); | |||||
} | |||||
} | |||||
$this->error(__('Parameter %s can not be empty', '')); | |||||
} | |||||
$this->view->assign("row", $row); | |||||
return $this->view->fetch(); | |||||
} | |||||
/** | /** | ||||
* 保存记录 | * 保存记录 | ||||
* @return \think\response\Json | * @return \think\response\Json | ||||
@@ -194,7 +49,8 @@ class ReceiptOrder extends Backend | |||||
public function save(){ | public function save(){ | ||||
$params=$this->request->post(); | $params=$this->request->post(); | ||||
$params['create_id']=$this->auth->id; | $params['create_id']=$this->auth->id; | ||||
$params['group_id']=$this->auth->getGroupId(); | |||||
$groupDao = new GroupDao(); | |||||
$params['group_id'] = $groupDao->getTopGroup($this->auth->getGroupId()); | |||||
$service = new ReceiptOrderService(); | $service = new ReceiptOrderService(); | ||||
$result = $service->save($params); | $result = $service->save($params); | ||||
return json($result); | return json($result); | ||||
@@ -206,6 +62,8 @@ class ReceiptOrder extends Backend | |||||
*/ | */ | ||||
public function getList(){ | public function getList(){ | ||||
$params=$this->request->post(); | $params=$this->request->post(); | ||||
$groupDao = new GroupDao(); | |||||
$params['group_id'] = $groupDao->getTopGroup($this->auth->getGroupId()); | |||||
$service = new ReceiptOrderService(); | $service = new ReceiptOrderService(); | ||||
$result = $service->getList($params); | $result = $service->getList($params); | ||||
return json($result); | return json($result); | ||||
@@ -251,6 +109,8 @@ class ReceiptOrder extends Backend | |||||
*/ | */ | ||||
public function getOrderMainList(){ | public function getOrderMainList(){ | ||||
$params=$this->request->post(); | $params=$this->request->post(); | ||||
$groupDao = new GroupDao(); | |||||
$params['group_id'] = $groupDao->getTopGroup($this->auth->getGroupId()); | |||||
$service = new ReceiptOrderService(); | $service = new ReceiptOrderService(); | ||||
$result = $service->getOrderMainList($params); | $result = $service->getOrderMainList($params); | ||||
return json($result); | return json($result); | ||||
@@ -18,6 +18,7 @@ use think\Validate; | |||||
*/ | */ | ||||
class Admin extends Backend | class Admin extends Backend | ||||
{ | { | ||||
protected $noNeedRight = ['getList']; | |||||
/** | /** | ||||
* @var \app\admin\model\Admin | * @var \app\admin\model\Admin | ||||
@@ -18,12 +18,11 @@ use think\Validate; | |||||
*/ | */ | ||||
class Config extends Backend | class Config extends Backend | ||||
{ | { | ||||
/** | /** | ||||
* @var \app\common\model\Config | * @var \app\common\model\Config | ||||
*/ | */ | ||||
protected $model = null; | protected $model = null; | ||||
protected $noNeedRight = ['check', 'rulelist', 'selectpage', 'get_fields_list']; | |||||
protected $noNeedRight = ['check', 'rulelist', 'selectpage', 'get_fields_list',"getList"]; | |||||
public function _initialize() | public function _initialize() | ||||
{ | { | ||||
@@ -75,6 +75,9 @@ class CfHotelInfoDao | |||||
if (!empty($param['id'])) { | if (!empty($param['id'])) { | ||||
$where['id'] = $param['id']; | $where['id'] = $param['id']; | ||||
} | } | ||||
if (!empty($param['group_id'])) { | |||||
$where['group_id'] = $param['group_id']; | |||||
} | |||||
$offset = ($param['pageNum'] - 1) * $param['pageSize']; | $offset = ($param['pageNum'] - 1) * $param['pageSize']; | ||||
$model = new CfHotelInfo(); | $model = new CfHotelInfo(); | ||||
$total = $model->where($where)->count(); | $total = $model->where($where)->count(); | ||||
@@ -59,7 +59,7 @@ class CfItemDao | |||||
public function getList($param) | public function getList($param) | ||||
{ | { | ||||
try { | try { | ||||
$where = ["del_flag"=>0]; | |||||
$where = ["del_flag"=>0,"group_id"=>$param['group_id']]; | |||||
if (!empty($param['item_name'])) { | if (!empty($param['item_name'])) { | ||||
$where['item_name'] = ["like","%".$param['item_name']."%"]; | $where['item_name'] = ["like","%".$param['item_name']."%"]; | ||||
} | } | ||||
@@ -0,0 +1,42 @@ | |||||
<?php | |||||
/** | |||||
* Created by PhpStorm. | |||||
* User: nizongfeng | |||||
* Date: 2021/11/30 | |||||
* Time: 11:31 | |||||
*/ | |||||
namespace app\admin\dao; | |||||
use app\admin\command\Util; | |||||
use app\admin\model\AuthGroup; | |||||
use think\Exception; | |||||
class GroupDao | |||||
{ | |||||
/** | |||||
* 获取顶级部门 非超管 | |||||
* @param $id | |||||
* @return mixed | |||||
*/ | |||||
public function getTopGroup($id){ | |||||
if ($id == 1) { | |||||
return $id; | |||||
} | |||||
try { | |||||
$model = new AuthGroup(); | |||||
$result = $model->where(["id" => $id])->find(); | |||||
if ($result == null) { | |||||
return $id; | |||||
} | |||||
$info = $result->toArray(); | |||||
if ($info['pid']==1) { | |||||
return $id; | |||||
} | |||||
return $this->getTopGroup($info['pid']); | |||||
} catch (Exception $e) { | |||||
return $id; | |||||
} | |||||
} | |||||
} |
@@ -74,7 +74,8 @@ class OrderHotelDao | |||||
]; | ]; | ||||
$orderHotelModel = new OrderHotel(); | $orderHotelModel = new OrderHotel(); | ||||
if (empty($param['id'])) { | if (empty($param['id'])) { | ||||
$data["create_id"]= $param['create_id']; | |||||
$data["group_id"]= $param['group_id']; | |||||
$id = $orderHotelModel->insertGetId($data); | $id = $orderHotelModel->insertGetId($data); | ||||
return Util::returnArrSu("", $id); | return Util::returnArrSu("", $id); | ||||
}else { | }else { | ||||
@@ -60,6 +60,8 @@ class OrderItemDao | |||||
]; | ]; | ||||
$model = new OrderItem(); | $model = new OrderItem(); | ||||
if (empty($param['id'])) { | if (empty($param['id'])) { | ||||
$data["create_id"]= $param['create_id']; | |||||
$data["group_id"]= $param['group_id']; | |||||
$id = $model->insertGetId($data); | $id = $model->insertGetId($data); | ||||
return Util::returnArrSu("",$id); | return Util::returnArrSu("",$id); | ||||
}else { | }else { | ||||
@@ -71,7 +71,7 @@ class PaymentOrderDao | |||||
public function checkName($param):bool { | public function checkName($param):bool { | ||||
try { | try { | ||||
$model = new PaymentOrder(); | $model = new PaymentOrder(); | ||||
$infoRe = $model->where(["name" => $param['name']])->find(); | |||||
$infoRe = $model->where(["name" => $param['name'],"group_id"=>$param['group_id']])->find(); | |||||
if ($infoRe == null) { | if ($infoRe == null) { | ||||
return false; | return false; | ||||
} | } | ||||
@@ -116,7 +116,7 @@ class PaymentOrderDao | |||||
public function getList($param) | public function getList($param) | ||||
{ | { | ||||
try { | try { | ||||
$where = ["a.del_flag"=>0]; | |||||
$where = ["a.del_flag"=>0,"a.group_id"=>$param['group_id']]; | |||||
if (!empty($param['name'])) { | if (!empty($param['name'])) { | ||||
$where['a.name'] = ["like","%".$param['name']."%"]; | $where['a.name'] = ["like","%".$param['name']."%"]; | ||||
} | } | ||||
@@ -72,7 +72,7 @@ class ReceiptOrderDao | |||||
public function checkName($param):bool { | public function checkName($param):bool { | ||||
try { | try { | ||||
$model = new ReceiptOrder(); | $model = new ReceiptOrder(); | ||||
$infoRe = $model->where(["name" => $param['name']])->find(); | |||||
$infoRe = $model->where(["name" => $param['name'],"group_id"=>$param['group_id']])->find(); | |||||
if ($infoRe == null) { | if ($infoRe == null) { | ||||
return false; | return false; | ||||
} | } | ||||
@@ -117,7 +117,7 @@ class ReceiptOrderDao | |||||
public function getList($param) | public function getList($param) | ||||
{ | { | ||||
try { | try { | ||||
$where = ["a.del_flag"=>0]; | |||||
$where = ["a.del_flag"=>0,"a.group_id"=>$param['group_id']]; | |||||
if (!empty($param['name'])) { | if (!empty($param['name'])) { | ||||
$where['a.name'] = ["like","%".$param['name']."%"]; | $where['a.name'] = ["like","%".$param['name']."%"]; | ||||
} | } | ||||
@@ -29,14 +29,15 @@ class CfHotelInfo extends Model | |||||
]; | ]; | ||||
public function getList($name='',$keyValue=''){ | |||||
public function getList($name='',$keyValue='',$params){ | |||||
$this->field('id,hotel_name as name'); | $this->field('id,hotel_name as name'); | ||||
$where = ["del_flag"=>0]; | |||||
$where = ["del_flag"=>0,"group_id"=>$params['group_id']]; | |||||
if($keyValue){ | if($keyValue){ | ||||
$where = ['id'=>$keyValue,"del_flag"=>0]; | |||||
$where = ['id'=>$keyValue,"del_flag"=>0,"group_id"=>$params['group_id']]; | |||||
}elseif($name){ | }elseif($name){ | ||||
$where = ['hotel_name'=>['like','%'.$name.'%'],"del_flag"=>0]; | |||||
$where = ['hotel_name'=>['like','%'.$name.'%'],"del_flag"=>0,"group_id"=>$params['group_id']]; | |||||
} | } | ||||
return $this->where($where)->select()->toArray(); | return $this->where($where)->select()->toArray(); | ||||
} | } | ||||
@@ -48,6 +48,7 @@ class OrderMainService | |||||
$purchasePriceDao->delete($orderId); | $purchasePriceDao->delete($orderId); | ||||
//循环子订单 | //循环子订单 | ||||
foreach ($param['subOrderList'] as $subOrderParam) { | foreach ($param['subOrderList'] as $subOrderParam) { | ||||
$subOrderParam['create_id'] = $param['create_id']; | |||||
$subOrderParam['group_id'] = $param['group_id']; | $subOrderParam['group_id'] = $param['group_id']; | ||||
//1.获取负责人昵称 | //1.获取负责人昵称 | ||||
$adminDao = new AdminDao(); | $adminDao = new AdminDao(); | ||||
@@ -306,7 +307,7 @@ class OrderMainService | |||||
*/ | */ | ||||
public function getOrderList($param){ | public function getOrderList($param){ | ||||
$orderMainDao = new OrderMainDao(); | $orderMainDao = new OrderMainDao(); | ||||
$where = [" a.del_flag = 0 "]; | |||||
$where = [" a.del_flag = 0 ","a.group_id= {$param['group_id']} "]; | |||||
if (!empty($param['order_id'])) { | if (!empty($param['order_id'])) { | ||||
$where[] =" a.id = {$param['order_id']} "; | $where[] =" a.id = {$param['order_id']} "; | ||||
} | } | ||||
@@ -147,8 +147,8 @@ class PaymentOrderService | |||||
*/ | */ | ||||
public function getSubOrderList($param){ | public function getSubOrderList($param){ | ||||
$dao = new PaymentOrderDao(); | $dao = new PaymentOrderDao(); | ||||
$item_where_arr = ["d.del_flag=0","a.del_flag=0"]; | |||||
$hotel_where_arr = ["c.del_flag=0","b.del_flag=0"]; | |||||
$item_where_arr = ["d.del_flag=0","a.del_flag=0","a.group_id = {$param['group_id']}"]; | |||||
$hotel_where_arr = ["c.del_flag=0","b.del_flag=0","b.group_id = {$param['group_id']}"]; | |||||
$where_arr = []; | $where_arr = []; | ||||
if ($param['prod_type']=='hotel'){ | if ($param['prod_type']=='hotel'){ | ||||
$item_where_arr[] = " a.id = 0 "; | $item_where_arr[] = " a.id = 0 "; | ||||
@@ -119,7 +119,7 @@ class ReceiptOrderService | |||||
*/ | */ | ||||
public function getOrderMainList($param){ | public function getOrderMainList($param){ | ||||
$orderMainDao = new OrderMainDao(); | $orderMainDao = new OrderMainDao(); | ||||
$where = ["id"=>["neq",""]]; | |||||
$where = ["id"=>["neq",""],"group_id"=>$param['group_id']]; | |||||
if (!empty($param['order_id'])) { | if (!empty($param['order_id'])) { | ||||
$where["id"]=$param['order_id']; | $where["id"]=$param['order_id']; | ||||
} | } | ||||