算力功能改版

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

@@ -9,6 +9,7 @@ use app\common\util\PaymentUtil;
use think\facade\Env;
use think\facade\Request;
use app\common\model\Order;
use app\common\model\User;
/**
* 支付服务(内部调用)
@@ -495,6 +496,13 @@ class PaymentService
switch ($order['orderType']) {
case 1:
// 处理购买算力
// 查询用户信息判断是否为管理员需要同时匹配userId和companyId
$user = User::where([
'id' => $order->userId,
'companyId' => $order->companyId
])->find();
$isAdmin = (!empty($user) && isset($user->isAdmin) && $user->isAdmin == 1) ? 1 : 0;
$token = TokensCompany::where(['companyId' => $order->companyId,'userId' => $order->userId])->find();
$goodsSpecs = json_decode($order->goodsSpecs, true);
if (!empty($token)) {
@@ -507,6 +515,7 @@ class PaymentService
$tokensCompany->userId = $order->userId;
$tokensCompany->companyId = $order->companyId;
$tokensCompany->tokens = $goodsSpecs['tokens'];
$tokensCompany->isAdmin = $isAdmin;
$tokensCompany->createTime = time();
$tokensCompany->updateTime = time();
$tokensCompany->save();