酒店预订平台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

107 lines
3.3 KiB

  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: nizongfeng
  5. * Date: 2021/11/30
  6. * Time: 19:01
  7. */
  8. namespace app\admin\dao;
  9. use app\admin\command\Util;
  10. use app\admin\model\CfRoomPlan;
  11. class CfRoomPlanDao
  12. {
  13. /**
  14. * 添加记录
  15. * @param $param
  16. * @return array
  17. */
  18. public function save($param)
  19. {
  20. try {
  21. $data = [
  22. 'hotel_id' => $param['hotel_id'],
  23. 'room_id' => $param['room_id'],
  24. 'plan_name' => $param['plan_name'],
  25. 'breakfast_num' => $param['breakfast_num'],
  26. 'book_end_day' => $param['book_end_day'],
  27. 'book_end_hour' => $param['book_end_hour'],
  28. 'continuity_type' => $param['continuity_type'],
  29. "coutinuity_day"=>$param['coutinuity_day'],
  30. 'plan_memo' => $param['plan_memo'],
  31. 'purchase_user_id' => $param['purchase_user_id']
  32. ];
  33. $model = new CfRoomPlan();
  34. if (empty($param['id'])) {
  35. $data['create_id'] = $param['create_id'];
  36. $data['group_id'] = $param['group_id'];
  37. $id = $model->insertGetId($data);
  38. return Util::returnArrSu("", $id);
  39. } else {
  40. $model->save($data, ['id' => $param['id']]);
  41. return Util::returnArrSu("", $param['id']);
  42. }
  43. } catch (\Exception $e) {
  44. return Util::returnArrEr("更新记录失败:" . $e->getMessage());
  45. }
  46. }
  47. /**
  48. * 获取列表
  49. * @param $param
  50. * @return array
  51. */
  52. public function getList($param)
  53. {
  54. try {
  55. $where = ["del_flag"=>0];
  56. if (!empty($param['hotel_id'])) {
  57. $where["hotel_id"] = $param['hotel_id'];
  58. }
  59. if (!empty($param['room_id'])) {
  60. $where["room_id"] = $param['room_id'];
  61. }
  62. if (!empty($param['plan_name'])) {
  63. $where["plan_name"] = ["like","%".$param['plan_name']."%"];
  64. }
  65. if (!empty($param['purchase_user_id'])) {
  66. $where["purchase_user_id"] = $param['purchase_user_id'];
  67. }
  68. if (!empty($param['id'])) {
  69. $where['id'] = $param['id'];
  70. }
  71. if (!empty($param['group_id'])) {
  72. $where['group_id'] = $param['group_id'];
  73. }
  74. $offset = ($param['pageNum'] - 1) * $param['pageSize'];
  75. $model = new CfRoomPlan();
  76. $total = $model->where($where)->count();
  77. $list = $model->where($where)
  78. ->limit($offset, $param['pageSize'])
  79. ->order("id","DESC")->select();
  80. $data = ["total" => $total, "list" => $list->toArray()];
  81. return Util::returnArrSu("", $data);
  82. } catch (\Exception $e) {
  83. return Util::returnArrSu("", ["total" => 0, "list" => []]);
  84. }
  85. }
  86. /**
  87. * 删除
  88. * @param $id
  89. * @return array
  90. */
  91. public function del($param){
  92. try {
  93. //设置收购单状态
  94. $model = new CfRoomPlan();
  95. $model->save(['del_flag' =>1], ['id' => $param['id']]);
  96. return Util::returnArrSu();
  97. } catch (\Exception $e) {
  98. return Util::returnArrEr("修改状态失败" . $e->getMessage());
  99. }
  100. }
  101. }