diff --git a/addons/shopro_huifu/library/onboard/HuifuOnboardQuery.php b/addons/shopro_huifu/library/onboard/HuifuOnboardQuery.php index a474638..8bc83e1 100644 --- a/addons/shopro_huifu/library/onboard/HuifuOnboardQuery.php +++ b/addons/shopro_huifu/library/onboard/HuifuOnboardQuery.php @@ -16,23 +16,39 @@ class HuifuOnboardQuery public function pollAndUpdate(Onboard $row) { + \think\Log::error('[shopro_huifu] onboard poll begin file=' . realpath(__FILE__) + . ' id=' . $row['id'] + . ' huifu_id=' . ($row['huifu_id'] ?? '') + . ' apply_no=' . ($row['apply_no'] ?? '') + . ' busi_req_seq_id=' . ($row['busi_req_seq_id'] ?? '') + . ' status=' . ($row['onboard_status'] ?? '')); + if (!$row['huifu_id']) { + \think\Log::error('[shopro_huifu] onboard poll skipped: missing huifu_id id=' . $row['id']); return $row; } if ($row['onboard_status'] === Onboard::STATUS_APPROVED) { + \think\Log::error('[shopro_huifu] onboard poll skipped: already approved id=' . $row['id']); return $row; } $applyNo = $row['apply_no']; if ($applyNo) { $status = $this->queryApply($row['huifu_id'], $applyNo); + \think\Log::error('[shopro_huifu] onboard apply query id=' . $row['id'] + . ' apply_no=' . $applyNo + . ' data=' . json_encode($status, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES)); $row = $this->applyRemoteStatus($row, $status); if ($row['onboard_status'] === Onboard::STATUS_APPROVED) { return $row; } + } else { + \think\Log::error('[shopro_huifu] onboard apply query skipped: empty apply_no id=' . $row['id']); } $basic = $this->queryBasic($row['huifu_id']); + \think\Log::error('[shopro_huifu] onboard basic query id=' . $row['id'] + . ' data=' . json_encode($basic, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES)); if ($this->isBasicActive($basic)) { if (in_array($row['onboard_status'], [Onboard::STATUS_BUSI_PENDING, Onboard::STATUS_BASIC_OK], true)) { $row->onboard_status = Onboard::STATUS_APPROVED; @@ -76,11 +92,17 @@ class HuifuOnboardQuery protected function applyRemoteStatus(Onboard $row, array $data) { if (!$data) { + \think\Log::error('[shopro_huifu] onboard remote status empty id=' . $row['id']); return $row; } $stat = strtolower((string) ($data['apply_status'] ?? $data['audit_status'] ?? $data['status'] ?? '')); $desc = (string) ($data['apply_desc'] ?? $data['resp_desc'] ?? $data['reject_reason'] ?? ''); + \think\Log::error('[shopro_huifu] onboard remote status parsed id=' . $row['id'] + . ' stat=' . $stat + . ' desc=' . $desc + . ' keys=' . implode(',', array_keys($data))); + if (in_array($stat, ['s', 'success', 'approved', '1', '02', '2'], true)) { $row->onboard_status = Onboard::STATUS_APPROVED; $row->reject_reason = ''; @@ -106,9 +128,14 @@ class HuifuOnboardQuery protected function isBasicActive(array $data) { if (!$data) { + \think\Log::error('[shopro_huifu] onboard basic active check: empty response'); return false; } $stat = strtolower((string) ($data['user_status'] ?? $data['status'] ?? $data['acct_stat'] ?? '')); - return in_array($stat, ['n', 'normal', 's', 'success', '1'], true); + $active = in_array($stat, ['n', 'normal', 's', 'success', '1'], true); + \think\Log::error('[shopro_huifu] onboard basic active check stat=' . $stat + . ' active=' . ($active ? '1' : '0') + . ' keys=' . implode(',', array_keys($data))); + return $active; } }