Files
zxjp-web/coolstore-partner-dao/src/main/resources/mapper/StoreMapper.xml
王非凡 3e227cc5fb Merge #144 into master from cc_20260520_unify_merge
0520需求汇总

* cc_20260520_unify_merge: (22 commits squashed)

  - fix:正新鸡排信发自动开通改造

  - fix:环境配置

  - fix

  - fix:信发门店设备信息接口入参修改

  - fix:信发门店设备信息接口入参修改

  - fix:新增根据门店id查询设备接口

  - fix

  - fix:限制设备数量

  - fix:问题修复

  - fix:网点信息获取转义;网点/设备创建异常抛出

  - fix:更新开业报备流程完成日期、首次在营业状态时间

  - fix

  - fix:云流水&新管家账号关闭接口传入闭店原因;新增闭店原因违约闭店

  - fix:闭店信息新增字段

  - Merge branch 'master' into cc_20260518_store_date

  - fix:开店流程完成状态判断排除食安阶段

  - fix

  - fix

  - Merge branch 'cc_20260514_xinfa_modify' into cc_20260520_unify_merge
    
    # Conflicts:
    #	coolstore-partner-common/src/main/java/com/cool/store/enums/ErrorCodeEnum.java

  - Merge branch 'cc_20260518_store_date' into cc_20260520_unify_merge

  - Merge branch 'cc_20260520_close_store_optimize' into cc_20260520_unify_merge

  - Merge remote-tracking branch 'origin/cc_20260518_close_reason' into cc_20260520_unify_merge

Signed-off-by: 王非凡 <accounts_67eba0c5fee9c49c80c8e2b4@mail.teambition.com>
Merged-by: 正新 <accounts_6964c7bcd2a2c377c5bbd01b@mail.teambition.com>

CR-link: https://codeup.aliyun.com/692ea314dec569489f6f167c/hangzhou/java/custom_zxjp/change/144
2026-05-20 08:44:35 +00:00

497 lines
21 KiB
XML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.cool.store.mapper.StoreMapper">
<resultMap id="BaseResultMap" type="com.cool.store.entity.StoreDO">
<!--
WARNING - @mbggenerated
-->
<id column="id" property="id" jdbcType="BIGINT"/>
<result column="store_id" property="storeId" jdbcType="VARCHAR"/>
<result column="store_name" property="storeName" jdbcType="VARCHAR"/>
<result column="store_num" property="storeNum" jdbcType="VARCHAR"/>
<result column="store_address" property="storeAddress" jdbcType="VARCHAR"/>
<result column="location_address" property="locationAddress" jdbcType="VARCHAR"/>
<result column="is_lock" property="isLock" jdbcType="CHAR"/>
<result column="longitude_latitude" property="longitudeLatitude" jdbcType="VARCHAR"/>
<result column="longitude" property="longitude" jdbcType="VARCHAR"/>
<result column="latitude" property="latitude" jdbcType="VARCHAR"/>
<result column="is_delete" property="isDelete" jdbcType="CHAR"/>
<result column="telephone" property="telephone" jdbcType="VARCHAR"/>
<result column="business_hours" property="businessHours" jdbcType="VARCHAR"/>
<result column="store_acreage" property="storeAcreage" jdbcType="VARCHAR"/>
<result column="store_bandwidth" property="storeBandwidth" jdbcType="VARCHAR"/>
<result column="create_time" property="createTime" jdbcType="BIGINT"/>
<result column="create_name" property="createName" jdbcType="VARCHAR"/>
<result column="create_user" property="createUser" jdbcType="VARCHAR"/>
<result column="update_time" property="updateTime" jdbcType="BIGINT"/>
<result column="update_name" property="updateName" jdbcType="VARCHAR"/>
<result column="update_user" property="updateUser" jdbcType="VARCHAR"/>
<result column="remark" property="remark" jdbcType="LONGVARCHAR"/>
<result column="is_device" property="isDevice" jdbcType="VARCHAR"/>
<result column="aliyun_corp_id" property="aliyunCorpId" jdbcType="VARCHAR"/>
<result column="vds_corp_id" property="vdsCorpId" jdbcType="VARCHAR"/>
<result column="syn_ding_dept_id" property="synDingDeptId" jdbcType="VARCHAR"/>
<result column="region_path" property="regionPath" jdbcType="VARCHAR"/>
<result column="has_camera" property="hasCamera" jdbcType="TINYINT"/>
<result column="region_id" property="regionId" jdbcType="VARCHAR"/>
<result column="store_status" property="storeStatus" jdbcType="VARCHAR"/>
<result column="open_date" property="openDate" jdbcType="DATE"/>
<result column="monthly_rent" property="monthlyRent"/>
<result column="monthly_personnel_salary" property="monthlyPersonnelSalary"/>
<result column="monthly_other_expenses" property="monthlyOtherExpenses"/>
<result column="unified_management" property="unifiedManagement" jdbcType="TINYINT"/>
<result column="join_model" property="joinModel" jdbcType="TINYINT"/>
<result column="join_supervision" property="joinSupervision" jdbcType="VARCHAR"/>
<result column="join_brand" property="joinBrand" jdbcType="TINYINT"/>
<result column="store_type" property="storeType" jdbcType="TINYINT"/>
<result column="mini_program_order_store_name" property="miniProgramOrderStoreName"/>
<result column="is_iot" property="isIot" jdbcType="TINYINT"/>
<result column="addressee_name" property="addresseeName" jdbcType="VARCHAR"/>
<result column="addressee_mobile" property="addresseeMobile" jdbcType="VARCHAR"/>
<result column="addressee_area" property="addresseeArea" jdbcType="VARCHAR"/>
<result column="addressee_address" property="addresseeAddress" jdbcType="VARCHAR"/>
<result column="branch" property="branch" jdbcType="TINYINT"/>
</resultMap>
<select id="getByStoreId" resultMap="BaseResultMap">
select *
from store_${enterpriseId}
where store_id = #{storeId}
</select>
<select id="getEffectiveByStoreId" resultMap="BaseResultMap">
select *
from store_${enterpriseId}
where store_id = #{storeId} AND is_delete = 'effective'
</select>
<select id="getEffectiveStoreByStoreIds" resultMap="BaseResultMap">
select *
from store_${enterpriseId}
where is_delete = 'effective'
<if test="storeIds != null">
<foreach collection="storeIds" item="item" separator="," open="and store_id in (" close=")">
#{item}
</foreach>
</if>
</select>
<select id="getStoreByStoreIds" resultMap="BaseResultMap">
select *
from store_${enterpriseId}
<where>
<if test="storeIds != null">
<foreach collection="storeIds" item="item" separator="," open="and store_id in (" close=")">
#{item}
</foreach>
</if>
</where>
</select>
<select id="listStoreByRegionId" resultMap="BaseResultMap">
select *
from store_${enterpriseId}
where is_delete = 'effective'
<if test="regionId != null and regionId!= '' ">
and region_path like concat('%/', #{regionId}, '/%')
</if>
</select>
<select id="getStoreNumByStoreIds" resultType="java.lang.String">
select store_num
from store_${enterpriseId}
where is_delete = 'effective'
<if test="storeIds != null">
<foreach collection="storeIds" item="item" separator="," open="and store_id in (" close=")">
#{item}
</foreach>
</if>
</select>
<select id="getByStoreNum" resultMap="BaseResultMap">
select *
from store_${enterpriseId}
where store_num = #{storeNum} and is_delete = 'effective'
</select>
<select id="listByMobile" resultMap="BaseResultMap">
select a.*
from store_${enterpriseId} a left join store_master_signer_info_${enterpriseId} b on a.store_id = b.store_id
<where>
and a.is_delete = 'effective'
<if test="mobile!=null and mobile !=''">
and ( b.signer1_mobile = #{mobile} or b.signer2_mobile = #{mobile})
</if>
</where>
union
select *
from store_${enterpriseId}
<where>
and is_delete = 'effective'
<if test="mobile!=null and mobile !=''">
and `extend_field` like concat('%', #{mobile}, '%')
</if>
</where>
limit 10
</select>
<select id="getSubStoreByRegionIdsAndMobile" resultType="com.cool.store.response.MiniShopsResponse">
<choose>
<!-- 情况1regionIdList不为空使用UNION优化 -->
<when test="regionIdList != null and regionIdList.size > 0">
SELECT store_id as storeId, store_name as shopName, store_num as shopCode, store_address as detailAddress, standard_store_type_name as standardStoreTypeName
FROM store_${enterpriseId} a
WHERE a.is_delete = 'effective' and a.store_status != 'closed'
<if test="storeName!=null and storeName!=''">
AND (a.store_name LIKE CONCAT('%', #{storeName}, '%') or a.store_num LIKE CONCAT('%', #{storeName}, '%'))
</if>
<if test="storeNum!=null and storeNum!=''">
AND a.store_num = #{storeNum}
</if>
AND (
<foreach collection="regionIdList" item="regionId" separator=" OR ">
a.region_path LIKE CONCAT('%/', #{regionId}, '/%')
</foreach>
)
UNION
SELECT a.store_id as storeId, a.store_name as shopName, a.store_num as shopCode, a.store_address as detailAddress,standard_store_type_name as standardStoreTypeName
FROM store_${enterpriseId} a
INNER JOIN store_master_signer_info_${enterpriseId} b ON a.store_id = b.store_id
WHERE a.is_delete = 'effective' and a.store_status != 'closed'
<if test="storeName!=null and storeName!=''">
AND (a.store_name LIKE CONCAT('%', #{storeName}, '%') or a.store_num LIKE CONCAT('%', #{storeName}, '%'))
</if>
<if test="storeNum!=null and storeNum!=''">
AND a.store_num = #{storeNum}
</if>
AND (b.signer1_mobile = #{mobile} OR b.signer2_mobile = #{mobile})
</when>
<!-- 情况2regionIdList为空直接查询关联表 -->
<otherwise>
SELECT a.store_id as storeId, a.store_name as shopName, a.store_num as shopCode, a.store_address as detailAddress,standard_store_type_name as standardStoreTypeName
FROM store_${enterpriseId} a
INNER JOIN store_master_signer_info_${enterpriseId} b ON a.store_id = b.store_id
WHERE a.is_delete = 'effective' and a.store_status != 'closed'
<if test="storeName!=null and storeName!=''">
AND (a.store_name LIKE CONCAT('%', #{storeName}, '%') or a.store_num LIKE CONCAT('%', #{storeName}, '%'))
</if>
<if test="storeNum!=null and storeNum!=''">
AND a.store_num = #{storeNum}
</if>
AND (b.signer1_mobile = #{mobile} OR b.signer2_mobile = #{mobile})
</otherwise>
</choose>
</select>
<select id="list" resultMap="BaseResultMap">
select *
from store_${enterpriseId}
where is_delete = 'effective'
<if test="isIot != null">
AND is_iot = #{isIot}
</if>
order by id asc
</select>
<select id="getStoreAreaList" resultType="com.cool.store.dto.store.StoreAreaDTO">
select
a.store_num as storeCode,
a.store_name as storeName,
a.store_id as storeId,
a.region_path as regionPath,
a.region_id as regionId,
a.region_id as areaId,
a.store_status as storeStatus
FROM store_${enterpriseId} a
<where>
a.is_delete='effective'
<if test="storeIds!=null and storeIds.size>0">
<foreach collection="storeIds" item="storeId" index="index" separator="," open="and a.store_id in("
close=")">
#{storeId}
</foreach>
</if>
</where>
</select>
<select id="getStoreNumByStoreCodes" resultMap="BaseResultMap">
select *
from store_${enterpriseId}
where is_delete = 'effective'
<if test="storeCodeIds != null">
<foreach collection="storeCodeIds" item="item" separator="," open="and store_num in (" close=")">
#{item}
</foreach>
</if>
</select>
<select id="listStoreByRegionPathList" resultType="com.cool.store.dto.store.StoreAreaDTO">
select
store_name as storeName,
store_id as storeId,
region_path as regionPath,
region_id as regionId,
region_id as areaId
from store_${enterpriseId}
where is_delete = 'effective'
<if test="regionPathList != null and regionPathList.size >0 ">
<foreach collection="regionPathList" item="regionPath" separator=" or " open="and (" close=" )">
region_path like concat(#{regionPath}, '%')
</foreach>
</if>
</select>
<insert id="batchInsertOrUpdateOrderTime">
INSERT INTO store_extend_info_${enterpriseId}
<trim prefix="(" suffix=")" suffixOverrides=",">
store_id,
latest_order_time
</trim>
VALUES
<foreach collection="dtoList" item="dto" separator=",">
<trim prefix="(" suffix=")" suffixOverrides=",">
#{dto.storeId},
#{dto.latestOrderTime}
</trim>
</foreach>
ON DUPLICATE KEY UPDATE
<trim suffixOverrides=",">
store_id = VALUES(store_id),
latest_order_time = VALUES(latest_order_time),
update_time = now(),
</trim>
</insert>
<select id="getAllStoreIdAndNum" resultType="com.cool.store.entity.StoreDO">
SELECT store_id, store_num
FROM store_${enterpriseId}
WHERE is_delete = 'effective'
<if test="storeStatus != null and !storeStatus.isEmpty()">
AND store_status IN
<foreach item="item" collection="storeStatus" separator="," open="(" close=")">
#{item}
</foreach>
</if>
</select>
<select id="getExistStoreNumAndFinishInvestStore" resultType="com.cool.store.entity.StoreDO">
SELECT a.store_id, a.store_num
FROM store_${enterpriseId} a
INNER JOIN xfsg_shop_info b ON a.store_num = b.shop_code
WHERE a.is_delete = 'effective' AND a.store_num IS NOT NULL AND a.store_num != ''
AND b.shop_status = 1
<if test="storeStatus != null and !storeStatus.isEmpty()">
AND a.store_status IN
<foreach item="item" collection="storeStatus" separator="," open="(" close=")">
#{item}
</foreach>
</if>
</select>
<select id="getStoreScore" resultType="java.math.BigDecimal">
SELECT score FROM store_extend_info_${enterpriseId}
WHERE store_id = #{storeId}
</select>
<select id="getScoreByStoreIds" resultType="java.util.Map">
SELECT store_id storeId, score FROM store_extend_info_${enterpriseId}
WHERE store_id IN
<foreach item="storeId" collection="storeIds" separator="," open="(" close=")">
#{storeId}
</foreach>
</select>
<insert id="updateStoreScore">
INSERT INTO store_extend_info_${enterpriseId} (store_id, score) VALUES (#{storeId}, #{score})
ON DUPLICATE KEY UPDATE
score = values(score)
</insert>
<update id="updateStoreStatus">
UPDATE store_${enterpriseId}
SET store_status = #{storeStatus},
open_date = #{actualOpenDate}
WHERE store_id = #{storeId} AND is_delete = 'effective'
</update>
<update id="updateStoreOpenDate">
UPDATE store_${enterpriseId}
SET open_date = #{actualOpenDate}
WHERE store_id = #{storeId} AND is_delete = 'effective'
</update>
<update id="updateStatus">
UPDATE store_${enterpriseId}
SET store_status = #{storeStatus}
WHERE store_id = #{storeId} AND is_delete = 'effective'
</update>
<update id="closeStore">
UPDATE store_${enterpriseId}
SET store_status = 'closed',
close_store_time = #{actualCloseData}
WHERE store_id = #{storeId} AND is_delete = 'effective' AND store_status != 'closed'
</update>
<insert id="insertOrUpdateCloseInfo">
INSERT INTO store_extend_info_${enterpriseId}(store_id, close_reason, close_nature)
VALUES(#{storeId}, #{closeReason}, #{closeNature})
ON DUPLICATE KEY UPDATE
close_reason = VALUES(close_reason),
close_nature = VALUES(close_nature)
</insert>
<insert id="insertOrUpdateCloseUpReason">
INSERT INTO store_extend_info_${enterpriseId}(store_id, close_up_reason, is_close_up)
VALUES(#{storeId}, #{closeUpReason}, #{isCloseUp})
ON DUPLICATE KEY UPDATE
close_up_reason = VALUES(close_up_reason),
is_close_up = VALUES(is_close_up)
</insert>
<select id="getCloseUpStatus" resultType="java.lang.Integer">
SELECT IFNULL(MAX(is_close_up), 0)
FROM store_extend_info_${enterpriseId}
WHERE store_id = #{storeId}
</select>
<select id="getNoOrderStore" resultType="com.cool.store.entity.StoreDO">
SELECT * FROM store_${enterpriseId} a
LEFT JOIN store_extend_info_${enterpriseId} b ON a.store_id = b.store_id
WHERE a.is_delete = 'effective' AND a.store_status != 'closed'
AND b.latest_order_time IS NOT NULL AND b.latest_order_time &lt; #{latestDate}
<choose>
<when test="inBusinessType != null and inBusinessType">
AND b.business_type IN
<foreach item="item" collection="businessTypes" separator="," open="(" close=")">
#{item}
</foreach>
</when>
<otherwise>
AND (b.business_type IS NULL OR b.business_type NOT IN
<foreach item="item" collection="businessTypes" separator="," open="(" close=")">
#{item}
</foreach>)
</otherwise>
</choose>
</select>
<select id="storeNumStatisticsByAd" resultType="java.util.Map">
SELECT YEAR(open_date) year, province, city, COUNT(1) store_num, QUARTER(open_date) quarter
FROM store_${enterpriseId}
WHERE is_delete = 'effective'
AND city IN
<foreach item="item" collection="cityNames" separator="," open="(" close=")">
#{item}
</foreach>
AND YEAR(open_date) IN
<foreach item="item" collection="years" separator="," open="(" close=")">
#{item}
</foreach>
GROUP BY YEAR(open_date), QUARTER(open_date), province, city
</select>
<select id="totalStoreNumByAd" resultType="java.lang.Integer">
SELECT COUNT(1)
FROM store_${enterpriseId}
WHERE is_delete = 'effective' AND province = #{province} AND city = #{city}
<if test="openStartTime != null">
AND open_time >= #{openStartTime}
</if>
<if test="openEndTime != null">
AND open_time &lt;= #{openEndTime}
</if>
</select>
<select id="getStoreByRegionIds" resultMap="BaseResultMap">
SELECT * FROM store_${enterpriseId}
<where>
is_delete = 'effective' AND store_status != 'closed'
<if test="keyword != null and keyword != ''">
AND (store_name LIKE concat('%', #{keyword}, '%') OR store_num LIKE concat('%', #{keyword}, '%'))
</if>
<if test="regionIds != null and !regionIds.isEmpty()">
AND (
<foreach collection="regionIds" item="regionId" separator=" OR ">
region_path LIKE concat('%/', #{regionId}, '/%')
</foreach>
)
</if>
</where>
</select>
<select id="getStoreAddress" resultType="com.cool.store.dto.store.StoreAddressDTO">
SELECT * FROM store_${enterpriseId}
<where>
is_delete = 'effective'
<if test="storeCode!=null and storeCode!=''">
and store_num = #{storeCode}
</if>
<if test="flag==null">
and (`city` is not null and city!='') and (county is null or county = '' )
</if>
</where>
</select>
<update id="batchUpdateAddress" parameterType="list">
UPDATE store_${enterpriseId}
<trim prefix="SET" suffixOverrides=",">
<trim prefix="province = CASE" suffix="END,">
<foreach collection="list" item="item" index="index">
WHEN store_id = #{item.storeId} THEN #{item.province}
</foreach>
</trim>
<trim prefix="city = CASE" suffix="END,">
<foreach collection="list" item="item" index="index">
WHEN store_id = #{item.storeId} THEN #{item.city}
</foreach>
</trim>
<trim prefix="county = CASE" suffix="END,">
<foreach collection="list" item="item" index="index">
WHEN store_id = #{item.storeId} THEN #{item.county}
</foreach>
</trim>
</trim>
WHERE store_id IN
<foreach collection="list" item="item" open="(" separator="," close=")">
#{item.storeId}
</foreach>
</update>
<select id="getPrivateSphereQrCode" resultType="java.lang.String">
SELECT private_sphere_qr FROM store_extend_info_${enterpriseId}
WHERE store_id = #{storeId}
</select>
<insert id="insertOrUpdateSoftOpenDate">
INSERT INTO store_extend_info_${enterpriseId}(store_id, soft_open_date, soft_open_job_time)
VALUES
<foreach collection="list" item="item" separator=",">
(#{item.storeId}, #{item.softOpenDate}, now())
</foreach>
ON DUPLICATE KEY UPDATE
soft_open_date = VALUES(soft_open_date),
soft_open_job_time = VALUES(soft_open_job_time)
</insert>
<update id="updateStatusBatch">
UPDATE store_${enterpriseId}
SET store_status = #{storeStatus}
WHERE store_id IN
<foreach item="item" collection="storeIds" separator="," open="(" close=")">
#{item}
</foreach>
</update>
<insert id="insertOrUpdateOpenReportTime">
INSERT INTO store_extend_info_${enterpriseId}(store_id, open_report_time)
VALUES
(#{storeId}, #{openReportTime})
ON DUPLICATE KEY UPDATE
open_report_time = VALUES(open_report_time)
</insert>
</mapper>