From abc7edc3c8ad59ff213c85413d0d6a10d7a0b6f7 Mon Sep 17 00:00:00 2001
From: quanwei <419654421@qq.com>
Date: Wed, 17 Dec 2025 18:03:09 +0800
Subject: [PATCH] 1.	发布供需消耗连盟币,连盟币数量在后台独立设置 2.	小程序供需个人中心可自由切换身份 3.	增加私信系统 4.	增加评论系统,用户可在发布者详情页进行评论操作,评论获得的连盟币可在后台设置 5.	增加发布者的等级,以好评个数为条件进行升级,小程序端会显示该等级的图标,如没有等级则不会显示图标 6.	增加设置消耗连盟币可以解锁、查看发布的信息,费用可在后台设置 7.	小程序供需大厅界面优化,以及增加了推荐栏目,该栏目按发布的分类相似进行匹配,比如A用户发布了 互联网 分类的需求,则会优先推荐匹配互联网分类的供应需求给他。

---
 admin/app/api/model/plus/business/Business.php |   79 +++++++++++++++++++++++++++++++++++++++
 1 files changed, 79 insertions(+), 0 deletions(-)

diff --git a/admin/app/api/model/plus/business/Business.php b/admin/app/api/model/plus/business/Business.php
index 2926385..a8ced24 100644
--- a/admin/app/api/model/plus/business/Business.php
+++ b/admin/app/api/model/plus/business/Business.php
@@ -1,7 +1,86 @@
 <?php
 namespace app\api\model\plus\business;
 use app\common\model\plus\business\Business as CommonBusiness;
+use app\common\model\plus\user\User;
+use app\api\model\plus\business\Saving as SavingModel;
 class Business extends CommonBusiness
 {
+    /**
+     * 设置默认名片
+     * @param $business_card_id
+     * @return false|int
+     * @throws \think\exception\DbException
+     */
+    public function editDefault($business_card_id='')
+    {
+        $model=$this->where(['business_card_id'=>$business_card_id])->find();
+        //(new User())->where(['user_id'=>$model['user_id']])->update(['business_card_id' => $business_card_id]);
+        $this->where(['user_id' => $model['user_id']])->update(['is_default' => 0]);
+        return $model->save(['is_default' => 1]);
+    }
+
+    /**
+     * 获取默认名片
+     * @param $user_id
+     * @return array|bool|\PDOStatement|string|\think\Model|null
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+    public function getDefault($user_id){
+        return $this->order('create_time', 'desc')->where(['user_id' => $user_id, 'is_default' => 1])->with(['image', 'logoImage'])->find();
+    }
+
+    /**
+     * 获取名片数量
+     * @param $user_id
+     * @return int|string
+     * @throws \think\Exception
+     */
+    public function getQuantity($user_id)
+    {
+        return $this->where('user_id', $user_id)->count();
+    }
     
+    /**
+     * 记录浏览
+     */
+    public function recordBrowse($business_id, $user_id)
+    {
+        $savingModel = new SavingModel();
+        $data = [
+            'user_id' => $user_id,
+            'business_id' => $business_id,
+            'affiliation_id' => $this->where('business_id', $business_id)->value('user_id'),
+            'type' => 10
+        ];
+        return $savingModel->add($data);
+    }
+    
+    /**
+     * 获取名片统计
+     */
+    public function getStatistics($user_id)
+    {
+        $savingModel = new SavingModel();
+        return [
+            'cards_count' => $this->where(['user_id' => $user_id])->count(),
+            'browse_stats' => $savingModel->getBrowseStats($user_id)
+        ];
+    }
+    
+    /**
+     * 获取名片列表(含统计信息)
+     */
+    public function getListWithStats($user_id)
+    {
+        $cards = $this->with(['template'])->where(['user_id' => $user_id])->select();
+        $savingModel = new SavingModel();
+        
+        foreach ($cards as &$card) {
+            $card['browse_count'] = $savingModel->where(['business_id' => $card['business_id'], 'type' => 10])->count();
+        }
+        
+        return $cards;
+    }
 }
\ No newline at end of file

--
Gitblit v1.9.2