ChangeLog.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. namespace app\admin\model;
  3. use think\Model;
  4. class ChangeLog extends Model
  5. {
  6. //记录商品、咨询单的修改记录
  7. static function logAdd($type,$code,$before_info,$after_info,$token,$post){
  8. if (is_array($token)) {
  9. $createrid = $token['id'];
  10. $creater = $token['nickname'];
  11. } else {
  12. $user = GetUserInfo($token);
  13. $createrid = isset($user['data']['id']) ? $user['data']['id'] : 0;
  14. $creater = isset($user['data']['nickname']) ? $user['data']['nickname'] : '';
  15. }
  16. unset($post['token']);
  17. // $item= array_diff($before_info,$after_info);
  18. // $json = json_encode($after_info,JSON_UNESCAPED_UNICODE);
  19. // $jsp = json_encode($before_info,JSON_UNESCAPED_UNICODE);
  20. $data=[
  21. "createrid"=>$createrid,
  22. "creater"=>$creater,
  23. "before_info"=>$before_info,
  24. "after_info"=>$after_info,
  25. "code"=>$code,
  26. "type"=>$type,
  27. // "action_data"=>json_encode($post),
  28. "addtime"=>date("Y-m-d H:i:s"),
  29. // "updatetime"=>date("Y-m-d H:i:s")
  30. ];
  31. // var_dump($data);
  32. self::insert($data);
  33. }
  34. }