feat: add dashboard and virtual pay enhancements

This commit is contained in:
王鹏
2026-07-29 14:34:54 +08:00
parent 2250f744d1
commit 349f1c0374
55 changed files with 3085 additions and 213 deletions

View File

@@ -33,6 +33,10 @@
<result property="listName" column="sub_list_name" />
<result property="listUrl" column="sub_list_url" />
<result property="password" column="sub_password" />
<result property="priceFen" column="sub_price_fen" />
<result property="status" column="sub_status" />
<result property="sortOrder" column="sub_sort_order" />
<result property="purchased" column="sub_purchased" />
<result property="appResourceId" column="sub_app_resource_id" />
</resultMap>
@@ -65,10 +69,36 @@
select a.id, a.resource_title, a.show_img, a.`explain`,a.`keyword`, a.resource_type, a.is_show, a.is_ad, a.ad_number, a.price_fen,
(select vp.product_id from app_virtual_product vp where vp.price_fen = a.price_fen and vp.status = 1 limit 1) as virtual_product_id,
a.down_num, a.weight, a.del_flag, a.create_by, a.create_time, a.remark,
b.id as sub_id, b.list_name as sub_list_name, b.list_url as sub_list_url, b.password as sub_password, b.app_resource_id as sub_app_resource_id
b.id as sub_id, b.list_name as sub_list_name, b.list_url as sub_list_url,
b.password as sub_password, b.price_fen as sub_price_fen,
b.status as sub_status, b.sort_order as sub_sort_order,
0 as sub_purchased, b.app_resource_id as sub_app_resource_id
from app_resource a
left join app_resource_list b on b.app_resource_id = a.id
where a.id = #{id}
order by b.sort_order asc, b.id asc
</select>
<select id="selectAppResourceListById" parameterType="Long" resultType="AppResourceList">
select id, list_name as listName, list_url as listUrl, password,
price_fen as priceFen, status, sort_order as sortOrder,
app_resource_id as appResourceId
from app_resource_list
where id = #{id}
limit 1
</select>
<select id="selectHighestEntitledResourceList" resultType="AppResourceList">
select rl.id, rl.list_name as listName, rl.list_url as listUrl, rl.password,
rl.price_fen as priceFen, rl.status, rl.sort_order as sortOrder,
rl.app_resource_id as appResourceId
from app_resource_entitlement re
inner join app_resource_list rl on rl.id = re.resource_list_id
where re.user_id = #{userId}
and re.resource_id = #{resourceId}
and re.status = 1
order by rl.sort_order desc, rl.id desc
limit 1
</select>
<insert id="insertAppResource" parameterType="AppResource" useGeneratedKeys="true" keyProperty="id">
@@ -154,42 +184,129 @@
</delete>
<insert id="batchAppResourceList">
insert into app_resource_list( id, list_name, list_url, password, app_resource_id) values
insert into app_resource_list
(id, list_name, list_url, password, price_fen, status, sort_order, app_resource_id) values
<foreach item="item" index="index" collection="list" separator=",">
( #{item.id}, #{item.listName}, #{item.listUrl}, #{item.password}, #{item.appResourceId})
(#{item.id}, #{item.listName}, #{item.listUrl}, #{item.password},
#{item.priceFen}, #{item.status}, #{item.sortOrder}, #{item.appResourceId})
</foreach>
</insert>
<select id="countOrderedRemovedResourceLists" resultType="int">
select count(1)
from app_virtual_order vo
inner join app_resource_list rl on rl.id = vo.resource_list_id
where rl.app_resource_id = #{resourceId}
<if test="retainedIds != null and retainedIds.size() > 0">
and rl.id not in
<foreach item="id" collection="retainedIds" open="(" separator="," close=")">
#{id}
</foreach>
</if>
</select>
<select id="countVirtualOrdersByResourceId" parameterType="Long" resultType="int">
select count(1) from app_virtual_order where resource_id = #{resourceId}
</select>
<select id="selectAppResourceByIdAndUserId" resultMap="AppResourceAppResourceListResult">
select a.id, a.resource_title, a.show_img, a.`explain`, a.`keyword`, a.resource_type, a.is_show,
CASE
WHEN #{userId} is not null and (
(SELECT COUNT(1) FROM app_integral_record
WHERE resource_id = #{id} AND user_id = #{userId}
AND source = '资源兑换' AND is_add = 1) > 0
OR
(SELECT COUNT(1) FROM app_resource_entitlement WHERE resource_id = #{id} AND user_id = #{userId} AND status = 1) > 0
) THEN 0
ELSE a.is_ad
END as is_ad,
case
when #{userId} is not null
and (
(a.is_ad in (2, 3)
and exists(select 1 from app_integral_record ir
where ir.resource_id = a.id and ir.user_id = #{userId}
and ir.source = '资源兑换' and ir.is_add = 1))
or
(a.is_ad = 3
and exists(select 1 from app_resource_entitlement re
where re.resource_id = a.id and re.user_id = #{userId}
and re.status = 1 and re.resource_list_id is null))
)
then 0
else a.is_ad
end as is_ad,
a.ad_number, a.price_fen,
(select vp.product_id from app_virtual_product vp where vp.price_fen = a.price_fen and vp.status = 1 limit 1) as virtual_product_id,
(select vp.product_id from app_virtual_product vp
where vp.price_fen = a.price_fen and vp.status = 1 limit 1) as virtual_product_id,
a.down_num, a.weight, a.del_flag, a.create_by, a.create_time, a.remark,
b.id as sub_id, b.list_name as sub_list_name, b.list_url as sub_list_url,
b.password as sub_password, b.app_resource_id as sub_app_resource_id
b.id as sub_id, b.list_name as sub_list_name,
case when
a.is_ad not in (2, 3)
or (
#{userId} is not null and (
exists(select 1 from app_integral_record ir
where ir.resource_id = a.id and ir.user_id = #{userId}
and ir.source = '资源兑换' and ir.is_add = 1)
or exists(select 1 from app_resource_entitlement re
left join app_resource_list owned_rl
on owned_rl.id = re.resource_list_id
where re.resource_id = a.id and re.user_id = #{userId}
and re.status = 1
and (re.resource_list_id is null
or (owned_rl.app_resource_id = a.id
and owned_rl.sort_order &gt;= b.sort_order)))
)
)
then b.list_url else null end as sub_list_url,
case when
a.is_ad not in (2, 3)
or (
#{userId} is not null and (
exists(select 1 from app_integral_record ir
where ir.resource_id = a.id and ir.user_id = #{userId}
and ir.source = '资源兑换' and ir.is_add = 1)
or exists(select 1 from app_resource_entitlement re
left join app_resource_list owned_rl
on owned_rl.id = re.resource_list_id
where re.resource_id = a.id and re.user_id = #{userId}
and re.status = 1
and (re.resource_list_id is null
or (owned_rl.app_resource_id = a.id
and owned_rl.sort_order &gt;= b.sort_order)))
)
)
then b.password else null end as sub_password,
b.price_fen as sub_price_fen, b.status as sub_status,
b.sort_order as sub_sort_order,
case when
a.is_ad not in (2, 3)
or (
#{userId} is not null and (
exists(select 1 from app_integral_record ir
where ir.resource_id = a.id and ir.user_id = #{userId}
and ir.source = '资源兑换' and ir.is_add = 1)
or exists(select 1 from app_resource_entitlement re
left join app_resource_list owned_rl
on owned_rl.id = re.resource_list_id
where re.resource_id = a.id and re.user_id = #{userId}
and re.status = 1
and (re.resource_list_id is null
or (owned_rl.app_resource_id = a.id
and owned_rl.sort_order &gt;= b.sort_order)))
)
)
then 1 else 0 end as sub_purchased,
b.app_resource_id as sub_app_resource_id
from app_resource a
left join app_resource_list b on b.app_resource_id = a.id
and (
a.is_ad not in (2, 3)
or (
#{userId} is not null and (
exists(select 1 from app_integral_record ir
where ir.resource_id = a.id and ir.user_id = #{userId}
and ir.source = '资源兑换' and ir.is_add = 1)
or exists(select 1 from app_resource_entitlement re where re.resource_id = a.id and re.user_id = #{userId} and re.status = 1)
a.is_ad != 3
or b.status = 1
or (
#{userId} is not null
and exists(select 1 from app_resource_entitlement re
left join app_resource_list owned_rl
on owned_rl.id = re.resource_list_id
where re.resource_id = a.id and re.user_id = #{userId}
and re.status = 1
and (re.resource_list_id is null
or (owned_rl.app_resource_id = a.id
and owned_rl.sort_order &gt;= b.sort_order)))
)
)
)
where a.id = #{id}
order by b.sort_order asc, b.id asc
</select>
</mapper>