43 lines
1.1 KiB
PHP
43 lines
1.1 KiB
PHP
<?php
|
||
|
||
namespace App\Cache\Table\Api;
|
||
|
||
use App\Cache\Base\TableBaseCache;
|
||
use App\Models\Api\Other\CustomerSettingModel;
|
||
|
||
//用户缓存用户基础信息(结构自己组装不完全等于数据表)uid为主键
|
||
class TableCustomerSettingCache extends TableBaseCache
|
||
{
|
||
|
||
public string $table_class = CustomerSettingModel::class;
|
||
public string $primary_prefix = 'TableCustomerSettingCache:'; //后面跟name
|
||
|
||
public string $primary_key_column = 'name';
|
||
public array $get_columns = [
|
||
'value',
|
||
];
|
||
|
||
const NAME_WITHDRAW_FEE_AMOUNT = 'withdraw_fee_amount';
|
||
|
||
//只存值 key为name value为value
|
||
function loadData(): array|string|null
|
||
{
|
||
$oTable = new $this->table_class();
|
||
$oData = $oTable->findItemByWhere([$this->primary_key_column => $this->primary_key], $this->get_columns);
|
||
if ($oData->isEmpty()) return null;
|
||
$aData = $oData->toArray();
|
||
|
||
if (empty($aData)) return null;
|
||
return $aData['value'];
|
||
}
|
||
|
||
function getWithdrawFeeAmount(): string|null
|
||
{
|
||
$res = $this->get(self::NAME_WITHDRAW_FEE_AMOUNT);
|
||
if (empty($res)) $res = 0;
|
||
return $res;
|
||
}
|
||
|
||
|
||
}
|