| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- <?php
- namespace app\api\model\service;
- use app\api\model\BaseModel;
- class Service extends BaseModel
- {
- // 表名
- protected $name = 'service';
- /**
- * @param $type
- * @param $params
- * @param $page
- * @param $size
- * @return \think\Paginator
- * @throws \think\exception\DbException
- */
- public function fetchServices($type, $params, $page = 1, $size = 10)
- {
- $where = [
- 'type' => $type,
- 'status' => \E_BASE_STATUS::Normal,
- ];
- if (isset($params['city_code']) && $params['city_code'] > 0) {
- $where['p_code'] = parse_area($params['city_code'])['p_code'];
- }
- if (isset($params['category_id']) && $params['category_id'] > 0)
- $where['category_id'] = $params['category_id'];
- if (isset($params['hot']) && $params['hot'])
- $where['hot'] = 1;
- if (isset($params['store_id']) && $params['store_id'] > 0)
- $where['store_id'] = $params['store_id'];
- if (isset($params["sift"]) && $params['sift'])
- $where['sift'] = 1;
- if (!isset($params["is_add_clock"]) || $params["is_add_clock"] != 1) {
- $where['is_add_clock'] = 0;
- }
- return $this->where($where)
- ->order('sort', 'desc')
- ->order('real_price', 'ASC')
- ->page($page)
- ->paginate($size);
- }
- }
|