From 929bbd74135fd867537adc18a171491b83679090 Mon Sep 17 00:00:00 2001
From: Hentua <wangdoubleone@gmail.com>
Date: Thu, 20 Apr 2023 15:47:57 +0800
Subject: [PATCH] 店铺列表

---
 src/main/resources/mapper/modules/MallShopMapper.xml |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/main/resources/mapper/modules/MallShopMapper.xml b/src/main/resources/mapper/modules/MallShopMapper.xml
index fe9c97d..413eb6b 100644
--- a/src/main/resources/mapper/modules/MallShopMapper.xml
+++ b/src/main/resources/mapper/modules/MallShopMapper.xml
@@ -3,7 +3,10 @@
 <mapper namespace="cc.mrbird.febs.mall.mapper.MallShopMapper">
 
     <select id="selectShopListInPage" resultType="cc.mrbird.febs.mall.entity.MallShop">
-        select * from mall_shop
+        select
+               a.*,
+               lat_lng_distance(#{record.latitude}, #{record.longitude}, a.latitude, a.longitude) distance
+        from mall_shop a
         <where>
             1=1
             <if test="record != null">
@@ -15,6 +18,11 @@
                 </if>
             </if>
         </where>
-        order by id desc
+        <if test="record.longitude != null and record.latitude != null">
+            order by lat_lng_distance(#{record.latitude}, #{record.longitude}, a.latitude, a.longitude) desc
+        </if>
+        <if test="record.longitude == null or record.latitude == null">
+            order by id desc
+        </if>
     </select>
 </mapper>
\ No newline at end of file

--
Gitblit v1.9.1