|
@@ -230,15 +230,26 @@ class ContractServer
|
|
|
$directMoney=round(($contract->{'money'}-$contract->{'platform_money'})*$directProportion/100,6);
|
|
|
$this->addDistribution($contract->{'id'},$contract->{'m_id'},0,$directMoney,2,$directMember->{'id'},$directMember->{'address'},$directProportion,1,'直推BOSS分红');
|
|
|
}else{
|
|
|
- $directMoney=round(($contract->{'money'}-$contract->{'platform_money'})*$contract->{'direct_proportion'}/100,6);
|
|
|
- $this->addDistribution($contract->{'id'},$contract->{'m_id'},0,$directMoney,2,$directMember->{'id'},$directMember->{'address'},$contract->{'direct_proportion'},1,'直推分红');
|
|
|
+ $directNum=Contract::where('m_id',$directMember->{'id'})->whereIn('status',[2,4])->count();
|
|
|
+ if($directNum>0){
|
|
|
+ $directMoney=round(($contract->{'money'}-$contract->{'platform_money'})*$contract->{'direct_proportion'}/100,6);
|
|
|
+ $this->addDistribution($contract->{'id'},$contract->{'m_id'},0,$directMoney,2,$directMember->{'id'},$directMember->{'address'},$contract->{'direct_proportion'},1,'直推分红');
|
|
|
+ }else{
|
|
|
+ $this->addContractLog($contract,'直推人未报单停止清分');
|
|
|
+ }
|
|
|
$indirectMember=Member::where('id',$memberTeam->{'two_m_id'})->select(['id','address','is_boss'])->first();
|
|
|
$indirectMoney=round(($contract->{'money'}-$contract->{'platform_money'})*$contract->{'indirect_proportion'}/100,6);
|
|
|
if(empty($indirectMember)){
|
|
|
$this->addContractLog($contract,'间推人信息不存在,停止清分');
|
|
|
$this->addDistribution($contract->{'id'},$contract->{'m_id'},0,$indirectMoney,3,0,'',$contract->{'indirect_proportion'},0,'间推推分红,间推人不存在,未划分');
|
|
|
}else{
|
|
|
- $this->addDistribution($contract->{'id'},$contract->{'m_id'},0,$indirectMoney,3,$indirectMember->{'id'},$indirectMember->{'address'},$contract->{'indirect_proportion'},1,'间推推分红');
|
|
|
+ $indirectNum=Contract::where('m_id',$indirectMember->{'id'})->whereIn('status',[2,4])->count();
|
|
|
+ if($indirectNum>0){
|
|
|
+ $this->addDistribution($contract->{'id'},$contract->{'m_id'},0,$indirectMoney,3,$indirectMember->{'id'},$indirectMember->{'address'},$contract->{'indirect_proportion'},1,'间推推分红');
|
|
|
+ }else{
|
|
|
+ $this->addContractLog($contract,'间推人未报单停止清分');
|
|
|
+ }
|
|
|
+
|
|
|
// $indirectNum=Member::where('recom_id',$indirectMember->{'id'})->count();
|
|
|
// if($indirectNum>2){
|
|
|
//
|
|
@@ -257,7 +268,7 @@ class ContractServer
|
|
|
* @param Contract $contract
|
|
|
* @param $pIds
|
|
|
*/
|
|
|
- private function teamProportion(Contract $contract,$pIds){
|
|
|
+ function teamProportion(Contract $contract,$pIds){
|
|
|
$levels=Level::select(['direct_num','id','lateral_num'])->get()->toArray();
|
|
|
$levelArr=[];
|
|
|
foreach ($levels as $level){
|
|
@@ -282,9 +293,10 @@ class ContractServer
|
|
|
if(empty($levelData)){
|
|
|
$this->addContractLog($contract,$pMember->{'id'}.'ID,'.$pMember->{'level_id'}.',无当前等级配置信息,停止清分');
|
|
|
}else{
|
|
|
- if($pMember->{'level_id'}>$startId || ($pMember->{'level_id'}==$startId &&!$isLateral)){
|
|
|
+ if($pMember->{'level_id'}>$startId || ($pMember->{'level_id'}==$startId && !$isLateral)){
|
|
|
//等级大于等于当前等级
|
|
|
$isLateral=true;
|
|
|
+ $startId=$pMember->{'level_id'};
|
|
|
//等级比例
|
|
|
$levelProportion=$levelData['direct_num'];
|
|
|
//等级比例-减去已经使用比例,获取到可用比列
|
|
@@ -305,6 +317,7 @@ class ContractServer
|
|
|
$isLateral=false;
|
|
|
$startId=$pMember->{'level_id'}+1;
|
|
|
$lateralMoney=round($grantMoney*$levelData['lateral_num']/100,6);
|
|
|
+
|
|
|
if($lateralMoney>0){
|
|
|
if($userMoney+$lateralMoney>$teamTotalMoney){
|
|
|
$lateralMoney=$teamTotalMoney-$userMoney;
|