酒店预订平台
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.
 
 
 
 
 
 

109 line
3.3 KiB

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