Photo.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. namespace App\Services\Violation;
  3. use App\Models\Media\MediaSecure;
  4. use App\Models\PartnerModel;
  5. use App\Models\User\UserModel;
  6. use App\Services\User\PartnerService;
  7. class Photo extends ViolationAbstract
  8. {
  9. public const FIELDS = [
  10. 'photo_src' => 'check_photo',
  11. 'photo_1' => 'photo_1_check',
  12. 'photo_2' => 'photo_2_check',
  13. 'photo_3' => 'photo_3_check',
  14. 'photo_4' => 'photo_4_check',
  15. ];
  16. public function handle()
  17. {
  18. $this->user = UserModel::find($this->media->uid);
  19. $partner = PartnerModel::whereRaw($this->media->field_primary)->first();
  20. if (
  21. in_array($this->media->origin, [
  22. 'http://oss.pocketuniversity.cn' . $partner->{$this->media->field},
  23. 'https://oss.pocketuniversity.cn' . $partner->{$this->media->field},
  24. ])
  25. ) {
  26. switch ($this->media->result) {
  27. case MediaSecure::MANUAL_SUGGESTION_BLOCK:
  28. $this->handleFailed($partner->id);
  29. break;
  30. case MediaSecure::MANUAL_SUGGESTION_PASS:
  31. $this->handleSuccess($partner->id);
  32. break;
  33. }
  34. }
  35. }
  36. public function handleFailed($partnerId)
  37. {
  38. $userService = new PartnerService();
  39. $userService->check($partnerId, self::FIELDS[$this->media->field], -1);
  40. }
  41. public function handleSuccess($partnerId)
  42. {
  43. $userService = new PartnerService();
  44. $userService->check($partnerId, self::FIELDS[$this->media->field], 1);
  45. }
  46. }