This commit is contained in:
2026-04-28 16:37:10 +08:00
parent 893a223e0e
commit 0d0bf8f81e
4 changed files with 39 additions and 9 deletions

View File

@@ -352,7 +352,8 @@ async function loadReportOptions() {
return
}
const list = data.value?.data?.AgentProductConfig || data.value?.data?.agent_product_config || []
reportOptions.value = list
reportOptions.value = [...list]
.sort((a, b) => Number(a.product_id) - Number(b.product_id))
.map(item => ({
label: item.product_name || `报告${item.product_id}`,
value: item.product_id,

View File

@@ -41,6 +41,7 @@ const currentPromoteData = computed(() => {
const currentTeamData = computed(() => {
const range = dateRangeMap[selectedTeamDate.value]
return data.value?.active_reward?.[range] || {
active_reward: 0,
sub_promote_reward: 0,
sub_upgrade_reward: 0,
sub_withdraw_reward: 0,
@@ -178,11 +179,18 @@ function toSubordinateList() {
</view>
<view class="rounded-xl from-green-50/40 to-cyan-50/30 bg-gradient-to-r p-6 shadow-lg">
<view class="mb-4">
<view class="mb-4 flex items-center justify-between">
<view>
<text class="text-lg text-gray-800 font-bold">
活跃下级奖励
</text>
</view>
<view class="text-right">
<text class="text-2xl text-green-600 font-bold">
¥ {{ (data?.active_reward?.total_reward || 0).toFixed(2) }}
</text>
</view>
</view>
<view class="grid grid-cols-3 mb-6 gap-2">
<view
@@ -197,6 +205,14 @@ function toSubordinateList() {
</view>
<view class="grid grid-cols-2 mb-6 gap-2">
<view class="rounded-lg bg-green-50/60 p-3 backdrop-blur-sm">
<view class="text-sm text-gray-500">
{{ teamTimeText }}奖励
</view>
<text class="mt-1 text-xl text-green-600 font-bold">
¥ {{ (currentTeamData.active_reward || 0).toFixed(2) }}
</text>
</view>
<view class="rounded-lg bg-green-50/60 p-3 backdrop-blur-sm">
<view class="text-sm text-gray-500">
{{ teamTimeText }}下级推广奖励

View File

@@ -22,7 +22,8 @@ const formData = ref({
const availableReportTypes = computed(() => {
if (!productConfig.value?.length)
return []
return productConfig.value
return [...productConfig.value]
.sort((a, b) => Number(a.product_id) - Number(b.product_id))
.map(item => ({
id: item.product_id,
label: item.product_name || `产品${item.product_id}`,

View File

@@ -7,6 +7,16 @@ export function safeTruncate(num, decimals = 2) {
return (scaled / factor).toFixed(decimals)
}
function toTruncatedCents(num) {
if (Number.isNaN(num) || !Number.isFinite(num))
return 0
return Math.trunc((num + Number.EPSILON) * 100)
}
function centsToFixed(cents) {
return (cents / 100).toFixed(2)
}
function calculatePlatformOverpricingCost(price, config) {
if (price <= config.p_pricing_standard)
return 0
@@ -37,10 +47,12 @@ export function calculatePromotionPricing(priceInput, config) {
const platformOverpricingCost = calculatePlatformOverpricingCost(price, config)
const superiorOverpricingCost = calculateSuperiorOverpricingCost(price, config)
const totalCost = baseCost + platformOverpricingCost + superiorOverpricingCost
const revenue = price - totalCost
const priceCents = toTruncatedCents(price)
const costCents = toTruncatedCents(totalCost)
const revenueCents = priceCents - costCents
return {
costPrice: safeTruncate(totalCost),
promotionRevenue: safeTruncate(revenue),
costPrice: centsToFixed(costCents),
promotionRevenue: centsToFixed(revenueCents),
}
}