CancelUserJob.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2022 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\user;
  12. use app\services\activity\integral\StoreIntegralOrderServices;
  13. use app\services\message\service\StoreServiceServices;
  14. use app\services\order\OtherOrderServices;
  15. use app\services\order\StoreCartServices;
  16. use app\services\order\StoreOrderRefundServices;
  17. use app\services\order\StoreOrderServices;
  18. use app\services\store\DeliveryServiceServices;
  19. use app\services\store\SystemStoreStaffServices;
  20. use app\services\user\UserAddressServices;
  21. use app\services\user\UserFriendsServices;
  22. use crmeb\basic\BaseJobs;
  23. use crmeb\traits\QueueTrait;
  24. use think\facade\Log;
  25. /**
  26. * 注销用户队列
  27. */
  28. class CancelUserJob extends BaseJobs
  29. {
  30. use QueueTrait;
  31. /**
  32. * 用户注销队列
  33. * @param $uid
  34. * @return bool
  35. */
  36. public function doJob($uid)
  37. {
  38. try {
  39. /** @var SystemStoreStaffServices $storeStaffServices */
  40. $storeStaffServices = app()->make(SystemStoreStaffServices::class);
  41. /** @var DeliveryServiceServices $deliveryServices */
  42. $deliveryServices = app()->make(DeliveryServiceServices::class);
  43. /** @var OtherOrderServices $otherOrderServices */
  44. $otherOrderServices = app()->make(OtherOrderServices::class);
  45. /** @var StoreCartServices $storeCartServices */
  46. $storeCartServices = app()->make(StoreCartServices::class);
  47. /** @var StoreOrderServices $storeOrderServices */
  48. $storeOrderServices = app()->make(StoreOrderServices::class);
  49. /** @var StoreOrderRefundServices $storeOrderRefundServices */
  50. $storeOrderRefundServices = app()->make(StoreOrderRefundServices::class);
  51. /** @var UserAddressServices $addressServices */
  52. $addressServices = app()->make(UserAddressServices::class);
  53. /** @var StoreIntegralOrderServices $integralOrderServices */
  54. $integralOrderServices = app()->make(StoreIntegralOrderServices::class);
  55. /** @var StoreServiceServices $storeServiceServices */
  56. $storeServiceServices = app()->make(StoreServiceServices::class);
  57. /** @var UserFriendsServices $userService */
  58. $userService = app()->make(UserFriendsServices::class);
  59. //删除好友关系记录
  60. $userService->delete(['uid' => $uid]);
  61. // 删除核销员,删除配送员,删除客服
  62. $storeStaffServices->update(['uid' => $uid], ['is_del' => 1]);
  63. $deliveryServices->update(['uid' => $uid], ['is_del' => 1]);
  64. $storeServiceServices->update(['uid' => $uid], ['is_del' => 1]);
  65. // 删除订单,删除退款单,删除其他订单,删除积分订单,删除购物车
  66. $otherOrderServices->update(['uid' => $uid], ['is_del' => 1]);
  67. $storeOrderServices->update(['uid' => $uid], ['is_del' => 1]);
  68. $storeOrderRefundServices->update(['uid' => $uid], ['is_del' => 1]);
  69. $integralOrderServices->update(['uid' => $uid], ['is_del' => 1]);
  70. $storeCartServices->delete(['uid' => $uid]);
  71. // 删除地址
  72. $addressServices->update(['uid' => $uid], ['is_del' => 1]);
  73. } catch (\Throwable $e) {
  74. Log::error('注销用户失败,失败原因:' . $e->getMessage());
  75. }
  76. return true;
  77. }
  78. }