UserIntegralJob.php 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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\UserIntegralServices;
  13. use crmeb\basic\BaseJobs;
  14. use crmeb\traits\QueueTrait;
  15. use think\facade\Log;
  16. /**
  17. * 清除到期积分
  18. * Class UserIntegralJob
  19. * @package app\jobs
  20. */
  21. class UserIntegralJob 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 UserIntegralServices $userIntegralServices */
  36. $userIntegralServices = app()->make(UserIntegralServices::class);
  37. $userIntegralServices->doClearExpireIntegral($uids);
  38. } catch (\Throwable $e) {
  39. Log::error('清除用户到期积分失败,失败原因:' . $e->getMessage());
  40. }
  41. return true;
  42. }
  43. /**
  44. * 赠送新人礼积分
  45. * @param $uid
  46. * @return bool
  47. */
  48. public function newcomerGiveIntegral($uid)
  49. {
  50. try {
  51. /** @var UserIntegralServices $userIntegralServices */
  52. $userIntegralServices = app()->make(UserIntegralServices::class);
  53. $userIntegralServices->newcomerGiveIntegral((int)$uid);
  54. } catch (\Throwable $e) {
  55. Log::error('赠送新人礼积分失败,失败原因:' . $e->getMessage());
  56. }
  57. return true;
  58. }
  59. /**
  60. * 会员卡激活赠送积分
  61. * @param $uid
  62. * @return bool
  63. */
  64. public function levelGiveIntegral($uid)
  65. {
  66. try {
  67. /** @var UserIntegralServices $userIntegralServices */
  68. $userIntegralServices = app()->make(UserIntegralServices::class);
  69. $userIntegralServices->levelGiveIntegral((int)$uid);
  70. } catch (\Throwable $e) {
  71. Log::error('会员卡激活赠送积分失败,失败原因:' . $e->getMessage());
  72. }
  73. return true;
  74. }
  75. }