Files
cycle_api/app/Cache/Table/Api/TableCustomerSettingCache.php
2024-03-25 06:15:36 +08:00

43 lines
1.1 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?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;
}
}