算力功能改版

This commit is contained in:
wong
2025-12-09 15:01:38 +08:00
parent c9a5d3091f
commit 3e145ca123
18 changed files with 763 additions and 203 deletions

View File

@@ -100,9 +100,6 @@ class TokensRecordController extends BaseController
return ResponseHelper::error('类型参数错误0为减少1为增加');
}
if (!in_array($form, [0, 1, 2, 3, 4, 5])) {
return ResponseHelper::error('来源参数错误');
}
// 重试机制最多重试3次
$maxRetries = 3;
@@ -130,7 +127,7 @@ class TokensRecordController extends BaseController
Db::startTrans();
try {
// 使用悲观锁获取用户当前tokens余额确保并发安全
$userInfo = TokensCompany::where('companyId', $companyId)->lock(true)->find();
$userInfo = TokensCompany::where(['companyId'=> $companyId,'userId' => $userId])->lock(true)->find();
if (!$userInfo) {
throw new \Exception('用户不存在');
}