ClearMerchantStoreJob.php 3.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2024 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace crmeb\jobs;
  12. use app\common\repositories\store\coupon\StoreCouponRepository;
  13. use app\common\repositories\store\coupon\StoreCouponUserRepository;
  14. use app\common\repositories\store\GuaranteeTemplateRepository;
  15. use app\common\repositories\store\GuaranteeValueRepository;
  16. use app\common\repositories\store\parameter\ParameterRepository;
  17. use app\common\repositories\store\parameter\ParameterTemplateRepository;
  18. use app\common\repositories\store\parameter\ParameterValueRepository;
  19. use app\common\repositories\store\product\ProductCateRepository;
  20. use app\common\repositories\store\product\ProductLabelRepository;
  21. use app\common\repositories\store\product\ProductReplyRepository;
  22. use app\common\repositories\store\product\ProductRepository;
  23. use app\common\repositories\store\product\StoreDiscountProductRepository;
  24. use app\common\repositories\store\product\StoreDiscountRepository;
  25. use app\common\repositories\store\shipping\ShippingTemplateRepository;
  26. use app\common\repositories\store\StoreCategoryRepository;
  27. use app\common\repositories\system\config\ConfigValueRepository;
  28. use app\common\repositories\system\groupData\GroupDataRepository;
  29. use crmeb\interfaces\JobInterface;
  30. use think\facade\Log;
  31. class ClearMerchantStoreJob implements JobInterface
  32. {
  33. public function fire($job, $data)
  34. {
  35. try{
  36. /**
  37. * 商户商品分类
  38. * 商户商品
  39. * 商品参数
  40. * 商品服务模板
  41. * 商品标签
  42. * 商品评价
  43. * 优惠套餐
  44. * 运费模板
  45. * 商户优惠券
  46. * 商户组合数据
  47. * 配置
  48. * 商户图片及源文件
  49. */
  50. $merId = (int)$data['mer_id'];
  51. app()->make(ProductRepository::class)->clearMerchantProduct($merId);
  52. $servers = [
  53. app()->make(ProductCateRepository::class),
  54. app()->make(StoreCategoryRepository::class),
  55. app()->make(ParameterRepository::class),
  56. app()->make(ParameterTemplateRepository::class),
  57. app()->make(ParameterValueRepository::class),
  58. app()->make(GuaranteeTemplateRepository::class),
  59. app()->make(GuaranteeValueRepository::class),
  60. app()->make(ProductLabelRepository::class),
  61. app()->make(ProductReplyRepository::class),
  62. app()->make(StoreDiscountRepository::class),
  63. app()->make(StoreDiscountProductRepository::class),
  64. app()->make(StoreCouponRepository::class),
  65. app()->make(StoreCouponUserRepository::class),
  66. app()->make(GroupDataRepository::class),
  67. app()->make(ConfigValueRepository::class),
  68. app()->make(ShippingTemplateRepository::class),
  69. ];
  70. foreach ($servers as $server) {
  71. $server->clear($merId,'mer_id');
  72. }
  73. }catch (\Exception $e){
  74. Log::info('商户ID:'.$data['mer_id'].'清除出错:'.$e->getMessage());
  75. }
  76. $job->delete();
  77. }
  78. public function failed($data)
  79. {
  80. // TODO: Implement failed() method.
  81. }
  82. }