Bläddra i källkod

推荐图片为空修复

zhangchen 1 vecka sedan
förälder
incheckning
4cff69c5a1

+ 1 - 1
alien-entity/src/main/java/shop/alien/mapper/StoreInfoMapper.java

@@ -144,7 +144,7 @@ public interface StoreInfoMapper extends BaseMapper<StoreInfo> {
             " from store_evaluation eval " +
             " where eval.store_id = a.id and eval.delete_flag = 0 " +
             ") score, " +
-            "ROUND(ST_Distance_Sphere(ST_GeomFromText(CONCAT('POINT(', REPLACE(#{position}, ',', ' '), ')' )), ST_GeomFromText(CONCAT('POINT(', REPLACE(a.store_position, ',', ' '), ')' ))), 0) distance3 " +
+            "ROUND(ST_Distance_Sphere(ST_GeomFromText(CONCAT('POINT(', REPLACE(#{position}, ',', ' '), ')' )), ST_GeomFromText(CONCAT('POINT(', REPLACE(a.store_position, ',', ' '), ')' )))) distance3 " +
             "from store_info a " +
             "left join store_user b on a.id = b.store_id and a.delete_flag = 0 and b.delete_flag = 0 " +
             "left join store_dictionary c on a.store_status = c.dict_id and c.type_name = 'storeState' and c.delete_flag = 0 " +

+ 9 - 0
alien-store/src/main/java/shop/alien/store/service/impl/StoreInfoServiceImpl.java

@@ -3059,6 +3059,15 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
             String[] split = record.getStorePosition().split(",");
             record.setStorePositionLongitude(split[0]);
             record.setStorePositionLatitude(split[1]);
+            // 格式化距离,移除无意义的小数位
+            if (!StringUtils.isEmpty(record.getDistance3())) {
+                try {
+                    BigDecimal distanceValue = new BigDecimal(record.getDistance3());
+                    record.setDistance3(distanceValue.stripTrailingZeros().toPlainString());
+                } catch (NumberFormatException ex) {
+                    log.warn("店铺距离格式化失败, storeId: {}, distance3: {}", record.getId(), record.getDistance3(), ex);
+                }
+            }
             //处理一下到期状态
             Date expirationTime = record.getExpirationTime();
             if (expirationTime != null) {