Преглед на файлове

Fixed 添加拒绝日志

程旭源 преди 7 месеца
родител
ревизия
1b7a7770b7
променени са 2 файла, в които са добавени 34 реда и са изтрити 0 реда
  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 = [
+    ];
+}