Commit bf0a44477fd34f088e547e3138ddb64c16e50f20

Authored by 曾国涛
1 parent 9e2b3f66

feat(product): 添加产品原价字段并更新相关逻辑

- 在 ProductDO 中添加 originMinPrice 和 originMaxPrice 字段
- 在 ProductServiceImpl 中计算并设置产品的原价信息
- 修改数据库连接配置,使用测试环境数据库
shop/src/main/java/com/canrd/shop/module/dto/ProductDO.java
... ... @@ -144,5 +144,9 @@ public class ProductDO implements Serializable {
144 144 private BigDecimal minPrice;
145 145 @TableField(exist = false)
146 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 407 records.forEach(product -> {
408 408 if (productPriceShow){
409 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 414 BigDecimal computedPrice = pId2ttMinPriceMap.get(product.getId())
411 415 .divide(new BigDecimal("0.7"), 2, RoundingMode.HALF_UP)
412   - .multiply(new BigDecimal("0.148"))
413 416 .setScale(2, RoundingMode.HALF_UP);
414 417 product.setPrice(computedPrice);
  418 + product.setOriginMinPrice(originMinPrice);
415 419 }
416 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 425 BigDecimal computedPrice = pId3ttMaxPriceMap.get(product.getId())
418 426 .divide(new BigDecimal("0.7"), 2, RoundingMode.HALF_UP)
419   - .multiply(new BigDecimal("0.148"))
420 427 .setScale(2, RoundingMode.HALF_UP);
421 428 product.setMaxPrice(computedPrice);
  429 + product.setOriginMaxPrice(originMaxPrice);
422 430 }
423 431 }
424 432 //将productDO的productimageliststore解析为map
... ...
shop/src/main/resources/application-test.yml
... ... @@ -57,10 +57,10 @@ spring:
57 57 testWhileIdle: true
58 58 testOnBorrow: true
59 59 testOnReturn: true
60   - password: 123456
  60 + password: 20011027zZ
61 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 66 #logging:
... ...
shop/src/main/resources/application.yml
... ... @@ -3,7 +3,7 @@ server:
3 3  
4 4 spring:
5 5 profiles:
6   - active: prod
  6 + active: test
7 7 mvc:
8 8 throw-exception-if-no-handler-found: true
9 9 resources:
... ...