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

@@ -11,6 +11,8 @@
<result property="nickName" column="nick_name"/>
<result property="resourceId" column="resource_id"/>
<result property="resourceTitle" column="resource_title"/>
<result property="resourceListId" column="resource_list_id"/>
<result property="specName" column="spec_name"/>
<result property="productId" column="product_id"/>
<result property="priceFen" column="price_fen"/>
<result property="openId" column="open_id"/>
@@ -24,31 +26,77 @@
<result property="lastQueryTime" column="last_query_time"/>
</resultMap>
<resultMap id="AppVirtualOrderSummaryResult" type="com.ruoyi.app.domain.AppVirtualOrderSummary">
<result property="orderNo" column="order_no"/>
<result property="resourceId" column="resource_id"/>
<result property="resourceTitle" column="resource_title"/>
<result property="resourceListId" column="resource_list_id"/>
<result property="specName" column="spec_name"/>
<result property="priceFen" column="price_fen"/>
<result property="status" column="status"/>
<result property="createTime" column="create_time"/>
<result property="payTime" column="pay_time"/>
<result property="refundTime" column="refund_time"/>
</resultMap>
<sql id="selectAppVirtualOrderVo">
select vo.id, vo.order_no, vo.user_id, u.user_name, u.nick_name,
vo.resource_id, r.resource_title, vo.product_id, vo.price_fen,
vo.resource_id, r.resource_title, vo.resource_list_id,
coalesce(vo.spec_name_snapshot, rl.list_name, '旧版整项资源') as spec_name,
vo.product_id, vo.price_fen,
vo.open_id, vo.status, vo.wx_order_no, vo.transaction_id,
vo.create_time, vo.pay_time, vo.provide_time, vo.refund_time, vo.last_query_time
from app_virtual_order vo
left join sys_user u on u.user_id = vo.user_id
left join app_resource r on r.id = vo.resource_id
left join app_resource_list rl on rl.id = vo.resource_list_id
</sql>
<select id="lockOpenIdForOrder" parameterType="Long" resultType="java.lang.String">
select open_id
from sys_user
where user_id = #{userId} and del_flag = '0'
for update
</select>
<insert id="insertAppVirtualOrder" parameterType="AppVirtualOrder" useGeneratedKeys="true" keyProperty="id">
insert into app_virtual_order
(order_no, user_id, resource_id, product_id, price_fen, open_id, status, create_time)
(order_no, user_id, resource_id, resource_list_id, spec_name_snapshot,
product_id, price_fen, open_id, status, create_time)
values
(#{orderNo}, #{userId}, #{resourceId}, #{productId}, #{priceFen}, #{openId}, #{status}, #{createTime})
(#{orderNo}, #{userId}, #{resourceId}, #{resourceListId}, #{specName},
#{productId}, #{priceFen}, #{openId}, #{status}, #{createTime})
</insert>
<select id="selectByOrderNo" resultMap="AppVirtualOrderResult">
select id, order_no, user_id, resource_id, product_id, price_fen, open_id, status,
select id, order_no, user_id, resource_id, resource_list_id,
spec_name_snapshot as spec_name, product_id, price_fen, open_id, status,
wx_order_no, transaction_id, create_time, pay_time, provide_time, refund_time, last_query_time
from app_virtual_order
where order_no = #{orderNo}
limit 1
</select>
<select id="selectPendingByPurchase" resultMap="AppVirtualOrderResult">
select id, order_no, user_id, resource_id, resource_list_id,
spec_name_snapshot as spec_name, product_id, price_fen, open_id, status,
wx_order_no, transaction_id, create_time, pay_time, provide_time, refund_time, last_query_time
from app_virtual_order
where user_id = #{userId}
and resource_id = #{resourceId}
and status = 0
<choose>
<when test="resourceListId != null">
and (resource_list_id = #{resourceListId} or resource_list_id is null)
</when>
<otherwise>
and resource_list_id is null
</otherwise>
</choose>
order by id desc
limit 1
</select>
<select id="selectAppVirtualOrderById" parameterType="Long" resultMap="AppVirtualOrderResult">
<include refid="selectAppVirtualOrderVo"/>
where vo.id = #{id}
@@ -72,6 +120,7 @@
or u.nick_name like concat('%', #{userName}, '%'))
</if>
<if test="resourceId != null">and vo.resource_id = #{resourceId}</if>
<if test="resourceListId != null">and vo.resource_list_id = #{resourceListId}</if>
<if test="productId != null and productId != ''">
and vo.product_id like concat('%', #{productId}, '%')
</if>
@@ -89,10 +138,30 @@
order by vo.create_time desc, vo.id desc
</select>
<select id="selectMyOrderList" resultMap="AppVirtualOrderSummaryResult">
select vo.order_no, vo.resource_id, coalesce(r.resource_title, '资源已删除') as resource_title,
vo.resource_list_id,
coalesce(vo.spec_name_snapshot, rl.list_name, '旧版整项资源') as spec_name,
vo.price_fen, vo.status, vo.create_time, vo.pay_time, vo.refund_time
from app_virtual_order vo
left join app_resource r on r.id = vo.resource_id
left join app_resource_list rl on rl.id = vo.resource_list_id
where vo.user_id = #{userId}
order by vo.create_time desc, vo.id desc
</select>
<select id="countAnyEntitlement" resultType="int">
select
(select count(1) from app_resource_entitlement
where user_id = #{userId} and resource_id = #{resourceId} and status = 1)
where user_id = #{userId} and resource_id = #{resourceId} and status = 1
<choose>
<when test="resourceListId != null">
and (resource_list_id is null or resource_list_id = #{resourceListId})
</when>
<otherwise>
and resource_list_id is null
</otherwise>
</choose>)
+
(select count(1) from app_integral_record
where user_id = #{userId}
@@ -108,14 +177,14 @@
transaction_id = coalesce(#{transactionId}, transaction_id),
pay_time = coalesce(#{payTime}, pay_time),
provide_time = now()
where order_no = #{orderNo} and status = 0
where order_no = #{orderNo} and status in (0, 3)
</update>
<insert id="insertEntitlement" parameterType="AppVirtualOrder">
insert into app_resource_entitlement
(user_id, resource_id, order_no, status, granted_time)
(user_id, resource_id, resource_list_id, order_no, status, granted_time)
values
(#{userId}, #{resourceId}, #{orderNo}, 1, now())
(#{userId}, #{resourceId}, #{resourceListId}, #{orderNo}, 1, now())
on duplicate key update
order_no = values(order_no),
status = 1,
@@ -140,6 +209,14 @@
where order_no = #{orderNo} and status = 0
</update>
<update id="cancelPendingOrder">
update app_virtual_order
set status = 3
where order_no = #{orderNo}
and user_id = #{userId}
and status = 0
</update>
<update id="markQuerying">
update app_virtual_order
set last_query_time = now()