|
|
@ -0,0 +1,63 @@ |
|
|
|
|
|
<?php |
|
|
|
|
|
|
|
|
|
|
|
namespace App\Service\v3\Implementations; |
|
|
|
|
|
|
|
|
|
|
|
use App\Service\v3\Interfaces\GoodsActivityServiceInterface; |
|
|
|
|
|
use Hyperf\DbConnection\Db; |
|
|
|
|
|
use App\Constants\v3\Store; |
|
|
|
|
|
use App\Constants\v3\goods as goodsConstants; |
|
|
|
|
|
use App\Model\v3\GoodsActivity; |
|
|
|
|
|
class GoodsActivityService implements GoodsActivityServiceInterface |
|
|
|
|
|
{ |
|
|
|
|
|
public function do($goodsId) |
|
|
|
|
|
{ |
|
|
|
|
|
$res = GoodsActivity::query()->with('store')->where('id',$goodsId)->first(); |
|
|
|
|
|
return $res; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function check($goodsId,$num = 1) |
|
|
|
|
|
{ |
|
|
|
|
|
$data = GoodsActivity::query()->with('store')->where('id', $goodsId)->first(); |
|
|
|
|
|
//活动商品 校验
|
|
|
|
|
|
if($data->expire_time < time()){ |
|
|
|
|
|
return '活动已结束'; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
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() |
|
|
|
|
|
{ |
|
|
|
|
|
$banner = [ |
|
|
|
|
|
[ |
|
|
|
|
|
'id' => 1, |
|
|
|
|
|
'type' => 1, |
|
|
|
|
|
'path' => 'https://img.lanzu.vip/static/img/dic_banners/dic_banner_0.jpg' |
|
|
|
|
|
], |
|
|
|
|
|
[ |
|
|
|
|
|
'id' => 2, |
|
|
|
|
|
'type' => 1, |
|
|
|
|
|
'path' => 'https://img.lanzu.vip/static/img/dic_banners/dic_banner_1.jpg' |
|
|
|
|
|
] |
|
|
|
|
|
]; |
|
|
|
|
|
return $banner; |
|
|
|
|
|
} |
|
|
|
|
|
} |