代码优化

This commit is contained in:
Billy 2025-11-20 19:18:52 +08:00
parent 2752693d3e
commit cc42c047d1
3 changed files with 16 additions and 13 deletions

View File

@ -77,8 +77,11 @@ class Withdraw extends Common
// 支付宝提现+自动打款
if ($withdraw->withdraw_type === 'alipay' && $withdrawService->config['auto_arrival']) {
try {
// 记录提现日志
// 记录提现日志(会自动检查时间限制)
$withdrawService->handleAlipayWithdraw($withdraw);
} catch (\addons\shopro\exception\ShoproException $e) {
// 时间限制检查失败,不自动打款,保持待审核状态
$this->error($e->getMessage());
} catch (HttpResponseException $e) {
$data = $e->getResponse()->getData();
$message = $data ? ($data['msg'] ?? '') : $e->getMessage();

View File

@ -277,18 +277,17 @@ class Withdraw
throw new ShoproException('请勿重复操作');
}
// 检查提现打款时间限制(小时)
$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);
$limitHours = 0;
if (is_array($freshConfig) && isset($freshConfig['days_7'])) {
$limitHours = intval($freshConfig['days_7']);
$this->config['days_7'] = $limitHours;
}
$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) {

View File

@ -116,10 +116,11 @@ class Withdraw extends Common
Db::commit();
} catch (ShoproException $e) {
// 不回滚,记录错误日志
Db::commit();
// 时间限制检查失败等业务异常,需要回滚事务
Db::rollback();
$this->error($e->getMessage());
} catch (HttpResponseException $e) {
Db::rollback();
$data = $e->getResponse()->getData();
$message = $data ? ($data['msg'] ?? '') : $e->getMessage();
$this->error($message);