Skip to content
This repository has been archived by the owner on Sep 18, 2024. It is now read-only.

Commit

Permalink
feat[trade]add latest time
Browse files Browse the repository at this point in the history
  • Loading branch information
汉广 committed Jun 25, 2023
1 parent 19f95fc commit cf6858c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
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

0 comments on commit cf6858c

Please sign in to comment.