fix(subscription): 修复价格单位错误导致金额多100倍问题

- 确认 product.price 实际单位为分,修正所有价格计算需除以100转为元
- 后端 generatePayQrcode 方法价格计算改为 price/100,年付按10个月计费,季度付按3个月计费
- 前端 dashboard/index.vue 月付价格除以100,年付价格按月付价乘以10计算,保持与后端一致
- 保持 subscribe 价格计算逻辑,避免价格单位不一致的错误
- 修复后价格显示和支付逻辑统一,解决用户反馈金额偏大问题
This commit is contained in:
2026-07-15 14:12:54 +08:00
parent 29a18ffbc6
commit 09af76e4ea
2 changed files with 11 additions and 4 deletions

View File

@@ -78,3 +78,10 @@
- 参考 `websopy-pc/app/pages/console/pay/[subscriptionNo].vue`:它用 `subscribe` 创建订阅 + `pay(id,'wechat')` 生成二维码(两步),避开了 `generatePayQrcode`,所以没遇到此 bug。
- 修复(后端 `AppSubscriptionController.java` generatePayQrcode 方法):补全 `setPriceType(product.getPriceType())` + `setOriginalPrice`/`setPayStatus(0)`/`setTenantId`,对齐 subscribe。**前端无需改动**,重启后端即可。
- 注意:`subscribe` 价格计算用 `price/100`(当分转元),`generatePayQrcode` 直接用 `price`当元两者不一致schema 标注 price 为「元」,故 `generatePayQrcode` 价格逻辑更合理,保留不动。
## 修复价格多了100倍product.price 实际单位是分)
- 用户反馈:`generatePayQrcode` 算出的金额多了100倍。确认 `product.price` 实际存的是**分**(非 schema 标注的元),故 `subscribe``/100` 是对的,`generatePayQrcode` 直接用 price 是错的。
- 后端 `AppSubscriptionController.generatePayQrcode` 价格计算改为 `price/100` 转元(对齐 subscribe年付按10个月*10对齐 subscribe 年付优惠),季付*3月付*1。
- 前端 `dashboard/index.vue` 参考价同步修正:`monthPrice = price/100``yearPrice = monthPrice*10`(原为 price 直接 + *12
- 结论product.price 实际单位是**分**,所有价格展示/计算都需 /100 转元。

View File

@@ -410,10 +410,10 @@ const isFreeProduct = computed(() => {
return p.priceType === 'free' || !p.price || Number(p.price) === 0;
});
// 月付参考价格(元)
const monthPrice = computed(() => Number(currentProduct.value?.price) || 0);
// 年付参考价格(元,按12个月)
const yearPrice = computed(() => monthPrice.value * 12);
// 月付参考价格(product.price 单位为分除以100转为元)
const monthPrice = computed(() => (Number(currentProduct.value?.price) || 0) / 100);
// 年付参考价格按10个月计费,对齐后端 subscribe/generatePayQrcode 年付优惠
const yearPrice = computed(() => monthPrice.value * 10);
// 距到期天数负数表示已过期null 表示无到期时间
const daysToExpire = computed(() => {