提交代码

This commit is contained in:
youda 2025-04-25 02:29:18 +08:00
parent 5f7abfcf9b
commit 1f9c3b55e9
7 changed files with 38 additions and 18 deletions

6
.env
View File

@ -6,9 +6,9 @@ DEFAULT_TIMEZONE = Asia/Shanghai
[DATABASE]
TYPE = mysql
HOSTNAME = 127.0.0.1
DATABASE = youda
USERNAME = youda
PASSWORD = youda
DATABASE = youda_neice
USERNAME = youda_neice
PASSWORD = youda_neice
HOSTPORT = 3306
CHARSET = utf8
DEBUG = false

View File

@ -64,7 +64,13 @@ class Goods extends Base
$redis = (new \app\common\server\RedisHelper())->getRedis();
$cache_key = "goods_list_{$type_str}_{$user_id}_{$page}";
$cache_data = $redis->get($cache_key);
$new_data = [
'data' => [],
'last_page' => 0,
];
return $this->renderSuccess('请求成功', $new_data);
// 如果缓存存在,直接返回缓存数据
if ($cache_data) {
$cached_data = json_decode($cache_data, true);
@ -810,6 +816,7 @@ class Goods extends Base
if (empty($user['mobile'])) {
return $this->renderError('请先绑定手机号', [], -9);
}
return $this->renderError('正在维护中', []);
$prize_num = request()->param('prize_num/d', 0); #抽几发
$goods_id = request()->param('goods_id/d', 0); #盒子ID
$num = request()->param('goods_num/d', 0); #第几箱

View File

@ -41,7 +41,7 @@ class Index extends Base
// // unset($tuijian[$key]);
// continue;
// }
$tuijian_list[] = $advert_value;
// $tuijian_list[] = $advert_value;
}
}
$tuijian = $tuijian_list;
@ -304,12 +304,30 @@ class Index extends Base
if (!in_array($type, $validTypes)) {
return $this->renderError('无效的排行榜类型');
}
// 设置分页参数
$page = request()->param('page/d', 1);
$limit = request()->param('limit/d', 10);
// 初始化排行榜服务类
// 获取Redis实例
$redis = (new \app\common\server\RedisHelper())->getRedis();
// 构建缓存键名
$cacheKey = "rank_list:{$type}:page_{$page}:limit_{$limit}";
// 检查缓存中是否有数据
$cachedData = $redis->get($cacheKey);
if ($cachedData) {
return $this->renderSuccess('请求成功', json_decode($cachedData, true));
}
// 缓存中没有数据,从服务获取
$rankService = new \app\common\service\RankService();
$data = $rankService->getRankList($type, $page, $limit);
// 将数据存入Redis缓存无过期时间
$redis->set($cacheKey, json_encode($data));
// 返回数据
return $this->renderSuccess('请求成功', $data);
}

View File

@ -507,6 +507,7 @@ class Infinite extends Base
if (empty($user['mobile'])) {
return $this->renderError('请先绑定手机号', [], -9);
}
return $this->renderError('正在维护中', []);
$ad_id = request()->header('adid');
$goods_id = request()->param('goods_id/d', 0); #盒子ID
$prize_num = request()->param('prize_num/d', 0); #抽几发

View File

@ -10,8 +10,8 @@ return [
// OPTIONS预检请求处理中间件
\app\api\middleware\OptionsRequestMiddleware::class,
// GET请求签名验证中间件
// \app\api\middleware\SignatureVerifyMiddleware::class,
//请求签名验证中间件
\app\api\middleware\SignatureVerifyMiddleware::class,
// 注意原来的Allow中间件已被拆分为上面三个专门的中间件不再需要
// \app\api\middleware\Allow::class,
];

View File

@ -24,7 +24,7 @@ class SignatureVerifyMiddleware
/**
* Redis键前缀
*/
const REDIS_KEY_PREFIX = 'api_nonce_';
const REDIS_KEY_PREFIX = 'api_nonce:';
/**
* Nonce过期时间

View File

@ -231,14 +231,6 @@ class RankService
->select()
->toArray();
// // 查询数据
// $list = Order::where($where)
// ->field('user_id, sum(use_money2) as use_money')
// ->group('user_id')
// ->order('use_money desc')
// ->page($page, $limit)
// ->select()
// ->toArray();
// 处理用户信息
$rankList = [];
@ -284,7 +276,9 @@ class RankService
if ($endTime > 0) {
$where[] = ['addtime', '<=', $endTime];
}
if($limit==10){
$limit=50;
}
// 查询数据
$list = User::where($where)
->field('pid, COUNT(1) as invite_count')