diff --git a/app/Service/Api/Good/OptionalListService.php b/app/Service/Api/Good/OptionalListService.php index 0034081..3ac4715 100644 --- a/app/Service/Api/Good/OptionalListService.php +++ b/app/Service/Api/Good/OptionalListService.php @@ -125,9 +125,10 @@ class OptionalListService extends BaseService $skuList = array_merge($skuList, $item['sku_list']); } - if (!empty($purchaseData)) { - if (empty($skuList)) throw new ErrException('数据错误'); + if (empty($skuList)) throw new ErrException('数据错误'); + $skuList = array_column($skuList,null,'id'); + if (!empty($purchaseData)) { foreach ($purchaseData as &$one) { $onePurchaseSkuIds = explode(',',$one['sku_ids']); $onePurchaseSkuList = []; @@ -154,8 +155,6 @@ class OptionalListService extends BaseService } if (!empty($favorable)) { - if (empty($skuList)) throw new ErrException('数据错误'); - $skuList = array_column($skuList,null,'id'); foreach ($favorable['sku_list'] as &$v) { $v['origin_spu_id'] = $skuList[$v['origin_sku_id']]['spu_id'] ?? 0; }