From 8f36621b7c879732fbe9d191171b7747b0cf0207 Mon Sep 17 00:00:00 2001
From: xin <1099200748@qq.com>
Date: Tue, 23 Sep 2025 11:37:55 +0800
Subject: [PATCH] 查询用户商户-sql优化

---
 oying-system/src/main/resources/mapper/system/MerchantMapper.xml |   13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletions(-)

diff --git a/oying-system/src/main/resources/mapper/system/MerchantMapper.xml b/oying-system/src/main/resources/mapper/system/MerchantMapper.xml
index 1c9d082..1ed3c94 100644
--- a/oying-system/src/main/resources/mapper/system/MerchantMapper.xml
+++ b/oying-system/src/main/resources/mapper/system/MerchantMapper.xml
@@ -3,6 +3,7 @@
 <mapper namespace="com.oying.modules.system.mapper.MerchantMapper">
     <resultMap id="BaseResultMap" type="com.oying.modules.system.domain.Merchant">
         <id column="merchant_id" property="merchantId"/>
+        <result column="merchant_type" property="merchantType"/>
         <result column="merchant_name" property="merchantName"/>
         <result column="merchant_code" property="merchantCode"/>
         <result column="business_license" property="businessLicense"/>
@@ -20,7 +21,7 @@
     </resultMap>
 
     <sql id="Base_Column_List">
-        merchant_id, merchant_name, merchant_code, business_license, business_license_path, contact_mobile, merchant_sort, enabled, create_by, update_by, create_time, update_time, audit_user, audit_time, audit_message
+        merchant_id, merchant_type, merchant_name, merchant_code, business_license, business_license_path, contact_mobile, merchant_sort, enabled, create_by, update_by, create_time, update_time, audit_user, audit_time, audit_message
     </sql>
 
     <select id="findAll" resultMap="BaseResultMap">
@@ -36,6 +37,9 @@
                 or contact_mobile like concat('%', #{criteria.blurry}, '%')
                 )
             </if>
+            <if test="criteria.merchantType != null and criteria.merchantType != ''">
+                and merchant_type = #{criteria.merchantType}
+            </if>
             <if test="criteria.enabled != null">
                 and enabled = #{criteria.enabled}
             </if>
@@ -45,4 +49,11 @@
         </where>
         order by merchant_sort desc
     </select>
+    <select id="findByUserId" resultMap="BaseResultMap">
+        select m.*
+        from sys_merchant as m
+                 left join sys_user_merchant as u on u.merchant_id = m.merchant_id
+        where user_id = #{userId}
+        order by m.merchant_id
+    </select>
 </mapper>

--
Gitblit v1.9.3