| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- <?php
- namespace app\api\model\service;
- use app\api\model\BaseModel;
- use redis\RedisClient;
- class Service extends BaseModel
- {
- // 表名
- protected $name = 'service';
- public function fetchServices($type, $params, $page = 1, $size = 10, $user = null)
- {
- $where = [
- 'type' => $type,
- 'status' => \E_BASE_STATUS::Normal
- ];
- 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;
- }
- $q = ["id", "<>", "276"];
- if ($user) {
- $exist = RedisClient::of()->get("scan:qr:codes:" . $user["id"]);
- if ($exist) {
- $q = ["id", ">", "0"];
- }
- }
- return $this->where($where)
- ->where($q[0], $q[1], $q[2])
- ->order('sort', 'desc')
- ->order('real_price', 'ASC')
- ->page($page)
- ->paginate($size);
- }
- public function fetchServicesV2($type, $params, $page = 1, $size = 10, $user = null)
- {
- $where = [
- 'type' => $type,
- 'status' => \E_BASE_STATUS::Normal,
- 'p_code' => $params['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);
- }
- }
|