-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
190 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
<script setup lang="ts"> | ||
const logStore = useLatestLogs(); | ||
const settingStore = useSettingStore(); | ||
const props = defineProps<{ isComeAndGo: boolean }>(); | ||
type TransactionRoute = { | ||
originatingCity: string; | ||
destinationCity: string; | ||
}; | ||
// 跑商路线 | ||
const transactionRoute = computed(() => { | ||
const oneWayRoute: TransactionRoute[] = []; | ||
cities.forEach(originatingCity => { | ||
cities.forEach(destinationCity => { | ||
if (originatingCity.name !== destinationCity.name) { | ||
// 存在往返路线 | ||
const isExistComeAndGoRoute = oneWayRoute.some(route => { | ||
return route.originatingCity === destinationCity.name && route.destinationCity === originatingCity.name; | ||
}); | ||
if (props.isComeAndGo && isExistComeAndGoRoute) return; | ||
oneWayRoute.push({ | ||
originatingCity: originatingCity.name, | ||
destinationCity: destinationCity.name | ||
}); | ||
} | ||
}); | ||
}); | ||
return oneWayRoute; | ||
}); | ||
const sortedTransactionRoute = computed(() => { | ||
// 计算每条路线的单票利润 | ||
const transactionRouteWithProfit = transactionRoute.value.map(route => { | ||
return { | ||
...route, | ||
profit: getCityProfit(route.originatingCity, route.destinationCity) | ||
+ (props.isComeAndGo ? getCityProfit(route.destinationCity, route.originatingCity) : 0) | ||
}; | ||
}); | ||
// 按利润排序 | ||
return transactionRouteWithProfit.toSorted((a, b) => b.profit - a.profit); | ||
}); | ||
const rankBarWidthPercent = (profit: number) => { | ||
const maxProfit = sortedTransactionRoute.value[0].profit; | ||
const minProfit = sortedTransactionRoute.value[sortedTransactionRoute.value.length - 1].profit; | ||
return ((profit - minProfit) / (maxProfit - minProfit)) * 90; | ||
}; | ||
const getCityProfit = (originatingCity: string, destinationCity: string) => { | ||
const allProduct = cities.find(city => city.name === originatingCity)?.products; | ||
const cityAllProductPerTicketProfit = allProduct?.reduce((result, currentProduct) => { | ||
// 仅计算展示的商品 | ||
if (!currentProduct.valuable) return result; | ||
const sourceCityPrice = logStore.getLatestLog(originatingCity, currentProduct.name, originatingCity)?.price || 0; | ||
const targetCityPrice = logStore.getLatestLog(originatingCity, currentProduct.name, destinationCity)?.price || 0; | ||
const profit = settingStore.getProfitWithRule(sourceCityPrice, targetCityPrice); | ||
const perTicketProfit = profit * (currentProduct.baseVolume || 0); | ||
return result + perTicketProfit; | ||
}, 0); | ||
return cityAllProductPerTicketProfit || 0; | ||
}; | ||
</script> | ||
|
||
<template> | ||
<Card class="w-full"> | ||
<CardContent class="pt-2"> | ||
<Table class="table-fixed"> | ||
<TableHeader> | ||
<TableRow> | ||
<TableHead class="border-r min-w-[160px] max-w-[240px]">跑商路线</TableHead> | ||
<TableHead class="min-w-[100px] w-1/2">单票利润</TableHead> | ||
</TableRow> | ||
</TableHeader> | ||
<TableBody> | ||
<TableRow | ||
v-for="route in sortedTransactionRoute" | ||
:key="`${route.originatingCity}->${route.destinationCity}`" | ||
> | ||
<TableCell class="border-r"> | ||
<div class="flex flex-col sm:items-center sm:flex-row"> | ||
<span>{{ route.originatingCity }}</span> | ||
<span v-if="props.isComeAndGo" class="i-icon-park-outline-transfer-data m-1 rotate-90 sm:rotate-0"></span> | ||
<span v-else class="i-icon-park-outline-arrow-right m-1 rotate-90 sm:rotate-0"></span> | ||
<span>{{ route.destinationCity }}</span> | ||
</div> | ||
</TableCell> | ||
<TableCell> | ||
<div class="w-full"> | ||
{{ route.profit }} | ||
<div :style="{ width: `${rankBarWidthPercent(route.profit)}%` }" class="h-2 bg-primary"></div> | ||
</div> | ||
</TableCell> | ||
</TableRow> | ||
</TableBody> | ||
</Table> | ||
</CardContent> | ||
</Card> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<script setup lang="ts"> | ||
import { ref } from 'vue'; | ||
const settingStore = useSettingStore(); | ||
const isComeAndGo = ref('往返'); // 是否往返 | ||
</script> | ||
|
||
<template> | ||
<div class="main pb-12"> | ||
<div class="mb-4"> | ||
<span href="#" class="block mt-1 text-lg leading-tight font-bold text-base-800">跑商路线规划</span> | ||
<div class="mt-2 px-2 text-slate-500"> | ||
<p class="mb-2">亲爱的列车长们: </p> | ||
<p class="ml-2">这是阿妮塔科技为您整理的两地运输路线收益排行。</p> | ||
<p class="ml-2">我们建议选择城市售价靠前的商品(一般为城市特产品)作为主攻对象,每次使用5本以内的进货采购书将货物尽可能填满车厢,这样可以在单程收益和进货采购数使用量之间维持一定平衡。</p> | ||
<p class="ml-2">希望这份排行能为您的运输之路提供参考。</p> | ||
<p class="ml-2">祝各位列车长旅途顺利,财源滚滚!</p> | ||
<p class="my-2">阿妮塔科技敬上</p> | ||
注:各位列车长的个性化配置页面正在开发中,目前展示的收益仅考虑特产商品,计算参数为(砍价抬价:{{ settingStore.priceChangeRate * 100 }}%,城市税率:{{ settingStore.taxRate * 100 }}%,特产品交易量仅为基础值)。 | ||
</div> | ||
</div> | ||
|
||
<div class="flex flex-wrap gap-4 mb-4"> | ||
<Button | ||
v-for="item in ['单程', '往返']" | ||
:key="item" | ||
@click="isComeAndGo = item" | ||
:variant="isComeAndGo == item ? 'default' : 'outline'" | ||
size="sm" | ||
>{{ item }}</Button> | ||
</div> | ||
|
||
<div class="space-y-4"> | ||
<PerTicketProfitRouteTable :isComeAndGo="isComeAndGo == '往返'" /> | ||
</div> | ||
</div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters