商品更新

This commit is contained in:
2025-12-11 17:48:16 +08:00
parent d493bf93c7
commit 2031635077
2 changed files with 49 additions and 1 deletions
+48
View File
@@ -102,6 +102,54 @@ class SkuService
return $res;
}
/**
* 添加前置处理
*/
public function beforeServiceUpdate($data, Request $request)
{
$spec = [];
SkuAttributeValue::where('sku_id', $data['id'])->delete();
foreach ($data['spec'] as $key => $value) {
$specItem = [];
$specItem['category_id'] = $data['category_id'];
$specItem['attr_id'] = $value['attr_id'];
$specItem['attr_name'] = $value['attr_name'];
$specItem['attr_value'] = $value['attr_value'];
$spec[] = $specItem;
SkuAttributeValue::create($specItem);
}
$spec_json = json_encode($spec,JSON_UNESCAPED_UNICODE);
unset($data['spec']);
$data['spec_json'] = $spec_json;
$data['user_id'] = $request->user->uid;
$data['image'] = implode(',',$data['image']);
// 将OSS直连地址替换为代理地址
$ossDomain = 'https://vehicle-album.oss-cn-beijing.aliyuncs.com/';
$proxyPath = '/proxy/ossurl?file=';
$data['desc'] = str_replace(
'?Expires=',
'&Expires=',
$data['desc']
);
$data['desc'] = str_replace(
$ossDomain,
$proxyPath,
$data['desc']
);
// 将OSS直连地址替换为代理地址
$ossDomain = 'https://oss-cn-beijing.aliyuncs.com/';
$proxyPath = '/proxy/ossurl?file=';
$data['desc'] = str_replace(
$ossDomain,
$proxyPath,
$data['desc']
);
return $data;
}
/**