feat: 添加阿里云短信服务支持并优化验证码逻辑
- 引入 alibabacloud/dysmsapi-20170525 依赖,集成阿里云短信服务 - 将短信验证码从6位改为4位,优化用户体验 - 添加聚水潭商品按时间范围同步功能,支持分页拉取 - 增强Cron任务异常处理,添加错误日志记录 - 修复系统附件服务中图片路径处理逻辑 - 更新阿里云SDK相关组件至最新版本 - 添加think-trace调试扩展,便于问题排查 - 优化跨域中间件,使用str_contains替代strpos
This commit is contained in:
@@ -15,6 +15,7 @@ use app\services\product\sku\StoreProductAttrValueServices;
|
||||
use crmeb\exceptions\AdminException;
|
||||
use crmeb\services\erp\AccessToken;
|
||||
use crmeb\services\erp\storage\Jushuitan;
|
||||
use think\facade\Log;
|
||||
|
||||
class Stock
|
||||
{
|
||||
@@ -39,7 +40,7 @@ class Stock
|
||||
|
||||
/**
|
||||
* 同步商品库存
|
||||
* @param array $ids
|
||||
* @param string $ids
|
||||
* @return void
|
||||
* @throws \Exception
|
||||
*/
|
||||
@@ -115,6 +116,8 @@ class Stock
|
||||
$params = $this->getParams($biz);
|
||||
|
||||
//请求平台接口
|
||||
$skuIdsList = array_values(array_filter(array_map('trim', explode(',', trim($codeStr, ", \t\n\r\0\x0B"))), static fn($v) => $v !== ''));
|
||||
Log::info('jst.api.stock.inventoryQuery.request', ['url' => $url, 'sku_ids_count' => count($skuIdsList), 'sku_ids' => $skuIdsList, 'sku_ids_raw' => $codeStr]);
|
||||
$request = $this->postRequest($url, $params);
|
||||
return $request["data"];
|
||||
}
|
||||
@@ -148,4 +151,4 @@ class Stock
|
||||
return call_user_func_array([$this->jushuitan, $name], $arguments);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,8 @@ namespace crmeb\services\sms\storage;
|
||||
use AlibabaCloud\SDK\Dysmsapi\V20170525\Dysmsapi;
|
||||
use AlibabaCloud\SDK\Dysmsapi\V20170525\Models\SendSmsRequest;
|
||||
use AlibabaCloud\Tea\Exception\TeaError;
|
||||
use AlibabaCloud\Tea\Utils\Utils\RuntimeOptions;
|
||||
// use AlibabaCloud\Tea\Utils\Utils\RuntimeOptions;
|
||||
use AlibabaCloud\Dara\Models\RuntimeOptions;
|
||||
use crmeb\basic\BaseSmss;
|
||||
use crmeb\exceptions\ApiException;
|
||||
use Darabonba\OpenApi\Models\Config as AliConfig;
|
||||
@@ -33,6 +34,39 @@ class Aliyun extends BaseSmss
|
||||
protected $AccessKeySecret = '';
|
||||
protected $SignName = '';
|
||||
|
||||
private function ensureAliyunSdkAutoload(): void
|
||||
{
|
||||
static $inited = false;
|
||||
if ($inited) {
|
||||
return;
|
||||
}
|
||||
$inited = true;
|
||||
|
||||
$rootDir = dirname(__DIR__, 4) . DIRECTORY_SEPARATOR;
|
||||
$map = [
|
||||
'AlibabaCloud\\Tea\\Utils\\' => $rootDir . 'vendor' . DIRECTORY_SEPARATOR . 'alibabacloud' . DIRECTORY_SEPARATOR . 'tea-utils' . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR,
|
||||
'Darabonba\\OpenApi\\' => $rootDir . 'vendor' . DIRECTORY_SEPARATOR . 'alibabacloud' . DIRECTORY_SEPARATOR . 'darabonba-openapi' . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR,
|
||||
'AlibabaCloud\\SDK\\Dysmsapi\\V20170525\\' => $rootDir . 'vendor' . DIRECTORY_SEPARATOR . 'alibabacloud' . DIRECTORY_SEPARATOR . 'dysmsapi-20170525' . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR,
|
||||
];
|
||||
|
||||
foreach ($map as $prefix => $baseDir) {
|
||||
if (!is_dir($baseDir)) {
|
||||
continue;
|
||||
}
|
||||
spl_autoload_register(static function ($class) use ($prefix, $baseDir) {
|
||||
$len = strlen($prefix);
|
||||
if (strncmp($class, $prefix, $len) !== 0) {
|
||||
return;
|
||||
}
|
||||
$relative = substr($class, $len);
|
||||
$file = $baseDir . str_replace('\\', DIRECTORY_SEPARATOR, $relative) . '.php';
|
||||
if (is_file($file)) {
|
||||
require_once $file;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $config
|
||||
* @return mixed|void
|
||||
@@ -57,6 +91,7 @@ class Aliyun extends BaseSmss
|
||||
if (empty($phone)) {
|
||||
return $this->setError('电话号码不能为空');
|
||||
}
|
||||
$this->ensureAliyunSdkAutoload();
|
||||
$config = new AliConfig([
|
||||
"accessKeyId" => $this->AccessKeyId,
|
||||
"accessKeySecret" => $this->AccessKeySecret
|
||||
|
||||
@@ -71,7 +71,15 @@ class Cron
|
||||
*/
|
||||
protected function runInSandbox(callable $callable)
|
||||
{
|
||||
$callable();
|
||||
try {
|
||||
$callable();
|
||||
} catch (\Throwable $e) {
|
||||
Log::error('cron.sandbox.error ' . json_encode([
|
||||
'message' => $e->getMessage(),
|
||||
'file' => $e->getFile(),
|
||||
'line' => $e->getLine(),
|
||||
], JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user