ProductLogJob.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2023 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;
  12. use app\services\product\product\StoreProductLogServices;
  13. use crmeb\basic\BaseJobs;
  14. use crmeb\traits\QueueTrait;
  15. use think\facade\Log;
  16. class ProductLogJob extends BaseJobs
  17. {
  18. use QueueTrait;
  19. /**
  20. * @param $type 'visit','cart','order','pay','collect','refund'
  21. * @param $data
  22. * @return bool
  23. */
  24. public function doJob($type,$data)
  25. {
  26. try {
  27. /** @var StoreProductLogServices $productLogServices */
  28. $productLogServices = app()->make(StoreProductLogServices::class);
  29. $productLogServices->createLog($type, $data);
  30. }catch (\Throwable $e){
  31. Log::error('写入商品记录发生错误,错误原因:' . $e->getMessage());
  32. }
  33. return true;
  34. }
  35. }