SpecService.php 872 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. declare(strict_types=1);
  3. namespace app\common\service;
  4. use app\common\model\Msg;
  5. /**
  6. * 消息服务
  7. */
  8. class SpecService extends BaseService{
  9. protected function init()
  10. {
  11. }
  12. //判断价格为空
  13. public static function getIsZeroSpecsPrice(array $data): bool
  14. {
  15. $result = false;
  16. foreach ($data as $item) {
  17. if(empty($item['price'])) return false;
  18. }
  19. return $result;
  20. }
  21. //获取规格列表
  22. public static function getSpecsList(int $type_id, array $data): array
  23. {
  24. $result = [];
  25. foreach ($data as $item) {
  26. if($item['type_id'] == $type_id){
  27. $result[] = $item;
  28. }
  29. }
  30. return $result;
  31. }
  32. }