ProductRelationJob.php 1.8 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\product;
  12. use app\services\product\product\StoreProductRelationServices;
  13. use crmeb\basic\BaseJobs;
  14. use crmeb\traits\QueueTrait;
  15. /**
  16. * 商品关联关系
  17. * Class ProductRelationJob
  18. * @package app\jobs\product
  19. */
  20. class ProductRelationJob extends BaseJobs
  21. {
  22. use QueueTrait;
  23. /**
  24. * @param int $id
  25. * @param array $relation_id
  26. * @param int $type
  27. * @param int $is_show
  28. * @return bool
  29. */
  30. public function doJob(int $id, array $relation_id, int $type = 1, int $is_show = 1)
  31. {
  32. try {
  33. /** @var StoreProductRelationServices $storeProductRelationServices */
  34. $storeProductRelationServices = app()->make(StoreProductRelationServices::class);
  35. //商品关联
  36. $storeProductRelationServices->saveRelation($id, $relation_id, $type, $is_show);
  37. } catch (\Throwable $e) {
  38. response_log_write([
  39. 'message' => '写入商品关联[type:' . $type . ']发生错误,错误原因:' . $e->getMessage(),
  40. 'file' => $e->getFile(),
  41. 'line' => $e->getLine()
  42. ]);
  43. }
  44. return true;
  45. }
  46. }