feat: 新增虚拟支付订单与网盘链接检测功能
This commit is contained in:
@@ -14,6 +14,8 @@
|
||||
<result property="isShow" column="is_show" />
|
||||
<result property="isAd" column="is_ad" />
|
||||
<result property="adNumber" column="ad_number" />
|
||||
<result property="priceFen" column="price_fen" />
|
||||
<result property="virtualProductId" column="virtual_product_id" />
|
||||
<result property="downNum" column="down_num" />
|
||||
<result property="weight" column="weight" />
|
||||
<result property="delFlag" column="del_flag" />
|
||||
@@ -35,27 +37,34 @@
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectAppResourceVo">
|
||||
select id, resource_title, show_img, `explain`, resource_type, keyword, is_show, is_ad, ad_number, down_num, weight, del_flag, create_by, create_time, remark from app_resource
|
||||
select a.id, a.resource_title, a.show_img, a.`explain`, a.resource_type, a.keyword,
|
||||
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
|
||||
from app_resource a
|
||||
</sql>
|
||||
|
||||
<select id="selectAppResourceList" parameterType="AppResource" resultMap="AppResourceResult">
|
||||
<include refid="selectAppResourceVo"/>
|
||||
<where>
|
||||
<if test="resourceTitle != null and resourceTitle != ''"> and resource_title like concat('%', #{resourceTitle}, '%')</if>
|
||||
<if test="showImg != null and showImg != ''"> and show_img = #{showImg}</if>
|
||||
<if test="explain != null and explain != ''"> and `explain` = #{explain}</if>
|
||||
<if test="resourceType != null "> and resource_type = #{resourceType}</if>
|
||||
<if test="isShow != null "> and is_show = #{isShow}</if>
|
||||
<if test="isAd != null "> and is_ad = #{isAd}</if>
|
||||
<if test="adNumber != null "> and ad_number = #{adNumber}</if>
|
||||
<if test="downNum != null "> and down_num = #{downNum}</if>
|
||||
<if test="weight != null "> and weight = #{weight}</if>
|
||||
<if test="keyword != null and keyword != ''"> and (keyword like concat('%', #{keyword}, '%') or resource_title like concat('%', #{keyword}, '%'))</if>
|
||||
</where> ORDER BY weight desc, create_time desc
|
||||
<if test="resourceTitle != null and resourceTitle != ''"> and a.resource_title like concat('%', #{resourceTitle}, '%')</if>
|
||||
<if test="showImg != null and showImg != ''"> and a.show_img = #{showImg}</if>
|
||||
<if test="explain != null and explain != ''"> and a.`explain` = #{explain}</if>
|
||||
<if test="resourceType != null "> and a.resource_type = #{resourceType}</if>
|
||||
<if test="isShow != null "> and a.is_show = #{isShow}</if>
|
||||
<if test="isAd != null "> and a.is_ad = #{isAd}</if>
|
||||
<if test="adNumber != null "> and a.ad_number = #{adNumber}</if>
|
||||
<if test="downNum != null "> and a.down_num = #{downNum}</if>
|
||||
<if test="weight != null "> and a.weight = #{weight}</if>
|
||||
<if test="keyword != null and keyword != ''"> and (a.keyword like concat('%', #{keyword}, '%') or a.resource_title like concat('%', #{keyword}, '%'))</if>
|
||||
</where> ORDER BY a.weight desc, a.create_time desc
|
||||
</select>
|
||||
|
||||
<select id="selectAppResourceById" parameterType="Long" resultMap="AppResourceAppResourceListResult">
|
||||
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.down_num, a.weight, a.del_flag, a.create_by, a.create_time, a.remark,
|
||||
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
|
||||
from app_resource a
|
||||
left join app_resource_list b on b.app_resource_id = a.id
|
||||
@@ -73,6 +82,7 @@
|
||||
<if test="isShow != null">is_show,</if>
|
||||
<if test="isAd != null">is_ad,</if>
|
||||
<if test="adNumber != null">ad_number,</if>
|
||||
<if test="priceFen != null">price_fen,</if>
|
||||
<if test="downNum != null">down_num,</if>
|
||||
<if test="weight != null">weight,</if>
|
||||
<if test="delFlag != null">del_flag,</if>
|
||||
@@ -89,6 +99,7 @@
|
||||
<if test="isShow != null">#{isShow},</if>
|
||||
<if test="isAd != null">#{isAd},</if>
|
||||
<if test="adNumber != null">#{adNumber},</if>
|
||||
<if test="priceFen != null">#{priceFen},</if>
|
||||
<if test="downNum != null">#{downNum},</if>
|
||||
<if test="weight != null">#{weight},</if>
|
||||
<if test="delFlag != null">#{delFlag},</if>
|
||||
@@ -109,6 +120,7 @@
|
||||
<if test="isShow != null">is_show = #{isShow},</if>
|
||||
<if test="isAd != null">is_ad = #{isAd},</if>
|
||||
<if test="adNumber != null">ad_number = #{adNumber},</if>
|
||||
<if test="priceFen != null">price_fen = #{priceFen},</if>
|
||||
<if test="downNum != null">down_num = #{downNum},</if>
|
||||
<if test="weight != null">weight = #{weight},</if>
|
||||
<if test="delFlag != null">del_flag = #{delFlag},</if>
|
||||
@@ -149,16 +161,35 @@
|
||||
</insert>
|
||||
|
||||
<select id="selectAppResourceByIdAndUserId" resultMap="AppResourceAppResourceListResult">
|
||||
select a.id, a.resource_title, a.show_img, a.`explain`, a.`keyword`, a.resource_type, a.is_show,
|
||||
select a.id, a.resource_title, a.show_img, a.`explain`, a.`keyword`, a.resource_type, a.is_show,
|
||||
CASE
|
||||
WHEN (SELECT COUNT(1) FROM app_integral_record WHERE resource_id = #{id} AND user_id = #{userId}) > 0 THEN 0
|
||||
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,
|
||||
a.ad_number, a.down_num, a.weight, a.del_flag, a.create_by, a.create_time, a.remark,
|
||||
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,
|
||||
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
|
||||
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)
|
||||
)
|
||||
)
|
||||
)
|
||||
where a.id = #{id}
|
||||
</select>
|
||||
</mapper>
|
||||
</mapper>
|
||||
|
||||
@@ -0,0 +1,150 @@
|
||||
<?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.ruoyi.app.mapper.AppVirtualOrderMapper">
|
||||
<resultMap id="AppVirtualOrderResult" type="AppVirtualOrder">
|
||||
<id property="id" column="id"/>
|
||||
<result property="orderNo" column="order_no"/>
|
||||
<result property="userId" column="user_id"/>
|
||||
<result property="userName" column="user_name"/>
|
||||
<result property="nickName" column="nick_name"/>
|
||||
<result property="resourceId" column="resource_id"/>
|
||||
<result property="resourceTitle" column="resource_title"/>
|
||||
<result property="productId" column="product_id"/>
|
||||
<result property="priceFen" column="price_fen"/>
|
||||
<result property="openId" column="open_id"/>
|
||||
<result property="status" column="status"/>
|
||||
<result property="wxOrderNo" column="wx_order_no"/>
|
||||
<result property="transactionId" column="transaction_id"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
<result property="payTime" column="pay_time"/>
|
||||
<result property="provideTime" column="provide_time"/>
|
||||
<result property="refundTime" column="refund_time"/>
|
||||
<result property="lastQueryTime" column="last_query_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.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
|
||||
</sql>
|
||||
|
||||
<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)
|
||||
values
|
||||
(#{orderNo}, #{userId}, #{resourceId}, #{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,
|
||||
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="selectAppVirtualOrderById" parameterType="Long" resultMap="AppVirtualOrderResult">
|
||||
<include refid="selectAppVirtualOrderVo"/>
|
||||
where vo.id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="selectAppVirtualOrderList" parameterType="AppVirtualOrder" resultMap="AppVirtualOrderResult">
|
||||
<include refid="selectAppVirtualOrderVo"/>
|
||||
<where>
|
||||
<if test="orderNo != null and orderNo != ''">
|
||||
and vo.order_no like concat('%', #{orderNo}, '%')
|
||||
</if>
|
||||
<if test="transactionId != null and transactionId != ''">
|
||||
and vo.transaction_id like concat('%', #{transactionId}, '%')
|
||||
</if>
|
||||
<if test="wxOrderNo != null and wxOrderNo != ''">
|
||||
and vo.wx_order_no like concat('%', #{wxOrderNo}, '%')
|
||||
</if>
|
||||
<if test="userId != null">and vo.user_id = #{userId}</if>
|
||||
<if test="userName != null and userName != ''">
|
||||
and (u.user_name like concat('%', #{userName}, '%')
|
||||
or u.nick_name like concat('%', #{userName}, '%'))
|
||||
</if>
|
||||
<if test="resourceId != null">and vo.resource_id = #{resourceId}</if>
|
||||
<if test="productId != null and productId != ''">
|
||||
and vo.product_id like concat('%', #{productId}, '%')
|
||||
</if>
|
||||
<if test="openId != null and openId != ''">
|
||||
and vo.open_id like concat('%', #{openId}, '%')
|
||||
</if>
|
||||
<if test="status != null">and vo.status = #{status}</if>
|
||||
<if test="params.beginTime != null and params.beginTime != ''">
|
||||
and vo.create_time >= #{params.beginTime}
|
||||
</if>
|
||||
<if test="params.endTime != null and params.endTime != ''">
|
||||
and vo.create_time <= concat(#{params.endTime}, ' 23:59:59')
|
||||
</if>
|
||||
</where>
|
||||
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)
|
||||
+
|
||||
(select count(1) from app_integral_record
|
||||
where user_id = #{userId}
|
||||
and resource_id = #{resourceId}
|
||||
and source = '资源兑换'
|
||||
and is_add = 1)
|
||||
</select>
|
||||
|
||||
<update id="markPaid">
|
||||
update app_virtual_order
|
||||
set status = 1,
|
||||
wx_order_no = coalesce(#{wxOrderNo}, wx_order_no),
|
||||
transaction_id = coalesce(#{transactionId}, transaction_id),
|
||||
pay_time = coalesce(#{payTime}, pay_time),
|
||||
provide_time = now()
|
||||
where order_no = #{orderNo} and status = 0
|
||||
</update>
|
||||
|
||||
<insert id="insertEntitlement" parameterType="AppVirtualOrder">
|
||||
insert into app_resource_entitlement
|
||||
(user_id, resource_id, order_no, status, granted_time)
|
||||
values
|
||||
(#{userId}, #{resourceId}, #{orderNo}, 1, now())
|
||||
on duplicate key update
|
||||
order_no = values(order_no),
|
||||
status = 1,
|
||||
granted_time = now(),
|
||||
revoked_time = null
|
||||
</insert>
|
||||
|
||||
<update id="markRefunded">
|
||||
update app_virtual_order
|
||||
set status = 2, refund_time = #{refundTime}
|
||||
where order_no = #{orderNo} and status in (0, 1)
|
||||
</update>
|
||||
|
||||
<update id="deleteEntitlementByOrderNo">
|
||||
update app_resource_entitlement
|
||||
set status = 0, revoked_time = now()
|
||||
where order_no = #{orderNo} and status = 1
|
||||
</update>
|
||||
|
||||
<update id="markClosed">
|
||||
update app_virtual_order set status = 3
|
||||
where order_no = #{orderNo} and status = 0
|
||||
</update>
|
||||
|
||||
<update id="markQuerying">
|
||||
update app_virtual_order
|
||||
set last_query_time = now()
|
||||
where order_no = #{orderNo}
|
||||
and status = 0
|
||||
and (last_query_time is null or last_query_time < date_sub(now(), interval 5 second))
|
||||
</update>
|
||||
</mapper>
|
||||
@@ -0,0 +1,40 @@
|
||||
<?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.ruoyi.app.mapper.AppVirtualProductMapper">
|
||||
<resultMap id="AppVirtualProductResult" type="AppVirtualProduct">
|
||||
<id property="id" column="id"/>
|
||||
<result property="productId" column="product_id"/>
|
||||
<result property="priceFen" column="price_fen"/>
|
||||
<result property="productName" column="product_name"/>
|
||||
<result property="status" column="status"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
<result property="updateTime" column="update_time"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="selectActiveByPrice" resultMap="AppVirtualProductResult">
|
||||
select id, product_id, price_fen, product_name, status, create_time, update_time
|
||||
from app_virtual_product
|
||||
where price_fen = #{priceFen} and status = 1
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
<select id="selectByProductId" resultMap="AppVirtualProductResult">
|
||||
select id, product_id, price_fen, product_name, status, create_time, update_time
|
||||
from app_virtual_product
|
||||
where product_id = #{productId}
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
<insert id="insertAppVirtualProduct" parameterType="AppVirtualProduct" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into app_virtual_product(product_id, price_fen, product_name, status, create_time)
|
||||
values(#{productId}, #{priceFen}, #{productName}, #{status}, #{createTime})
|
||||
</insert>
|
||||
|
||||
<update id="updateProductIdByPrice" parameterType="AppVirtualProduct">
|
||||
update app_virtual_product
|
||||
set product_id = #{productId}, product_name = #{productName}, status = 1, update_time = #{updateTime}
|
||||
where price_fen = #{priceFen}
|
||||
</update>
|
||||
</mapper>
|
||||
@@ -51,7 +51,7 @@
|
||||
<sql id="selectUserVo">
|
||||
select u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.avatar, u.phonenumber, u.password, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark, u.integral,
|
||||
d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.status as dept_status,
|
||||
r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.status as role_statusselectUserVo, u.open_id as openId
|
||||
r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.status as role_status, u.open_id
|
||||
from sys_user u
|
||||
left join sys_dept d on u.dept_id = d.dept_id
|
||||
left join sys_user_role ur on u.user_id = ur.user_id
|
||||
@@ -232,4 +232,4 @@
|
||||
select date_format(create_time,'%Y-%m-%d') as date, count(*) as count from sys_user where del_flag = '0' and create_time >= DATE_SUB(CURDATE(), INTERVAL 30 DAY) group by date_format(create_time,'%Y-%m-%d') order by date
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user