0 ? $quantity : 1; $pricingEnterpriseId = null; if ($enterpriseId !== null && (int) $enterpriseId > 0) { $pricingEnterpriseId = (int) $enterpriseId; } elseif ($wechatUserId > 0) { $userEid = (int) Db::name('wechat_users')->where('id', $wechatUserId)->value('enterpriseId'); if ($userEid > 0) { $pricingEnterpriseId = $userEid; } } $pricingTypeForRead = $pricingType; $priceKey = $productType; if ($pricingTier === 'gaokao') { $pricingTypeForRead = 'gaokao'; $priceKey = $productType === 'gaokao' ? 'gaokao' : $productType; } elseif ($productType === 'gaokao') { $pricingTypeForRead = 'gaokao'; $priceKey = 'gaokao'; } $pricingConfig = PricingConfigModel::getByTypeAndEnterprise($pricingTypeForRead, $pricingEnterpriseId); $config = []; if ($pricingConfig && !empty($pricingConfig->config)) { $raw = $pricingConfig->config; $config = is_array($raw) ? $raw : (array) $raw; } $keyMap = ['team_analysis' => 'teamAnalysis']; $key = $keyMap[$priceKey] ?? $priceKey; $unitPriceYuan = isset($config[$key]) ? (float) $config[$key] : 0.0; $amountFen = (int) round($unitPriceYuan * 100 * $quantity); return [$amountFen, $pricingTypeForRead]; } }