From f2255b1dacd4df89eb7565fcfb3c093a23bcfb32 Mon Sep 17 00:00:00 2001
From: zhaojs <349234519@qq.com>
Date: 星期三, 12 七月 2023 09:38:19 +0800
Subject: [PATCH] no message

---
 application/api/logic/ActivityInfo.php  |  143 +++++++++++++++++++++++++++++++++++
 application/common/model/UserExtend.php |   14 +++
 application/api/logic/taoke/Parser.php  |   13 ++-
 application/api/controller/Activity.php |   46 +++++++++++
 4 files changed, 212 insertions(+), 4 deletions(-)

diff --git a/application/api/controller/Activity.php b/application/api/controller/Activity.php
index 317737e..a404d53 100644
--- a/application/api/controller/Activity.php
+++ b/application/api/controller/Activity.php
@@ -175,6 +175,22 @@
         $this->success('鑾峰彇鎴愬姛',$list);
     }
 
+
+    /**
+     * 鑾峰彇娲诲姩淇℃伅
+     * 
+     */
+    public function getActInfo()
+    {
+        $actid=request()->param('actid');
+        if(empty($actid)) $this->error('鍙傛暟閿欒');
+        $actInfo=new ActInfo();
+        $user = $this->auth->getUser();
+        $res=$actInfo->getActInfo($actid,$user->id);
+        
+        $this->success('鑾峰彇鎴愬姛',$res);
+    }
+
     /**
      * 鍙傚姞娲诲姩
      */
@@ -189,4 +205,34 @@
         $res?$this->success('鎴愬姛',$res):  $this->error('娲诲姩寮傚父');;
     }
 
+    /**
+     * 鑾峰彇娲诲姩宸查個璇蜂汉鏁�
+     * 
+     */
+    public function getActRecruitCount()
+    {
+        $actid=request()->param('actid');
+        if(empty($actid)) $this->error('鍙傛暟閿欒');
+        $actInfo=new ActInfo();
+        $user = $this->auth->getUser();
+        $res=$actInfo->getActRecruitCount($actid,$user->id);
+        $data = [
+            'hascount' => $res
+        ];
+        $this->success('鑾峰彇鎴愬姛',$data);
+    }
+
+    /**
+     * 鑾峰彇鎺掑悕
+     */
+    public function getRankingList()
+    {
+        $actid=request()->param('actid');
+        if(empty($actid)) $this->error('鍙傛暟閿欒');
+        $actInfo=new ActInfo();
+        $user = $this->auth->getUser();
+        $res=$actInfo->getRankingList($actid,$user->id);
+        $this->success('鑾峰彇鎴愬姛',$res);
+    }
+
 }
\ No newline at end of file
diff --git a/application/api/logic/ActivityInfo.php b/application/api/logic/ActivityInfo.php
index d8b28e2..0fcac64 100644
--- a/application/api/logic/ActivityInfo.php
+++ b/application/api/logic/ActivityInfo.php
@@ -2,9 +2,54 @@
 namespace app\api\logic;
 
 use app\common\logic\Basic as BasicLogic;
+use think\console\output\descriptor\Console;
 use think\Db;
 class ActivityInfo extends BasicLogic
 {
+
+
+    /**
+     * 鑾峰彇娲诲姩淇℃伅
+     */
+    public function getActInfo($actid,$userid)
+    {
+        $res=Db::query('SELECT * FROM t_activity_manage WHERE id=?',[$actid]);
+        $response=[
+                'actstatus'=>1,
+                'joinstatus'=>0
+            ];
+        if(empty($res)){
+            $response['actstatus']=0;//涓嶅瓨鍦�
+            return $response;
+        }
+        if($res[0]['act_status']==0)
+        {
+            $response['actstatus']=-1;//宸茬粨鏉�
+            return $response;
+        }
+        if(time()<strtotime($res[0]['start_time']))
+        {
+            $response['actstatus']= -2;//鏈紑濮�
+            return $response;
+        }
+        if(time()>strtotime($res[0]['end_time']))
+        {
+            $response['actstatus']= -3;//宸茬粨鏉�
+            return $response;
+        }
+        //鏄惁宸插弬鍔犳椿鍔�
+        $recruitid=$actid.'u'.$userid;
+        $canjia=Db::query('select id from t_recruit_act where id=?',[$recruitid]);
+        if(empty($canjia))
+        {
+            $response['joinstatus']=0;//鏈弬鍔�
+        }
+        else{
+            $response['joinstatus']=1;//宸插弬鍔�
+        }
+        return $response;
+    }
+
     /**
      * 鍙傚姞娲诲姩
      * 
@@ -56,4 +101,102 @@
         }
        
     }
+
+    /**
+     * 鑾峰彇宸查個璇蜂汉鏁�
+     */
+    public function getActRecruitCount($actid,$userid)
+    {
+        $recruitid=$actid.'u'.$userid;
+        $count=Db::query('select recruit_count from t_recruit_act where id=?',[$recruitid]);
+        if(empty($count))
+        {
+            return 0;
+        }
+        return $count[0]['recruit_count'];
+    }
+
+    /**
+     * 鑾峰彇鎺掑悕
+     */
+    public function getRankingList($actid,$userid)
+    {
+        $rList=Db::query('	SELECT a.id,a.nickname,a.avatar,b.recruit_count from t_recruit_act b left join t_user a on a.id =b.user_id where b.act_id=? and b.recruit_count>0 order by b.recruit_count desc limit 7',[$actid]);
+        if(empty($rList))
+        {
+            return [];
+        }
+        return $rList;
+    }
+
+
+    /**
+     * 璁$畻鎷涘嫙娲诲姩閲戦
+     * 
+     */
+    public function run_countRecruitAct()
+    {
+        //鍏堟煡璇㈡嫑鍕熸椿鍔�
+        $actList=Db::query('select * from t_activity_manage where count_status=0 and act_type=0 and act_status=1');
+        if(empty($actList))
+        {
+            return '娌℃湁绗﹀悎鐨勬椿鍔�';
+        }
+       
+        foreach($actList as $act)
+        {//寰幆娲诲姩锛岃绠楅噾棰�
+            //淇敼娲诲姩璁$畻鐘舵��
+           $this->run_UpdateActCount($act['id'],1);
+            $actEndTime=strtotime($act['end_time']);//娲诲姩缁撴潫鏃堕棿
+            //鏌ヨ鎵�鏈夊弬涓庢椿鍔ㄧ殑浼氬憳
+            $cusList=Db::query('select * from t_recruit_act where act_id=? and settlement_status=0 and user_t=0',[$act['id']]);
+            if(empty($cusList))
+            {
+                $this->run_UpdateActCount($act['id'],2);
+                continue;
+            }
+            foreach($cusList as $cus)
+            {//寰幆鍙備笌娲诲姩鐨勪細鍛�
+                $yqCount=Db::query('select count(1) as count from t_user where invitation_id=? and invite_bind_time>=? and invite_bind_time<=?',[$cus['user_id'],$cus['create_time'],$actEndTime]);
+                if(empty($yqCount))
+                {
+                    continue;
+                }
+                //璁$畻搴斿緱閲戦
+                $price=0;
+                //
+                //
+                //
+
+
+
+                $tradeId=$act['id'].$cus['user_id'];
+                //鎻掑叆鑱氭帹瀹㈢殑璁㈠崟
+                $tradeHas=Db::query('select id from t_jtk_union_order_commission where trade_parent_id=?',[$tradeId]);
+                if(!empty($tradeHas))
+                {//宸茬粡鏈夎鍗�
+                    continue;
+                }
+                $tradeRes=Db::execute('insert into t_jtk_union_order_commission (trade_parent_id,trade_id,member_id,buy_member_id,is_own,alipay_total_price,pub_share_pre_fee,item_title,item_id,is_settle,tb_paid_time,create_time,update_time)values(?,?,?,?,1,?,?,?,?,?,?,?,?)',[$tradeId,$tradeId,$cus['user_id'],$cus['user_id'],$price,$price,$act['act_name'],$act['id'],0,time(),time(),time()]);
+                if($tradeRes==1)
+                {//淇敼璁$畻鐘舵��
+                    Db::execute('update t_recruit_act set settlement_status=?,settlement_time=? where id=?',[1,time(),$tradeId]);
+                }
+            }
+            $this->run_UpdateActCount($act['id'],2);
+        }
+        return '鎵ц-success';
+    }
+
+    public function run_UpdateActCount($actid,$countStatus)
+    {
+        if($countStatus==1)
+        {
+            Db::execute('update t_activity_manage set count_status=? where id=?',[$countStatus,$actid]);
+        }
+        else{
+            Db::execute('update t_activity_manage set count_status=?,count_time=? where id=?',[$countStatus,time(),$actid]);
+        }
+    }
+
 }
\ No newline at end of file
diff --git a/application/api/logic/taoke/Parser.php b/application/api/logic/taoke/Parser.php
index adce3cc..2e90422 100644
--- a/application/api/logic/taoke/Parser.php
+++ b/application/api/logic/taoke/Parser.php
@@ -7,7 +7,7 @@
 use app\api\logic\UserCollect;
 use app\api\logic\User as LogicUser;
 use app\common\model\UserLevel as ModelUserLevel;
-
+use \app\common\model\UserExtend as ModelUserExtend;
 class Parser extends BasicLogic
 {
     //TODO 妫�鏌ユ墍鏈夋帴鍙f槸涓嶆槸鏈夎皟鏁寸殑锛岄渶瑕佷紶浠g悊鐨勭浉搴斿瓧娈�
@@ -28,7 +28,7 @@
 
     protected static $buyCount=-1;//璐拱娆℃暟
 
-    protected static $returnLimit=-2;//浣i噾鍏ㄨ繑鐨勮喘涔版鏁伴檺鍒�
+    protected static $returnLimit=1;//浣i噾鍏ㄨ繑鐨勮喘涔版鏁伴檺鍒�
 
 
     public function __construct(){
@@ -47,8 +47,13 @@
         $topLevelInfo = $ModelUserLevel->where(['level'=>3])->find();
         if(empty($topLevelInfo)) fault('浠g悊閰嶇疆澶辫触');
         //鑾峰彇璐拱娆℃暟
-        //self::$buyCount=0;
-        if(self::$buyCount>0&&self::$buyCount<=self::$returnLimit)
+        $ModelUserExtend=new ModelUserExtend();
+        $userBuy= $ModelUserExtend->where(['id'=>USERID])->find();
+        if(!empty($userBuy))
+        {
+            self::$buyCount=$userBuy['tradecount'];
+        }
+        if(self::$buyCount>=0&&self::$buyCount<self::$returnLimit)
         {//绗﹀悎鍏ㄨ繑瑙勫垯
             self::$userRate =1;
         }
diff --git a/application/common/model/UserExtend.php b/application/common/model/UserExtend.php
new file mode 100644
index 0000000..16927b3
--- /dev/null
+++ b/application/common/model/UserExtend.php
@@ -0,0 +1,14 @@
+<?php
+
+namespace app\common\model;
+
+use think\Model;
+
+
+class UserExtend extends Model
+{
+    // 琛ㄥ悕
+    protected $name = 'user_extend';
+
+
+}

--
Gitblit v1.9.3