多店分销绑定用户上下级无法绑定问题
修复文件 : app\services\user\UserServices
修复方法:spread()
public function spread(int $uid, int $spreadUid, $code)
{
$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 == 0) return true;
//记录好友关系
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) {
$data['login_type'] = $user['login_type'] ?? $userInfo->login_type;
} 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}}