SystemSubscribe.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. namespace crmeb\subscribes;
  3. use app\admin\model\system\SystemAdmin;
  4. use app\admin\model\system\SystemLog;
  5. use crmeb\utils\Redis;
  6. /**
  7. * 后台系统事件
  8. * Class SystemSubscribe
  9. * @package crmeb\subscribes
  10. */
  11. class SystemSubscribe
  12. {
  13. public function handle()
  14. {
  15. }
  16. /**
  17. * 添加管理员访问记录
  18. * @param $event
  19. */
  20. public function onAdminVisit($event)
  21. {
  22. list($adminInfo, $type) = $event;
  23. if (strtolower(app('request')->controller()) != 'index') SystemLog::adminVisit($adminInfo->id, $adminInfo->account, $type);
  24. }
  25. /**
  26. * 添加管理员最后登录时间和ip
  27. * @param $event
  28. */
  29. public function onSystemAdminLoginAfter($event)
  30. {
  31. list($adminInfo) = $event;
  32. SystemAdmin::edit(['last_ip' => app('request')->ip(), 'last_time' => time()], $adminInfo['id']);
  33. }
  34. /**
  35. * 商户注册成功之后
  36. * @param $event
  37. */
  38. public function onMerchantRegisterAfter($event)
  39. {
  40. list($merchantInfo) = $event;
  41. }
  42. /**
  43. * 管理员添加商品成功
  44. */
  45. public function onAdminAddStoreProduct($event)
  46. {
  47. list('product' => $product, 'admin' => $admin) = $event;
  48. errlog($admin->account . ' create product ' . $product['store_name'] . ' id:' . $product['id']);
  49. Redis::hSet('log:admin_add_products:' . $admin['id'], $product['id'], $product['store_name']);
  50. }
  51. }