Commit 7c9a5a0dfca004b03618218c6c818dfcccc1cda8
1 parent
d64fe3d7
feat(product): 更新产品价格显示逻辑
- 在 ProductServiceImpl 中添加价格计算逻辑,将原始价格除以 0.7 后乘以 0.148,保留两位小数 - 在 canrud.ftl 模板中添加美元符号前缀显示价格
Showing
2 changed files
with
6 additions
and
2 deletions
shop/src/main/java/com/canrd/shop/service/impl/ProductServiceImpl.java
@@ -348,7 +348,11 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, ProductDO> im | @@ -348,7 +348,11 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, ProductDO> im | ||
348 | records.forEach(product -> { | 348 | records.forEach(product -> { |
349 | if (productPriceShow){ | 349 | if (productPriceShow){ |
350 | if (Objects.nonNull(pId2ttMinPriceMap.get(product.getId()))){ | 350 | if (Objects.nonNull(pId2ttMinPriceMap.get(product.getId()))){ |
351 | - product.setPrice(pId2ttMinPriceMap.get(product.getId())); | 351 | + BigDecimal computedPrice = pId2ttMinPriceMap.get(product.getId()) |
352 | + .divide(new BigDecimal("0.7"), 2, RoundingMode.HALF_UP) | ||
353 | + .multiply(new BigDecimal("0.148")) | ||
354 | + .setScale(2, RoundingMode.HALF_UP); | ||
355 | + product.setPrice(computedPrice); | ||
352 | } | 356 | } |
353 | } | 357 | } |
354 | //将productDO的productimageliststore解析为map | 358 | //将productDO的productimageliststore解析为map |
shop/src/main/resources/templates/canrud.ftl
@@ -27202,7 +27202,7 @@ | @@ -27202,7 +27202,7 @@ | ||
27202 | </div> | 27202 | </div> |
27203 | <div data-v-f467c4e7="" class="v-card-text tw-text-left font-weight-medium title"> | 27203 | <div data-v-f467c4e7="" class="v-card-text tw-text-left font-weight-medium title"> |
27204 | <!--商品--> | 27204 | <!--商品--> |
27205 | - <h3 data-v-f6bc2735="" style="color: red;"> ${item.price!""}</h3> | 27205 | + <h3 data-v-f6bc2735="" style="color: red;"> $${item.price!""}</h3> |
27206 | <h4 data-v-f467c4e7="">${item.name}</h4> | 27206 | <h4 data-v-f467c4e7="">${item.name}</h4> |
27207 | </div> | 27207 | </div> |
27208 | <!----><span class="v-card__overlay"></span><span | 27208 | <!----><span class="v-card__overlay"></span><span |