1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- <?php
- namespace App\Services\Violation;
- use App\Models\Media\MediaSecure;
- use App\Models\PartnerModel;
- use App\Models\User\UserModel;
- use App\Services\User\PartnerService;
- class Photo extends ViolationAbstract
- {
- public const FIELDS = [
- 'photo_src' => 'check_photo',
- 'photo_1' => 'photo_1_check',
- 'photo_2' => 'photo_2_check',
- 'photo_3' => 'photo_3_check',
- 'photo_4' => 'photo_4_check',
- ];
- public function handle()
- {
- $this->user = UserModel::find($this->media->uid);
- $partner = PartnerModel::whereRaw($this->media->field_primary)->first();
- if (
- in_array($this->media->origin, [
- 'http://oss.pocketuniversity.cn' . $partner->{$this->media->field},
- 'https://oss.pocketuniversity.cn' . $partner->{$this->media->field},
- ])
- ) {
- switch ($this->media->result) {
- case MediaSecure::MANUAL_SUGGESTION_BLOCK:
- $this->handleFailed($partner->id);
- break;
- case MediaSecure::MANUAL_SUGGESTION_PASS:
- $this->handleSuccess($partner->id);
- break;
- }
- }
- }
- public function handleFailed($partnerId)
- {
- $userService = new PartnerService();
- $userService->check($partnerId, self::FIELDS[$this->media->field], -1);
- }
- public function handleSuccess($partnerId)
- {
- $userService = new PartnerService();
- $userService->check($partnerId, self::FIELDS[$this->media->field], 1);
- }
- }
|