From 3ea53e61cc23fdb3ddf8b38a199ca60a6da8c407 Mon Sep 17 00:00:00 2001
From: quanwei <419654421@qq.com>
Date: Fri, 28 Nov 2025 18:32:41 +0800
Subject: [PATCH] 添加商品

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

diff --git a/admin/app/common/model/plus/shareholder/Apply.php b/admin/app/common/model/plus/shareholder/Apply.php
index 348b429..a266726 100644
--- a/admin/app/common/model/plus/shareholder/Apply.php
+++ b/admin/app/common/model/plus/shareholder/Apply.php
@@ -6,6 +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;
 
 /**
  * 股东申请模型
@@ -180,4 +182,70 @@
         return ['text' => $method[$value], 'value' => $value];
     }
 
-}
\ No newline at end of file
+    /**
+     * 统计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

--
Gitblit v1.9.2