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.

58 lines
1.4 KiB

6 years ago
6 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\Constants\v3\Store;
  7. use App\Constants\v3\goods as goodsConstants;
  8. use App\Model\v3\GoodsActivity;
  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 = [
  37. [
  38. 'id' => 1,
  39. 'type' => 1,
  40. 'path' => 'https://img.lanzu.vip/static/img/dic_banners/dic_banner_0.jpg'
  41. ],
  42. [
  43. 'id' => 2,
  44. 'type' => 1,
  45. 'path' => 'https://img.lanzu.vip/static/img/dic_banners/dic_banner_1.jpg'
  46. ]
  47. ];
  48. return $banner;
  49. }
  50. }