From 93449f49e6d70f3fe63d5567bc7063e20cd3640d Mon Sep 17 00:00:00 2001 From: ctexthuang Date: Fri, 18 Apr 2025 09:37:28 +0800 Subject: [PATCH] feat : sts --- app/Service/Api/Good/OptionalListService.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) 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)),