瀏覽代碼

商家距离改为整数类型

qizai 1 年之前
父節點
當前提交
138170cb9b

+ 6 - 1
vehicle-api/src/main/java/com/chelvc/cloud/vehicle/api/dto/MerchantDTO.java

@@ -77,10 +77,15 @@ public class MerchantDTO implements Serializable {
      */
     private Integer sale;
 
+    /**
+     * 好评数量
+     */
+    private Integer goodReview;
+
     /**
      * 距离(米)
      */
-    private Double distance;
+    private Integer distance;
 
     /**
      * 经度

+ 6 - 0
vehicle-api/src/main/java/com/chelvc/cloud/vehicle/api/param/CategoryModifyParam.java

@@ -30,6 +30,12 @@ public class CategoryModifyParam implements Serializable {
     @Size(max = 50, message = "分类名称长度不能大于50")
     private String name;
 
+    /**
+     * 分类图标
+     */
+    @Size(max = 200, message = "分类图标长度不能大于200")
+    private String icon;
+
     /**
      * 排序数字
      */

+ 9 - 0
vehicle-api/src/main/java/com/chelvc/cloud/vehicle/api/service/MerchantService.java

@@ -51,6 +51,15 @@ public interface MerchantService {
      */
     MerchantDetailDTO getMerchantDetail(Long id);
 
+    /**
+     * 获取商家详情
+     *
+     * @param id 商家ID
+     * @param param 查询参数
+     * @return 商家详情
+     */
+    MerchantDetailDTO getMerchantDetail(Long id, LocationQueryParam param);
+
     /**
      * 新增商家
      *

+ 9 - 0
vehicle-server/src/main/java/com/chelvc/cloud/vehicle/server/dao/MerchantMapper.java

@@ -43,4 +43,13 @@ public interface MerchantMapper extends BaseMapper<Merchant> {
      * @return 商家信息列表
      */
     List<MerchantDTO> listSimpleMerchants(MerchantQueryParam param);
+
+    /**
+     * 获取商家详情
+     *
+     * @param id 商家ID
+     * @param param 查询参数
+     * @return 商家详情
+     */
+    Merchant getMerchantById(@Param("id") Long id, @Param("param") LocationQueryParam param);
 }

+ 11 - 0
vehicle-server/src/main/java/com/chelvc/cloud/vehicle/server/entity/Merchant.java

@@ -112,4 +112,15 @@ public class Merchant extends ModifyEntity<Long> {
      * 商家状态
      */
     private MerchantStatus status;
+
+    /**
+     * 好评数量
+     */
+    private Integer goodReview;
+
+    /**
+     * 距离(米)
+     */
+    @TableField(exist = false)
+    private Integer distance;
 }

+ 16 - 0
vehicle-server/src/main/java/com/chelvc/cloud/vehicle/server/service/impl/MerchantServiceImpl.java

@@ -73,6 +73,22 @@ public class MerchantServiceImpl extends ServiceImpl<MerchantMapper, Merchant> i
         return MerchantDetailDTO.builder().merchant(merchant).goods(goods).categories(types).build();
     }
 
+    @Override
+    public MerchantDetailDTO getMerchantDetail(Long id, LocationQueryParam param) {
+        // 获取商家信息
+        MerchantDTO merchant = MerchantCopier.INSTANCE.copying(
+                ResourceUtils.required(this.baseMapper.getMerchantById(id, param), "商家不存在")
+        );
+
+        // 获取商家全部商品列表
+        List<GoodsDTO> goods = this.goodsService.listMerchantSimpleGoods(
+                id, GoodsQueryParam.builder().size(10).build()
+        );
+
+        // 获取商家商品分类类型列表
+        List<CategoryType> types = this.goodsService.listMerchantGoodsCategoryTypes(id);
+        return MerchantDetailDTO.builder().merchant(merchant).goods(goods).categories(types).build();
+    }
 
     @Override
     public Long addMerchant(@NonNull MerchantModifyParam param) {

+ 1 - 1
vehicle-server/src/main/resources/mapper/FavoriteMapper.xml

@@ -28,7 +28,7 @@
         select fe.id,fe.content_id,mt.id as merchant_id, mt.name, mt.logo, mt.score, mt.sale, mt.address,
         round(st_distance_sphere(
         point(mt.longitude, mt.latitude), point(#{param.longitude}, #{param.latitude})
-        ),1) distance from favorite fe
+        )) distance from favorite fe
         inner join merchant mt on fe.content_id = mt.id and mt.status = 'ONLINE'
         and mt.region = #{param.region}
         where fe.user_id = #{userId} and fe.type = 'MERCHANT'

+ 17 - 5
vehicle-server/src/main/resources/mapper/MerchantMapper.xml

@@ -3,8 +3,8 @@
 <mapper namespace="com.chelvc.cloud.vehicle.server.dao.MerchantMapper">
     <sql id="BASIC_MERCHANT_SELECT">
         select mt.id, mt.user_id, mt.name, mt.logo, mt.banners, mt.liaison, mt.mobile, mt.opening, mt.address,
-        mt.score, mt.sale, mt.region, mt.longitude, mt.latitude, mt.recommend, mt.status, mt.creator, mt.create_time,
-        mt.updater, mt.update_time
+        mt.score, mt.sale, mt.good_review,mt.region, mt.longitude, mt.latitude, mt.recommend, mt.status, mt.creator,
+        mt.create_time,mt.updater, mt.update_time
         from `merchant` mt
     </sql>
 
@@ -12,7 +12,7 @@
         select mt.id, mt.name, mt.logo, mt.score, mt.sale, mt.address,
         round(st_distance_sphere(
             point(mt.longitude, mt.latitude), point(#{param.longitude}, #{param.latitude})
-        ),1) distance
+        )) distance
         from `merchant` mt
         where mt.region = #{param.region} and mt.status = 'ONLINE'
         order by distance asc limit #{size}
@@ -22,7 +22,7 @@
         select mt.id, mt.name, mt.logo, mt.score, mt.sale, mt.address,
         round(st_distance_sphere(
             point(mt.longitude, mt.latitude), point(#{param.longitude}, #{param.latitude})
-        ),1) distance
+        )) distance
         from `merchant` mt
         where mt.region = #{param.region} and mt.status = 'ONLINE' and mt.recommend = 1
         order by distance asc limit #{size}
@@ -32,7 +32,7 @@
         select mt.id, mt.name, mt.logo, mt.score, mt.sale, mt.address,
         round(st_distance_sphere(
             point(mt.longitude, mt.latitude), point(#{longitude}, #{latitude})
-        ),1) distance
+        )) distance
         from `merchant` mt
         <if test="categoryId != null or (keyword != null and !keyword.isEmpty())">
             left join `goods` gs on gs.merchant_id = mt.id
@@ -67,4 +67,16 @@
         </if>
         limit #{size}
     </select>
+
+    <select id="getMerchantById" resultType="com.chelvc.cloud.vehicle.server.entity.Merchant">
+        select mt.id, mt.user_id as userId, mt.name, mt.logo, mt.banners, mt.liaison, mt.mobile,
+        mt.opening, mt.address, mt.score, mt.sale, mt.good_review as goodReview,mt.region, mt.longitude,
+        mt.latitude, mt.recommend, mt.status, mt.creator,
+        mt.create_time as createTime,
+        round(st_distance_sphere(
+        point(mt.longitude, mt.latitude), point(#{param.longitude}, #{param.latitude})
+        )) distance
+        from `merchant` mt
+        where mt.id = #{id} and mt.region = #{param.region}
+    </select>
 </mapper>