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.

52 lines
1.2 KiB

5 years ago
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. }
  14. public function check($goodsId,$num = 1)
  15. {
  16. $data = Goods::query()->with('store')->where('id', $goodsId)->first();
  17. if($data->store->is_rest != Store::IS_OPEN_YES){
  18. return '店铺已休息';
  19. }
  20. if($data->on_sale == 0 || !is_null($data->deleted_at)){
  21. return '商品已下架';
  22. }
  23. if($data->is_infinite != 1 && $data->inventory < $num){
  24. return '库存不足';
  25. }
  26. return '';
  27. }
  28. public function undo()
  29. {
  30. // TODO: Implement undo() method.
  31. }
  32. public function getBanner($goodsId)
  33. {
  34. $banner = GoodsBanner::query()->where('goods_id',$goodsId)->orderByDesc('type')->get();
  35. return $banner;
  36. }
  37. public function detail($goodsId)
  38. {
  39. $res = Goods::query()->with('store')->where('id',$goodsId)->first();
  40. return $res;
  41. }
  42. }