|
- <?php
- /**
- * Created by PhpStorm.
- * User: nizongfeng
- * Date: 2021/11/23
- * Time: 11:35
- */
-
- namespace app\admin\dao;
-
-
- use app\admin\command\Util;
- use app\admin\model\CfHotelInfo;
-
- class CfHotelInfoDao
- {
- /**
- * 添加记录
- * @param $param
- * @return array
- */
- public function save($param)
- {
- try {
- $data = [
- 'hotel_name' => $param['hotel_name'],
- 'hotel_phone' => $param['hotel_phone'],
- 'area' => $param['area'],
- 'area_name' => $param['area_name'],
- 'province' => $param['province'],
- 'province_name' => $param['province_name'],
- 'city' => $param['city'],
- 'city_name' => $param['city_name'],
- 'detail_address' => $param['detail_address']
- ];
- $model = new CfHotelInfo();
- 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_name'])) {
- $where['hotel_name'] = ["like","%".$param['hotel_name']."%"];
- }
- if (!empty($param['hotel_phone'])) {
- $where["hotel_phone"] = $param['hotel_phone'];
- }
- if (!empty($param['area'])) {
- $where["area"] = $param['area'];
- }
- if (!empty($param['province'])) {
- $where["province"] = $param['province'];
- }
- if (!empty($param['city'])) {
- $where["city"] = $param['city'];
- }
- 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 CfHotelInfo();
- $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($id){
- try {
- //设置收购单状态
- $model = new CfHotelInfo();
- $model->save(['del_flag' => 1], ['id' => $id]);
- return Util::returnArrSu();
- } catch (\Exception $e) {
- return Util::returnArrEr("修改状态失败" . $e->getMessage());
- }
- }
- }
|