Browse Source

Fixed 添加拒绝日志

程旭源 7 months ago
parent
commit
1b7a7770b7
2 changed files with 34 additions and 0 deletions
  1. 11 0
      application/admin/model/Admin.php
  2. 23 0
      application/admin/model/MoneyLog.php

+ 11 - 0
application/admin/model/Admin.php

@@ -2,6 +2,7 @@
 
 namespace app\admin\model;
 
+use app\common\model\MoneyLog;
 use think\Model;
 use think\Session;
 
@@ -28,5 +29,15 @@ class Admin extends Model
             }
         });
     }
+    public static function money($money, $user_id, $memo)
+    {
+
+        $user = self::get($user_id);
+        if ($user && $money != 0) {
+            $before = $user->money;
+            $after = function_exists('bcadd') ? bcadd($user->money, $money, 7) : $user->money + $money;
+            MoneyLog::create(['user_id' => $user_id, 'money' => $money, 'before' => $before, 'after' => $after, 'memo' => $memo]);
+        }
 
+    }
 }

+ 23 - 0
application/admin/model/MoneyLog.php

@@ -0,0 +1,23 @@
+<?php
+
+namespace app\admin\model;
+
+use think\Model;
+
+/**
+ * 会员余额日志模型
+ */
+class MoneyLog extends Model
+{
+
+    // 表名
+    protected $name = 'user_money_log';
+    // 开启自动写入时间戳字段
+    protected $autoWriteTimestamp = 'int';
+    // 定义时间戳字段名
+    protected $createTime = 'createtime';
+    protected $updateTime = '';
+    // 追加属性
+    protected $append = [
+    ];
+}