mirror of
https://github.com/Bigherollc/wticreatorstudio.git
synced 2026-10-01 09:13:19 -04:00
37 lines
1.1 KiB
PHP
37 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace Modules\StaffPayroll\Services;
|
|
|
|
use Modules\StudioPlus\Entities\StudioPlusVideo;
|
|
use Modules\StudioPlusWtiiabaddon\Entities\StudioPlusIncentive;
|
|
|
|
class GenerateIncentiveForAmazonReviews extends GenerateInvoiceService
|
|
{
|
|
public function __invoke(): void
|
|
{
|
|
$incentive = StudioPlusIncentive::query()
|
|
->whereHas('incentiveCategory', fn ($query) => $query->where('name', 'ASIN Rating Bonus'))
|
|
->first();
|
|
|
|
if (!$incentive || ($incentive && $incentive->amount_value_earned === 0)) return;
|
|
|
|
StudioPlusVideo::query()
|
|
->with(
|
|
[
|
|
'channel.user'
|
|
]
|
|
)
|
|
->whereIn('status', [
|
|
StudioPlusVideo::STATUS_APPROVED,
|
|
StudioPlusVideo::STATUS_AMAZON_UPLOADED,
|
|
StudioPlusVideo::STATUS_AMAZON_APPROVED,
|
|
StudioPlusVideo::STATUS_PUBLISHED_TO_AMAZON,
|
|
])
|
|
->thisMonth()
|
|
->where('amazon_total_reviews', '>', $incentive->target_rule)
|
|
->each(function ($video) use ($incentive) {
|
|
$this->addIncentiveItemForVideo($video->channel->user, $video, $incentive, 'Rating Incentive Bonus');
|
|
});
|
|
}
|
|
}
|