From a90ac240c499e686793744b25732b6ac6a57edfd Mon Sep 17 00:00:00 2001
From: quanwei <419654421@qq.com>
Date: Wed, 26 Nov 2025 10:46:51 +0800
Subject: [PATCH] 1、商家端添加会员管理 2、修复分会绑定会长时获取获取会员信息报错 3、修复添加分会成员是没保存分会id问题 4、修复获取分会成员时获取的是所有的分会的成员

---
 admin/app/common/model/supplier/Supplier.php |   42 +++++++++++++++++++++++++++++++++++++++---
 1 files changed, 39 insertions(+), 3 deletions(-)

diff --git a/admin/app/common/model/supplier/Supplier.php b/admin/app/common/model/supplier/Supplier.php
index 6383036..c01a9e2 100644
--- a/admin/app/common/model/supplier/Supplier.php
+++ b/admin/app/common/model/supplier/Supplier.php
@@ -3,9 +3,10 @@
 namespace app\common\model\supplier;
 
 use app\common\model\BaseModel;
-use app\shop\model\auth\User as AuthUserModel;
-use app\shop\model\auth\UserRole as UserRoleModel;
 use app\common\model\shop\Role as RoleModel;
+use app\common\model\supplier\member\Member as MemberModel;
+use app\common\model\supplier\PointsLog as PointsLogModel;
+use app\shop\model\auth\UserRole as UserRoleModel;
 
 /**
  * 商家供应商模型
@@ -81,6 +82,27 @@
         }
         return true;
     }
+
+    /**
+     * 累积商户的可用积分
+     */
+    public function setIncPoints($points, $describe, $decPoints = 0)
+    {
+        // 新增积分变动明细
+        PointsLogModel::add([
+            'shop_supplier_id' => $this['shop_supplier_id'],
+            'value' => $points,
+            'describe' => $describe,
+            'app_id' => $this['app_id'],
+        ]);
+
+        // 更新用户可用积分
+        $data['points'] = ($this['points'] + $points + $decPoints <= 0) ? 0 : $this['points'] + $points + $decPoints;
+        $this->where('branch_id', '=', $this['branch_id'])->update($data);
+        
+        return true;
+    }
+
     //判断营业时间
     public function supplierStatus($shop_supplier_id)
     {
@@ -154,6 +176,14 @@
     }
 
     /**
+     * 获取供应商当前有效的年卡
+     */
+    public function getCurrentMember()
+    {
+        return MemberModel::getCurrentMember($this['shop_supplier_id'], $this['app_id']);
+    }
+    
+    /**
      * 获取角色管理的区域
      */
     public static function getAreaIdsByUser($user)
@@ -215,6 +245,12 @@
             ->find();
         return empty($data['is_independent']) ? 0 : $data['is_independent'];
     }
-
+    /**
+     * 冻结用户资金
+     */
+    public function freezeMoney($money)
+    {
+        $this->save(['money' => $this['money'] - $money,'freeze_money'=>$this['freeze_money']+$money]);
+    }
 
 }
\ No newline at end of file

--
Gitblit v1.9.2