UserSvipJob.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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\jobs\user;
  12. use app\services\user\UserServices;
  13. use crmeb\basic\BaseJobs;
  14. use crmeb\traits\QueueTrait;
  15. use think\facade\Log;
  16. /**
  17. * 清除到期svip
  18. * Class UserSvipJob
  19. * @package app\jobs\user
  20. */
  21. class UserSvipJob extends BaseJobs
  22. {
  23. use QueueTrait;
  24. /**
  25. * 执行清除到期积分
  26. * @param $openids
  27. * @return bool
  28. */
  29. public function doJob($uids)
  30. {
  31. if (!$uids || !is_array($uids)) {
  32. return true;
  33. }
  34. try {
  35. /** @var UserServices $userServices */
  36. $userServices = app()->make(UserServices::class);
  37. foreach ($uids as $uid) {
  38. $userServices->offMemberLevel($uid);
  39. }
  40. } catch (\Throwable $e) {
  41. Log::error('清除到期用户svip失败,失败原因:' . $e->getMessage());
  42. }
  43. return true;
  44. }
  45. }