feat: 添加阿里云短信服务支持并优化验证码逻辑
- 引入 alibabacloud/dysmsapi-20170525 依赖,集成阿里云短信服务 - 将短信验证码从6位改为4位,优化用户体验 - 添加聚水潭商品按时间范围同步功能,支持分页拉取 - 增强Cron任务异常处理,添加错误日志记录 - 修复系统附件服务中图片路径处理逻辑 - 更新阿里云SDK相关组件至最新版本 - 添加think-trace调试扩展,便于问题排查 - 优化跨域中间件,使用str_contains替代strpos
This commit is contained in:
@@ -157,6 +157,7 @@ class JstProductSync extends HaichaoJstServices
|
||||
} else {
|
||||
$productServices->update($pidNow, $productInfo);
|
||||
}
|
||||
$productServices->ensureSpu((int)$pidNow);
|
||||
ProductStockTips::dispatch([$pidNow, 0]);
|
||||
$attr = [[
|
||||
'value' => '规格',
|
||||
@@ -324,6 +325,7 @@ class JstProductSync extends HaichaoJstServices
|
||||
} else {
|
||||
$productServices->update($pid, $productInfo);
|
||||
}
|
||||
$productServices->ensureSpu((int)$pid);
|
||||
ProductStockTips::dispatch([$pid, 0]);
|
||||
$attr = [[
|
||||
'value' => '规格',
|
||||
|
||||
@@ -16,45 +16,76 @@ class JstStorkSync extends HaichaoJstServices
|
||||
{
|
||||
public function syncStorkFromInneropenErp(): void
|
||||
{
|
||||
$startAt = microtime(true);
|
||||
/** @var StoreProductAttrValueServices $storeProductAttrValueServices */
|
||||
$storeProductAttrValueServices = app()->make(StoreProductAttrValueServices::class);
|
||||
Log::info('jst.stork.sync.start');
|
||||
$inventorySkuIds = [];
|
||||
$skuIds = '';
|
||||
$index = 1;
|
||||
$count = 0;
|
||||
$codes = [];
|
||||
$spuIds = [];
|
||||
$codeIdMap = [];
|
||||
$codeProductIdMap = [];
|
||||
foreach ($storeProductAttrValueServices->getList(['is_del' => 0]) as $item) {
|
||||
if ($item['code']) {
|
||||
$skuIds .= $item['code'] . ',';
|
||||
$count++;
|
||||
$inventorySkuIds[$index] = [
|
||||
'length' => $count,
|
||||
'ids' => $skuIds,
|
||||
];
|
||||
if ($count >= 500) {
|
||||
$skuIds = '';
|
||||
$index++;
|
||||
$count = 0;
|
||||
$code = (string)($item['code'] ?? '');
|
||||
if ($code !== '') {
|
||||
$codes[] = $code;
|
||||
$id = (int)($item['id'] ?? 0);
|
||||
if ($id > 0) {
|
||||
$codeIdMap[$code] = $id;
|
||||
}
|
||||
$productId = (int)($item['product_id'] ?? 0);
|
||||
if ($productId > 0) {
|
||||
$spuIds[$productId] = 1;
|
||||
$codeProductIdMap[$code] = $productId;
|
||||
}
|
||||
}
|
||||
}
|
||||
$productStock = [];
|
||||
foreach ($inventorySkuIds as $inventorySkuId) {
|
||||
foreach ($this->getInneropenStockAndDetailList($inventorySkuId['ids']) as $product) {
|
||||
$productStock[] = [
|
||||
'code' => $product['item_code'],
|
||||
'stock' => $product['stock']
|
||||
];
|
||||
$codes = array_values(array_unique($codes));
|
||||
Log::info('jst.stork.sync.request_stats ' . json_encode([
|
||||
'spu_count' => count($spuIds),
|
||||
'sku_count' => count($codes),
|
||||
], JSON_UNESCAPED_UNICODE));
|
||||
|
||||
$pullStats = [];
|
||||
$productStockMap = [];
|
||||
foreach ($this->getInneropenStockAndDetailList($codes, $pullStats) as $product) {
|
||||
$productStockMap[(string)$product['item_code']] = (int)$product['stock'];
|
||||
}
|
||||
$respSpuIds = [];
|
||||
foreach (array_keys($productStockMap) as $code) {
|
||||
if (isset($codeProductIdMap[$code])) {
|
||||
$respSpuIds[$codeProductIdMap[$code]] = 1;
|
||||
}
|
||||
}
|
||||
Log::info('jst.stork.sync.merge ' . count($productStock));
|
||||
foreach ($productStock as $item) {
|
||||
$storeProductAttrValueServices->update(['code' => $item['code']], [
|
||||
'stock' => $item['stock'],
|
||||
'sum_stock' => $item['stock']
|
||||
Log::info('jst.stork.sync.response_stats ' . json_encode([
|
||||
'spu_count' => count($respSpuIds),
|
||||
'sku_count' => count($productStockMap),
|
||||
'api_call_count' => (int)($pullStats['api_call_count'] ?? 0),
|
||||
'api_resp_row_count' => (int)($pullStats['api_resp_row_count'] ?? 0),
|
||||
], JSON_UNESCAPED_UNICODE));
|
||||
|
||||
$updatedSkuCount = 0;
|
||||
$notFoundSkuCount = 0;
|
||||
foreach ($productStockMap as $code => $stock) {
|
||||
$id = (int)($codeIdMap[$code] ?? 0);
|
||||
if ($id < 1) {
|
||||
$notFoundSkuCount++;
|
||||
continue;
|
||||
}
|
||||
$storeProductAttrValueServices->update($id, [
|
||||
'stock' => $stock,
|
||||
'sum_stock' => $stock
|
||||
]);
|
||||
$updatedSkuCount++;
|
||||
}
|
||||
Log::info('jst.stork.sync.end');
|
||||
Log::info('jst.stork.sync.finish ' . json_encode([
|
||||
'requested_spu_count' => count($spuIds),
|
||||
'requested_sku_count' => count($codes),
|
||||
'response_spu_count' => count($respSpuIds),
|
||||
'response_sku_count' => count($productStockMap),
|
||||
'update_sku_count' => $updatedSkuCount,
|
||||
'not_found_sku_count' => $notFoundSkuCount,
|
||||
'duration_ms' => (int)round((microtime(true) - $startAt) * 1000),
|
||||
], JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
|
||||
public function syncStockFromErp(array $ids): bool
|
||||
|
||||
Reference in New Issue
Block a user