|
@@ -411,8 +411,13 @@ def get_inquiry_detail(
|
|
|
category_name = None
|
|
category_name = None
|
|
|
first_category_id = None
|
|
first_category_id = None
|
|
|
first_category_name = None
|
|
first_category_name = None
|
|
|
|
|
+ first_category_image = None
|
|
|
|
|
+ first_category_sort_order = 0
|
|
|
second_category_id = None
|
|
second_category_id = None
|
|
|
second_category_name = None
|
|
second_category_name = None
|
|
|
|
|
+ second_category_image = None
|
|
|
|
|
+ second_category_sort_order = 0
|
|
|
|
|
+ product_sort_order = int(getattr(product, "sort_order", None) or 0) if product else 0
|
|
|
unit_name = None
|
|
unit_name = None
|
|
|
if product and product.category_id:
|
|
if product and product.category_id:
|
|
|
category = category_crud.get(db, product.category_id)
|
|
category = category_crud.get(db, product.category_id)
|
|
@@ -422,11 +427,18 @@ def get_inquiry_detail(
|
|
|
parent_category = category_crud.get(db, category.parent_id)
|
|
parent_category = category_crud.get(db, category.parent_id)
|
|
|
first_category_id = parent_category.id if parent_category else category.id
|
|
first_category_id = parent_category.id if parent_category else category.id
|
|
|
first_category_name = parent_category.name if parent_category else category.name
|
|
first_category_name = parent_category.name if parent_category else category.name
|
|
|
|
|
+ first_category_image = parent_category.image_url if parent_category else category.image_url
|
|
|
|
|
+ first_category_sort_order = int(parent_category.sort_order or 0) if parent_category else int(category.sort_order or 0)
|
|
|
second_category_id = category.id
|
|
second_category_id = category.id
|
|
|
second_category_name = category.name
|
|
second_category_name = category.name
|
|
|
|
|
+ second_category_image = category.image_url
|
|
|
|
|
+ second_category_sort_order = int(category.sort_order or 0)
|
|
|
else:
|
|
else:
|
|
|
first_category_id = category.id
|
|
first_category_id = category.id
|
|
|
first_category_name = category.name
|
|
first_category_name = category.name
|
|
|
|
|
+ first_category_image = category.image_url
|
|
|
|
|
+ first_category_sort_order = int(category.sort_order or 0)
|
|
|
|
|
+ second_category_sort_order = int(category.sort_order or 0)
|
|
|
if product and product.unit_id:
|
|
if product and product.unit_id:
|
|
|
unit = unit_crud.get(db, product.unit_id)
|
|
unit = unit_crud.get(db, product.unit_id)
|
|
|
unit_name = unit.name if unit else None
|
|
unit_name = unit.name if unit else None
|
|
@@ -440,15 +452,35 @@ def get_inquiry_detail(
|
|
|
"categoryName": category_name,
|
|
"categoryName": category_name,
|
|
|
"firstCategoryId": first_category_id,
|
|
"firstCategoryId": first_category_id,
|
|
|
"firstCategoryName": first_category_name,
|
|
"firstCategoryName": first_category_name,
|
|
|
|
|
+ "firstCategoryImage": first_category_image,
|
|
|
"secondCategoryId": second_category_id,
|
|
"secondCategoryId": second_category_id,
|
|
|
"secondCategoryName": second_category_name,
|
|
"secondCategoryName": second_category_name,
|
|
|
|
|
+ "secondCategoryImage": second_category_image,
|
|
|
"unitId": product.unit_id if product else None,
|
|
"unitId": product.unit_id if product else None,
|
|
|
"unitName": unit_name,
|
|
"unitName": unit_name,
|
|
|
"measureValue": float(product.measure_value) if product and product.measure_value is not None else None,
|
|
"measureValue": float(product.measure_value) if product and product.measure_value is not None else None,
|
|
|
"lastPrice": latest_quote_price_map.get(item.product_id),
|
|
"lastPrice": latest_quote_price_map.get(item.product_id),
|
|
|
- "createAt": str(item.create_at) if item.create_at else None
|
|
|
|
|
|
|
+ "createAt": str(item.create_at) if item.create_at else None,
|
|
|
|
|
+ "_firstCategorySortOrder": first_category_sort_order,
|
|
|
|
|
+ "_secondCategorySortOrder": second_category_sort_order,
|
|
|
|
|
+ "_productSortOrder": product_sort_order
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
|
|
+ # 与客户端首页商品区一致:一级分类排序 -> 二级分类排序 -> 商品排序 -> 名称 -> id
|
|
|
|
|
+ item_details.sort(
|
|
|
|
|
+ key=lambda row: (
|
|
|
|
|
+ int(row.get("_firstCategorySortOrder") or 0),
|
|
|
|
|
+ int(row.get("_secondCategorySortOrder") or 0),
|
|
|
|
|
+ int(row.get("_productSortOrder") or 0),
|
|
|
|
|
+ (row.get("productName") or "").lower(),
|
|
|
|
|
+ row.get("productId") or "",
|
|
|
|
|
+ )
|
|
|
|
|
+ )
|
|
|
|
|
+ for row in item_details:
|
|
|
|
|
+ row.pop("_firstCategorySortOrder", None)
|
|
|
|
|
+ row.pop("_secondCategorySortOrder", None)
|
|
|
|
|
+ row.pop("_productSortOrder", None)
|
|
|
|
|
+
|
|
|
return success_response({
|
|
return success_response({
|
|
|
"id": inquiry.id,
|
|
"id": inquiry.id,
|
|
|
"title": inquiry.title,
|
|
"title": inquiry.title,
|