|
|
@@ -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 >= #{startSubmitDate})
|
|
|
- OR (si.img_type = 35 AND slh.created_time >= #{startSubmitDate})
|
|
|
- )
|
|
|
+ AND slh.created_time >= #{startSubmitDate}
|
|
|
</if>
|
|
|
<if test="endSubmitDate != null and endSubmitDate != ''">
|
|
|
- AND (
|
|
|
- (si.img_type = 14 AND s.update_business_license_time <= #{endSubmitDate})
|
|
|
- OR (si.img_type = 35 AND slh.created_time <= #{endSubmitDate})
|
|
|
- )
|
|
|
+ AND slh.created_time <= #{endSubmitDate}
|
|
|
</if>
|
|
|
- ORDER BY submit_date DESC, s.store_name ASC
|
|
|
+ ORDER BY slh.created_time DESC, s.store_name ASC
|
|
|
</select>
|
|
|
|
|
|
</mapper>
|