AutoAgent.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\listener\user;
  12. use crmeb\utils\Cron;
  13. use crmeb\interfaces\ListenerInterface;
  14. use app\services\agent\AgentManageServices;
  15. use think\facade\Log;
  16. /**
  17. * 定时自动解绑上下级
  18. * Class AutoClearIntegral
  19. * @package app\listener\user
  20. */
  21. class AutoAgent extends Cron implements ListenerInterface
  22. {
  23. /**
  24. * @param $event
  25. */
  26. public function handle($event): void
  27. {
  28. //自动取消订单
  29. $this->tick(1000 * 60 * 10, function (){
  30. //自动解绑上级绑定
  31. try {
  32. /** @var AgentManageServices $agentManage */
  33. $agentManage = app()->make(AgentManageServices::class);
  34. $agentManage->removeSpread();
  35. return true;
  36. } catch (\Throwable $e) {
  37. Log::error('自动解除上级绑定失败,失败原因:[' . class_basename($this) . ']' . $e->getMessage());
  38. }
  39. });
  40. }
  41. }