123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- <?php
- declare (strict_types = 1);
- namespace app\admin\model;
- use think\Model;
- use think\facade\Db;
- /**
- * @mixin \think\Model
- */
- class ActionLog extends Model
- {
- /**
- * 记录操作日志
- * @param $token
- * @param $order
- * @param $type
- * @param $status
- */
- static function logAdd($token,$order,$type,$status,$post){
- if(is_string($token)){
- $user = GetUserInfo($token);
- unset($post['token']);
- $uid = isset($user['data']['id']) ? $user['data']['id'] :0;
- $name = isset($user['data']['nickname']) ? $user['data']['nickname'] :'';
- }else{
- $uid = isset($token['id']) ? $token['id'] :0;
- $name = isset($token['nickname']) ? $token['nickname'] :'';
- }
- $roleid=0;
- if($uid!=0){
- $userrole = Db::name("user_role")->where(["uid"=>$uid,"is_del"=>0,"status"=>1])->find();
- $roleid = isset($userrole['roleid']) ? $userrole['roleid'] :0;
- }
- $data=[
- "action_id"=>$uid,
- "action_name"=>$name,
- "role_id"=>$roleid,
- "action_status"=>$status,
- "action_remark"=>isset($order[ 'remark']) ? trim($order['remark']) :"",
- "order_code"=>isset($order['order_code']) ? trim($order['order_code']."") :"",
- "order_type"=>$type,
- "action_type"=>isset($order['action_type']) ? trim($order['action_type']) :"",
- "action_data"=>json_encode($post),
- "order_status"=>isset($order['status']) ? $order['status'] :"",
- "addtime"=>date("Y-m-d H:i:s"),
- "updatetime"=>date("Y-m-d H:i:s")
- ];
- self::insert($data);
- }
- }
|