/
home
/
henzagold
/
server
/
app
/
Console
/
Commands
/
File Upload :
llllll
Current File: //home/henzagold/server/app/Console/Commands/ExpireCommand.php
<?php namespace App\Console\Commands; use App\Models\SingleCustomer; use Illuminate\Console\Command; use Rooyesh\Wallet\interfaces\TransactionInterface; use Rooyesh\Wallet\interfaces\WalletInterface; use Rooyesh\Wallet\models\Transaction; class ExpireCommand extends Command { /** * The name and signature of the console command. * * @var string */ protected $signature = 'transaction:expire'; /** * The console command description. * * @var string */ protected $description = 'Command description'; /** * Create a new command instance. * * @return void */ public function __construct() { parent::__construct(); } /** * Execute the console command. * * @return int */ public function handle() { $customers = SingleCustomer::all(); foreach ($customers as $customer){ $transactions_expired_credit = Transaction::whereDate('expire_at', '<', now()->format('Y-m-d')) ->where('transaction_type', 2) ->where('customer_id', $customer->id) ->sum('value'); $transactions_expired_gold = Transaction::whereDate('expire_at', '<', now()->format('Y-m-d')) ->where('transaction_type', 1) ->where('customer_id', $customer->id) ->sum('value'); $transaction_gold = Transaction::where('value', '<', 0) ->where('transaction_type', 1) ->where('customer_id', $customer->id) ->sum('value'); $transaction_credit = Transaction::where('value', '<', 0) ->where('transaction_type', 2) ->where('customer_id', $customer->id) ->sum('value'); $total_gold = $transactions_expired_gold - abs($transaction_gold); $total_credit = $transactions_expired_credit - abs($transaction_credit); if ($total_gold > 0 || $total_credit > 0){ $wallet_interface = new WalletInterface($customer->id, 1); if ($total_gold > 0){ new TransactionInterface($wallet_interface, $_inp = [ "value" => $total_gold, "note"=>"for expire system", ], 1, false); } if ($total_credit > 0){ new TransactionInterface($wallet_interface, $_inp = [ "value" => $total_credit, "note"=>"for expire system", ], 2, false); } } } } }
Copyright ©2k19 -
Hexid
|
Tex7ure