ProductCateJob.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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\StoreProductCateServices;
  13. use crmeb\basic\BaseJobs;
  14. use crmeb\traits\QueueTrait;
  15. use think\facade\Log;
  16. /**
  17. * 商品分类
  18. * Class ProductCateJob
  19. * @package app\jobs\product
  20. */
  21. class ProductCateJob extends BaseJobs
  22. {
  23. use QueueTrait;
  24. /**
  25. * @param int $id
  26. * @param array $cate_id
  27. * @param int $is_show
  28. * @return bool
  29. */
  30. public function doJob(int $id, array $cate_id, int $is_show = 0)
  31. {
  32. try {
  33. /** @var StoreProductCateServices $storeProductCateServices */
  34. $storeProductCateServices = app()->make(StoreProductCateServices::class);
  35. //商品分类关联
  36. $storeProductCateServices->saveCate($id, $cate_id, $is_show);
  37. } catch (\Throwable $e) {
  38. Log::error('写入商品分类关联发生错误,错误原因:' . $e->getMessage());
  39. }
  40. return true;
  41. }
  42. }