ProductSupplierJob.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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\activity\bargain\StoreBargainServices;
  13. use app\services\activity\combination\StoreCombinationServices;
  14. use app\services\activity\integral\StoreIntegralServices;
  15. use app\services\activity\seckill\StoreSeckillServices;
  16. use crmeb\basic\BaseJobs;
  17. use crmeb\traits\QueueTrait;
  18. use think\facade\Log;
  19. /**
  20. * 商品供应商修改
  21. * Class ProductSupplierJob
  22. * @package app\jobs\product
  23. */
  24. class ProductSupplierJob extends BaseJobs
  25. {
  26. use QueueTrait;
  27. /**
  28. * 修改商品、活动商品供应商ID
  29. * @param $product_id
  30. * @param $supplier_id
  31. * @return bool
  32. */
  33. public function updateSupplierId($product_id, $supplier_id = 0)
  34. {
  35. $supplier_id = (int)$supplier_id;
  36. $product_id = (int)$product_id;
  37. if ($product_id && $supplier_id) {
  38. try {
  39. /** @var StoreSeckillServices $seckillServices */
  40. $seckillServices = app()->make(StoreSeckillServices::class);
  41. $seckillServices->update(['product_id' => $product_id], ['type' => 2, 'relation_id' => $supplier_id]);
  42. /** @var StoreCombinationServices $pinkServices */
  43. $pinkServices = app()->make(StoreCombinationServices::class);
  44. $pinkServices->update(['product_id' => $product_id], ['type' => 2, 'relation_id' => $supplier_id]);
  45. /** @var StoreBargainServices $bargainServices */
  46. $bargainServices = app()->make(StoreBargainServices::class);
  47. $bargainServices->update(['product_id' => $product_id], ['type' => 2, 'relation_id' => $supplier_id]);
  48. /** @var StoreIntegralServices $integralServices */
  49. $integralServices = app()->make(StoreIntegralServices::class);
  50. $integralServices->update(['product_id' => $product_id], ['type' => 2, 'relation_id' => $supplier_id]);
  51. } catch (\Throwable $e) {
  52. Log::error('修改商品供应商ID发生错误,错误原因:' . $e->getMessage());
  53. }
  54. }
  55. return true;
  56. }
  57. }