Browse Source

商品详情 规格转数组

master
Lemon 5 years ago
parent
commit
60305d5938
  1. 2
      app/Model/v3/Goods.php
  2. 43
      app/Service/v3/Implementations/GoodsService.php

2
app/Model/v3/Goods.php

@ -74,7 +74,7 @@ class Goods extends Model
public function getCartNumAttribute()
{
return (integer)$this->shopCartService->check($this->id);
return (integer)$this->shopCartService->getGoodsNum($this->id);
}
public function store()

43
app/Service/v3/Implementations/GoodsService.php

@ -4,52 +4,13 @@ namespace App\Service\v3\Implementations;
use App\Service\v3\Interfaces\GoodsServiceInterface;
use Hyperf\DbConnection\Db;
use App\Model\v3\Goods;
class GoodsService implements GoodsServiceInterface
{
public function detail()
{
/*
* 返回商品 封面图
* * 返回商品 轮播图
* 返回商品信息 包括名称 规格 tag等
* 返回店铺信息
* 返回商品规格信息
* 猜你喜欢
* 限时抢购
* 为你推荐
* */
// $goods['detail'] = [
// "id" => 170,
// "market_id" => 2,
// "store_id" => 39,
// "goods_type_id" => 39,
// "on_sale" => 1,
// "sort" => 0,
// "is_infinite" => 2,
// "start_num" => 0,
// "restrict_num" => 0,
// "inventory" => 1000,
// "name" => "冬菜",
// "cover_img" => "https => //store.lanzu.vip/attachment/images/2/2020/06/en2nQYncqN4f44qnA7CwnNOG2WqQ2q.jpg",
// "price" => "2.50",
// "original_price" => "2.50",
// "vip_price" => "0.00",
// "sales" => 0,
// "good_unit" => "",
// "tags" => null,
// "details_imgs" => null,
// "spec" => null,
// "content" => "",
// "details" => "<p><img src=\"https => //store.lanzu.vip/attachment/images/2/2020/06/J1Z5N818NqCt581LF1V1Tqd88151fV.jpg\" _src=\"https => //store.lanzu.vip/attachment/images/2/2020/06/J1Z5N818NqCt581LF1V1Tqd88151fV.jpg\" alt=\"冬菜.jpg\" style=\"max-width => 100%\"></p><p>​<br></p>",
// "created_at" => null,
// "updated_at" => 1598769782,
// "deleted_at" => null,
// '净含量' => '约500G',
// '保存条件' => '常温',
// '保质期' => '10天'
// ];
$goods['detail'] = Db::table('lanzu_goods')->where('id',35)->get();
$goods['detail'] = Goods::query()->where('id',35)->get();
$goods['banner'] = $this->getBanner();
return $goods;
}

Loading…
Cancel
Save