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.

62 lines
1.6 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 as goodsConstants;
  7. use App\Model\v3\GoodsActivity;
  8. class GoodsActivityService implements GoodsActivityServiceInterface
  9. {
  10. public function do($goodsId)
  11. {
  12. $res = GoodsActivity::query()->with('store')->where('id',$goodsId)->first();
  13. return $res;
  14. }
  15. public function check($goodsId,$num = 1)
  16. {
  17. $data = GoodsActivity::query()->with('store')->where('id', $goodsId)->first();
  18. //活动商品 校验
  19. if($data->expire_time < time()){
  20. return '活动已结束';
  21. }
  22. if($data->store->is_rest != Store::IS_OPEN_YES){
  23. return '店铺已休息';
  24. }
  25. if($data->on_sale == 0 || !is_null($data->deleted_at)){
  26. return '商品已下架';
  27. }
  28. if($data->is_infinite != 1 && $data->inventory < $num){
  29. return '库存不足';
  30. }
  31. return '';
  32. }
  33. public function undo()
  34. {
  35. // TODO: Implement undo() method.
  36. }
  37. public function getBanner()
  38. {
  39. $banner = [
  40. [
  41. 'id' => 1,
  42. 'type' => 1,
  43. 'path' => 'https://img.lanzu.vip/static/img/dic_banners/dic_banner_0.jpg'
  44. ],
  45. [
  46. 'id' => 2,
  47. 'type' => 1,
  48. 'path' => 'https://img.lanzu.vip/static/img/dic_banners/dic_banner_1.jpg'
  49. ]
  50. ];
  51. return $banner;
  52. }
  53. }