产品编辑

This commit is contained in:
2025-12-23 09:43:51 +08:00
parent 5f87899156
commit 60fdd57da9
2 changed files with 13 additions and 1 deletions
+8 -1
View File
@@ -64,7 +64,14 @@ class SkuController extends BaseController
if (isset($data['spec_json'])){
$data['spec'] = json_decode($data['spec_json'], true);
foreach ($data['spec'] as $k=>$v){
$data['spec'][$k]['attr_type'] = SkuAttribute::where('id', $v['attr_id'])->value('attr_type');
$skuAttribute = SkuAttribute::where('category_id',$data['category_id'])
->where('attr_name', $v['attr_name'])->first();
if ($skuAttribute){
$data['spec'][$k]['attr_id'] = $skuAttribute['id'];
$data['spec'][$k]['attr_type'] = $skuAttribute['attr_type'];
}else{
$data['spec'][$k]['attr_type'] = SkuAttribute::where('id', $v['attr_id'])->value('attr_type');
}
}
}
if (isset($data['category_id']))
+5
View File
@@ -231,6 +231,7 @@ class PostService
$lat = $request->get('lat');
$status = $request->get('status', 1);
$keyword = $request->get('keyword', '');
$category_id = $request->get('category_id');
if (!$lng || !$lat) {
throw new BusinessException('经纬度必传');
@@ -261,6 +262,10 @@ class PostService
FROM post
WHERE status = " . $status;
if (!empty($category_id)) {
$sql = $sql." AND category_id = " . $category_id;
}
if (!empty($keyword)) {
$sql = $sql." AND (content LIKE '%".$keyword."%' OR `model` LIKE '%".$keyword."%')";
}