fix: load mall claimed counts from database

This commit is contained in:
richjohnrambo
2026-10-19 00:02:35 +08:00
parent 8b773a1a1f
commit 804318e5f5
3 changed files with 3 additions and 10 deletions
@@ -743,7 +743,7 @@ GET /v1/manual-products?page=1&page_size=20&category_id=0
}
```
金额单位为分。现有 `hg_product` 没有独立摘要字段,`summary` 由商品详情转换为纯文本后截取前 120 个字符。`claimed_count` 统计该商品 `order_type=3` 且状态不是已取消或失败的订单。`is_limited` 在商品配置了 `end_at` 时为 `true`,客户端使用该字段区分限时商品,不根据分类名称推断;`start_at`、`end_at` 为商品展示有效期。
金额单位为分。现有 `hg_product` 没有独立摘要字段,`summary` 由商品详情转换为纯文本后截取前 120 个字符。`claimed_count` 直接读取商品表中的固定展示数,不在页面或接口中重新计算。`is_limited` 在商品配置了 `end_at` 时为 `true`,客户端使用该字段区分限时商品,不根据分类名称推断;`start_at`、`end_at` 为商品展示有效期。
### 8.2 商品详情
+1 -2
View File
@@ -73,8 +73,7 @@ func manualProductSelectSQL() string {
COALESCE(p.detail_html,'') AS detail_html,(p.is_recommended=1) AS is_recommended,
COALESCE(DATE_FORMAT(p.start_at,'%Y-%m-%dT%H:%i:%sZ'),'') AS start_at,
COALESCE(DATE_FORMAT(p.end_at,'%Y-%m-%dT%H:%i:%sZ'),'') AS end_at,
(SELECT COUNT(*) FROM hg_trade_order o WHERE o.tenant_id=p.tenant_id AND o.product_id=p.id
AND o.order_type=3 AND o.order_status NOT IN (7,8)) AS claimed_count,
p.claimed_count,
DATE_FORMAT(p.created_at,'%Y-%m-%dT%H:%i:%sZ') AS created_at,
DATE_FORMAT(p.updated_at,'%Y-%m-%dT%H:%i:%sZ') AS updated_at
FROM hg_product p JOIN hg_product_category c
+1 -7
View File
@@ -18,7 +18,7 @@
<n-icon v-else :component="ImageOutline" />
</span>
<strong>{{ item.name }}</strong>
<small>已领取:{{ displayClaimedCount(item) }}</small>
<small>已领取:{{ item.claimed_count || 0 }}</small>
</button>
</div>
</AsyncState>
@@ -76,12 +76,6 @@
const product = ref<any>();
let listController: AbortController | undefined;
function displayClaimedCount(item: any) {
const claimedCount = Number(item?.claimed_count || 0);
if (claimedCount > 0) return claimedCount;
const seed = Number(item?.id || 1);
return 100 + ((seed * 137 + 83) % 401);
}
function openSupport() {
router.push({ name: 'MobileSupport' });
}