limu 9 months ago
parent f563d159df
commit 4428c6f3ee
  1. 32
      app/controller/api/Auth.php

@ -382,12 +382,16 @@ class Auth extends BaseController
if (!$sms_code) return app('json')->fail('验证码不正确');
$user = $repository->accountByUser($data['phone']);
$auth = $this->parseAuthToken($data['auth_token']);
if (!$user) $user = $repository->registr($data['phone'], null, $data['user_type']);
$is_new = false;
if (!$user) {
$is_new = 1;
$user = $repository->registr($data['phone'], null, $data['user_type']);
}
if ($auth && !$user['wechat_user_id']) {
$repository->syncBaseAuth($auth, $user);
}
$user = $repository->mainUser($user);
$repository->bindSpread($user, intval($data['spread']), 1);
$repository->bindSpread($user, intval($data['spread']), $is_new);
$tokenInfo = $repository->createToken($user);
$repository->loginAfter($user);
@ -445,7 +449,7 @@ class Auth extends BaseController
$repository->syncBaseAuth($auth, $user);
}
$user = $repository->mainUser($user);
if(!empty($data['spread'])){
if (!empty($data['spread'])) {
$repository->bindSpread($user, intval($data['spread']), 1);
}
$tokenInfo = $repository->createToken($user);
@ -784,10 +788,10 @@ class Auth extends BaseController
->where("spread_uid", $userInfo->uid)
->select()
->toArray();
foreach ($data as &$item ){
foreach ($data as &$item) {
$item['invites'] = $this->countSpInvites($users, $item['uid']);
$item['referrals'] = $this->countSpReferrals($users, $item['uid'],'pay_price');
if($item['pay_price'] > 0){
$item['referrals'] = $this->countSpReferrals($users, $item['uid'], 'pay_price');
if ($item['pay_price'] > 0) {
$item['referrals'] += 1;
}
}
@ -815,7 +819,7 @@ class Auth extends BaseController
$item['community_level'] = $level[$item['community_level']] ?? '';
$item['invites'] = $this->countSpInvites($users, $item['uid']);
$item['referrals'] = $this->countSpReferrals($users, $item['uid'], 'pay_price');
if($item['pay_price'] > 0){
if ($item['pay_price'] > 0) {
$item['referrals'] += 1;
}
$item['amount'] = $this->countSpReferrals($users, $item['tid'], 'spread_pay_price');
@ -854,11 +858,15 @@ class Auth extends BaseController
$visited[] = $parentId; // 将当前节点标记为已访问
foreach ($nodes as $node) {
if($node['uid'] == $parentId && $node[$field] > 0){
$count += 1;
}
if ($node['sid'] == $parentId && $node[$field] > 0) {
$count += 1;
// if($node['uid'] == $parentId && $node['pay_price'] > 0){
// file_put_contents("/tmp/fensi",$node['uid'].PHP_EOL,8);
// $count += 1;
// }
if ($node['sid'] == $parentId) {
if ($node['pay_price'] > 0) {
file_put_contents("/tmp/fensi", $node['uid'], 8);
$count += 1;
}
$count += $this->countSpReferrals($nodes, $node['uid'], $field, $visited);
}
}

Loading…
Cancel
Save