Commit bf0a44477fd34f088e547e3138ddb64c16e50f20
1 parent
9e2b3f66
feat(product): 添加产品原价字段并更新相关逻辑
- 在 ProductDO 中添加 originMinPrice 和 originMaxPrice 字段 - 在 ProductServiceImpl 中计算并设置产品的原价信息 - 修改数据库连接配置,使用测试环境数据库
Showing
4 changed files
with
18 additions
and
6 deletions
shop/src/main/java/com/canrd/shop/module/dto/ProductDO.java
@@ -144,5 +144,9 @@ public class ProductDO implements Serializable { | @@ -144,5 +144,9 @@ public class ProductDO implements Serializable { | ||
144 | private BigDecimal minPrice; | 144 | private BigDecimal minPrice; |
145 | @TableField(exist = false) | 145 | @TableField(exist = false) |
146 | private BigDecimal maxPrice; | 146 | private BigDecimal maxPrice; |
147 | + @TableField(exist = false) | ||
148 | + private BigDecimal originMinPrice; | ||
149 | + @TableField(exist = false) | ||
150 | + private BigDecimal originMaxPrice; | ||
147 | 151 | ||
148 | } | 152 | } |
shop/src/main/java/com/canrd/shop/service/impl/ProductServiceImpl.java
@@ -407,18 +407,26 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, ProductDO> im | @@ -407,18 +407,26 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, ProductDO> im | ||
407 | records.forEach(product -> { | 407 | records.forEach(product -> { |
408 | if (productPriceShow){ | 408 | if (productPriceShow){ |
409 | if (Objects.nonNull(pId2ttMinPriceMap.get(product.getId()))){ | 409 | if (Objects.nonNull(pId2ttMinPriceMap.get(product.getId()))){ |
410 | + BigDecimal originMinPrice = pId2ttMinPriceMap.get(product.getId()) | ||
411 | + .divide(new BigDecimal("0.7"), 2, RoundingMode.HALF_UP) | ||
412 | + .divide(new BigDecimal("0.7"), 2, RoundingMode.HALF_UP) | ||
413 | + .setScale(2, RoundingMode.HALF_UP); | ||
410 | BigDecimal computedPrice = pId2ttMinPriceMap.get(product.getId()) | 414 | BigDecimal computedPrice = pId2ttMinPriceMap.get(product.getId()) |
411 | .divide(new BigDecimal("0.7"), 2, RoundingMode.HALF_UP) | 415 | .divide(new BigDecimal("0.7"), 2, RoundingMode.HALF_UP) |
412 | - .multiply(new BigDecimal("0.148")) | ||
413 | .setScale(2, RoundingMode.HALF_UP); | 416 | .setScale(2, RoundingMode.HALF_UP); |
414 | product.setPrice(computedPrice); | 417 | product.setPrice(computedPrice); |
418 | + product.setOriginMinPrice(originMinPrice); | ||
415 | } | 419 | } |
416 | if (Objects.nonNull(pId3ttMaxPriceMap.get(product.getId()))){ | 420 | if (Objects.nonNull(pId3ttMaxPriceMap.get(product.getId()))){ |
421 | + BigDecimal originMaxPrice = pId2ttMinPriceMap.get(product.getId()) | ||
422 | + .divide(new BigDecimal("0.7"), 2, RoundingMode.HALF_UP) | ||
423 | + .divide(new BigDecimal("0.7"), 2, RoundingMode.HALF_UP) | ||
424 | + .setScale(2, RoundingMode.HALF_UP); | ||
417 | BigDecimal computedPrice = pId3ttMaxPriceMap.get(product.getId()) | 425 | BigDecimal computedPrice = pId3ttMaxPriceMap.get(product.getId()) |
418 | .divide(new BigDecimal("0.7"), 2, RoundingMode.HALF_UP) | 426 | .divide(new BigDecimal("0.7"), 2, RoundingMode.HALF_UP) |
419 | - .multiply(new BigDecimal("0.148")) | ||
420 | .setScale(2, RoundingMode.HALF_UP); | 427 | .setScale(2, RoundingMode.HALF_UP); |
421 | product.setMaxPrice(computedPrice); | 428 | product.setMaxPrice(computedPrice); |
429 | + product.setOriginMaxPrice(originMaxPrice); | ||
422 | } | 430 | } |
423 | } | 431 | } |
424 | //将productDO的productimageliststore解析为map | 432 | //将productDO的productimageliststore解析为map |
shop/src/main/resources/application-test.yml
@@ -57,10 +57,10 @@ spring: | @@ -57,10 +57,10 @@ spring: | ||
57 | testWhileIdle: true | 57 | testWhileIdle: true |
58 | testOnBorrow: true | 58 | testOnBorrow: true |
59 | testOnReturn: true | 59 | testOnReturn: true |
60 | - password: 123456 | 60 | + password: 20011027zZ |
61 | time-between-eviction-runs-millis: 1000 | 61 | time-between-eviction-runs-millis: 1000 |
62 | - url: jdbc:mysql://192.168.31.242:13306/canrd_overseas?useUnicode=true&characterEncoding=UTF-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai&useSSL=false&autoReconnect=true&failOverReadOnly=false&maxReconnects=10&allowMultiQueries=true&useAffectedRows=true&autoReconnectForPools=true | ||
63 | - username: root | 62 | + url: jdbc:mysql://rm-wz9q8019sj272b0y0lo.mysql.rds.aliyuncs.com/canrd_overseas?useUnicode=true&characterEncoding=UTF-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai&useSSL=false&autoReconnect=true&failOverReadOnly=false&maxReconnects=10&allowMultiQueries=true&useAffectedRows=true&autoReconnectForPools=true |
63 | + username: zgtroot | ||
64 | 64 | ||
65 | 65 | ||
66 | #logging: | 66 | #logging: |
shop/src/main/resources/application.yml