SystemSubscribe.php 1.4 KB

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