Cron Jobs, Reminder, Fonts, Members / Wizard / Price, Credit and Promotion
This commit is contained in:
parent
a0f4eda6ea
commit
6167273a48
204 changed files with 8746 additions and 215 deletions
87
app/Cron/CronController.php
Normal file
87
app/Cron/CronController.php
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
<?php
|
||||
namespace App\Cron;
|
||||
|
||||
use App\User;
|
||||
use App\Models\UserBusiness;
|
||||
use App\Services\HTMLHelper;
|
||||
use App\Models\UserCreditItem;
|
||||
use App\Repositories\CreditRepository;
|
||||
|
||||
class UserCheckPaymentsAccounts
|
||||
{
|
||||
private $month;
|
||||
private $year;
|
||||
|
||||
|
||||
public function __construct($month, $year)
|
||||
{
|
||||
$this->month = $month;
|
||||
$this->year = $year;
|
||||
}
|
||||
|
||||
|
||||
public function getUserBusinessByMonthYear(){
|
||||
return UserBusiness::select('user_businesses.*')
|
||||
->where('user_businesses.month', '=', $this->month)
|
||||
->where('user_businesses.year', '=', $this->year)
|
||||
->where(function($q) {
|
||||
return $q->where('user_businesses.commission_team_total', '>', 0)
|
||||
->orWhere('user_businesses.commission_shop_sales', '>', 0);
|
||||
})
|
||||
->get();
|
||||
}
|
||||
|
||||
public function addUserCreditItem($userBusiness)
|
||||
{
|
||||
$date = HTMLHelper::getMonth($userBusiness->month).' '.$userBusiness->year;
|
||||
|
||||
if($userBusiness->commission_shop_sales > 0){
|
||||
if($this->hasNotUserCreditItem($userBusiness, 1)){
|
||||
UserCreditItem::create([
|
||||
'user_id' => $userBusiness->user_id,
|
||||
'user_business_id' => $userBusiness->id,
|
||||
'credit' => $userBusiness->commission_shop_sales,
|
||||
'message' => 'Provision Shop '.$date,
|
||||
'status' => 1,
|
||||
]);
|
||||
}
|
||||
}
|
||||
if($userBusiness->commission_team_total > 0){
|
||||
if($this->hasNotUserCreditItem($userBusiness, 2)){
|
||||
UserCreditItem::create([
|
||||
'user_id' => $userBusiness->user_id,
|
||||
'user_business_id' => $userBusiness->id,
|
||||
'credit' => $userBusiness->commission_team_total,
|
||||
'message' => 'Provision Team '.$date,
|
||||
'status' => 2,
|
||||
]);
|
||||
}
|
||||
}
|
||||
return $userBusiness;
|
||||
|
||||
}
|
||||
|
||||
public function getUserCreditItemUsersByMonthYear(){
|
||||
return UserCreditItem::select('user_credit_items.*')
|
||||
->where('paid', '=', false)
|
||||
->groupBy('user_id')
|
||||
->get();
|
||||
}
|
||||
|
||||
public function makeCreditPaymentPDF($user_id, $credit_send_mail)
|
||||
{
|
||||
//$user_id = 2;
|
||||
$user = User::findOrFail($user_id);
|
||||
$data = [];
|
||||
if($credit_send_mail){
|
||||
$data['credit_send_mail'] = true;
|
||||
}
|
||||
$credit_repo = new CreditRepository($user);
|
||||
return $credit_repo->create($data);
|
||||
}
|
||||
|
||||
private function hasNotUserCreditItem($userBusiness, $status){
|
||||
return (UserCreditItem::where('user_business_id', $userBusiness->id)
|
||||
->where('user_id', $userBusiness->user_id)->where('status', $status)->count() > 0) ? false : true;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue