diff --git a/addons/shopro_huifu/library/onboard/HuifuOnboardQuery.php b/addons/shopro_huifu/library/onboard/HuifuOnboardQuery.php index 8bc83e1..2a2b105 100644 --- a/addons/shopro_huifu/library/onboard/HuifuOnboardQuery.php +++ b/addons/shopro_huifu/library/onboard/HuifuOnboardQuery.php @@ -132,10 +132,43 @@ class HuifuOnboardQuery return false; } $stat = strtolower((string) ($data['user_status'] ?? $data['status'] ?? $data['acct_stat'] ?? '')); - $active = in_array($stat, ['n', 'normal', 's', 'success', '1'], true); + $respCode = (string) ($data['resp_code'] ?? ''); + $settleConfig = $this->decodeJsonObject($data['settle_config'] ?? null); + $cashConfigList = $this->decodeJsonList($data['qry_cash_config_list'] ?? null); + $settleActive = (string) ($settleConfig['settle_status'] ?? '') === '1'; + $cashActive = false; + foreach ($cashConfigList as $cashConfig) { + if ((string) ($cashConfig['switch_state'] ?? '') === '1') { + $cashActive = true; + break; + } + } + $active = in_array($stat, ['n', 'normal', 's', 'success', '1'], true) + || ($respCode === '00000000' && ($settleActive || $cashActive)); \think\Log::error('[shopro_huifu] onboard basic active check stat=' . $stat + . ' resp_code=' . $respCode + . ' settle_active=' . ($settleActive ? '1' : '0') + . ' cash_active=' . ($cashActive ? '1' : '0') . ' active=' . ($active ? '1' : '0') . ' keys=' . implode(',', array_keys($data))); return $active; } + + protected function decodeJsonObject($value) + { + if (is_array($value)) { + return $value; + } + $decoded = json_decode((string) $value, true); + return is_array($decoded) ? $decoded : []; + } + + protected function decodeJsonList($value) + { + $decoded = $this->decodeJsonObject($value); + if (isset($decoded[0]) && is_array($decoded[0])) { + return $decoded; + } + return []; + } }