瀏覽代碼

订单,积分,分类,退货的功能优化

wang 4 天之前
父節點
當前提交
878436a151

+ 5 - 0
yami-shop-bean/src/main/java/com/yami/shop/bean/app/dto/ShopHeadInfoDto.java

@@ -59,4 +59,9 @@ public class ShopHeadInfoDto {
     @ApiModelProperty(value = "第三方id", required = true)
     private String thirdPartyCode;
 
+    @ApiModelProperty(value = "店铺经度")
+    private String lat;
+    @ApiModelProperty(value = "店铺纬度")
+    private String lon;
+
 }

+ 14 - 2
yami-shop-service/src/main/java/com/yami/shop/service/impl/ShopDetailServiceImpl.java

@@ -325,6 +325,8 @@ public class ShopDetailServiceImpl extends ServiceImpl<ShopDetailMapper, ShopDet
         if (ObjectUtils.isNotEmpty(shopDetails)) {
             dto.setShopId(shopDetails.get(0).getShopId());
             dto.setShopName(shopDetails.get(0).getShopName());
+            dto.setLat(shopDetails.get(0).getShopLat());
+            dto.setLon(shopDetails.get(0).getShopLng());
         }
         return ResponseEntity.ok(dto);
     }
@@ -332,7 +334,12 @@ public class ShopDetailServiceImpl extends ServiceImpl<ShopDetailMapper, ShopDet
     @Override
     public ResponseEntity<List<ShopHeadInfoDto>> neighborShopList(String lat, String lon, Integer platform) {
         List<ShopHeadInfoDto> collect = shopDetailMapper.neighborShop(lat, lon, platform)
-                .stream().map((s) -> ShopHeadInfoDto.builder().shopId(s.getShopId()).shopName(s.getShopName()).build()).collect(Collectors.toList());
+                .stream().map((s) -> ShopHeadInfoDto.builder()
+                        .shopId(s.getShopId())
+                        .shopName(s.getShopName())
+                        .lat(s.getShopLat())
+                        .lon(s.getShopLng())
+                        .build()).collect(Collectors.toList());
         return ResponseEntity.ok(collect);
     }
 
@@ -340,7 +347,12 @@ public class ShopDetailServiceImpl extends ServiceImpl<ShopDetailMapper, ShopDet
     public ResponseEntity<List<ShopHeadInfoDto>> neighborShopByAddr(Long addr, Integer platform) {
         UserAddr userAddr = userAddrMapper.selectById(addr);
         List<ShopHeadInfoDto> collect = shopDetailMapper.neighborShop(userAddr.getLatitude().toString(), userAddr.getLongitude().toString(), platform)
-                .stream().map((s) -> ShopHeadInfoDto.builder().shopId(s.getShopId()).shopName(s.getShopName()).build()).collect(Collectors.toList());
+                .stream().map((s) -> ShopHeadInfoDto.builder()
+                        .shopId(s.getShopId())
+                        .shopName(s.getShopName())
+                        .lat(s.getShopLat())
+                        .lon(s.getShopLng())
+                        .build()).collect(Collectors.toList());
         return ResponseEntity.ok(collect);
     }
 

+ 78 - 41
yami-shop-service/src/main/resources/mapper/ProductMapper.xml

@@ -668,60 +668,97 @@
         where oi.prod_id=#{prodId} and o.hb_order_status=80
     </select>
     <select id="getSearchProdDtoPageByProdName2" resultType="com.yami.shop.bean.dto.SearchProdDto">
-        select  t.*,t1.salesVolume from (
-        select
-        any_value(p.prod_id) as prod_id,
-        any_value(p.pic) as pic,
-        any_value(p.prod_name) as prod_name,
-        any_value(p.price) as price,
-        any_value(p.brief) as brief,
-        any_value(p.shop_id) as shopId,
-        any_value(p.update_time) as update_time
-        from
+        SELECT
+        t.*,
+        t1.salesVolume
+        FROM (
+        SELECT
+        ANY_VALUE(p.prod_id) AS prod_id,
+        ANY_VALUE(p.pic) AS pic,
+        ANY_VALUE(p.prod_name) AS prod_name,
+        ANY_VALUE(p.price) AS price,
+        ANY_VALUE(p.brief) AS brief,
+        ANY_VALUE(p.shop_id) AS shopId,
+        ANY_VALUE(p.update_time) AS update_time
+        FROM
         tz_prod p
-        where 1 = 1 and p.`status` = 1
+        WHERE
+        1 = 1
+        AND p.`status` = 1
         <if test="searchParam.prodName != null and searchParam.prodName != ''">
-            and prod_name like concat('%',#{searchParam.prodName} ,'%')
+            AND prod_name LIKE CONCAT('%', #{searchParam.prodName}, '%')
         </if>
         <if test="searchParam.shopId != null">
-            and p.shop_id = #{searchParam.shopId}
+            AND p.shop_id = #{searchParam.shopId}
         </if>
-
         <if test="searchParam.categoryId != null">
-            and p.shop_category_id = #{searchParam.categoryId}
+            AND p.shop_category_id = #{searchParam.categoryId}
         </if>
         <if test="searchParam.shopCategoryId != null">
-            and p.shop_category_id = #{searchParam.shopCategoryId}
+            AND p.shop_category_id = #{searchParam.shopCategoryId}
         </if>
         <if test="searchParam.prodType != null and searchParam.isAllProdType == null">
-            and p.prod_type = #{searchParam.prodType}
+            AND p.prod_type = #{searchParam.prodType}
         </if>
         <if test="searchParam.isAllProdType == true">
-            and p.prod_type in (0,1,2)
-        </if>
-        GROUP BY p.prod_id
-        ) t left JOIN (
-        select oi.prod_id,ifnull(sum(oi.prod_count),0) as salesVolume from tz_order o
-        join tz_order_item oi on oi.order_number=o.order_number
-        where  o.hb_order_status=80  GROUP BY oi.prod_id) t1  on t.prod_id = t1.prod_id
-        <if test="searchParam.sort == 0">
-            ORDER BY t.update_time
-        </if>
-        <if test="searchParam.sort == 1">
-            ORDER BY t1.salesVolume
-        </if>
-        <if test="searchParam.sort == 2">
-            ORDER BY t.price
-        </if>
-        <if test="searchParam.orderBy == 0">
-            asc
-        </if>
-        <if test="searchParam.orderBy == 1">
-            desc
-        </if>
-        <if test="searchParam.sort == 1">
-            , t.prod_id DESC
+            AND p.prod_type IN (0,1,2)
         </if>
+        GROUP BY
+        p.prod_id
+        ) t
+        LEFT JOIN (
+        SELECT
+        oi.prod_id,
+        IFNULL(SUM(oi.prod_count), 0) AS salesVolume
+        FROM
+        tz_order o
+        JOIN
+        tz_order_item oi ON oi.order_number = o.order_number
+        WHERE
+        o.hb_order_status = 80
+        GROUP BY
+        oi.prod_id
+        ) t1 ON t.prod_id = t1.prod_id
+        <!-- 修改点:合并排序条件 -->
+        <choose>
+            <when test="searchParam.sort != null">
+                ORDER BY
+                <choose>
+                    <when test="searchParam.sort == 0">
+                        t.update_time
+                        <if test="searchParam.orderBy != null">
+                            <choose>
+                                <when test="searchParam.orderBy == 0">ASC</when>
+                                <when test="searchParam.orderBy == 1">DESC</when>
+                            </choose>
+                        </if>
+                    </when>
+                    <when test="searchParam.sort == 1">
+                        t1.salesVolume
+                        <if test="searchParam.orderBy != null">
+                            <choose>
+                                <when test="searchParam.orderBy == 0">ASC</when>
+                                <when test="searchParam.orderBy == 1">DESC</when>
+                            </choose>
+                        </if>
+                        , t.prod_id DESC
+                    </when>
+                    <when test="searchParam.sort == 2">
+                        t.price
+                        <if test="searchParam.orderBy != null">
+                            <choose>
+                                <when test="searchParam.orderBy == 0">ASC</when>
+                                <when test="searchParam.orderBy == 1">DESC</when>
+                            </choose>
+                        </if>
+                    </when>
+                </choose>
+            </when>
+            <otherwise>
+                <!-- 默认排序(当sort未指定时) -->
+                ORDER BY t.update_time DESC
+            </otherwise>
+        </choose>
     </select>
 
     <select id="listProdByCategoryIdAndShopId" parameterType="com.yami.shop.bean.dto.ProdByCategoryIdAndShopIdDTO" resultType="com.yami.shop.bean.model.Product">

+ 2 - 0
yami-shop-service/src/main/resources/mapper/ShopDetailMapper.xml

@@ -132,6 +132,8 @@
         select DISTINCT
         sd.shop_id,
         shop_name,
+        sd.shop_lat ,
+        sd.shop_lng,
         ( 6371 * acos( cos( radians(#{lat}) ) * cos( radians( shop_lat ) ) * cos( radians( shop_lng ) - radians(#{lon})
         ) + sin( radians(#{lat}) ) * sin( radians( shop_lat ) ) ) ) distance
         from