fix(fulfillment): 稳定任务列表排序并展示任务 ID
This commit is contained in:
@@ -308,6 +308,45 @@ class TestSyncAndMapping(_Base):
|
||||
|
||||
assert listed["pagination"]["total"] == 0
|
||||
|
||||
def test_list_order_is_stable_by_paid_time_not_updated_at(self):
|
||||
first = self.task()
|
||||
second = PlatformFulfillmentTask(
|
||||
source_system="order_site",
|
||||
source_order_id="108",
|
||||
source_order_item_id="109",
|
||||
source_fulfillment_id="209",
|
||||
platform_order_id="ORDER-109",
|
||||
provider="91kaquan",
|
||||
shop_id="shop-1",
|
||||
shop_name="测试店",
|
||||
sku_code=INTERNAL_SKU,
|
||||
sku_name=INTERNAL_SKU,
|
||||
internal_sku_key=INTERNAL_SKU,
|
||||
quantity=1,
|
||||
order_amount_fen=9900,
|
||||
target_platform="douyu",
|
||||
scope="elite",
|
||||
commodity_mapping_id=first.commodity_mapping_id,
|
||||
commodity_id=COMMODITY,
|
||||
required_points=1280,
|
||||
binding_status="not_started",
|
||||
execution_status="ready",
|
||||
exchange_status="not_started",
|
||||
paid_at=NOW + timedelta(minutes=1),
|
||||
created_at=NOW,
|
||||
updated_at=NOW,
|
||||
)
|
||||
self.session.add(second)
|
||||
self.session.commit()
|
||||
|
||||
# 模拟 worker 重试:旧订单的 updated_at 变得更新,但列表顺序不能跳。
|
||||
first.updated_at = NOW + timedelta(minutes=10)
|
||||
self.session.commit()
|
||||
|
||||
listed = service.list_tasks(self.session)
|
||||
|
||||
assert [item["id"] for item in listed["items"]] == [second.id, first.id]
|
||||
|
||||
def test_list_includes_recent_paid_task_created_before_order_match_cutoff(self):
|
||||
mapping = self.mapping()
|
||||
task = PlatformFulfillmentTask(
|
||||
|
||||
@@ -911,7 +911,7 @@ def list_tasks(
|
||||
total = query.count()
|
||||
rows = (
|
||||
query.order_by(
|
||||
PlatformFulfillmentTask.updated_at.desc(),
|
||||
PlatformFulfillmentTask.paid_at.desc(),
|
||||
PlatformFulfillmentTask.id.desc(),
|
||||
)
|
||||
.offset((max(1, page) - 1) * max(1, page_size))
|
||||
|
||||
@@ -586,6 +586,16 @@ export default function PlatformFulfillmentPage() {
|
||||
};
|
||||
|
||||
const columns: ColumnsType<PlatformFulfillmentTask> = [
|
||||
{
|
||||
title: '任务 ID',
|
||||
dataIndex: 'id',
|
||||
key: 'id',
|
||||
width: 100,
|
||||
fixed: 'left',
|
||||
render: (value: number) => (
|
||||
<Text copyable={{ text: String(value) }}>#{value}</Text>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: '订单 / 商品',
|
||||
key: 'order',
|
||||
@@ -805,7 +815,7 @@ export default function PlatformFulfillmentPage() {
|
||||
loading={loading}
|
||||
columns={columns}
|
||||
dataSource={rows}
|
||||
scroll={{ x: 1500 }}
|
||||
scroll={{ x: 1600 }}
|
||||
pagination={{
|
||||
current: page,
|
||||
pageSize,
|
||||
|
||||
Reference in New Issue
Block a user