541469799@qq.com 9 månader sedan
förälder
incheckning
20fd24afd4

+ 43 - 0
app/common/model/user/UserAccessLog.php

@@ -0,0 +1,43 @@
+<?php
+// +----------------------------------------------------------------------
+// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
+// +----------------------------------------------------------------------
+// | Copyright (c) 2017~2021 https://www.yiovo.com All rights reserved.
+// +----------------------------------------------------------------------
+// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
+// +----------------------------------------------------------------------
+// | Author: 萤火科技 <admin@yiovo.com>
+// +----------------------------------------------------------------------
+declare (strict_types=1);
+
+namespace app\common\model\user;
+
+use cores\BaseModel;
+
+/**
+ * 文章模型
+ * Class ShareKey
+ * @package app\common\model
+ */
+class UserAccessLog extends BaseModel
+{
+    // 定义表名
+    protected $name = 'user_access_log';
+
+    // 定义主键
+    protected $pk = 'id';
+
+    // 追加字段
+    protected $append = [];
+
+
+    /**
+     * 详情
+     * @param int $id
+     * @return array|null|static
+     */
+    public static function detail(int $id)
+    {
+        return self::get($id);
+    }
+}

+ 10 - 0
app/index/controller/Captcha.php

@@ -13,6 +13,7 @@ declare (strict_types=1);
 namespace app\index\controller;
 
 use app\common\library\Log;
+use app\index\model\user\UserAccessLog;
 use app\index\service\passport\MailCaptcha;
 use think\response\Json;
 use app\index\service\passport\{Captcha as CaptchaService,
@@ -63,6 +64,15 @@ class Captcha extends Controller
     {
         $data = $this->postForm();
         $email = $data['mobile'] ?? '';
+        UserAccessLog::doSave([
+            'user_id' => 0,
+            'path' => $this->request->action(),
+            'remark' => $email,
+            'ip' => $this->request->ip(),
+            'store_id' => $this->getStoreId(),
+            'create_time' => time()
+        ]);
+
         if (empty($email) || !is_email($email)) {
             return $this->renderError('Invalid email address.');
         }

+ 1 - 1
app/index/controller/Checkout.php

@@ -171,7 +171,7 @@ class Checkout extends Controller
         $userInfo = User::getCurrentLoginUser();
         $points = $userInfo['points'];
         if ($params['payType'] == OrderPayTypeEnum::POINTS) {
-            $payPoints = intval(bcmul(strval($orderInfo['orderPayPrice']), strval(UserAlias::POINTS_FOR_REGISTER), 0));//订单所需积分
+            $payPoints = intval(bcmul(strval($orderInfo['orderPayPrice']), strval(UserAlias::POINTS_FOR_ONE_DOLLAR), 0));//订单所需积分
             if (intval($points) < $payPoints) {
                 return $this->renderError('Not enough points');
             }

+ 18 - 1
app/index/controller/Index.php

@@ -8,6 +8,7 @@ use app\console\service\OrderGetYundan as OrderGetYundanService;
 use app\index\model\Article as ArticleModel;
 use app\index\model\Comment as CommentModel;
 use app\index\model\Goods as GoodsModel;
+use app\index\model\user\UserAccessLog;
 use think\facade\Cache;
 use think\facade\Log;
 use think\facade\Session;
@@ -22,7 +23,15 @@ class Index extends Controller
 {
     public function index()
     {
-        Log::notice($this->request->ip());
+        //Log::notice($this->request->ip());
+        UserAccessLog::doSave([
+            'user_id' => 0,
+            'path' => $this->request->action(),
+            'remark' => '',
+            'ip' => $this->request->ip(),
+            'store_id' => $this->getStoreId(),
+            'create_time' => time()
+        ]);
         //banner位
         $newArrivalCache = Cache::get('index_newArrival');
         $bestsellerCache = Cache::get('index_bestseller');
@@ -176,6 +185,14 @@ class Index extends Controller
 
     public function vapePoints(): View
     {
+        UserAccessLog::doSave([
+            'user_id' => 0,
+            'path' => $this->request->action(),
+            'remark' => '',
+            'ip' => $this->request->ip(),
+            'store_id' => $this->getStoreId(),
+            'create_time' => time()
+        ]);
         return view('vapePoints');
     }
 

+ 23 - 4
app/index/controller/Passport.php

@@ -14,6 +14,7 @@ namespace app\index\controller;
 
 use app\common\model\User as UserAlias;
 use app\index\model\User as UserModel;
+use app\index\model\user\UserAccessLog;
 use think\facade\Cache;
 use app\index\service\passport\Login as LoginService;
 use think\facade\Session;
@@ -37,6 +38,15 @@ class Passport extends Controller
     public function login()
     {
         if ($this->request->method() == 'GET') {
+            UserAccessLog::doSave([
+                'user_id' => 0,
+                'path' => $this->request->action(),
+                'remark' => '',
+                'ip' => $this->request->ip(),
+                'store_id' => $this->getStoreId(),
+                'create_time' => time()
+            ]);
+
             return view('logIn');
         }
         // 执行登录
@@ -51,7 +61,7 @@ class Passport extends Controller
         Session::set('access_token', $token);
         Session::set('user_id', $userInfo['user_id']);
 
-       $returnUri = Session::pull('returnuri');
+        $returnUri = Session::pull('returnuri');
         return $this->renderSuccess([
             'userId' => (int)$userInfo['user_id'],
             'token' => $LoginService->getToken((int)$userInfo['user_id']),
@@ -61,13 +71,22 @@ class Passport extends Controller
 
     public function register()
     {
+        $form = $this->postForm();
+        UserAccessLog::doSave([
+            'user_id' => 0,
+            'path' => $this->request->action(),
+            'remark' => json_encode($form),
+            'ip' => $this->request->ip(),
+            'store_id' => $this->getStoreId(),
+            'create_time' => time()
+        ]);
+
         // 执行登录
         $LoginService = new LoginService;
-        if (!$LoginService->toRegister($this->postForm())) {
+        if (!$LoginService->toRegister($form)) {
             return $this->renderError($LoginService->getError());
         }
-        $form = $this->postForm();
-        if (!empty($form['mobile'])){
+        if (!empty($form['mobile'])) {
             $userInfo = $LoginService->getUserInfo();
             UserModel::setIncPoints(intval($userInfo['user_id']), UserAlias::POINTS_FOR_REGISTER, 'Register .');
         }

+ 34 - 0
app/index/model/user/UserAccessLog.php

@@ -0,0 +1,34 @@
+<?php
+// +----------------------------------------------------------------------
+// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
+// +----------------------------------------------------------------------
+// | Copyright (c) 2017~2021 https://www.yiovo.com All rights reserved.
+// +----------------------------------------------------------------------
+// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
+// +----------------------------------------------------------------------
+// | Author: 萤火科技 <admin@yiovo.com>
+// +----------------------------------------------------------------------
+declare (strict_types = 1);
+
+namespace app\index\model\user;
+
+use app\common\model\user\UserAccessLog as UserAccessLogModel;
+
+/**
+ * 系统设置模型
+ * Class Setting
+ * @package app\api\model
+ */
+class UserAccessLog extends UserAccessLogModel
+{
+    /**
+     * 获取积分名称
+     * @return bool
+     */
+    public static function doSave($data)
+    {
+        if (empty($data))return false;
+        return static::insert($data);
+    }
+
+}

+ 15 - 1
public/install/data/install_struct.sql

@@ -980,4 +980,18 @@ CREATE TABLE `yoshop_share_key` (
  `create_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',
  `update_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '更新时间',
  PRIMARY KEY (`key_id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户分享商品记录key表';
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户分享商品记录key表';
+
+DROP TABLE IF EXISTS `yoshop_user_access_log`;
+CREATE TABLE `yoshop_user_access_log` (
+    `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
+    `user_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '用户ID',
+    `ip` varchar(255) NOT NULL DEFAULT '' COMMENT 'IP',
+    `path` varchar(255) NOT NULL DEFAULT '' COMMENT '行为',
+    `remark` varchar(2550) NOT NULL DEFAULT '' COMMENT '备注',
+    `is_delete` tinyint(3) unsigned NOT NULL DEFAULT '0' COMMENT '是否删除',
+    `store_id` int unsigned NOT NULL DEFAULT '0' COMMENT '商城ID',
+    `create_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',
+    `update_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '更新时间',
+    PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户访问记录表';