84 lines
2.6 KiB
PHP
84 lines
2.6 KiB
PHP
<?php
|
|
|
|
namespace app\common\repositories\user;
|
|
|
|
use app\common\dao\user\ExchangePickupPointDao;
|
|
use app\common\repositories\BaseRepository;
|
|
|
|
class ExchangePickupPointRepository extends BaseRepository{
|
|
|
|
protected $dao;
|
|
|
|
public function __construct(ExchangePickupPointDao $dao){
|
|
$this->dao = $dao;
|
|
}
|
|
|
|
|
|
/**
|
|
* Common: 编辑信息
|
|
* Author: wu-hui
|
|
* Time: 2024/01/14 10:52
|
|
* @param $params
|
|
*/
|
|
public function editInfo($params){
|
|
$info = $this->dao->getSearch([])->where('id',(int)$params['id'])->findOrEmpty();
|
|
$info->title = $params['title'];
|
|
$info->address = $params['address'];
|
|
$info->is_show = $params['is_show'];
|
|
$info->uid_list = implode(',',$params['uid_list']);
|
|
|
|
$info->save();
|
|
}
|
|
/**
|
|
* Common: 获取信息列表
|
|
* Author: wu-hui
|
|
* Time: 2024/01/14 10:47
|
|
* @param array $params
|
|
* @param int $page
|
|
* @param int $limit
|
|
* @return array
|
|
* @throws \think\db\exception\DataNotFoundException
|
|
* @throws \think\db\exception\DbException
|
|
* @throws \think\db\exception\ModelNotFoundException
|
|
*/
|
|
public function getList(array $params,int $page,int $limit):array{
|
|
$query = $this->dao->getSearch([])
|
|
->when((int)$params['uid'] > 0,function($query) use ($params){
|
|
$query->where('find_in_set(' . $params['uid'] . ',`uid_list`)');
|
|
})
|
|
->when(isset($params['is_show']) && $params['is_show'] !== '',function($query) use ($params){
|
|
$query->where('is_show',$params['is_show']);
|
|
})
|
|
->when(isset($params['default_point_id']) && $params['default_point_id'] > 0,function($query) use ($params){
|
|
$query->where('id',$params['default_point_id']);
|
|
})
|
|
->when(!empty($params['address']),function($query) use ($params){
|
|
$query->where('address', "like", "%{$params['address']}%")
|
|
->whereOr('title','like',"%{$params['address']}%");
|
|
})
|
|
->order('create_time DESC,id DESC');
|
|
$count = $query->count();
|
|
$list = $query->page($page,$limit)->append(['user_list'])->select();
|
|
|
|
return compact('count','list');
|
|
}
|
|
/**
|
|
* Common: 获取单条信息
|
|
* Author: wu-hui
|
|
* Time: 2024/01/14 11:31
|
|
* @param $id
|
|
* @return array
|
|
*/
|
|
public function getInfo($id){
|
|
return $this->dao->getSearch([])
|
|
->append(['user_list'])
|
|
->where('id',$id)
|
|
->findOrEmpty()
|
|
->toArray();
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|