Parcourir la source

fix: 问题分析 — 「先删后审」空窗期的详细分析 + 证照列表 SQL 只取最新记录的问题
修改方案与代码改动 — 4 个文件的具体改动,包含改动前后对比
涉及文件清单 — 一目了然的表格
测试要点 — 覆盖空窗期修复和全量记录两部分的 checklist
影响范围 — 说明前端无需改动、无数据库结构变更

李亚非 il y a 2 mois
Parent
commit
1600e19a2d

+ 29 - 60
alien-entity/src/main/resources/mapper/StoreInfoMapper.xml

@@ -5,68 +5,43 @@
 <mapper namespace="shop.alien.mapper.StoreInfoMapper">
 
     <!--
-        门店证照查询
-        证照类型与状态、提交时间、到期时间映射关系:
-          - img_type = 14: 营业执照
-          - img_type = 35: 其他资质证明
+        门店证照查询(存档审计)
+        以 store_license_history 为驱动表,展示所有上传记录
+        证照类型映射:license_status 1→营业执照(img_type=14)  2→其他资质证明(img_type=35)
+        审核状态:license_execute_status 1→审核通过  2→审核中  3→审核拒绝
     -->
     <select id="getStoreLicensePage"
             resultType="shop.alien.entity.store.vo.StoreLicenseInfoVo">
         SELECT
             CASE
-                WHEN si.img_type = 14 THEN '营业执照'
-                WHEN si.img_type = 35 THEN '其他资质证明'
+                WHEN slh.license_status = 1 THEN '营业执照'
+                WHEN slh.license_status = 2 THEN '其他资质证明'
                 ELSE ''
             END AS img_description,
-            si.img_type AS img_type,
+            CASE
+                WHEN slh.license_status = 1 THEN 14
+                WHEN slh.license_status = 2 THEN 35
+                ELSE 0
+            END AS img_type,
             s.id AS id,
             s.store_name AS store_name,
             s.store_tel AS store_tel,
             su.name AS name,
-            si.img_url,
+            slh.img_url,
             s.business_section_name,
             s.business_classify_name,
             s.business_types_name,
+            slh.license_execute_status AS states,
+            slh.created_time AS submit_date,
             CASE
-                WHEN si.img_type = 14 THEN s.business_license_status
-                WHEN si.img_type = 35 THEN slh.license_execute_status
-                ELSE ''
-            END AS states,
-            CASE
-                WHEN si.img_type = 14 THEN s.update_business_license_time
-                WHEN si.img_type = 35 THEN slh.created_time
-                ELSE NULL
-            END AS submit_date,
-            CASE
-                WHEN si.img_type = 14 THEN s.business_license_expiration_time
-                WHEN si.img_type = 35 THEN NULL
+                WHEN slh.license_status = 1 THEN s.business_license_expiration_time
                 ELSE NULL
             END AS expiration_time,
-            CASE
-                WHEN si.img_type = 14 THEN s.business_license_reason
-                WHEN si.img_type = 35 THEN slh.reason_refusal
-                ELSE NULL
-            END AS expiration_reason
-        FROM store_info s
-                 LEFT JOIN store_img si
-                           ON s.id = si.store_id
-                               AND si.img_type IN (14, 35)
-                               AND si.delete_flag = 0
-                 LEFT JOIN store_user su ON s.id = su.store_id
-                 LEFT JOIN (
-                     SELECT slh.store_id, slh.license_execute_status, slh.created_time, slh.reason_refusal, slh.img_url
-                     FROM store_license_history slh
-                     INNER JOIN (
-                         SELECT store_id, MAX(created_time) AS max_time
-                         FROM store_license_history
-                         WHERE license_status = 2 AND delete_flag = 0
-                         GROUP BY store_id
-                     ) slh2 ON slh.store_id = slh2.store_id 
-                             AND slh.created_time = slh2.max_time
-                     WHERE slh.license_status = 2 AND slh.delete_flag = 0
-                 ) slh ON s.id = slh.store_id AND si.img_type = 35
-        WHERE s.delete_flag = 0
-            AND si.img_type IS NOT NULL
+            slh.reason_refusal AS expiration_reason
+        FROM store_license_history slh
+                 INNER JOIN store_info s ON slh.store_id = s.id AND s.delete_flag = 0
+                 LEFT JOIN store_user su ON s.id = su.store_id AND su.delete_flag = 0
+        WHERE slh.delete_flag = 0
         <if test="storeName != null and storeName != ''">
             AND s.store_name LIKE CONCAT('%', #{storeName}, '%')
         </if>
@@ -79,28 +54,22 @@
         <if test="businessSection != null and businessSection != ''">
             AND s.business_section = #{businessSection}
         </if>
-        <if test="imgType != null">
-            AND si.img_type = #{imgType}
+        <if test="imgType != null and imgType == 14">
+            AND slh.license_status = 1
+        </if>
+        <if test="imgType != null and imgType == 35">
+            AND slh.license_status = 2
         </if>
         <if test="states != null and states != ''">
-            AND (
-                (si.img_type = 14 AND s.business_license_status = #{states})
-                OR (si.img_type = 35 AND slh.license_execute_status = #{states})
-            )
+            AND slh.license_execute_status = #{states}
         </if>
         <if test="startSubmitDate != null and startSubmitDate != ''">
-            AND (
-                (si.img_type = 14 AND s.update_business_license_time &gt;= #{startSubmitDate})
-                OR (si.img_type = 35 AND slh.created_time &gt;= #{startSubmitDate})
-            )
+            AND slh.created_time &gt;= #{startSubmitDate}
         </if>
         <if test="endSubmitDate != null and endSubmitDate != ''">
-            AND (
-                (si.img_type = 14 AND s.update_business_license_time &lt;= #{endSubmitDate})
-                OR (si.img_type = 35 AND slh.created_time &lt;= #{endSubmitDate})
-            )
+            AND slh.created_time &lt;= #{endSubmitDate}
         </if>
-        ORDER BY submit_date DESC, s.store_name ASC
+        ORDER BY slh.created_time DESC, s.store_name ASC
     </select>
 
 </mapper>

+ 15 - 25
alien-store/src/main/java/shop/alien/store/service/impl/StoreInfoServiceImpl.java

@@ -4261,32 +4261,22 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
                                                          String endSubmitDate) {
         IPage<StoreLicenseInfoVo> page = new Page<>(pageNum, pageSize);
         IPage<StoreLicenseInfoVo> storeLicensePage = storeInfoMapper.getStoreLicensePage(page, storeName, storeContact, storeTel, businessSection, imgType, states, startSubmitDate, endSubmitDate);
+        // 所有记录统一来自 store_license_history,状态值为 license_execute_status: 1-审核通过, 2-审核中, 3-审核拒绝
         for (StoreLicenseInfoVo record : storeLicensePage.getRecords()) {
-            if(record.getStates() != null){
-                if(record.getImgType() != null && record.getImgType() == 35){
-                    // 其他资质证明:直接使用状态值描述
-                    // license_execute_status: 1-审核通过, 2-审核中, 3-审核拒绝
-                    switch (record.getStates().toString()) {
-                        case "1":
-                            record.setStatesName("审核通过");
-                            break;
-                        case "2":
-                            record.setStatesName("审核中");
-                            break;
-                        case "3":
-                            record.setStatesName("审核拒绝");
-                            break;
-                        default:
-                            record.setStatesName("未知");
-                            break;
-                    }
-                } else {
-                    // 营业执照:从字典表获取状态名称
-                    StoreDictionary storeDictionary = storeDictionaryMapper.selectOne(new LambdaQueryWrapper<StoreDictionary>().eq(StoreDictionary::getDictId, record.getStates())
-                            .eq(StoreDictionary::getTypeName, "foodLicenceStatus"));
-                    if(storeDictionary != null){
-                        record.setStatesName(storeDictionary.getDictDetail());
-                    }
+            if (record.getStates() != null) {
+                switch (record.getStates().toString()) {
+                    case "1":
+                        record.setStatesName("审核通过");
+                        break;
+                    case "2":
+                        record.setStatesName("审核中");
+                        break;
+                    case "3":
+                        record.setStatesName("审核拒绝");
+                        break;
+                    default:
+                        record.setStatesName("未知");
+                        break;
                 }
             }
         }