|
- <?php
- /**
- * Created by PhpStorm.
- * User: nizongfeng
- * Date: 2021/11/30
- * Time: 19:01
- */
-
- namespace app\admin\dao;
-
-
- use app\admin\command\Util;
- use app\admin\model\CfRoomPlan;
-
- class CfRoomPlanDao
- {
- /**
- * 添加记录
- * @param $param
- * @return array
- */
- public function save($param)
- {
- try {
- $data = [
- 'hotel_id' => $param['hotel_id'],
- 'room_id' => $param['room_id'],
- 'plan_name' => $param['plan_name'],
- 'breakfast_num' => $param['breakfast_num'],
- 'book_end_day' => $param['book_end_day'],
- 'book_end_hour' => $param['book_end_hour'],
- 'continuity_type' => $param['continuity_type'],
- "coutinuity_day"=>$param['coutinuity_day'],
- 'plan_memo' => $param['plan_memo'],
- 'purchase_user_id' => $param['purchase_user_id']
- ];
- $model = new CfRoomPlan();
- if (empty($param['id'])) {
- $data['create_id'] = $param['create_id'];
- $data['group_id'] = $param['group_id'];
- $id = $model->insertGetId($data);
- return Util::returnArrSu("", $id);
- } else {
- $model->save($data, ['id' => $param['id']]);
- return Util::returnArrSu("", $param['id']);
- }
- } catch (\Exception $e) {
- return Util::returnArrEr("更新记录失败:" . $e->getMessage());
- }
- }
-
- /**
- * 获取列表
- * @param $param
- * @return array
- */
- public function getList($param)
- {
- try {
- $where = ["del_flag"=>0];
- if (!empty($param['hotel_id'])) {
- $where["hotel_id"] = $param['hotel_id'];
- }
- if (!empty($param['room_id'])) {
- $where["room_id"] = $param['room_id'];
- }
- if (!empty($param['plan_name'])) {
- $where["plan_name"] = ["like","%".$param['plan_name']."%"];
- }
- if (!empty($param['purchase_user_id'])) {
- $where["purchase_user_id"] = $param['purchase_user_id'];
- }
- if (!empty($param['id'])) {
- $where['id'] = $param['id'];
- }
- if (!empty($param['group_id'])) {
- $where['group_id'] = $param['group_id'];
- }
- $offset = ($param['pageNum'] - 1) * $param['pageSize'];
- $model = new CfRoomPlan();
- $total = $model->where($where)->count();
- $list = $model->where($where)
- ->limit($offset, $param['pageSize'])
- ->order("id","DESC")->select();
- $data = ["total" => $total, "list" => $list->toArray()];
- return Util::returnArrSu("", $data);
- } catch (\Exception $e) {
- return Util::returnArrSu("", ["total" => 0, "list" => []]);
- }
- }
-
- /**
- * 删除
- * @param $id
- * @return array
- */
- public function del($param){
- try {
- //设置收购单状态
- $model = new CfRoomPlan();
- $model->save(['del_flag' =>1], ['id' => $param['id']]);
- return Util::returnArrSu();
- } catch (\Exception $e) {
- return Util::returnArrEr("修改状态失败" . $e->getMessage());
- }
- }
- }
|