VideoJob.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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\activity;
  12. use app\services\activity\bargain\StoreBargainServices;
  13. use app\services\activity\video\VideoServices;use crmeb\basic\BaseJobs;
  14. use crmeb\traits\QueueTrait;
  15. use think\facade\Log;
  16. /**
  17. * 营销:短视频
  18. * Class VideoJob
  19. * @package app\jobs\activity
  20. */
  21. class VideoJob extends BaseJobs
  22. {
  23. use QueueTrait;
  24. /**
  25. * 增加短视频浏览播放量
  26. * @param array $ids
  27. * @param int $num
  28. * @return bool
  29. */
  30. public function setVideoPlayNum(array $ids, int $uid = 0, int $num = 1)
  31. {
  32. if (!$ids) {
  33. return true;
  34. }
  35. try {
  36. /** @var VideoServices $videoServices */
  37. $videoServices = app()->make(VideoServices::class);
  38. foreach ($ids as $id) {
  39. $videoServices->userRelationVideo($uid, (int)$id, 'play', $num);
  40. }
  41. } catch (\Throwable $e) {
  42. Log::error('增加短视频浏览播放量失败,失败原因:' . $e->getMessage());
  43. }
  44. return true;
  45. }
  46. }