From 2752693d3e5acf92043f90d10cd0b38bc382d41d Mon Sep 17 00:00:00 2001 From: Billy <641833868@qq.com> Date: Thu, 20 Nov 2025 19:11:03 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E7=8E=B0=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- addons/shopro/service/Withdraw.php | 64 +++++++++++++++++++++++++++--- 1 file changed, 58 insertions(+), 6 deletions(-) diff --git a/addons/shopro/service/Withdraw.php b/addons/shopro/service/Withdraw.php index a71b796..e6ab07b 100755 --- a/addons/shopro/service/Withdraw.php +++ b/addons/shopro/service/Withdraw.php @@ -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) {