diff --git a/app/Service/Api/Good/OptionalListService.php b/app/Service/Api/Good/OptionalListService.php index b73591f..eeaceed 100644 --- a/app/Service/Api/Good/OptionalListService.php +++ b/app/Service/Api/Good/OptionalListService.php @@ -126,6 +126,25 @@ class OptionalListService extends BaseService } if (!empty($purchaseData)) { + if (empty($skuList)) throw new ErrException('数据错误'); + + foreach ($purchaseData as &$one) { + $onePurchaseSkuIds = explode(',',$one['sku_ids']); + $onePurchaseSkuList = []; + $onePurchaseSkuPrice = 0; + $onePurchaseSkuNames = []; + + foreach ($onePurchaseSkuIds as $skuId) { + $onePurchaseSkuList[] = $skuList[$skuId]; + $onePurchaseSkuPrice = bcadd((string)$onePurchaseSkuPrice, (string)$onePurchaseSkuList[$skuId]['price'], 2); + $onePurchaseSkuNames[] = $skuList[$skuId]['name'] ?? ''; + } + + $one['purchase_sku_list'] = $onePurchaseSkuList; + $one['purchase_sku_price'] = $onePurchaseSkuPrice; + $one['purchase_sku_names'] = $onePurchaseSkuNames; + } + array_unshift($res,[ 'category_name' => $this->configCache->getConfigValueByKey(ConfigCode::ONE_CLICK_SHOPPING_FOR_CATEGORY_NAME), 'category_image' => $this->getOssObjectById((int)$this->configCache->getConfigValueByKey(ConfigCode::ONE_CLICK_SHOPPING_FOR_CATEGORY_IMAGE)),