prevented main users from being registered as alts in a strange oddity.
This commit is contained in:
@@ -160,9 +160,14 @@ class LoginController extends Controller
|
|||||||
* @param \Laravel\Socialite\Two\User $user
|
* @param \Laravel\Socialite\Two\User $user
|
||||||
*/
|
*/
|
||||||
private function createAlt($user, $orgCharacter) {
|
private function createAlt($user, $orgCharacter) {
|
||||||
|
//Check to see if the alt is already in the database
|
||||||
|
$altCount = UserAlt::where(['character_id' => $user->id])->count();
|
||||||
|
|
||||||
$altCount = UserAlt::where('character_id', $user->id)->count();
|
//Check to see if the new character being added is already a main character
|
||||||
if($altCount == 0) {
|
$mainCount = User::where(['character_id' => $user->id])->count();
|
||||||
|
|
||||||
|
//If not already in the database, then add the new character
|
||||||
|
if($altCount == 0 && $mainCount == 0) {
|
||||||
//Create the new alt in the table
|
//Create the new alt in the table
|
||||||
$newAlt = new UserAlt;
|
$newAlt = new UserAlt;
|
||||||
$newAlt->name = $user->getName();
|
$newAlt->name = $user->getName();
|
||||||
@@ -175,7 +180,6 @@ class LoginController extends Controller
|
|||||||
$newAlt->expires_in = $user->expiresIn;
|
$newAlt->expires_in = $user->expiresIn;
|
||||||
$newAlt->save();
|
$newAlt->save();
|
||||||
|
|
||||||
//Create the entry into the EsiToken table
|
|
||||||
//Create the entry into the EsiToken table
|
//Create the entry into the EsiToken table
|
||||||
if(EsiToken::where(['character_id' => $user->id])->count() == 0) {
|
if(EsiToken::where(['character_id' => $user->id])->count() == 0) {
|
||||||
$this->SaveEsiToken($user);
|
$this->SaveEsiToken($user);
|
||||||
|
|||||||
@@ -22,4 +22,56 @@ class TestController extends Controller
|
|||||||
public function CharacterLookupTest(Request $request) {
|
public function CharacterLookupTest(Request $request) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function DebugMiningTaxes($invoiceId) {
|
||||||
|
$invoice = array();
|
||||||
|
$ores = array();
|
||||||
|
$totalPrice = 0.00;
|
||||||
|
$body = null;
|
||||||
|
$lookup = new LookupHelper;
|
||||||
|
$config = config('esi');
|
||||||
|
|
||||||
|
$rows = Ledger::where([
|
||||||
|
'invoice_id' => $invoiceId,
|
||||||
|
])->get()->toArray();
|
||||||
|
|
||||||
|
//Taly up the item composition from each row and multiply by the quantity
|
||||||
|
if(sizeof($rows) > 0) {
|
||||||
|
foreach($rows as $row) {
|
||||||
|
if(!isset($ores[$row['type_id']])) {
|
||||||
|
$ores[$row['type_id']] = 0;
|
||||||
|
}
|
||||||
|
$ores[$row['type_id']] = $ores[$row['type_id']] + $row['quantity'];
|
||||||
|
|
||||||
|
//Add up the total price from the ledger rows for the report later
|
||||||
|
$totalPrice = $totalPrice + $row['amount'];
|
||||||
|
}
|
||||||
|
|
||||||
|
//Reduce the total price by the take percentage
|
||||||
|
$invoiceAmount = $totalPrice * $config['mining_tax'];
|
||||||
|
$invoiceAmount = round($invoiceAmount, 2);
|
||||||
|
|
||||||
|
//Get the character name from the character id
|
||||||
|
$charName = $lookup->CharacterIdToName($charId);
|
||||||
|
|
||||||
|
//Generate a unique invoice id
|
||||||
|
$invoiceId = "M" . uniqid();
|
||||||
|
//Set the due date of the invoice
|
||||||
|
$dateDue = Carbon::now()->addDays(7);
|
||||||
|
$invoiceDate = Carbon::now();
|
||||||
|
|
||||||
|
//Format the mining tax into a human readable number
|
||||||
|
$numberMiningTax = number_format(($config['mining_tax'] * 100.00), 2, ".", ",");
|
||||||
|
}
|
||||||
|
|
||||||
|
return view('test.miningtax.display')->with('rows', $rows)
|
||||||
|
->with('ores', $ores)
|
||||||
|
->with('totalPrice', $totalPrice)
|
||||||
|
->with('invoiceAmount', $invoiceAmount)
|
||||||
|
->with('charName', $charName)
|
||||||
|
->with('invoiceId', $invoiceId)
|
||||||
|
->with('dateDue' $dateDue)
|
||||||
|
->with('invoiceDate', $invoiceDate)
|
||||||
|
->with('numberMiningTax', $numberMiningTax);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -209,8 +209,6 @@ class SendMiningTaxesInvoices implements ShouldQueue
|
|||||||
$mailDelay = $mailDelay + 20;
|
$mailDelay = $mailDelay + 20;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function CreateInvoice($charId, $ledgers, &$mailDelay) {
|
private function CreateInvoice($charId, $ledgers, &$mailDelay) {
|
||||||
@@ -326,11 +324,7 @@ class SendMiningTaxesInvoices implements ShouldQueue
|
|||||||
|
|
||||||
//Increase the delay for the next mail
|
//Increase the delay for the next mail
|
||||||
$mailDelay += 20;
|
$mailDelay += 20;
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function LedgersWithAlts($charId) {
|
private function LedgersWithAlts($charId) {
|
||||||
@@ -371,32 +365,41 @@ class SendMiningTaxesInvoices implements ShouldQueue
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//If the alt count is greater than zero, let's add the alt's ledgers to the ledger array
|
||||||
if($altCount > 0) {
|
if($altCount > 0) {
|
||||||
|
//Run through all of the alts and add the individual ledger rows to the ledger array
|
||||||
foreach($alts as $alt) {
|
foreach($alts as $alt) {
|
||||||
$rows = Ledger::where([
|
//Check to make sure we aren't adding the main character twice
|
||||||
'character_id' => $alt->character_id,
|
if($alt->character_id != $charId){
|
||||||
'invoiced' => 'No',
|
//Get the count of the ledgers to make sure something is actually there to process
|
||||||
])->get();
|
$rowCount = Ledger::where([
|
||||||
|
'character_id' => $alt->character_id,
|
||||||
|
'invoiced' => 'No',
|
||||||
|
])->count();
|
||||||
|
|
||||||
$rowCount = Ledger::where([
|
//If there are rows to process, get the rows, and add to the array
|
||||||
'character_id' => $alt->character_id,
|
if($rowCount > 0) {
|
||||||
'invoiced' => 'No',
|
//Get all of the rows
|
||||||
])->count();
|
$rows = Ledger::where([
|
||||||
|
'character_id' => $alt->character_id,
|
||||||
|
'invoiced' => 'No',
|
||||||
|
])->get();
|
||||||
|
|
||||||
if($rowCount > 0) {
|
//Add all of the rows to the ledger array
|
||||||
foreach($rows as $row) {
|
foreach($rows as $row) {
|
||||||
array_push($ledgers, [
|
array_push($ledgers, [
|
||||||
'character_id' => $row->character_id,
|
'character_id' => $row->character_id,
|
||||||
'character_name' => $row->character_name,
|
'character_name' => $row->character_name,
|
||||||
'observer_id' => $row->observer_id,
|
'observer_id' => $row->observer_id,
|
||||||
'last_updated' => $row->last_updated,
|
'last_updated' => $row->last_updated,
|
||||||
'type_id' => $row->type_id,
|
'type_id' => $row->type_id,
|
||||||
'ore_name' => $row->ore_name,
|
'ore_name' => $row->ore_name,
|
||||||
'quantity' => $row->quantity,
|
'quantity' => $row->quantity,
|
||||||
'amount' => $row->amount,
|
'amount' => $row->amount,
|
||||||
'invoiced' => $row->invoiced,
|
'invoiced' => $row->invoiced,
|
||||||
'invoice_id' => $row->invoice_id,
|
'invoice_id' => $row->invoice_id,
|
||||||
]);
|
]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
73
app/Library/Helpers/MiningTaxHelper.php
Normal file
73
app/Library/Helpers/MiningTaxHelper.php
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Library\Helpers;
|
||||||
|
|
||||||
|
//Internal Libraries
|
||||||
|
use Log;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
|
//Application Library
|
||||||
|
use App\Library\Helpers\LookupHelper;
|
||||||
|
|
||||||
|
//Models
|
||||||
|
use App\Models\MiningTax\Invoice;
|
||||||
|
use App\Models\MiningTax\Ledger;
|
||||||
|
use App\Models\User\User;
|
||||||
|
use App\Models\User\UserAlt;
|
||||||
|
|
||||||
|
class MiningTaxHelper {
|
||||||
|
/**
|
||||||
|
* Private variables
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*/
|
||||||
|
public function __construct() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the main character ledgers and send back as a collection
|
||||||
|
*
|
||||||
|
* @var $charId
|
||||||
|
* @return collection $ledgers
|
||||||
|
*/
|
||||||
|
public function GetMainLedgers($charId) {
|
||||||
|
$ledgers = new Collection;
|
||||||
|
|
||||||
|
$rowCount = Ledger::where([
|
||||||
|
'character_id' => $charId,
|
||||||
|
'invoiced' => 'No',
|
||||||
|
])->count();
|
||||||
|
|
||||||
|
$rows = Ledger::where([
|
||||||
|
'character_id' => $charId,
|
||||||
|
'invoiced' => 'No',
|
||||||
|
])->get()->toArry();
|
||||||
|
|
||||||
|
if($rowCount > 0) {
|
||||||
|
foreach($rows as $row) {
|
||||||
|
$ledgers->push($row);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $ledgers;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the alt characters ledgers and send back as a collection
|
||||||
|
*
|
||||||
|
* @var array $alts
|
||||||
|
* @return collection ledgers
|
||||||
|
*/
|
||||||
|
public function GetAltLedgers($alts) {
|
||||||
|
$ledgers = new Collection;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user