Service.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2017~2024 https://www.yiovo.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
  8. // +----------------------------------------------------------------------
  9. // | Author: 萤火科技 <admin@yiovo.com>
  10. // +----------------------------------------------------------------------
  11. declare (strict_types=1);
  12. namespace app\common\model\goods;
  13. use cores\BaseModel;
  14. /**
  15. * 商品服务与承诺模型
  16. * Class Service
  17. */
  18. class Service extends BaseModel
  19. {
  20. // 定义表名
  21. protected $name = 'goods_service';
  22. // 定义主键
  23. protected $pk = 'service_id';
  24. /**
  25. * 帮助详情
  26. * @param int $helpId
  27. * @return static|array|null
  28. */
  29. public static function detail(int $helpId)
  30. {
  31. return self::get($helpId);
  32. }
  33. /**
  34. * 过滤不存在的ID集
  35. * @param array $serviceIds
  36. * @param int|null $storeId
  37. * @return array
  38. */
  39. public static function filterServiceIds(array $serviceIds, int $storeId = null): array
  40. {
  41. return (new static)->where('service_id', 'in', $serviceIds)
  42. ->where('is_delete', '=', 0)
  43. ->where('store_id', '=', $storeId ?: self::$storeId)
  44. ->column('service_id');
  45. }
  46. }