BF-202210271038\Administrator %!s(int64=2) %!d(string=hai) anos
pai
achega
6fe1adf62d

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

@@ -32,6 +32,7 @@ use App\Servers\AlbumServer;
 use App\Servers\BarrageServer;
 use App\Servers\CommentServer;
 use App\Servers\CommonServer;
+use App\Servers\ContractServer;
 use App\Servers\Coupon\CouponGrantServer;
 use App\Servers\Electricity\JdElectricityServer;
 use App\Servers\Electricity\TbElectricityServer;
@@ -99,10 +100,12 @@ class TestCommand extends Command
      */
     public function handle()
     {
-        MemberServer::creatServer()->verificationLevel([3]);
-        dd(1221);
-        $data=Address::generate();
-        dd($data);
+        ContractServer::creatServer()->verifyContractCommon();
+        dd(12);
+//        MemberServer::creatServer()->verificationLevel([3]);
+//        dd(1221);
+//        $data=Address::generate();
+//        dd($data);
 //        for ($i=0;$i<=23;++$i){
 //            $address='0x848da9d7fcbfe80afc47b4383f178184589acfa9';
 //            $p_member= Member::orderBy('id','desc')->select(['id', 'address'])->first();

+ 8 - 8
app/Http/Controllers/Api/CommonController.php

@@ -34,15 +34,15 @@ class CommonController extends FrontController
 
     function index()
     {
-        $data=Address::generate();
-//        $key='a4bdfb7ca1f44358806d5c291e20a815864360d1b8915273777aa3e22f4379d4';
-        $key=$data['key'];
-        dump($key);
-        $key=PassServer::creatServer()->setSecretKey($key);
-        dump($key);
+//        $data=Address::generate();
+//        $key='1212';
+//        $key=$data['key'];
+//        dump($key);
+//        $key=PassServer::creatServer()->setSecretKey($key);
+//        dump($key);
 //        dump($data['key']);
-        dump(PassServer::creatServer()->getSecretKey($key));
-        dd($data);
+//        dump(PassServer::creatServer()->getSecretKey($key));
+//        dd($data);
     }
 
 

+ 7 - 2
app/Observers/ContractDistributionObserver.php

@@ -38,8 +38,13 @@ class ContractDistributionObserver
             if($distribution->{'nbn_money'}>0 && $distribution->{'to_address'}){
                 //需要清分的账户进行转换
                 if($distribution->{'nbn_money'}-$distribution->{'service_money'}>0){
-                    $sysAddress=CommonServer::creatServer()->getConfigValue('sys_address');
-                    $sysPrivate=CommonServer::creatServer()->getConfigValue('sys_private');
+                    if($distribution->{'type'}==9){
+                        $sysAddress=CommonServer::creatServer()->getConfigValue('common_address');
+                        $sysPrivate=CommonServer::creatServer()->getConfigValue('common_private');
+                    }else{
+                        $sysAddress=CommonServer::creatServer()->getConfigValue('sys_address');
+                        $sysPrivate=CommonServer::creatServer()->getConfigValue('sys_private');
+                    }
                    $broadcastId= BroadcastServer::addBroadcast(1,$distribution->{'nbn_money'}-$distribution->{'service_money'},$sysAddress,$sysPrivate,$distribution->{'to_address'},0,$distribution->{'id'},$distribution->{'type'});
                    if($broadcastId){
                        $distribution->update(['broadcast_id' => $broadcastId]);

+ 11 - 3
app/Servers/ContractServer.php

@@ -236,9 +236,17 @@ class ContractServer
                 $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,$directMember->{'id'},$directMember->{'address'},$contract->{'indirect_proportion'},0,'间推推分红,间推人不存在,未划分');
+                    $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,$directMember->{'id'},$directMember->{'address'},$contract->{'indirect_proportion'},1,'间推推分红');
+                    $this->addDistribution($contract->{'id'},$contract->{'m_id'},0,$indirectMoney,3,$indirectMember->{'id'},$indirectMember->{'address'},$contract->{'indirect_proportion'},1,'间推推分红');
+//                    $indirectNum=Member::where('recom_id',$indirectMember->{'id'})->count();
+//                    if($indirectNum>2){
+//
+//                    }else{
+//                        $this->addContractLog($contract,'间推人推广人数低于两人,停止清分');
+//                        $this->addDistribution($contract->{'id'},$contract->{'m_id'},0,$indirectMoney,3,$directMember->{'id'},$directMember->{'address'},$contract->{'indirect_proportion'},0,'间推人推广人数低于两人,停止清分');
+//                    }
+
                 }
             }
         }
@@ -372,7 +380,7 @@ class ContractServer
             $this->addDistribution($contract->{'id'},$contract->{'m_id'},$dbMoney,0,7,$member->{'id'},$member->{'address'},$contract->{'agency_proportion'},1,'代币分账');
             MoneyDetailServer::creatServer()->write(1,1,$dbMoney,1,$member->{'id'},'报单代币清分',$contract->{'id'});
         }else{
-            $sedimentAddress=CommonServer::creatServer()->getConfigValue('sediment_address');
+            $sedimentAddress=CommonServer::creatServer()->getConfigValue('agency_address');
             $this->addDistribution($contract->{'id'},$contract->{'m_id'},0,$agencyMoney,7,0,$sedimentAddress,$contract->{'agency_proportion'},1,'代币价格为0,转入沉淀分账');
             $this->addContractLog($contract,'代币价格为0,不分发');
         }

+ 10 - 1
app/Servers/MemberServer.php

@@ -6,6 +6,7 @@ namespace App\Servers;
 use App\Jobs\RelevanceJob;
 use App\Jobs\UploadingImgJob;
 use App\Models\CoinType;
+use App\Models\Contract;
 use App\Models\ErrorRecord;
 use App\Models\ImService;
 use App\Models\Level;
@@ -190,12 +191,20 @@ class MemberServer
      */
     function verificationLevel($pIds){
         foreach ($pIds as $pId){
-            $member=Member::where('id',$pId)->select(['id','address','level_id'])->first();
+            $member=Member::where('id',$pId)->select(['id','address','level_id','recom_id'])->first();
             $contractNum=ContractServer::creatServer()->getTeamContractNum($pId);
             $newLevelId=Level::where('total_num','<=',$contractNum)->where('id','>',$member->{'level_id'})->orderBy('id','desc')->value('id');
             if(!empty($newLevelId) && $newLevelId>$member->{'level_id'}){
                 $member->update(['level_id'=>$newLevelId]);
             }
+            $recomIds=Member::where('recom_id',$pId)->pluck('id')->toArray();
+            if($recomIds){
+                $contractList=Contract::whereIn('status',[2,4])->whereIn('m_id',$recomIds)->select(['m_id'])->groupBy(['m_id','status'])->get();
+                $contractNum=$contractList->count();
+                if($contractNum>=2){
+                    $member->update(['is_boss' => 1]);
+                }
+            }
         }
     }