diff --git a/.env b/.env index b7e4920..89cab74 100755 --- a/.env +++ b/.env @@ -19,4 +19,5 @@ default_lang = zh-cn [REDIS] HOST = 127.0.0.1 PORT = 6379 -PASSWORD = \ No newline at end of file +PASSWORD = +DB = 3 \ No newline at end of file diff --git a/app/api/controller/Goods.php b/app/api/controller/Goods.php index 9aebf19..dddaa6d 100755 --- a/app/api/controller/Goods.php +++ b/app/api/controller/Goods.php @@ -73,7 +73,7 @@ class Goods extends Base } elseif ($type_str == 8) { $whe[] = ['type', '=', 8]; } elseif ($type_str == 9) { - $whe[] = ['type', 'in', [11]]; + $whe[] = ['type', 'in', [9]]; } elseif ($type_str == 10) { $paginate = 999; $whe[] = ['type', '=', 10]; @@ -81,7 +81,7 @@ class Goods extends Base $whe[] = ['type', '=', 11]; } elseif ($type_str == 12) { - $whe[] = ['type', '=', 9]; + $whe[] = ['type', '=', 12]; } else { $whe[] = ['type', 'not in', [4, 10]]; } @@ -807,7 +807,12 @@ class Goods extends Base $price = 0; } $order_zhe_total = $price; - if ($goods['type'] == 1 || $goods['type'] == 3 || $goods['type'] == 6 || $goods['type'] == 11 || $goods['type'] == 10) { + if ( + $goods['type'] == 1 || + $goods['type'] == 3 || + $goods['type'] == 6 || + $goods['type'] == 11 || $goods['type'] == 10 + ) { #折扣 $zhe = 0; diff --git a/app/common/server/RedisHelper.php b/app/common/server/RedisHelper.php index 6f05caf..1f08971 100755 --- a/app/common/server/RedisHelper.php +++ b/app/common/server/RedisHelper.php @@ -22,10 +22,14 @@ class RedisHelper // 从环境变量中获取 Redis 主机和端口,默认为 127.0.0.1 和 6379 $host = env('redis.host', '127.0.0.1'); $port = env('redis.port', '6379'); + // 从环境变量中获取 Redis 数据库编号,默认为 0 + $db = env('redis.db', '0'); // 创建 Redis 实例 $this->redis = new \Redis(); // 连接到 Redis 服务器 $this->connect($host, $port); + // 选择数据库 + $this->redis->select((int)$db); } /** @@ -109,4 +113,15 @@ class RedisHelper { return $this->redis->expire($key, $timeout); } + + /** + * 选择 Redis 数据库 + * + * @param int $db 数据库编号 + * @return bool 选择是否成功 + */ + public function select($db) + { + return $this->redis->select($db); + } } \ No newline at end of file