Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat[trade]add latest time #251

Merged
merged 1 commit into from
Jun 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/plugins/jx3/price_goods/lib/GoodsPrice.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
class GoodsPriceRecord:
def __init__(self) -> None:
self.updated: int = 0

def updated_time(self):
self.updated = time.time()


class GoodsPriceSummary(GoodsPriceRecord):
def __init__(self, data: dict = None) -> None:
if data is None:
Expand All @@ -33,6 +35,7 @@ def __init__(self, prices: list = None) -> None:
key = ['created', 'n_count', 'unit_price']
self.prices = [[x.get(k) for k in key] for x in prices] # 创建时间 数量 单价
self.valid_price = self.get_valid_price()
self.latest = None # 最新数据时间
super().__init__()

def get_valid_price(self, prices: list = None):
Expand All @@ -46,6 +49,7 @@ def get_valid_price(self, prices: list = None):
self.price_valid = GoodsPriceDetail.InvalidPrice
return self.price_valid
prices.sort(key=lambda x: x[2]) # 按价格升序排列
self.latest = max(prices, key=lambda x: x[1])

total_price = 0
self.price_lowest = prices[0][2]
Expand Down
8 changes: 3 additions & 5 deletions src/views/jx3/trade/goods_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -59,22 +59,20 @@
</div>
</template>
</el-table-column>
<el-table-column label="更新时间" width="150px">
<template #default="scope">{{ formatTime(scope.row.price.UpdatedAt) }}</template>
</el-table-column>
<el-table-column label="均价" width="100px">
<template #default="scope">
<span>{{ convertGold(scope.row.price.AvgPrice)[0] }}</span>
<img :src="convertGold(scope.row.price.AvgPrice)[1]" />
</template>
</el-table-column>
<el-table-column v-if="any_price_current_available" label="实时" width="100px">
<el-table-column v-if="any_price_current_available" label="实时" width="200px">
<template #default="scope">
<span v-if="scope.row.current_price&&scope.row.current_price.price_valid">
<span>{{ convertGold(scope.row.current_price.price_valid)[0] }}</span>
<img :src="convertGold(scope.row.current_price.price_valid)[1]" />
<span v-if="scope.row.current_price.latest">({{ parseTime(scope.row.current_price.latest) }})</span>
</span>
<span v-else style="color:#cccccc">暂无</span>
<span v-else style="color:#cccccc">暂无统计</span>
</template>
</el-table-column>
<el-table-column label="底价" width="100px">
Expand Down
6 changes: 2 additions & 4 deletions src/views/jx3/trade/goods_list_fav.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,6 @@
</div>
</template>
</el-table-column>
<el-table-column label="更新时间" width="150px">
<template #default="scope">{{ formatTime(scope.row.price.UpdatedAt) }}</template>
</el-table-column>
<el-table-column label="均价" width="100px">
<template #default="scope">
<span>{{ convertGold(scope.row.price.AvgPrice)[0] }}</span>
Expand All @@ -69,8 +66,9 @@
<span v-if="scope.row.current_price&&scope.row.current_price.price_valid">
<span>{{ convertGold(scope.row.current_price.price_valid)[0] }}</span>
<img :src="convertGold(scope.row.current_price.price_valid)[1]" />
<span v-if="scope.row.current_price.latest">({{ parseTime(scope.row.current_price.latest) }})</span>
</span>
<span v-else style="color:#cccccc">暂无</span>
<span v-else style="color:#cccccc">暂无统计</span>
</template>
</el-table-column>
<el-table-column label="底价" width="100px">
Expand Down