Browse Source

no message

BF-202210271038\Administrator 2 years ago
parent
commit
7b536ab42f

+ 12 - 4
app/Console/Commands/TestCommand.php

@@ -5,6 +5,7 @@ namespace App\Console\Commands;
 use App\Jobs\BarrageJob;
 use App\Jobs\ShopNoticeJob;
 use App\Jobs\VerifyImg;
+use App\Models\Contract;
 use App\Models\CouponGrantRange;
 use App\Models\ErrorRecord;
 use App\Models\Express;
@@ -13,6 +14,7 @@ use App\Models\GoodsSpec;
 use App\Models\ImGroup;
 use App\Models\ImMyGroup;
 use App\Models\Member;
+use App\Models\MemberClan;
 use App\Models\MemberOpenId;
 use App\Models\Members;
 use App\Models\Menu;
@@ -100,10 +102,16 @@ class TestCommand extends Command
      */
     public function handle()
     {
-        ContractServer::creatServer()->verifyContractCommon();
-        dd(12);
-//        MemberServer::creatServer()->verificationLevel([3]);
-//        dd(1221);
+//        ContractServer::creatServer()->verifyContractCommon();
+//        dd(12);
+//        $ids=Member::where('id','>',1)->pluck('id')->toArray();
+//        MemberServer::creatServer()->verificationLevel($ids);
+        $contract=Contract::where('id',33)->first();
+        $memberTeam=MemberClan::where('m_id',$contract->{'m_id'})->select(['id','m_id','p_ids','one_m_id','two_m_id'])->first();
+        $pIds=array_reverse(array_filter(explode(',',$memberTeam->{'p_ids'})));
+        dd($contract,$pIds);
+        ContractServer::creatServer()->teamProportion($contract,$pIds);
+        dd(1221);
 //        $data=Address::generate();
 //        dd($data);
 //        for ($i=0;$i<=23;++$i){

+ 7 - 0
app/Http/Controllers/Api/CommonController.php

@@ -8,6 +8,8 @@ use App\Http\Controllers\FrontController;
 use App\Jobs\BarrageJob;
 use App\Models\AgencySet;
 use App\Models\Config;
+use App\Models\Contract;
+use App\Models\MemberClan;
 use App\Models\Region;
 use App\Servers\CommonServer;
 use App\Servers\ContractServer;
@@ -34,6 +36,11 @@ class CommonController extends FrontController
 
     function index()
     {
+        $contract=Contract::where('id',33)->first();
+        $memberTeam=MemberClan::where('m_id',$contract->{'m_id'})->select(['id','m_id','p_ids','one_m_id','two_m_id'])->first();
+        $pIds=array_reverse(array_filter(explode(',',$memberTeam->{'p_ids'})));
+        ContractServer::creatServer()->teamProportion($contract,$pIds);
+        dd(1221);
 //        $data=Address::generate();
 //        $key='1212';
 //        $key=$data['key'];

+ 1 - 1
app/Servers/CommonServer.php

@@ -156,7 +156,7 @@ class CommonServer
     function getConfigValue($key)
     {
         $key=strtolower($key);
-        if(in_array($key,['sys_address','sys_private','receive_address','common_address','sediment_address'])){
+        if(in_array($key,['sys_address','sys_private','receive_address','common_address','sediment_address','common_private'])){
             $value=env(strtoupper($key));
             if($value){
                 return $value;

+ 18 - 5
app/Servers/ContractServer.php

@@ -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;