瀏覽代碼

修改bug

zjy 6 天之前
父節點
當前提交
b0484409e9

+ 5 - 1
alien-entity/src/main/java/shop/alien/entity/second/SecondGoods.java

@@ -50,7 +50,11 @@ public class SecondGoods implements Serializable {
 
     @TableField("price")
     @ApiModelProperty(value = "商品价格(元,保留小数后两位)")
-    private BigDecimal price;
+    private String price;
+
+    @TableField("price")
+    @ApiModelProperty(value = "商品价格(元,保留小数后两位)")
+    private BigDecimal amount;
 
     @TableField(exist = false)
     private Integer auditRecordId;

+ 5 - 1
alien-entity/src/main/resources/mapper/second/SecondGoodsInfoMapper.xml

@@ -8,6 +8,7 @@
         <result column="title" property="title" jdbcType="VARCHAR"/>
         <result column="description" property="description" jdbcType="VARCHAR"/>
         <result column="price" property="price" jdbcType="DECIMAL"/>
+        <result column="amount" property="amount" jdbcType="DECIMAL"/>
         <result column="position" property="position" jdbcType="VARCHAR"/>
         <result column="like_count" property="likeCount" jdbcType="INTEGER"/>
         <result column="collect_count" property="collectCount" jdbcType="INTEGER"/>
@@ -44,6 +45,7 @@
             g.title,
             g.description,
             g.price,
+            g.price as amount,
             g.position,
             g.like_count,
             g.collect_count,
@@ -85,6 +87,7 @@
             g.title,
             g.description,
             g.price,
+            g.price as amount,
             ROUND(ST_Distance_Sphere(ST_GeomFromText(CONCAT('POINT(', REPLACE(#{position}, ',', ' '), ')' )), ST_GeomFromText(CONCAT('POINT(', REPLACE(g.position, ',', ' '), ')' ))) / 1000, 2) AS dist,
             g.like_count,
             g.collect_count,
@@ -158,6 +161,7 @@
             g.title,
             g.description,
             g.price,
+            g.price as amount,
             g.position,
             g.like_count,
             g.collect_count,
@@ -198,7 +202,7 @@
             g.user_id,
             g.title,
             g.description,
-            g.price,
+            g.price as amount,
             g.position,
             g.like_count,
             g.collect_count,

+ 1 - 1
alien-second/src/main/java/shop/alien/second/service/impl/SecondGoodsReportingServiceImpl.java

@@ -78,7 +78,7 @@ public class SecondGoodsReportingServiceImpl implements SecondGoodsReportingServ
         if (lifeUserViolation.getReportContextType().equals("4")) {
             // 获取商品信息
             SecondGoods secondGoods = secondGoodsMapper.selectById(lifeUserViolation.getBusinessId());
-            secondReportingVo.setPrice(secondGoods.getPrice() != null ? secondGoods.getPrice().setScale(2, BigDecimal.ROUND_HALF_UP).toString() : null);
+            secondReportingVo.setPrice(secondGoods.getPrice() != null ? secondGoods.getAmount().setScale(2, BigDecimal.ROUND_HALF_UP).toString() : null);
             secondReportingVo.setHomeImage(secondGoods.getHomeImage());
             secondReportingVo.setTitle(secondGoods.getTitle());
             secondReportingVo.setDescription(secondGoods.getDescription());

+ 9 - 0
alien-second/src/main/java/shop/alien/second/service/impl/SecondRecommendServiceImpl.java

@@ -20,6 +20,7 @@ import shop.alien.mapper.second.SecondRecommendMapper;
 import shop.alien.second.service.SecondRecommendService;
 import shop.alien.util.common.JwtUtil;
 
+import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.stream.Collectors;
@@ -61,6 +62,9 @@ public class SecondRecommendServiceImpl extends ServiceImpl<SecondRecommendMappe
             }
             IPage<SecondGoodsRecommendVo> result = mapper.getSecondRecommendByPage(page, userId, longitude + "," + latitude, typeId, "user_" + phoneId);
             for (SecondGoodsRecommendVo row : result.getRecords()) {
+                // 价格保留两位小数
+                row.setPrice(row.getPrice() != null ? row.getAmount().setScale(2, BigDecimal.ROUND_HALF_UP).toString() : null);
+                // 距离拼接
                 if (StringUtil.isNotBlank(row.getDist())) {
                     row.setPosition("距离" + row.getDist() + "km");
                 }
@@ -101,6 +105,8 @@ public class SecondRecommendServiceImpl extends ServiceImpl<SecondRecommendMappe
                 if (StringUtil.isNotBlank(item.getDist())) {
                     item.setPosition("距离" + item.getDist() + "km");
                 }
+                // 价格保留两位小数
+                item.setPrice(item.getPrice() != null ? item.getAmount().setScale(2, BigDecimal.ROUND_HALF_UP).toString() : null);
 
                 // 评论列表
                 List<SecondCommentVo> cList = new ArrayList<>();
@@ -152,6 +158,8 @@ public class SecondRecommendServiceImpl extends ServiceImpl<SecondRecommendMappe
                 if (StringUtil.isNotBlank(item.getDist())) {
                     item.setPosition("距离" + item.getDist() + "km");
                 }
+                // 价格保留两位小数
+                item.setPrice(item.getPrice() != null ? item.getAmount().setScale(2, BigDecimal.ROUND_HALF_UP).toString() : null);
 
                 // 评论列表
                 List<SecondCommentVo> cList = new ArrayList<>();
@@ -223,6 +231,7 @@ public class SecondRecommendServiceImpl extends ServiceImpl<SecondRecommendMappe
             if (StringUtil.isNotBlank(item.getDist())) {
                 item.setPosition("距离" + item.getDist() + "km");
             }
+            item.setPrice(item.getPrice() != null ? item.getAmount().setScale(2, BigDecimal.ROUND_HALF_UP).toString() : null);
             return item;
         } catch (Exception e) {
             log.error("SecondRecommendServiceImpl.querySecondGoodsDetail Error Mgs={}", e.getMessage());