feat(service): 批量获取景区和设备信息

- 在 DeviceRepository 中添加批量获取设备信息的方法
- 在 ScenicRepository 中添加批量获取景区信息的方法
- 修改 OrderServiceImpl,使用批量方法获取景区名称
- 移除多个 mapper 文件中冗余的景区信息查询
This commit is contained in:
2025-09-07 01:42:38 +08:00
parent d9a2da49bb
commit 5a89a7c60a
14 changed files with 289 additions and 60 deletions

View File

@@ -42,7 +42,7 @@
(select min(r.create_time) from broker_record r where r.broker_id = b.id) as first_broker_date,
(select max(r.create_time) from broker_record r where r.broker_id = b.id) as last_broker_date,
b.create_at, b.update_at
from broker b left join scenic s on b.scenic_id = s.id
from broker b
<where>
<if test="scenicId!= null">
and b.scenic_id = #{scenicId}
@@ -65,8 +65,8 @@
</where>
</select>
<select id="getById" resultType="com.ycwl.basic.model.pc.broker.resp.BrokerRespVO">
select b.id, scenic_id, s.name as scenicName, b.`name`, b.phone, b.broker_enable, b.broker_rate, b.status, b.create_at, b.update_at
from broker b left join scenic s on b.scenic_id = s.id
select b.id, scenic_id, b.`name`, b.phone, b.broker_enable, b.broker_rate, b.status, b.create_at, b.update_at
from broker b
where b.id = #{id}
</select>
</mapper>

View File

@@ -10,13 +10,12 @@
</update>
<select id="selectByQuery" resultType="com.ycwl.basic.model.pc.coupon.resp.CouponRespVO">
SELECT
c.id, scenic_id AS scenicId, s.name as scenicName,
c.id, scenic_id AS scenicId,
c.name AS name, c.description AS description, c.countdown AS countdown, c.broadcast,
config_ids AS configIds, discount_price AS discountPrice,
type, discount_type AS discountType,
c.status, c.create_at
FROM coupon c
LEFT JOIN scenic s ON c.scenic_id = s.id
<where>
AND c.deleted = 0
<if test="scenicId != null">AND scenic_id = #{scenicId}</if>

View File

@@ -4,7 +4,7 @@
<select id="listExtraDeviceByScenicId" resultType="com.ycwl.basic.model.pc.device.resp.DeviceRespVO">
select d.id, d.ident as no, d.scenic_id, d.name, d.status, s.name as scenic_name
from extra_device d
left join scenic s on d.scenic_id = s.id
where d.scenic_id = #{scenicId}
and d.status = 1
</select>

View File

@@ -110,8 +110,7 @@
oi.order_id AS orderId,
oi.goods_id,
msd.source_id,
sc.id AS scenic_id,
sc.name AS scenic_name,
o.scenic_id AS scenic_id,
CASE oi.goods_type
WHEN '0' THEN mvd.cover_url
WHEN '3' THEN mpd.url
@@ -147,7 +146,6 @@
END AS imgUrl
FROM order_item oi
LEFT JOIN `order` o ON oi.order_id = o.id
LEFT JOIN scenic sc ON o.scenic_id = sc.id
LEFT JOIN member_video_data mvd ON o.face_id = mvd.face_id AND oi.goods_id = mvd.video_id
LEFT JOIN member_source_data msd ON o.face_id = msd.face_id AND oi.goods_id = msd.face_id AND msd.type = oi.goods_type
LEFT JOIN member_photo_data mpd ON oi.goods_id = mpd.id AND mpd.type = oi.goods_type
@@ -238,13 +236,12 @@
delete from `order` where id = #{id}
</delete>
<select id="list" resultMap="PCBaseResultListMap">
select o.id, o.scenic_id, s.name as scenic_name, o.member_id,m.nickname, m.uid, o.type, o.openid, o.face_id, f.face_url, o.price, pay_price, remark, o.broker_id, o.promo_code,
select o.id, o.scenic_id, o.member_id,m.nickname, m.uid, o.type, o.openid, o.face_id, f.face_url, o.price, pay_price, remark, o.broker_id, o.promo_code,
o.coupon_price,
refund_reason, refund_status, o.`status`, refund_at, pay_at, cancel_at, o.create_at
from `order` AS o
left join face f on o.face_id = f.id
left join member m on o.member_id = m.id
left join scenic s on o.scenic_id = s.id
<where>
<if test="id!= null ">
and o.id LIKE CONCAT('%',#{id},'%')
@@ -312,13 +309,12 @@
order by o.create_at desc
</select>
<select id="listDetail" resultMap="PCBaseResultMap">
select o.id, o.scenic_id, s.name as scenic_name, o.member_id,m.nickname, m.uid, o.type, o.openid, o.face_id, f.face_url, o.price, pay_price, remark, o.broker_id, o.promo_code,
select o.id, o.scenic_id, o.member_id,m.nickname, m.uid, o.type, o.openid, o.face_id, f.face_url, o.price, pay_price, remark, o.broker_id, o.promo_code,
o.coupon_price,
refund_reason, refund_status, o.`status`, refund_at, pay_at, cancel_at, o.create_at
from `order` AS o
left join face f on o.face_id = f.id
left join member m on o.member_id = m.id
left join scenic s on o.scenic_id = s.id
<where>
<if test="id!= null ">
and o.id = #{id}
@@ -378,14 +374,13 @@
order by o.create_at desc
</select>
<select id="getById" resultMap="PCBaseResultMap">
select o.id, o.scenic_id, s.name as scenic_name, o.member_id, o.type, o.openid, o.face_id, f.face_url, o.price, o.pay_price, o.remark, o.broker_id, o.promo_code, o.refund_reason,
select o.id, o.scenic_id, o.member_id, o.type, o.openid, o.face_id, f.face_url, o.price, o.pay_price, o.remark, o.broker_id, o.promo_code, o.refund_reason,
o.coupon_price,
o.refund_status, o.status, o.create_at, o.update_at, o.pay_at, o.cancel_at, o.refund_at,
m.nickname, m.uid
from `order` o
left join face f on o.face_id = f.id
left join member m on m.id = o.member_id
left join scenic s on o.scenic_id = s.id
where o.id = #{id}
</select>
<select id="countByUserId" resultType="java.lang.Integer">
@@ -397,10 +392,9 @@
select o.id, o.member_id,o.openid, o.type, o.face_id, f.face_url, o.price, pay_price, remark, o.broker_id, o.promo_code,
o.coupon_price,
refund_reason, refund_status, o.`status`, o.create_at, refund_at, pay_at, cancel_at,
sc.name scenicName
o.scenic_id
from `order` AS o
left join face f on o.face_id = f.id
left join scenic sc on o.scenic_id = sc.id
<where>
<if test="memberId!=null">
and o.member_id=#{memberId}
@@ -412,18 +406,16 @@
select o.id, o.member_id, o.face_id,o.openid, o.type, o.price, o.slash_price, pay_price, remark, o.broker_id, o.promo_code,
o.coupon_price,
refund_reason, refund_status, o.`status`, o.create_at, refund_at, pay_at, cancel_at,
o.scenic_id, sc.name scenicName
o.scenic_id
from `order` AS o
left join member m on o.member_id = m.id
left join scenic sc on o.scenic_id = sc.id
where o.id = #{id}
</select>
<select id="refundList" resultType="com.ycwl.basic.model.pc.order.resp.OrderRespVO">
select o.id, o.scenic_id, s.name as scenic_name, o.member_id,m.nickname,m.uid as memberUid , o.type, o.openid, o.price, pay_price, remark, o.broker_id, o.promo_code,
select o.id, o.scenic_id, o.member_id,m.nickname,m.uid as memberUid , o.type, o.openid, o.price, pay_price, remark, o.broker_id, o.promo_code,
refund_reason, refund_status, o.`status`, refund_at, pay_at, cancel_at, o.create_at
from `order` AS o
left join member m on o.member_id = m.id
left join scenic s on o.scenic_id = s.id
<where>
o.refund_status != 0
<if test="id!= null ">

View File

@@ -34,14 +34,12 @@
</delete>
<select id="getById" resultType="com.ycwl.basic.model.pc.price.resp.PriceConfigRespVO">
select p.*, s.name as scenic_name from price_config p
left join scenic s on s.id = p.scenic_id
select p.* from price_config p
where p.id = #{id}
</select>
<select id="listByCondition" resultType="com.ycwl.basic.model.pc.price.resp.PriceConfigRespVO">
select p.*, s.name as scenic_name from price_config p
left join scenic s on s.id = p.scenic_id
select p.* from price_config p
<where>
<if test="req.scenicId != null">
and p.scenic_id = #{req.scenicId}

View File

@@ -33,44 +33,39 @@
select * from print_task WHERE id = #{id}
</select>
<select id="listByScenicId" resultType="com.ycwl.basic.model.pc.printer.resp.PrinterResp">
SELECT p.*, s.name as scenic_name
SELECT p.*
FROM printer p
LEFT JOIN scenic s on s.id = p.scenic_id
WHERE p.scenic_id = #{scenicId} and p.status = 1
</select>
<select id="listRelation" resultType="com.ycwl.basic.model.pc.printer.resp.MemberPrintResp">
SELECT p.id, p.scenic_id as scenicId, s.name as scenicName, p.member_id as memberId,
SELECT p.id, p.scenic_id as scenicId, p.member_id as memberId,
p.orig_url as origUrl, p.crop_url as cropUrl, p.order_id as orderId, p.quantity,
p.status, p.create_time as createTime, p.printer_id
FROM member_print p
LEFT JOIN scenic s ON s.id = p.scenic_id
WHERE p.member_id = #{memberId} AND p.scenic_id = #{scenicId} AND p.status = 0
</select>
<select id="getUserPhoto" resultType="com.ycwl.basic.model.pc.printer.resp.MemberPrintResp">
SELECT p.id, p.scenic_id, s.name as scenicName, p.member_id as memberId,
SELECT p.id, p.scenic_id, p.member_id as memberId,
p.member_id, p.orig_url as origUrl, p.crop_url as cropUrl, p.order_id as orderId, p.quantity,
p.status, p.create_time as createTime, p.printer_id
FROM member_print p
LEFT JOIN scenic s ON s.id = p.scenic_id
WHERE p.id = #{id} AND p.member_id = #{memberId} AND p.scenic_id = #{scenicId}
</select>
<select id="getUserPhotoByIds" resultType="com.ycwl.basic.model.pc.printer.resp.MemberPrintResp">
SELECT p.id, p.scenic_id, s.name as scenicName, p.member_id as memberId,
SELECT p.id, p.scenic_id, p.member_id as memberId,
p.orig_url as origUrl, p.crop_url as cropUrl, p.order_id as orderId, p.quantity,
p.status, p.create_time as createTime, p.printer_id
FROM member_print p
LEFT JOIN scenic s ON s.id = p.scenic_id
WHERE p.id IN
<foreach collection="ids" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</select>
<select id="listRelationByOrderId" resultType="com.ycwl.basic.model.pc.printer.resp.MemberPrintResp">
SELECT p.id, p.scenic_id as scenicId, s.name as scenicName, p.member_id as memberId,
SELECT p.id, p.scenic_id as scenicId, p.member_id as memberId,
p.orig_url as origUrl, p.crop_url as cropUrl, p.order_id as orderId, p.quantity,
p.status, p.create_time as createTime, p.printer_id
FROM member_print p
LEFT JOIN scenic s ON s.id = p.scenic_id
WHERE p.id in (select order_item.goods_id from order_item where order_item.order_id = #{orderId} and order_item.goods_type = 3)
</select>

View File

@@ -2,9 +2,9 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.ycwl.basic.profitsharing.mapper.ProfitSharingConfigMapper">
<select id="list" resultType="com.ycwl.basic.profitsharing.dto.ProfitSharingConfigVO">
SELECT c.*, s.name as scenic_name
SELECT c.*
FROM profit_sharing_config c
left join scenic s on c.scenic_id = s.id
<where>
<if test="scenicId != null">
AND scenic_id = #{scenicId}

View File

@@ -14,9 +14,8 @@
WHERE scenic_id = #{scenicId} AND order_id = #{orderId}
</update>
<select id="list" resultType="com.ycwl.basic.profitsharing.dto.ProfitSharingRecordRespVO">
SELECT r.*, s.name as scenic_name
SELECT r.*
FROM profit_sharing_record r
LEFT JOIN scenic s ON s.id = r.scenic_id
<where>
<if test="withDeleted != true">
delete_time is null
@@ -65,9 +64,8 @@
GROUP BY order_id
</select>
<select id="listByOrderIds" resultType="com.ycwl.basic.profitsharing.dto.ProfitSharingRecordRespVO">
SELECT r.*, s.name as scenic_name
SELECT r.*
FROM profit_sharing_record r
LEFT JOIN scenic s ON s.id = r.scenic_id
WHERE r.order_id IN
<foreach collection="orderIds" item="orderId" open="(" close=")" separator=",">
#{orderId}

View File

@@ -91,13 +91,13 @@
select so.id, ms.scenic_id, device_id, ms.member_id, url, ms.is_free, so.create_time, so.update_time,sc.`name` as scenicName
from member_source ms
left join source so on ms.source_id = so.id
left join scenic sc on sc.id = so.scenic_id
where so.id = #{id} and ms.member_id = #{userId} and so.id is not null
</select>
<select id="getById" resultType="com.ycwl.basic.model.pc.source.resp.SourceRespVO">
select so.id, scenic_id, device_id, url, video_url, so.create_time, so.update_time,sc.`name` as scenicName
from source so
left join scenic sc on sc.id = so.scenic_id
where so.id = #{id}
</select>
<select id="listGroupByType" resultType="com.ycwl.basic.model.pc.source.resp.SourceRespVO">
@@ -141,7 +141,7 @@
select so.id, ms.scenic_id, device_id, url, ms.is_free, so.create_time, so.update_time,sc.`name` as scenicName, ms.is_buy, video_url
from member_source ms
left join source so on ms.source_id = so.id
left join scenic sc on sc.id = so.scenic_id
where
ms.member_id = #{memberId} and so.id is not null
<if test="scenicId!= null">and ms.scenic_id = #{scenicId} </if>
@@ -155,7 +155,7 @@
select so.id, ms.scenic_id, device_id, url, ms.is_free, video_url, so.create_time, so.update_time,sc.`name` as scenicName, ms.is_buy
from member_source ms
left join source so on ms.source_id = so.id
left join scenic sc on sc.id = so.scenic_id
where ms.member_id = #{userId} and ms.source_id = #{sourceId} and so.id is not null
limit 1
</select>
@@ -163,7 +163,7 @@
select so.id, ms.face_id, ms.scenic_id, ms.type, so.url, ms.is_free, so.create_time, so.update_time,sc.`name` as scenicName, ms.is_buy
from member_source ms
left join source so on ms.source_id = so.id
left join scenic sc on sc.id = so.scenic_id
where
ms.member_id = #{memberId} and so.id
<if test="faceId!= null">and ms.face_id = #{faceId} </if>

View File

@@ -76,8 +76,8 @@
delete from template_config where id = #{id}
</delete>
<select id="list" resultType="com.ycwl.basic.model.pc.template.resp.TemplateRespVO">
select t.*, s.name as scenic_name
from template t left join scenic s on s.id = t.scenic_id
select t.*
from template t
<where>
pid = 0
<if test="scenicId!=null" >
@@ -93,13 +93,13 @@
order by scenic_id, sort
</select>
<select id="getById" resultType="com.ycwl.basic.model.pc.template.resp.TemplateRespVO">
select t.*, s.name as scenic_name
from template t left join scenic s on s.id = t.scenic_id
select t.*
from template t
where t.id = #{id}
</select>
<select id="getByPid" resultType="com.ycwl.basic.model.pc.template.resp.TemplateRespVO">
select t.*, s.name as scenic_name
from template t left join scenic s on s.id = t.scenic_id
select t.*
from template t
where pid = #{id}
order by sort
</select>
@@ -113,10 +113,10 @@
order by sort
</select>
<select id="listFor" resultType="com.ycwl.basic.model.mobile.scenic.content.ContentPageVO">
select t.id templateId, t.scenic_id, s.name as scenic_name, t.`name`, pid, t.cover_url templateCoverUrl,
select t.id templateId, t.scenic_id, t.`name`, pid, t.cover_url templateCoverUrl,
0 as sourceType, sort,
t.create_time, t.price
from template t left join scenic s on s.id = t.scenic_id
from template t
where t.scenic_id = #{scenicId} and pid = 0 and t.status = 1
order by sort
</select>

View File

@@ -77,9 +77,8 @@
</delete>
<select id="list" resultType="com.ycwl.basic.model.pc.video.resp.VideoRespVO">
select v.id, v.scenic_id, template_id, task_id, worker_id, video_url, v.create_time, v.update_time,
s.name scenicName, s.latitude, s.longitude, t.name templateName, t.price templatePrice,t.cover_url templateCoverUrl
t.name templateName, t.price templatePrice,t.cover_url templateCoverUrl
from video v
left join scenic s on s.id = v.scenic_id
left join template t on v.template_id = t.id
<where>
<if test="scenicId!= null">and v.scenic_id = #{scenicId} </if>
@@ -99,9 +98,8 @@
<select id="getById" resultType="com.ycwl.basic.model.pc.video.resp.VideoRespVO">
select v.id, v.scenic_id, template_id, task_id, worker_id, video_url, v.create_time, v.update_time,
t.name templateName,t.price templatePrice, t.cover_url templateCoverUrl, t.slash_price slashPrice,
s.name scenicName, v.height, v.width, v.duration
v.height, v.width, v.duration
from video v
left join scenic s on v.scenic_id = s.id
left join template t on v.template_id = t.id
where v.id = #{id}
</select>
@@ -110,10 +108,9 @@
</select>
<select id="queryByRelation" resultType="com.ycwl.basic.model.pc.video.resp.VideoRespVO">
select v.id, mv.scenic_id, v.template_id, mv.task_id, mv.face_id, worker_id, video_url, v.create_time, v.update_time,
s.name scenicName, t.name templateName, t.price templatePrice,t.cover_url templateCoverUrl, mv.is_buy
t.name templateName, t.price templatePrice,t.cover_url templateCoverUrl, mv.is_buy
from member_video mv
left join video v on mv.video_id = v.id
left join scenic s on s.id = v.scenic_id
left join template t on mv.template_id = t.id
<where>
<if test="scenicId!= null">and mv.scenic_id = #{scenicId} </if>