ProductLabelJob.php 1.6 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\product;
  12. use app\services\product\label\StoreProductLabelAuxiliaryServices;
  13. use crmeb\basic\BaseJobs;
  14. use crmeb\traits\QueueTrait;
  15. use think\facade\Log;
  16. /**
  17. * 商品标签
  18. * Class ProductLabelJob
  19. * @package app\jobs\product
  20. */
  21. class ProductLabelJob extends BaseJobs
  22. {
  23. use QueueTrait;
  24. /**
  25. * @param int $id
  26. * @param array $storeLabelId
  27. * @return bool
  28. */
  29. public function doJob(int $id, array $storeLabelId)
  30. {
  31. if (!$id) {
  32. return true;
  33. }
  34. try {
  35. /** @var StoreProductLabelAuxiliaryServices $auxiliaryService */
  36. $auxiliaryService = app()->make(StoreProductLabelAuxiliaryServices::class);
  37. //标签关联
  38. $auxiliaryService->saveLabelRelation($id, $storeLabelId);
  39. } catch (\Throwable $e) {
  40. Log::error('写入商品标签发生错误,错误原因:' . $e->getMessage());
  41. }
  42. return true;
  43. }
  44. }