修改:权重值赠送修改,当前下级非上级的大区团队成员时,上级才能获取赠送的权重值
This commit is contained in:
parent
58659a686f
commit
197e059fcb
|
|
@ -30,9 +30,19 @@ class WeightValueRepository extends BaseRepository{
|
|||
public function getUserHoldList($uid,$userList = []){
|
||||
// 获取用户所有上级
|
||||
if(count($userList) <= 0){
|
||||
$userList = app()->make(UserRepository::class)->getAllSuperiorLv($uid);
|
||||
unset($userList[$uid]);// 删除本人
|
||||
if(count($userList) <= 0) return [];// 不存在上级
|
||||
$allUserList = app()->make(UserRepository::class)->getAllSuperiorLv($uid);
|
||||
unset($allUserList[$uid]);// 删除本人
|
||||
if(count($allUserList) <= 0) return [];// 不存在上级
|
||||
// 循环处理 仅小区业绩消费才会获得权重值奖励
|
||||
$userList = [];// 符合条件的用户
|
||||
$currentUid = $uid;
|
||||
foreach($allUserList as $userInfo){
|
||||
// 判断:当前用户是否为上级的大区业绩的线
|
||||
if(!app()->make(UserRepository::class)->isBigAreaPart((int)$currentUid,(int)$userInfo['uid'])){
|
||||
$userList[] = $userInfo;
|
||||
}
|
||||
$currentUid = $userInfo['uid'];
|
||||
}
|
||||
}
|
||||
// 获取持有信息
|
||||
$holdList = $this->dao->getSearch([])
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ namespace app\common\repositories\user;
|
|||
|
||||
use app\common\dao\BaseDao;
|
||||
use app\common\dao\user\UserDao;
|
||||
use app\common\model\store\order\StoreOrder;
|
||||
use app\common\model\user\User;
|
||||
use app\common\model\wechat\WechatUser;
|
||||
use app\common\repositories\BaseRepository;
|
||||
|
|
@ -1511,8 +1512,6 @@ class UserRepository extends BaseRepository
|
|||
'uid' => $user_info['uid'] ?? '-1'
|
||||
] + $append_info;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Common: 获取全部上级信息
|
||||
* Author: wu-hui
|
||||
|
|
@ -1537,6 +1536,67 @@ class UserRepository extends BaseRepository
|
|||
if(empty($userInfo) || (int)$userInfo['spread_uid'] <= 0) return $superiorList;
|
||||
return $this->getAllSuperiorLv($userInfo['spread_uid'], $superiorList, ++$level);
|
||||
}
|
||||
/**
|
||||
* Common: 获取某个用户全部下级
|
||||
* Author: wu-hui
|
||||
* Time: 2023/12/27 14:08
|
||||
* @param $uidS
|
||||
* @param array $subordinateList
|
||||
* @param int $level
|
||||
* @return array
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function getAllSubordinate($uidS,array $subordinateList = [],int $level = 1){
|
||||
// 获取用户上级列表
|
||||
$userInfo = $this->dao->getSearch([])
|
||||
->whereIn('spread_uid',$uidS)
|
||||
->field(['uid','nickname','brokerage_level','spread_uid',"{$level} as level"])
|
||||
->select()
|
||||
->toArray();
|
||||
if(!empty($userInfo)){
|
||||
$subordinateList = array_merge($subordinateList,$userInfo);
|
||||
|
||||
return $this->getAllSubordinate(array_column($userInfo,'uid'), $subordinateList, ++$level);
|
||||
}
|
||||
|
||||
return $subordinateList;
|
||||
}
|
||||
/**
|
||||
* Common: 判断:当前用户是否存在上级的大区团队中
|
||||
* Author: wu-hui
|
||||
* Time: 2023/12/27 14:12
|
||||
* @param int $uid
|
||||
* @param int $spreadUid
|
||||
* @return bool
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function isBigAreaPart(int $uid,int $spreadUid){
|
||||
// 获取:当前上级的所有直推下级
|
||||
$subIds = $this->dao->getSearch([])->where('spread_uid',$spreadUid)->column('uid');
|
||||
if(count($subIds) <= 1) return true;// 只有一条线 在大区业绩中
|
||||
// 存在多条线 循环判断
|
||||
$bigAreaIds = [];// 大区业绩所有用户的uid
|
||||
$bigAreaMoney = 0;// 大全业绩金额
|
||||
foreach($subIds as $subUid){
|
||||
// 获取全部下级 用户id
|
||||
$subUserList = $this->getAllSubordinate([$subUid]);
|
||||
$currentLineUserIds = array_merge(array_column($subUserList,'uid'),[$subUid]);
|
||||
// 获取当前线的业绩数量
|
||||
$currentLineMoney = StoreOrder::whereIn('uid',$currentLineUserIds)->sum('pay_price');
|
||||
// 判断:当前线业绩 大于 当前大区业绩;更新大区信息
|
||||
if($bigAreaMoney < $currentLineMoney) {
|
||||
$bigAreaIds = $currentLineUserIds;
|
||||
$bigAreaMoney = $currentLineMoney;
|
||||
}
|
||||
}
|
||||
|
||||
return in_array($uid,$bigAreaIds);// 当前用户id 存在大区用户id列表中;当前用户为大区团队成员
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue