修改分类同步小程序分类相关

This commit is contained in:
liu 2024-06-27 15:37:04 +08:00
parent 28c94be5c9
commit a944e9936f

View File

@ -127,6 +127,33 @@ class StoreProductLogic extends BaseLogic
}
}
/*
* 传入三级或者二级分类返还上级分类 一级那全是相同
*/
public static function dealChangeCate($cate_id)
{
$value =[];
$last_cate = Db::name('store_category')->where('id',$cate_id)->value('pid');
if(!empty($last_cate)){
//2
$value['two_cate_id'] = $last_cate;
//1
$first_cate = Db::name('store_category')->where('id',$value['two_cate_id'])->value('pid');
if(empty($first_cate)){//顶级了
$value['two_cate_id'] = $cate_id;
$value['top_cate_id'] = $last_cate;
}else{
$value['top_cate_id'] = $first_cate;
}
}else{
//1-2 选的1级目录
$value['two_cate_id'] = $cate_id;
$value['top_cate_id'] = $cate_id;
}
return $value;
}
/**
* @notes 编辑商品列表
* @param array $params
@ -175,15 +202,15 @@ class StoreProductLogic extends BaseLogic
self::updateGoodsclass($params['cate_id'], $value['store_id']);
}
}*/
$dealCate = self::dealChangeCate($params['cate_id']);
//修改
StoreBranchProduct::where('product_id', $params['id'])->update([
'price' => $params['price'], 'vip_price' => $params['vip_price'],
'cost' => $params['cost'],'unit'=>$params['unit'],
'batch'=>$params['batch'],'store_name'=>$params['store_name'],
'manufacturer_information' => $params['manufacturer_information']??'',
'store_info' => $params['store_info']??'',
'store_info' => $params['store_info']??'','cate_id'=>$params['cate_id'],
'top_cate_id'=>$dealCate['top_cate_id'],'two_cate_id'=>$dealCate['two_cate_id']
]);
Db::commit();