修改redis

This commit is contained in:
manghe 2025-03-23 15:27:55 +00:00
parent 9599280ff8
commit a869bf5ba0
3 changed files with 25 additions and 4 deletions

3
.env
View File

@ -19,4 +19,5 @@ default_lang = zh-cn
[REDIS]
HOST = 127.0.0.1
PORT = 6379
PASSWORD =
PASSWORD =
DB = 3

View File

@ -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;

View File

@ -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);
}
}