From 04102f7237efefa744090ed7c25f7b5d0807b679 Mon Sep 17 00:00:00 2001
From: quanwei <419654421@qq.com>
Date: Thu, 05 Feb 2026 18:11:57 +0800
Subject: [PATCH] 完成运营中心提现和运营中心权限管理

---
 admin/app/common/model/plus/shareholder/Apply.php |   87 ++++++++-----------------------------------
 1 files changed, 17 insertions(+), 70 deletions(-)

diff --git a/admin/app/common/model/plus/shareholder/Apply.php b/admin/app/common/model/plus/shareholder/Apply.php
index a266726..e3ea400 100644
--- a/admin/app/common/model/plus/shareholder/Apply.php
+++ b/admin/app/common/model/plus/shareholder/Apply.php
@@ -6,9 +6,8 @@
 use app\common\model\plus\agent\User as AgentUserModel;
 use app\common\model\plus\team\User as TeamUserModel;
 use app\common\model\plus\team\Order as TeamOrderModel;
-use app\common\model\plus\vip\User as VipUserModel;
-use app\common\model\plus\vip\Order as VipOrderModel;
-
+use app\common\model\plus\team\Referee as TeamRefereeModel;
+use app\common\model\order\Order as OrderModel;
 /**
  * 股东申请模型
  */
@@ -150,6 +149,20 @@
                 $becomeShareholder = true;
             }
         }
+        if ($config['become'] == '110'){
+            $subordinateUserId=(new TeamRefereeModel())->where(['heads_id'=>$userId])->column('user_id');
+            $subordinateUserId[]=$userId;
+            $vipNum=(new \app\common\model\user\User)->getRefereeGradeCount($subordinateUserId,$config['referee_grade_ids']);
+            $supplierNum=(new \app\common\model\supplier\Supplier())->getSubordinateNum($subordinateUserId);
+            $user=(new \app\common\model\user\User)->where(['user_id'=>$userId,'is_delete'=>0])->find();
+            if ($vipNum >= $config['totalvip_down'] && $supplierNum >= $config['totalsh_down']&&$user['purchase_count']>=$config['purchase_count']){
+                $becomeShareholder = true;
+            }else if (!empty($config['become__buy_product_ids'])){
+                if ((new OrderModel())->getOrderProductIds($userId,$config['become__buy_product_ids'],true)){
+                    $becomeShareholder = true;
+                }
+            }
+        }
         // 新增股东用户
         if ($becomeShareholder) {
             User::add($userId, [
@@ -182,70 +195,4 @@
         return ['text' => $method[$value], 'value' => $value];
     }
 
-    /**
-     * 统计VIP会员直接推荐数量
-     * @param $userId
-     * @return int
-     */
-    public function countVipRecommendations($userId)
-    {
-        return VipUserModel::where('referee_id', '=', $userId)->count();
-    }
-
-    /**
-     * 统计企业商户入驻数量
-     * @param $userId
-     * @return int
-     */
-    public function countMerchantSettlements($userId)
-    {
-        // 假设商家入驻与推广团队的关联字段是referee_id
-        // 需要根据实际数据库结构调整
-        return \app\common\model\Shop::where('referee_id', '=', $userId)->count();
-    }
-
-    /**
-     * 统计VIP专区商品购买次数
-     * @param $userId
-     * @return int
-     */
-    public function countSelfVipPurchases($userId)
-    {
-        return VipOrderModel::where('user_id', '=', $userId)
-            ->where('is_vip', '=', 1)
-            ->count();
-    }
-
-    /**
-     * 检查股东候选人是否满足新的三个条件
-     * @param $userId
-     * @param $appId
-     * @return bool
-     */
-    public function checkNewShareholderConditions($userId, $appId)
-    {
-        $config = Setting::getItem('basic', $appId);
-        
-        // 1. 检查VIP会员直接推荐数量
-        $vipRecommendCount = $this->countVipRecommendations($userId);
-        if ($vipRecommendCount < $config['vip_recommend_count']) {
-            return false;
-        }
-        
-        // 2. 检查企业商户入驻数量
-        $merchantCount = $this->countMerchantSettlements($userId);
-        if ($merchantCount < $config['merchant_settle_count']) {
-            return false;
-        }
-        
-        // 3. 检查VIP专区商品购买次数
-        $selfVipPurchaseCount = $this->countSelfVipPurchases($userId);
-        if ($selfVipPurchaseCount < $config['self_vip_purchase_count']) {
-            return false;
-        }
-        
-        // 所有条件都满足
-        return true;
-    }
-
-},
\ No newline at end of file
+}
\ No newline at end of file

--
Gitblit v1.9.2