wupengfei 2 years ago
parent
commit
a4eab28a39

+ 0 - 9
application/api/controller/Base.php

@@ -14,9 +14,6 @@
 // +----------------------------------------------------------------------
 
 namespace app\api\controller;
-
-use app\common\controller\Api;
-use app\common\model\UserTrack;
 use Firebase\JWT\JWT;
 use think\Controller;
 use think\Db;
@@ -78,12 +75,6 @@ class Base extends Controller
         }
     }
 
-    // 生成浏览记录
-    protected function userTrack()
-    {
-
-    }
-
 
     protected function setUid(){
         $authorization = app()->request->header('Authorization');

+ 2 - 0
application/api/controller/Expedite.php

@@ -14,6 +14,7 @@ use app\common\model\OrderComment;
 use app\common\model\RemarkLabel;
 use app\common\model\StoreGoods;
 use app\common\model\UserCollect;
+use app\common\model\UserTrack;
 use app\common\service\Activity;
 use think\Db;
 /**
@@ -213,6 +214,7 @@ class Expedite extends Base
     public function getGoodsDetail()
     {
         $goods_id = input('goods_id');
+        if($this->user_id)UserTrack::createTrack($this->user_id,1,$goods_id);
         $detail = StoreGoods::with(['itemList'])->field('g.*,p.goods_param')->alias('g')->leftJoin('GoodsParam p','g.id = p.goods_id')->where('g.id',$goods_id)->find()->toArray();
         if(isset($detail['goods_param']) && !empty($detail['goods_param'])) $detail['goods_param'] = json_decode($detail['goods_param'],true);
         $detail['max_price'] = max(array_column($detail['item_list'],'original_price'));

+ 2 - 0
application/api/controller/Information.php

@@ -6,6 +6,7 @@ use app\common\model\NewsCate;
 use app\common\model\NutritionCase;
 use app\common\model\StoreBanner;
 use app\common\model\UserCollect;
+use app\common\model\UserTrack;
 
 /**
  * @title 资讯(营养百科)
@@ -228,6 +229,7 @@ class Information extends Base
         $sel_where[]  = ['is_deleted','=',0];
         $sel_where[]  = ['status','=',1];
         $sel_where[]  = ['id','=',input('get.id')];
+        if($this->user_id)UserTrack::createTrack($this->user_id,2,input('get.id'));
         $detail = InformationArticle::where($sel_where)
             ->order('is_top desc,sort desc ,id desc')->find();
         if(!$detail)$this->error('该资讯已下线');

+ 0 - 4
application/api/controller/UserCenter.php

@@ -1,14 +1,10 @@
 <?php
 namespace app\api\controller;
-use AlibabaCloud\Client\AlibabaCloud;
-use AlibabaCloud\Client\Exception\ClientException;
-use AlibabaCloud\Client\Exception\ServerException;
 use app\common\model\GoodsOrder;
 use app\common\model\UserCollect;
 use app\common\model\UserCouponList;
 use app\common\model\UserLevel;
 use app\common\model\UserTrack;
-use app\order\controller\StoreOrder;
 use think\Db;
 use app\common\model\UserBank;
 use app\common\model\User;

+ 21 - 1
application/common/model/UserTrack.php

@@ -1,8 +1,28 @@
 <?php
 namespace app\common\model;
+use library\tools\Data;
 use think\Model;
 // 足迹
 class UserTrack extends Model
 {
-
+    public static function createTrack($user_id,$type,$rel_id)
+    {
+        $data = [
+            'user_id'=>$user_id,
+            'rel_id'=>$rel_id,
+            'type'=>$type,
+            'update_int'=>time(),
+            'year'=>date("Y"),
+            'month'=>date("m"),
+            'day'=>date("d"),
+        ];
+        Data::save('UserTrack',$data,'user_id',[
+            'user_id'=>$user_id,
+            'rel_id'=>$rel_id,
+            'type'=>$type,
+            'year'=>date("Y"),
+            'month'=>date("m"),
+            'day'=>date("d"),
+        ]);
+    }
 }