修改redis
This commit is contained in:
parent
9599280ff8
commit
a869bf5ba0
1
.env
1
.env
|
|
@ -20,3 +20,4 @@ default_lang = zh-cn
|
||||||
HOST = 127.0.0.1
|
HOST = 127.0.0.1
|
||||||
PORT = 6379
|
PORT = 6379
|
||||||
PASSWORD =
|
PASSWORD =
|
||||||
|
DB = 3
|
||||||
|
|
@ -73,7 +73,7 @@ class Goods extends Base
|
||||||
} elseif ($type_str == 8) {
|
} elseif ($type_str == 8) {
|
||||||
$whe[] = ['type', '=', 8];
|
$whe[] = ['type', '=', 8];
|
||||||
} elseif ($type_str == 9) {
|
} elseif ($type_str == 9) {
|
||||||
$whe[] = ['type', 'in', [11]];
|
$whe[] = ['type', 'in', [9]];
|
||||||
} elseif ($type_str == 10) {
|
} elseif ($type_str == 10) {
|
||||||
$paginate = 999;
|
$paginate = 999;
|
||||||
$whe[] = ['type', '=', 10];
|
$whe[] = ['type', '=', 10];
|
||||||
|
|
@ -81,7 +81,7 @@ class Goods extends Base
|
||||||
|
|
||||||
$whe[] = ['type', '=', 11];
|
$whe[] = ['type', '=', 11];
|
||||||
} elseif ($type_str == 12) {
|
} elseif ($type_str == 12) {
|
||||||
$whe[] = ['type', '=', 9];
|
$whe[] = ['type', '=', 12];
|
||||||
} else {
|
} else {
|
||||||
$whe[] = ['type', 'not in', [4, 10]];
|
$whe[] = ['type', 'not in', [4, 10]];
|
||||||
}
|
}
|
||||||
|
|
@ -807,7 +807,12 @@ class Goods extends Base
|
||||||
$price = 0;
|
$price = 0;
|
||||||
}
|
}
|
||||||
$order_zhe_total = $price;
|
$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;
|
$zhe = 0;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,10 +22,14 @@ class RedisHelper
|
||||||
// 从环境变量中获取 Redis 主机和端口,默认为 127.0.0.1 和 6379
|
// 从环境变量中获取 Redis 主机和端口,默认为 127.0.0.1 和 6379
|
||||||
$host = env('redis.host', '127.0.0.1');
|
$host = env('redis.host', '127.0.0.1');
|
||||||
$port = env('redis.port', '6379');
|
$port = env('redis.port', '6379');
|
||||||
|
// 从环境变量中获取 Redis 数据库编号,默认为 0
|
||||||
|
$db = env('redis.db', '0');
|
||||||
// 创建 Redis 实例
|
// 创建 Redis 实例
|
||||||
$this->redis = new \Redis();
|
$this->redis = new \Redis();
|
||||||
// 连接到 Redis 服务器
|
// 连接到 Redis 服务器
|
||||||
$this->connect($host, $port);
|
$this->connect($host, $port);
|
||||||
|
// 选择数据库
|
||||||
|
$this->redis->select((int)$db);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -109,4 +113,15 @@ class RedisHelper
|
||||||
{
|
{
|
||||||
return $this->redis->expire($key, $timeout);
|
return $this->redis->expire($key, $timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 选择 Redis 数据库
|
||||||
|
*
|
||||||
|
* @param int $db 数据库编号
|
||||||
|
* @return bool 选择是否成功
|
||||||
|
*/
|
||||||
|
public function select($db)
|
||||||
|
{
|
||||||
|
return $this->redis->select($db);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user