添加本地生活商品属性关联

This commit is contained in:
wangxiaowei 2024-09-12 17:01:03 +08:00
parent 5501a0e18f
commit 16ef63aac2
3 changed files with 18 additions and 7 deletions

@ -9,6 +9,8 @@ use app\common\server\JsonServer;
class LocalStoreGoods extends Api
{
public $like_not_need_login = ['shopDetails'];
// 商品列表
public function lists()
{

@ -232,13 +232,22 @@ class LocalStoreGoodsLogic extends Logic
'goods_id' => $get['id']
])->field('id, image, spec_value_ids, spec_value_str, price, stock, note')->select();
$data['spec'] = LocalStoreGoodsSpec::where([
$data['spec'] = LocalStoreGoodsSpec::with('item')->where([
'goods_id' => $get['id']
])->field('id, name')->select();
$data['spec_value'] = LocalStoreGoodsSpecValue::where([
'goods_id' => $get['id']
])->field('id, spec_id, value')->select();
dump($data['spec']);
die;
// $data['spec_value'] = LocalStoreGoodsSpecValue::where([
// 'goods_id' => $get['id']
// ])->field('id, spec_id, value')->select();
//
// foreach ($data['spec'] as $k1 => &$v1) {
// foreach ($data['spec_value'] as $k2 => &$v2) {
// if ($v2['id'] == $v2['spec_id']) {
//
// }
// }
// }
}
if ($data) {

@ -8,8 +8,8 @@ class LocalStoreGoodsSpec extends Models
{
protected $table = 'ls_local_store_goods_spec';
public function pic()
public function item()
{
return $this->hasMany(LocalStoreGoodsPic::class, 'lsg_id');
return $this->hasMany(LocalStoreGoodsSpecValue::class, 'spec_id');
}
}