You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

53 lines
1.2 KiB

<?php
namespace App\Service\v3\Implementations;
use App\Service\v3\Interfaces\GoodsServiceInterface;
use Hyperf\DbConnection\Db;
use App\Model\v3\Goods;
use App\Model\v3\GoodsBanner;
use App\Constants\v3\Store;
use App\Constants\v3\goods as goodsConstants;
class GoodsService implements GoodsServiceInterface
{
public function do($goodsId)
{
}
public function check($goodsId,$num = 1)
{
$data = Goods::query()->with('store')->where('id', $goodsId)->first();
if($data->store->is_rest != Store::IS_OPEN_YES){
return '店铺已休息';
}
if($data->on_sale == 0 || !is_null($data->deleted_at)){
return '商品已下架';
}
if($data->is_infinite != 1 && $data->inventory < $num){
return '库存不足';
}
return '';
}
public function undo()
{
// TODO: Implement undo() method.
}
public function getBanner($goodsId)
{
$banner = GoodsBanner::query()->where('goods_id',$goodsId)->orderByDesc('type')->get();
return $banner;
}
public function detail($goodsId)
{
$res = Goods::query()->with('store')->where('id',$goodsId)->first();
return $res;
}
}