Update UserUpgradeService.php

This commit is contained in:
邹景立 2021-05-19 19:22:50 +08:00
parent 4452bfd77a
commit 3febde6ab8

View File

@ -46,8 +46,9 @@ class UserUpgradeService extends Service
if (empty($agent['vip_code'])) return [0, '代理无推荐资格'];
if (stripos($agent['path'], "-{$uid}-") !== false) return [0, '不能绑定下属'];
// 组装代理数据
$result = [0, '绑定代理失败'];
$this->app->db->transaction(function () use ($user, $agent, $mod, &$result) {
try {
$this->app->db->transaction(function () use ($user, $agent, $mod) {
// 更新用户代理
$path1 = rtrim($agent['path'] ?: '-', '-') . "-{$agent['id']}-";
$this->app->db->name('DataUser')->where(['id' => $user['id']])->update([
@ -64,11 +65,12 @@ class UserUpgradeService extends Service
]);
}
}
// 更新用户等级
$this->upgrade($user['id']);
$result = [1, '绑定代理成功'];
});
return $result;
$this->upgrade($user['id']);
return [1, '绑定代理成功'];
} catch (\Exception $exception) {
return [0, "绑定代理失败, {$exception->getMessage()}"];
}
}
/**