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.3 KiB

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