mirror of
https://gitee.com/liuxioabin/fengketrade.git
synced 2026-04-17 21:03:17 +08:00
提现配置
This commit is contained in:
parent
dea4d38267
commit
2752693d3e
@ -30,13 +30,21 @@ class Withdraw
|
||||
$this->user = is_numeric($user) ? User::get($user) : $user;
|
||||
}
|
||||
|
||||
// 提现规则
|
||||
$config = sheep_config('shop.recharge_withdraw.withdraw');
|
||||
// 提现规则 - 不使用缓存,确保读取最新配置
|
||||
$config = sheep_config('shop.recharge_withdraw.withdraw', false);
|
||||
|
||||
// 确保配置是数组
|
||||
if (!is_array($config)) {
|
||||
$config = [];
|
||||
}
|
||||
|
||||
$config['min_amount'] = $config['min_amount'] == 0 ? $config['min_amount'] : number_format(floatval($config['min_amount']), 2, '.', '');
|
||||
$config['max_amount'] = $config['max_amount'] == 0 ? $config['max_amount'] : number_format(floatval($config['max_amount']), 2, '.', '');
|
||||
$config['charge_rate_format'] = round(floatval($config['charge_rate']), 1); // 1 位小数
|
||||
$config['charge_rate'] = round((floatval($config['charge_rate']) * 0.01), 3);
|
||||
$config['min_amount'] = isset($config['min_amount']) && $config['min_amount'] == 0 ? $config['min_amount'] : number_format(floatval($config['min_amount'] ?? 0), 2, '.', '');
|
||||
$config['max_amount'] = isset($config['max_amount']) && $config['max_amount'] == 0 ? $config['max_amount'] : number_format(floatval($config['max_amount'] ?? 0), 2, '.', '');
|
||||
$config['charge_rate_format'] = round(floatval($config['charge_rate'] ?? 0), 1); // 1 位小数
|
||||
$config['charge_rate'] = round((floatval($config['charge_rate'] ?? 0) * 0.01), 3);
|
||||
|
||||
// 确保 days_7 字段存在,默认为 0(不限制)
|
||||
$config['days_7'] = isset($config['days_7']) ? intval($config['days_7']) : 0;
|
||||
|
||||
$this->config = $config;
|
||||
}
|
||||
@ -194,6 +202,40 @@ class Withdraw
|
||||
{
|
||||
operate_disabled();
|
||||
|
||||
// 在自动打款前,先检查7天限制(重新读取配置确保最新)
|
||||
$freshConfig = sheep_config('shop.recharge_withdraw.withdraw', false);
|
||||
$limitHours = 0;
|
||||
if (is_array($freshConfig) && isset($freshConfig['days_7'])) {
|
||||
$limitHours = intval($freshConfig['days_7']);
|
||||
$this->config['days_7'] = $limitHours;
|
||||
} elseif (isset($this->config['days_7'])) {
|
||||
$limitHours = intval($this->config['days_7']);
|
||||
}
|
||||
|
||||
// 如果配置了时间限制,先检查是否满足条件
|
||||
if ($limitHours > 0) {
|
||||
$createtime = intval($withdraw->createtime);
|
||||
if ($createtime > 0) {
|
||||
$hoursDiff = (time() - $createtime) / 3600; // 3600秒 = 1小时
|
||||
if ($hoursDiff < $limitHours) {
|
||||
$remainingHours = ceil($limitHours - $hoursDiff);
|
||||
$remainingDays = floor($remainingHours / 24);
|
||||
$remainingHoursInDay = $remainingHours % 24;
|
||||
$timeText = '';
|
||||
if ($remainingDays > 0) {
|
||||
$timeText = $remainingDays . '天';
|
||||
}
|
||||
if ($remainingHoursInDay > 0) {
|
||||
$timeText .= ($timeText ? '零' : '') . $remainingHoursInDay . '小时';
|
||||
}
|
||||
if (empty($timeText)) {
|
||||
$timeText = '1小时';
|
||||
}
|
||||
throw new ShoproException('提现申请时间未超过' . $limitHours . '小时,还需等待' . $timeText . '才能放款');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Db::startTrans();
|
||||
try {
|
||||
$withdraw = $this->handleAgree($withdraw, $this->user);
|
||||
@ -237,6 +279,16 @@ class Withdraw
|
||||
|
||||
// 检查提现打款时间限制(小时)
|
||||
$limitHours = isset($this->config['days_7']) ? intval($this->config['days_7']) : 0;
|
||||
|
||||
// 如果配置中没有读取到,尝试重新读取一次(不使用缓存)
|
||||
if (!isset($this->config['days_7'])) {
|
||||
$freshConfig = sheep_config('shop.recharge_withdraw.withdraw', false);
|
||||
if (is_array($freshConfig) && isset($freshConfig['days_7'])) {
|
||||
$limitHours = intval($freshConfig['days_7']);
|
||||
$this->config['days_7'] = $limitHours;
|
||||
}
|
||||
}
|
||||
|
||||
if ($limitHours > 0) {
|
||||
$createtime = intval($withdraw->createtime);
|
||||
if ($createtime > 0) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user