GoodnightComplaintHandle.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. namespace App\Services\Complain;
  3. use App\Models\BlackListModel;
  4. use App\Services\User\ProfileService;
  5. class GoodnightComplaintHandle extends ComplaintHandle
  6. {
  7. public function erasing()
  8. {
  9. $be_user = $this->getBeUser();
  10. foreach ($this->fields as $field) {
  11. try {
  12. switch ($field) {
  13. case "sex":
  14. $value = 0;
  15. if ($be_user->sex == 1) {
  16. $value = 2;
  17. } elseif ($be_user->sex == 2) {
  18. $value = 1;
  19. }
  20. $userService = new ProfileService();
  21. $userService->updateUser($be_user, [$field => $value]);
  22. break;
  23. }
  24. } catch (\Exception $e) {
  25. }
  26. }
  27. }
  28. public function reply()
  29. {
  30. switch ($this->state) {
  31. case "1":
  32. return "仅回复";
  33. break;
  34. case "2":
  35. return "联系客服";
  36. break;
  37. }
  38. }
  39. /**
  40. * 拉入黑名单
  41. * @return mixed|void
  42. */
  43. public function defriend()
  44. {
  45. BlackListModel::create([
  46. 'uid' => $this->complaint->be_uid,
  47. 'complaint_id' => $this->complaint->id,
  48. 'end_at' => $this->defriend_at,
  49. 'type' => 'goodnight',
  50. 'state' => $this->defriend_state,
  51. ]);
  52. }
  53. }