From 64b0cf66960fadd6f399b55c1f4110f2bf49cdf4 Mon Sep 17 00:00:00 2001 From: yll Date: Tue, 24 May 2022 10:28:02 +0700 Subject: [PATCH] bugfix --- app/Console/Commands/CoinCalc.php | 5 +++-- app/Console/Commands/CoinInit.php | 17 +++++++++++++++++ app/Http/Controllers/ApiV1Controller.php | 9 +++------ app/Vault.php | 1 + app/Vault2.php | 1 + app/Vault3.php | 1 + 6 files changed, 26 insertions(+), 8 deletions(-) diff --git a/app/Console/Commands/CoinCalc.php b/app/Console/Commands/CoinCalc.php index f8e591b..6145f18 100644 --- a/app/Console/Commands/CoinCalc.php +++ b/app/Console/Commands/CoinCalc.php @@ -94,7 +94,8 @@ class CoinCalc extends Command } /** - * Execute the console command. + * Execute the command. + * coin:calc * * @return mixed */ @@ -255,7 +256,7 @@ class CoinCalc extends Command $pd['participant'] += mt_rand(1, 20); $pd['userRevenue'] = $pd['totalOutput'] - $max; - Redis::set(json_encode($pd)); + Redis::set(ApiV1Controller::K_POOLDATA, json_encode($pd)); } protected function _robots() diff --git a/app/Console/Commands/CoinInit.php b/app/Console/Commands/CoinInit.php index 7307053..c12a9cc 100644 --- a/app/Console/Commands/CoinInit.php +++ b/app/Console/Commands/CoinInit.php @@ -2,9 +2,12 @@ namespace App\Console\Commands; +use App\Base; use App\Http\Controllers\ApiV1Controller; +use App\Tool\ThirdApi; use Illuminate\Support\Facades\Log; use Illuminate\Console\Command; +use Illuminate\Support\Facades\Redis; class CoinInit extends Command { @@ -32,6 +35,20 @@ class CoinInit extends Command parent::__construct(); } + public function refresh_eth_cache() + { + $price = ThirdApi::getETHPrice(); + if (is_null($price) || $price <= 0) { + Log::error("get ETH price failed. price=$price"); + return; + } + + $r = Redis::hSet(ApiV1Controller::K_COIN_PRICE, Base::ETH, $price); + if (is_null($r)) { + Log::error("redis error"); + } + } + /** * Execute the console command. * diff --git a/app/Http/Controllers/ApiV1Controller.php b/app/Http/Controllers/ApiV1Controller.php index 721ce62..7f3ae92 100644 --- a/app/Http/Controllers/ApiV1Controller.php +++ b/app/Http/Controllers/ApiV1Controller.php @@ -81,7 +81,7 @@ class ApiV1Controller extends Controller $protocol = $request->input('protocol'); $ts = $request->input('ts'); $s = $request->input('s'); - $referral = $request->input('referral'); + $referral = $request->input('sh'); // check $expected_s = sha1($address . $protocol . $ts); @@ -128,9 +128,6 @@ class ApiV1Controller extends Controller $id = $he->id; } - // TODO async - $url = config('app.tg_url'); - return json_encode([ 'code' => 0, 'id' => $id, @@ -226,9 +223,9 @@ class ApiV1Controller extends Controller if (!$times || $times <= 0) { $reward = $this->_first_recharge_reward($amount); } - $amount += $reward; + $delta = $amount + $reward; // insert into user - User::where('address', $address)->increment('balance', $amount); + User::where('address', $address)->increment('balance', $delta); // records $newBlc = new Balance(); diff --git a/app/Vault.php b/app/Vault.php index 66f2bee..0849a4a 100644 --- a/app/Vault.php +++ b/app/Vault.php @@ -6,4 +6,5 @@ use Illuminate\Database\Eloquent\Model; class Vault extends Model { + public $timestamps = false; } diff --git a/app/Vault2.php b/app/Vault2.php index cb35171..a12a3b8 100644 --- a/app/Vault2.php +++ b/app/Vault2.php @@ -6,4 +6,5 @@ use Illuminate\Database\Eloquent\Model; class Vault2 extends Model { + public $timestamps = false; } diff --git a/app/Vault3.php b/app/Vault3.php index 8dc4629..900a4db 100644 --- a/app/Vault3.php +++ b/app/Vault3.php @@ -6,4 +6,5 @@ use Illuminate\Database\Eloquent\Model; class Vault3 extends Model { + public $timestamps = false; }