分离 模块统计
This commit is contained in:
parent
b2ee0f3244
commit
e94c86eb53
@ -15,7 +15,7 @@ public function index()
|
|||||||
{
|
{
|
||||||
$module = auth('module')->user();
|
$module = auth('module')->user();
|
||||||
|
|
||||||
$calc = $this->calcModule($module);
|
$calc = $module->calculate();
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'module' => $module,
|
'module' => $module,
|
||||||
@ -28,22 +28,6 @@ public function index()
|
|||||||
return $this->success($data);
|
return $this->success($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function calcModule(Module|Authenticatable $module): array
|
|
||||||
{
|
|
||||||
|
|
||||||
$default = [
|
|
||||||
'balance' => 0,
|
|
||||||
'drops' => 0,
|
|
||||||
];
|
|
||||||
|
|
||||||
return [
|
|
||||||
'transactions' => [
|
|
||||||
'this_month' => Cache::get('this_month_balance_and_drops_' . $module->id, $default),
|
|
||||||
'last_month' => Cache::get('last_month_balance_and_drops_' . $module->id, $default),
|
|
||||||
]
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function call(Request $request, Module $module)
|
public function call(Request $request, Module $module)
|
||||||
{
|
{
|
||||||
$path = request()->path();
|
$path = request()->path();
|
||||||
|
@ -5,9 +5,11 @@
|
|||||||
use GeneaLabs\LaravelModelCaching\Traits\Cachable;
|
use GeneaLabs\LaravelModelCaching\Traits\Cachable;
|
||||||
use GuzzleHttp\Exception\ConnectException;
|
use GuzzleHttp\Exception\ConnectException;
|
||||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||||
|
use Illuminate\Support\Facades\Cache;
|
||||||
use Illuminate\Support\Facades\Http;
|
use Illuminate\Support\Facades\Http;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
|
use JetBrains\PhpStorm\ArrayShape;
|
||||||
|
|
||||||
class Module extends Authenticatable
|
class Module extends Authenticatable
|
||||||
{
|
{
|
||||||
@ -71,8 +73,7 @@ public function remoteRequest($method, $path, $requests)
|
|||||||
{
|
{
|
||||||
$user = auth()->user();
|
$user = auth()->user();
|
||||||
|
|
||||||
$http = Http::module($this->api_token, $this->url)
|
$http = Http::module($this->api_token, $this->url);
|
||||||
->accept('application/json');
|
|
||||||
|
|
||||||
// add Headers
|
// add Headers
|
||||||
$http->withHeaders([
|
$http->withHeaders([
|
||||||
@ -167,4 +168,21 @@ public function check($module_id = null)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[ArrayShape(['transactions' => "array"])]
|
||||||
|
public function calculate(): array
|
||||||
|
{
|
||||||
|
|
||||||
|
$default = [
|
||||||
|
'balance' => 0,
|
||||||
|
'drops' => 0,
|
||||||
|
];
|
||||||
|
|
||||||
|
return [
|
||||||
|
'transactions' => [
|
||||||
|
'this_month' => Cache::get('this_month_balance_and_drops_' . $this->id, $default),
|
||||||
|
'last_month' => Cache::get('last_month_balance_and_drops_' . $this->id, $default),
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user