Commit dc6fd23f by Phạm Văn Đoan

tạo task xử lý báo cáo tuần/tháng

parent 1ee12f80
<?php
namespace App\Console\Commands;
use App\Models\Crontjob;
use App\Repositories\TrackRepository;
use Carbon\Carbon;
use Illuminate\Console\Command;
class CalculateWeeklyReportCommand extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'calculate:weekly-report';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Tính toán số liệu báo cáo tuần';
protected $trackRepository;
/**
* Create a new command instance.
*
* CalculateWeeklyReportCommand constructor.
* @param TrackRepository $trackRepository
*/
public function __construct(TrackRepository $trackRepository)
{
parent::__construct();
ini_set('max_execution_time', -1);
$this->trackRepository = $trackRepository;
}
public function handle()
{
// Ghi log xem có gọi không
Crontjob::create(['message' => 'CalculateWeeklyReportCommand is called']);
// Xử lý di chuyển
echo "\n Bắt đầu xử lý tính toán báo cáo tuần";
echo "\n Kết thúc xử lý tính toán báo cáo tuần";
}
}
......@@ -3,6 +3,7 @@
namespace App\Console;
use App\Console\Commands\CalculateDailyListenCommand;
use App\Console\Commands\CalculateWeeklyReportCommand;
use App\Console\Commands\CrawlerTrackListenCommand;
use App\Console\Commands\CrontjobCommand;
use App\Console\Commands\Keeng\KeengCrawlerByCateCommand;
......@@ -39,6 +40,8 @@ class Kernel extends ConsoleKernel
CalculateDailyListenCommand::class,
CalculateWeeklyReportCommand::class,
];
......
......@@ -22,6 +22,11 @@ class Constants
const TABLE_PASSWORD_RESETS = 'password_resets';
const TABLE_PERMISSION_USER = 'permission_user';
const TABLE_PERMISSIONS = 'permissions';
const TABLE_REPORT_VIEWS_DAILY = 'report_views_daily';
const TABLE_REPORT_VIEWS_WEEKLY = 'report_views_weekly';
const TABLE_REPORTS_VIEWS_MONTHLY = 'reports_views_monthly';
const TABLE_ROLE_USER = 'role_user';
const TABLE_ROLES = 'roles';
......@@ -51,73 +56,6 @@ class Constants
const MESSAGE_ERROR = 'error';
const MESSAGE_EMPTY = 'empty';
const BIRTHDAY_STATUS_NEW = 0;
const BIRTHDAY_STATUS_PROCESSING = 1;
const BIRTHDAY_STATUS_SUCCESS = 2;
const BIRTHDAY_STATUS_FAILED = 3;
const BIRTHDAY_STATUS_SUCCESS_AGAIN = 4;
const BIRTHDAY_STATUS_CANCEL = 5;
const BIRTHDAY_CHANNEL_CODE_SMS = 'SMS';
const BIRTHDAY_CHANNEL_CODE_EMAIL = 'EMAIL';
const BIRTHDAY_CHANNEL_CODE_EMAIL_SMS = 'EMAIL_SMS';
const CHANNEL_CODE_DEFAULT = 'EMAIL';
const EMAIL_CONTENT_DEFAULT = 'Hi! Thay mặt Công Đoàn Công ty DCV, tôi xin gửi lời chúc sinh nhật vui vẻ, thành công và hạnh phúc tới đồng chí. Chúc đồng chí luôn hoàn thành tốt nhiệm vụ!';
const SMS_CONTENT_DEFAULT = '(DCV - CONG DOAN) Thay mat Cong Doan Cong ty DCV, chuc Ban sinh nhat VUI VE.';
/* Cấu hình khoảng giá trị sinh mã bảo mật */
const VERIFICATION_CODE_MIN = 100000;
const VERIFICATION_CODE_MAX = 999999;
/* Cấu hình thời gian bắt đầu gửi chúc mừng sinh nhật */
const BIRTHDAY_START_SEND_HOUR = '09';
const BIRTHDAY_START_SEND_MINUTE = '00';
const BIRTHDAY_START_SEND_SECOND = '00';
const BIRTHDAY_EMAIL_TEMPLATE_FILENAME = 'mail_birthday.html';
const BIRTHDAY_EMAIL_TEMPLATE_FROM_PUBLIC = 'storage/templates/mail/';
const BIRTHDAY_EMAIL_TEMPLATE_FROM_STORAGE = 'app/public/templates/mail/';
/* Backend view path */
const BE_VIEW_PATH_DASHBOARD = 'pages.backend.dashboard.index';
/* Tên Tab ứng dụng extension PMS */
const BROWSER_TYPE_NOTIFICATION = 'NOTIFICATION';
const BROWSER_TYPE_PROJECT = 'PROJECT';
const BROWSER_TYPE_TASK = 'TASK';
const BROWSER_TYPE_COWORKER = 'COWORKER';
/* Tên Tab ứng dụng extension SmartJob */
const SMARTJOB_TYPE_JOBS = 'JOBS';
const SMARTJOB_TYPE_COMPANIES = 'COMPANIES';
const SMARTJOB_TYPE_BLOG = 'BLOG';
/* Tên Tab ứng dụng extension AHoaDon */
const AHOADON_TYPE_SEARCH = 'SEARCH';
const AHOADON_TYPE_PACKAGE = 'PACKAGE';
const AHOADON_TYPE_TEMPLATE = 'TEMPLATE';
const AHOADON_PRICE_INIT = 500000;
const AHOADON_VAT = 10;
const STORAGE_OPENWEATHERMAP_ICON = 'storage/weather/openweathermap';
const STORAGE_COURSE_ICON = 'storage/courses';
const STORAGE_IMG_TRACKS_DB = 'storage/tracks/images/';
const STORAGE_IMG_TRACKS = 'storage/app/public/tracks/images/';
const STORAGE_IMG_EMPTY_PNG = 'storage/app/public/empty-1x1-png.png';
const STORAGE_IMG_EMPTY_JPG = 'storage/app/public/empty-1x1-jpg.jpg';
const STORAGE_IMG_EMPTY_GIF = 'storage/app/public/empty-1x1-gif.gif';
const STORAGE_FILE_TRACKS_DB = 'storage/tracks/files/';
const STORAGE_FILE_TRACKS = 'storage/app/public/tracks/files/';
const STORAGE_COVER_ARTISTS_DB = 'storage/artists/covers/';
const STORAGE_COVER_ARTISTS = 'storage/app/public/artists/covers/';
const STORAGE_THUMBNAIL_ARTISTS_DB = 'storage/artists/thumbnails/';
const STORAGE_THUMBNAIL_ARTISTS = 'storage/app/public/artists/thumbnails/';
const VMUSICCHART_IMG_TRACKS_DB = 'uploads/tracks/arts/';
const VMUSICCHART_IMG_TRACKS = '/home/aseanvn/public_html/vmusicchart.dcv.vn/uploads/tracks/arts/';
const VMUSICCHART_IMG_EMPTY_PNG = '/home/aseanvn/public_html/vmusicchart.dcv.vn/uploads/empty-1x1-png.png';
......
......@@ -267,3 +267,29 @@ if (!function_exists('getKeengUrlNewRealease')) {
return $url;
}
}
if (!function_exists('convertViews')) {
/**
* Hàm tính toán quy đổi lượt nghe thành điểm từ các hệ thống nhạc: zing/nc/nhacvn/keeng
*
* @param $views_top1
* @param $views_needed
* @param $web
*
* @return string
*/
function convertViews($views_top1, $views_needed, $web) {
$point = 0;
if ($views_top1 > 0 && $views_needed > 0) {
switch ($web) {
case 'zing': $factor = 100000; break;
case 'nct': $factor = 94000; break;
case 'keeng': $factor = 12000; break;
case 'nhacvn': $factor = 14000; break;
default: $point = 100000;
}
$point = $factor * ($views_needed / $views_top1);
}
return $point;
}
}
<?php
namespace App\Models;
use App\Helpers\Constants;
use Illuminate\Database\Eloquent\Model;
class DailyReport extends Model
{
protected $table = Constants::TABLE_REPORT_VIEWS_DAILY;
public $timestamps = true;
protected $fillable = [
'date', 'day', 'month', 'year',
'track_id',
'views_zing', 'views_nct', 'views_keeng',
'point_zing', 'point_keeng', 'total_point',
'order'
];
}
<?php
namespace App\Models;
use App\Helpers\Constants;
use Illuminate\Database\Eloquent\Model;
class MonthlyReport extends Model
{
protected $table = Constants::TABLE_REPORTS_VIEWS_MONTHLY;
public $timestamps = true;
protected $fillable = [
'date', 'day', 'month', 'year',
'track_id',
'views_zing', 'views_nct', 'views_keeng',
'point_zing', 'point_keeng', 'total_point',
'order'
];
}
<?php
namespace App\Models;
use App\Helpers\Constants;
use Illuminate\Database\Eloquent\Model;
class WeeklyReport extends Model
{
protected $table = Constants::TABLE_REPORT_VIEWS_WEEKLY;
public $timestamps = true;
protected $fillable = [
'date', 'day', 'month', 'year',
'track_id',
'views_zing', 'views_nct', 'views_keeng',
'point_zing', 'point_keeng', 'total_point',
'order'
];
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment