|
|
@@ -120,7 +120,7 @@ class LedgerWalletModel extends Model
|
|
|
* @return string 变动后的金额
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
- public function changeWalletOnly(int $uid, string $asset, string $amount ): string
|
|
|
+ public function changeWalletOnly(int $uid, string $asset, string $amount): string
|
|
|
{
|
|
|
$available = $this->getWalletTX($uid);
|
|
|
if (empty($available)) {
|
|
|
@@ -267,113 +267,6 @@ class LedgerWalletModel extends Model
|
|
|
|
|
|
|
|
|
|
|
|
- /**
|
|
|
- * 发放见点奖
|
|
|
- * @param int $uid 服务器算力的用户ID
|
|
|
- * @param string $power 该租赁得到的算力
|
|
|
- * @return void
|
|
|
- * @throws Exception
|
|
|
- */
|
|
|
- public function sendRegBonus(int $uid)
|
|
|
- {
|
|
|
- $parentIDs = (new UserPathModel())->getAllParentIDs($uid);
|
|
|
- if (count($parentIDs) == 0) {
|
|
|
- return;
|
|
|
- }
|
|
|
- $userList = (new UserModel())
|
|
|
- ->field('id,team_level_id')
|
|
|
- ->where('id', 'in', $parentIDs)
|
|
|
- ->where('team_level_id', '>', 0)
|
|
|
- ->order('id desc')
|
|
|
- ->select();
|
|
|
- if (empty($userList)) {
|
|
|
- //没有符合条件的上级
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- $team_level_config = DB::table('team_level')
|
|
|
- ->field('level_id, reg_bonus')
|
|
|
- ->select();
|
|
|
- $level_reg_bonus = [];
|
|
|
- foreach ($team_level_config as $item) {
|
|
|
- $level_reg_bonus[$item['level_id']] = $item['reg_bonus'];
|
|
|
- }
|
|
|
-
|
|
|
- $now_level = 0;
|
|
|
- foreach ($userList as $item) {
|
|
|
- if ($item['team_level_id'] > $now_level && isset($level_reg_bonus[$item['team_level_id']])) {
|
|
|
- (new LedgerWalletModel())->changeWalletAccount($item['id'], Asset::USDT, $level_reg_bonus[$item['team_level_id']], Action::UsdtRegBonus, $uid);
|
|
|
- $now_level = $item['team_level_id'];
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 发放服务器市场推荐相关收益
|
|
|
- * @param int $uid
|
|
|
- * @param string $power
|
|
|
- * @return void
|
|
|
- * @throws DbException
|
|
|
- */
|
|
|
- public function sendMarketBonus(int $uid, array $server_info)
|
|
|
- {
|
|
|
- //直推奖
|
|
|
- $user = (new UserModel())->get($uid);
|
|
|
- if (empty($user) || $user['parent_id'] == 0) {
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- $parent = (new UserModel())->get($user['parent_id']);
|
|
|
- if (empty($parent) || $parent['effective_time'] == 0) {//必须参加过算力租赁才能领取该收益
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- $this->changeWalletAccount($user['parent_id'], Asset::USDT, $server_info['referral_bonus'], Action::ServerReferralBonus, $uid);
|
|
|
-
|
|
|
- //间推荐奖,向上级的上级发放佣金
|
|
|
- if ($parent['parent_id'] == 0) {
|
|
|
- return;
|
|
|
- }
|
|
|
- $indirect = (new UserModel())->get($parent['parent_id']);
|
|
|
- if (empty($indirect) || $indirect['effective_time'] == 0) {//必须参加过算力租赁才能领取该收益
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- $this->changeWalletAccount($parent['parent_id'], Asset::USDT, $server_info['indirect_bonus'], Action::ServerIndirectBonus, $uid);
|
|
|
-
|
|
|
- //社长费用
|
|
|
- $user_parent_ids = (new UserPathModel())->where('user_id', $uid)->column('parent_id');
|
|
|
- $parent_users = (new UserModel())
|
|
|
- ->field('id,parent_id')
|
|
|
- ->where('id', 'in', $user_parent_ids)
|
|
|
- ->where('effective_time', '>', 0)//必须参加过算力租赁才能领取该收益
|
|
|
-
|
|
|
- ->order('id desc')
|
|
|
- ->select();
|
|
|
- if (empty($parent_users)) {
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- //发放社区长费用
|
|
|
- $info = $parent_users[0];//取第一个
|
|
|
- $this->changeWalletAccount($info['id'], Asset::USDT, $server_info['community_bonus'], Action::ServerCommunityBonus, $uid);
|
|
|
-
|
|
|
- //发放社区长推荐奖
|
|
|
- if ($info['parent_id'] > 0) {
|
|
|
- $community_info = (new UserModel())->get($info['parent_id']);
|
|
|
- if ($community_info['effective_time'] > 0) {
|
|
|
- $this->changeWalletAccount($info['id'], Asset::USDT, $server_info['community_referral_bonus'], Action::ServerCommunityReferralBonus, $uid);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //系统领导人费用
|
|
|
- $sys_leader_info_id = 0;//定义待发放收益的系统领导人ID
|
|
|
-
|
|
|
- if ($sys_leader_info_id > 0) {
|
|
|
- $this->changeWalletAccount($sys_leader_info_id, Asset::USDT, $server_info['sys_leader_bonus'], Action::ServerSysLeaderBonus, $uid);
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
public function users()
|
|
|
{
|