Browse Source

代理被删除,旗下用户归属代理的代理变为一级

master
wanghongjun 2 years ago
parent
commit
b8d7d883b5
  1. 5
      app/model/AgentInfo.php

5
app/model/AgentInfo.php

@ -101,12 +101,9 @@ class AgentInfo extends Model
*/ */
public static function syncUpdateAid($oldAid) public static function syncUpdateAid($oldAid)
{ {
// 被删除aid的上级id
$newAid = User::withTrashed()->where('id',$oldAid)->value('aid');
$newAid = $newAid ?: 0;
$UserRes = User::where(['aid' => $oldAid, 'identity' => 2])->field('id')->select()->toArray(); $UserRes = User::where(['aid' => $oldAid, 'identity' => 2])->field('id')->select()->toArray();
$userIdArr = []; $userIdArr = [];
foreach ($UserRes as $UserRow) $userIdArr[] = $UserRow['id']; foreach ($UserRes as $UserRow) $userIdArr[] = $UserRow['id'];
User::update(['aid' => $newAid],['id' => $userIdArr],['aid']); User::update(['aid' => 0],['id' => $userIdArr],['aid']);
} }
} }

Loading…
Cancel
Save