feat: 添加阿里云短信服务支持并优化验证码逻辑

- 引入 alibabacloud/dysmsapi-20170525 依赖,集成阿里云短信服务
- 将短信验证码从6位改为4位,优化用户体验
- 添加聚水潭商品按时间范围同步功能,支持分页拉取
- 增强Cron任务异常处理,添加错误日志记录
- 修复系统附件服务中图片路径处理逻辑
- 更新阿里云SDK相关组件至最新版本
- 添加think-trace调试扩展,便于问题排查
- 优化跨域中间件,使用str_contains替代strpos
This commit is contained in:
2026-04-30 15:19:40 +08:00
parent 0334fef6c1
commit c7f85ffbda
565 changed files with 59742 additions and 3391 deletions

View File

@@ -23,6 +23,35 @@ use think\facade\Log;
*/
class PrivacyPhoneServices extends BaseServices
{
/**
* 标准化AX小号:从后往前截取11位手机号
* @param string $number
* @return string
*/
private function normalizeAxNumber(string $number): string
{
if ($number === '') {
return '';
}
return strlen($number) > 11 ? substr($number, -11) : $number;
}
/**
* 日志上下文转字符串(ThinkPHP日志上下文仅支持占位符替换)
* @param mixed $value
* @return string
*/
private function toLogString($value): string
{
if (is_string($value)) {
return $value;
}
$json = json_encode($value, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
return $json === false ? var_export($value, true) : $json;
}
/**
* API地址
*/
@@ -122,10 +151,10 @@ class PrivacyPhoneServices extends BaseServices
'decoded' => json_decode($response, true) ?? []
];
Log::info('隐私小号API请求', [
Log::info('隐私小号API请求 url={url} params={params} result={result}', [
'url' => $url,
'params' => $params,
'result' => $result
'params' => $this->toLogString($params),
'result' => $this->toLogString($result),
]);
return $result;
@@ -267,23 +296,33 @@ class PrivacyPhoneServices extends BaseServices
return $result;
}
$bindResult = $this->axBind($number, $realPhone);
$bindNumber = $this->normalizeAxNumber($number);
if (strlen($bindNumber) !== 11) {
Log::error('隐私小号格式异常 raw_number={raw_number} bind_number={bind_number}', [
'raw_number' => $number,
'bind_number' => $bindNumber,
]);
return $result;
}
$bindResult = $this->axBind($bindNumber, $realPhone);
if (!empty($bindResult['success']) && $bindResult['code'] == 200) {
$result = [
'user_phone' => $number,
'user_phone' => $bindNumber,
'bind_id' => $realPhone,
'status' => 1
];
Log::info('隐私小号绑定成功', [
'privacy_phone' => $number,
'real_phone' => $realPhone
Log::info('隐私小号绑定成功 privacy_phone={privacy_phone} real_phone={real_phone}', [
'privacy_phone' => $bindNumber,
'real_phone' => $realPhone,
]);
}
} catch (\Exception $e) {
Log::error('隐私小号绑定异常', [
Log::error('隐私小号绑定异常 real_phone={real_phone} ax_number={ax_number} error={error}', [
'real_phone' => $realPhone,
'error' => $e->getMessage()
'ax_number' => $bindNumber ?? ($number ?? ''),
'error' => $e->getMessage(),
]);
}
@@ -306,21 +345,30 @@ class PrivacyPhoneServices extends BaseServices
return false;
}
$unbindPhone = $this->normalizeAxNumber($privacyPhone);
if (strlen($unbindPhone) !== 11) {
Log::error('隐私小号格式异常 privacy_phone={privacy_phone} unbind_phone={unbind_phone}', [
'privacy_phone' => $privacyPhone,
'unbind_phone' => $unbindPhone,
]);
return false;
}
try {
$result = $this->unAxBind($privacyPhone, $realPhone);
$result = $this->unAxBind($unbindPhone, $realPhone);
if (!empty($result['success']) && $result['code'] == 200) {
Log::info('隐私小号解绑成功', [
'privacy_phone' => $privacyPhone,
'real_phone' => $realPhone
Log::info('隐私小号解绑成功 privacy_phone={privacy_phone} real_phone={real_phone}', [
'privacy_phone' => $unbindPhone,
'real_phone' => $realPhone,
]);
return true;
}
} catch (\Exception $e) {
Log::error('隐私小号解绑异常', [
'privacy_phone' => $privacyPhone,
Log::error('隐私小号解绑异常 privacy_phone={privacy_phone} real_phone={real_phone} error={error}', [
'privacy_phone' => $unbindPhone,
'real_phone' => $realPhone,
'error' => $e->getMessage()
'error' => $e->getMessage(),
]);
}