feat: 添加阿里云短信服务支持并优化验证码逻辑
- 引入 alibabacloud/dysmsapi-20170525 依赖,集成阿里云短信服务 - 将短信验证码从6位改为4位,优化用户体验 - 添加聚水潭商品按时间范围同步功能,支持分页拉取 - 增强Cron任务异常处理,添加错误日志记录 - 修复系统附件服务中图片路径处理逻辑 - 更新阿里云SDK相关组件至最新版本 - 添加think-trace调试扩展,便于问题排查 - 优化跨域中间件,使用str_contains替代strpos
This commit is contained in:
@@ -13,31 +13,82 @@ class JstProductEvent implements JstEvent
|
||||
{
|
||||
try {
|
||||
$param = $request->param();
|
||||
$body = json_decode((string)($param['biz'] ?? '{}'), true);
|
||||
$actionCode = (string)($param['action_code'] ?? '');
|
||||
$parseFrom = 'param.biz';
|
||||
$bizRaw = (string)($param['biz'] ?? '');
|
||||
$body = json_decode($bizRaw !== '' ? $bizRaw : '{}', true);
|
||||
if (!is_array($body)) {
|
||||
Log::warning('jst.cb.product_stock.parse_fail ' . json_encode([
|
||||
'action_code' => $actionCode,
|
||||
'from' => $parseFrom,
|
||||
'biz_raw_len' => strlen($bizRaw),
|
||||
], JSON_UNESCAPED_UNICODE));
|
||||
$body = [];
|
||||
}
|
||||
$skuId = (string)($body['skuId'] ?? '');
|
||||
$stock = (int)($body['qty'] ?? 0);
|
||||
if (!$skuId) {
|
||||
$cont = $request->getContent();
|
||||
$output = [];
|
||||
parse_str($cont, $output);
|
||||
$body = json_decode((string)($output['biz'] ?? '{}'), true);
|
||||
$actionCode = (string)($output['action_code'] ?? $actionCode);
|
||||
$parseFrom = 'content.parse_str.biz';
|
||||
$bizRaw = (string)($output['biz'] ?? '');
|
||||
$body = json_decode($bizRaw !== '' ? $bizRaw : '{}', true);
|
||||
if (!is_array($body)) {
|
||||
Log::warning('jst.cb.product_stock.parse_fail ' . json_encode([
|
||||
'action_code' => $actionCode,
|
||||
'from' => $parseFrom,
|
||||
'biz_raw_len' => strlen($bizRaw),
|
||||
'content_len' => strlen((string)$cont),
|
||||
], JSON_UNESCAPED_UNICODE));
|
||||
$body = [];
|
||||
}
|
||||
$skuId = (string)($body['skuId'] ?? '');
|
||||
$stock = (int)($body['qty'] ?? 0);
|
||||
}
|
||||
if (!$skuId) return [];
|
||||
if (!$skuId) {
|
||||
Log::warning('jst.cb.product_stock.miss ' . json_encode([
|
||||
'action_code' => $actionCode,
|
||||
'from' => $parseFrom,
|
||||
'sku_id' => $skuId,
|
||||
], JSON_UNESCAPED_UNICODE));
|
||||
return [];
|
||||
}
|
||||
/** @var StoreProductAttrValueServices $spas */
|
||||
$spas = app()->make(StoreProductAttrValueServices::class);
|
||||
$model = $spas->getOne(['code' => $skuId]);
|
||||
if ($model) {
|
||||
$pdt = $model->toArray();
|
||||
$id = $pdt['id'] ?? 0;
|
||||
if ($id) {
|
||||
$spas->update($id, [
|
||||
if (!$model) {
|
||||
Log::warning('jst.cb.product_stock.not_found ' . json_encode([
|
||||
'action_code' => $actionCode,
|
||||
'from' => $parseFrom,
|
||||
'sku_id' => $skuId,
|
||||
'stock' => $stock,
|
||||
'sum_stock' => $stock
|
||||
]);
|
||||
}
|
||||
], JSON_UNESCAPED_UNICODE));
|
||||
return [];
|
||||
}
|
||||
$pdt = $model->toArray();
|
||||
$id = (int)($pdt['id'] ?? 0);
|
||||
if (!$id) {
|
||||
Log::warning('jst.cb.product_stock.not_found ' . json_encode([
|
||||
'action_code' => $actionCode,
|
||||
'from' => $parseFrom,
|
||||
'sku_id' => $skuId,
|
||||
'stock' => $stock,
|
||||
], JSON_UNESCAPED_UNICODE));
|
||||
return [];
|
||||
}
|
||||
$spas->update($id, [
|
||||
'stock' => $stock,
|
||||
'sum_stock' => $stock
|
||||
]);
|
||||
Log::info('jst.cb.product_stock.updated ' . json_encode([
|
||||
'action_code' => $actionCode,
|
||||
'from' => $parseFrom,
|
||||
'attr_value_id' => $id,
|
||||
'sku_id' => $skuId,
|
||||
'stock' => $stock,
|
||||
], JSON_UNESCAPED_UNICODE));
|
||||
} catch (Throwable $e) {
|
||||
Log::error('jst.cb.product_stock.error ' . json_encode([
|
||||
'msg' => $e->getMessage(),
|
||||
|
||||
Reference in New Issue
Block a user