|
|
|
@ -71,5 +71,42 @@ class AgentInfo extends Model |
|
|
|
$AgentInfoRes->rebate_ratio = $rebate_ratio / 100; |
|
|
|
$AgentInfoRes->update_time = date("Y-m-d H:i:s",time()); |
|
|
|
$AgentInfoRes->save(); |
|
|
|
self::syncUpdateRebateRatio($aid); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 代理修改占比,旗下代理全部清零 |
|
|
|
* @param $aid |
|
|
|
* @return false|void |
|
|
|
* @throws \think\db\exception\DataNotFoundException |
|
|
|
* @throws \think\db\exception\DbException |
|
|
|
* @throws \think\db\exception\ModelNotFoundException |
|
|
|
*/ |
|
|
|
protected static function syncUpdateRebateRatio($aid) |
|
|
|
{ |
|
|
|
$UserRes = User::where(['aid' => $aid,'identity' => 2])->field('id')->select()->toArray(); |
|
|
|
if (empty($UserRes)) return false; |
|
|
|
foreach ($UserRes as $UserRow) { |
|
|
|
# 修改为0 |
|
|
|
self::updateRebateRatio($UserRow['id'],0); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 代理被删除,旗下用户变为代理上级代理 |
|
|
|
* @param $oldAid // 被删除的aid |
|
|
|
* @throws \think\db\exception\DataNotFoundException |
|
|
|
* @throws \think\db\exception\DbException |
|
|
|
* @throws \think\db\exception\ModelNotFoundException |
|
|
|
*/ |
|
|
|
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(); |
|
|
|
$userIdArr = []; |
|
|
|
foreach ($UserRes as $UserRow) $userIdArr[] = $UserRow['id']; |
|
|
|
User::update(['aid' => $newAid],['id' => $userIdArr],['aid']); |
|
|
|
} |
|
|
|
} |
|
|
|
|