From 21512703df5ddf962893003a460e75af10d4757f Mon Sep 17 00:00:00 2001
From: zhaojs <349234519@qq.com>
Date: 星期三, 02 八月 2023 09:49:21 +0800
Subject: [PATCH] no message

---
 application/api/logic/UserBrowse.php |   27 ++++++++++++++++++++++++---
 1 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/application/api/logic/UserBrowse.php b/application/api/logic/UserBrowse.php
index 6512126..8f4921a 100644
--- a/application/api/logic/UserBrowse.php
+++ b/application/api/logic/UserBrowse.php
@@ -80,18 +80,39 @@
      * @param [type] $ids
      * @return void
      */
-    public function updatefirstfreelog($user_id,$ids,$new_goodsId)
+    public function updatefirstfreelog($user_id,$ids,$new_goodsId,$plateform)
     {
-        if(empty($ids)){
+        if(empty($ids)||empty($new_goodsId)){
             fault('瀹濊礉ID涓嶈兘涓虹┖');
             return true;
         }
-        $res=Db::name('user_browse')->where(['user_id'=>$user_id,'goodsId'=>$ids])->update(['is_free'=>1,'goodsId'=>$new_goodsId]);
+        //鏌ヨ鏄惁宸茬粡鏍囪杩�
+        $res=Db::query('SELECT id FROM t_user_first_free_browse WHERE user_id=? AND goodsId=?',[$user_id,$ids]);
+        if(!empty($res)){
+             return true;
+        }
+        $res=Db::execute('INSERT INTO t_user_first_free_browse(user_id,goodsId,new_goodsId,plateform) VALUES (?,?,?,?)',[$user_id,$ids,$new_goodsId,$plateform]);
 
         return true;
 
     }
 
+    /**
+     * 鏌ヨ鏄惁棣栬喘
+     *
+     * * @param [type] $user_id
+     * @param [type] $ids
+     * @return void
+     */
+
+    public function checkisfirstfree($user_id)
+    {
+        //鏌ヨ鏄惁宸茬粡鏍囪杩�
+        $res=Db::query('SELECT id FROM t_user_first_free_browse WHERE user_id=? AND is_order=?',[$user_id,1]);
+        return $res;
+
+    }
+
 
    
 

--
Gitblit v1.9.3