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.

47 lines
1.1 KiB

5 years ago
5 years ago
  1. <?php
  2. namespace App\Service\v3\Implementations;
  3. use App\Service\v3\Interfaces\GoodsServiceInterface;
  4. use Hyperf\DbConnection\Db;
  5. use App\Model\v3\Goods;
  6. use App\Model\v3\GoodsBanner;
  7. use App\Constants\v3\Store;
  8. use App\Constants\v3\goods as goodsConstants;
  9. class GoodsService implements GoodsServiceInterface
  10. {
  11. public function do($goodsId)
  12. {
  13. $res = Goods::query()->with('store')->where('id',$goodsId)->first();
  14. return $res;
  15. }
  16. public function check($goodsId,$num = 1)
  17. {
  18. $data = Goods::query()->with('store')->where('id', $goodsId)->first();
  19. if($data->store->is_rest != Store::IS_OPEN_YES){
  20. return '店铺已休息';
  21. }
  22. if($data->on_sale == 0 || !is_null($data->deleted_at)){
  23. return '商品已下架';
  24. }
  25. if($data->is_infinite != 1 && $data->inventory < $num){
  26. return '库存不足';
  27. }
  28. return '';
  29. }
  30. public function undo()
  31. {
  32. // TODO: Implement undo() method.
  33. }
  34. public function getBanner()
  35. {
  36. $banner = GoodsBanner::query()->where('goods_id',1572)->get();
  37. return $banner;
  38. }
  39. }