问题表现为:原方法缺少对自己和两个用户互为上下级的拦截
修复方案:
找到文件app/services/user/UserServices.php
将方法spread整个代码替换为
/**
* 静默绑定推广人
* @param Request $request
* @return mixed
*/
public function spread(int $uid, int $spreadUid, $code)
{
if ($uid == $spreadUid){
return true;
}
$userInfo = $this->getUserInfo($uid);
if (!$userInfo) {
throw new ValidateException('数据不存在');
}
if ($code && !$spreadUid) {
/** @var QrcodeServices $qrCode */
$qrCode = app()->make(QrcodeServices::class);
if ($info = $qrCode->getOne(['id' => $code, 'status' => 1])) {
$spreadUid = $info['third_id'];
}
}
//记录好友关系
if ($spreadUid && $uid && $spreadUid != $uid) {
/** @var UserFriendsServices $serviceFriend */
$serviceFriend = app()->make(UserFriendsServices::class);
$serviceFriend->saveFriend($uid, $spreadUid);
}
$data = [];
//永久绑定
$store_brokergae_binding_status = sys_config('store_brokerage_binding_status', 1);
if ($userInfo->spread_uid && $store_brokergae_binding_status == 1) {
return true;
} else {
//绑定分销关系 = 所有用户
if (sys_config('brokerage_bindind', 1) == 1) {
//分销绑定类型为时间段且过期 ||临时
$store_brokerage_binding_time = sys_config('store_brokerage_binding_time', 30);
if (!$userInfo['spread_uid'] || $store_brokergae_binding_status == 3 || ($store_brokergae_binding_status == 2 && ($userInfo['spread_time'] + $store_brokerage_binding_time * 24 * 3600) < time())) {
if ($spreadUid && ($userInfo['uid'] == $spreadUid || $userInfo->uid == $this->dao->value(['uid' => $spreadUid], 'spread_uid'))) {
$spreadUid = 0;
}
if ($spreadUid && $this->dao->get((int)$spreadUid)) {
$data['spread_uid'] = $spreadUid;
$data['spread_time'] = time();
}
}
}
}
if ($data && !$this->dao->update($userInfo['uid'], $data, 'uid')) {
throw new ValidateException('绑定失败');
}
if (isset($data['spread_uid']) && $data['spread_uid']) {
/** @var UserBillServices $userBill */
$userBill = app()->make(UserBillServices::class);
//邀请新用户增加经验
$userBill->inviteUserIncExp((int)$spreadUid);
}
return true;
}
{{item.user_info.nickname ? item.user_info.nickname : item.user_name}}
作者 管理员 企业
{{itemf.name}}
{{itemc.user_info.nickname}}
{{itemc.user_name}}
回复 {{itemc.comment_user_info.nickname}}
{{itemf.name}}