feat: add dashboard and virtual pay enhancements
This commit is contained in:
@@ -29,7 +29,7 @@ INSERT INTO tt_copy_template (template_name, template_body, sort_num, status, cr
|
||||
#### 运行环境
|
||||
{codeEnvironment}
|
||||
|
||||
#### 项目技术
|
||||
#### 其他技术
|
||||
{codeTechnology}
|
||||
|
||||
#### 项目截图
|
||||
@@ -48,7 +48,7 @@ INSERT INTO tt_copy_template (template_name, template_body, sort_num, status, cr
|
||||
### 运行环境
|
||||
{codeEnvironment}
|
||||
|
||||
### 项目技术
|
||||
### 其他技术
|
||||
{codeTechnology}
|
||||
|
||||
标价包含项目源码+数据库脚本+文档,没有调试解答,由于此商品的可复制性,发货后,不退不换,介意勿拍', 2, '0', NOW(), 'admin'),
|
||||
@@ -74,7 +74,7 @@ INSERT INTO tt_copy_template (template_name, template_body, sort_num, status, cr
|
||||
### 运行环境
|
||||
{codeEnvironment}
|
||||
|
||||
### 项目技术
|
||||
### 其他技术
|
||||
{codeTechnology}
|
||||
|
||||
获取项目源码资源,\\/X小CX:南音源码库', 4, '0', NOW(), 'admin'),
|
||||
@@ -255,4 +255,4 @@ INSERT INTO tt_copy_template (template_name, template_body, sort_num, status, cr
|
||||
<img src="https://img.yidaima.cn/qrcode.jpg" style="width: 100px;">
|
||||
<br>
|
||||
<span>长按小程序码,打开小程序搜索 "<Strong style="color:var(--md-primary-color);">{projectCode}</Strong>" 即可获取资源</span>
|
||||
</center>', 6, '0', NOW(), 'admin');
|
||||
</center>', 6, '0', NOW(), 'admin');
|
||||
|
||||
46
sql/dashboard_statistics_indexes.sql
Normal file
46
sql/dashboard_statistics_indexes.sql
Normal file
@@ -0,0 +1,46 @@
|
||||
-- 首页统计查询索引(可重复执行)
|
||||
|
||||
SET @dashboard_index_sql = (
|
||||
SELECT IF(
|
||||
COUNT(1) = 0,
|
||||
'ALTER TABLE app_virtual_order ADD INDEX idx_virtual_order_create_time (create_time)',
|
||||
'SELECT 1'
|
||||
)
|
||||
FROM information_schema.statistics
|
||||
WHERE table_schema = DATABASE()
|
||||
AND table_name = 'app_virtual_order'
|
||||
AND index_name = 'idx_virtual_order_create_time'
|
||||
);
|
||||
PREPARE dashboard_index_stmt FROM @dashboard_index_sql;
|
||||
EXECUTE dashboard_index_stmt;
|
||||
DEALLOCATE PREPARE dashboard_index_stmt;
|
||||
|
||||
SET @dashboard_index_sql = (
|
||||
SELECT IF(
|
||||
COUNT(1) = 0,
|
||||
'ALTER TABLE app_pay_order ADD INDEX idx_pay_order_status_pay_time (status, pay_time)',
|
||||
'SELECT 1'
|
||||
)
|
||||
FROM information_schema.statistics
|
||||
WHERE table_schema = DATABASE()
|
||||
AND table_name = 'app_pay_order'
|
||||
AND index_name = 'idx_pay_order_status_pay_time'
|
||||
);
|
||||
PREPARE dashboard_index_stmt FROM @dashboard_index_sql;
|
||||
EXECUTE dashboard_index_stmt;
|
||||
DEALLOCATE PREPARE dashboard_index_stmt;
|
||||
|
||||
SET @dashboard_index_sql = (
|
||||
SELECT IF(
|
||||
COUNT(1) = 0,
|
||||
'ALTER TABLE app_virtual_order ADD INDEX idx_virtual_order_status_pay_time (status, pay_time)',
|
||||
'SELECT 1'
|
||||
)
|
||||
FROM information_schema.statistics
|
||||
WHERE table_schema = DATABASE()
|
||||
AND table_name = 'app_virtual_order'
|
||||
AND index_name = 'idx_virtual_order_status_pay_time'
|
||||
);
|
||||
PREPARE dashboard_index_stmt FROM @dashboard_index_sql;
|
||||
EXECUTE dashboard_index_stmt;
|
||||
DEALLOCATE PREPARE dashboard_index_stmt;
|
||||
7
sql/source_code_technology_fields.sql
Normal file
7
sql/source_code_technology_fields.sql
Normal file
@@ -0,0 +1,7 @@
|
||||
-- 源码信息新增前端、后端、数据库技术字段。
|
||||
-- 执行前请先备份数据库。适用于当前项目的 MySQL 数据库。
|
||||
|
||||
ALTER TABLE `tt_code`
|
||||
ADD COLUMN `frontend_technology` VARCHAR(255) NULL COMMENT '前端' AFTER `code_technology`,
|
||||
ADD COLUMN `backend_technology` VARCHAR(255) NULL COMMENT '后端' AFTER `frontend_technology`,
|
||||
ADD COLUMN `database_technology` VARCHAR(255) NULL COMMENT '数据库' AFTER `backend_technology`;
|
||||
30
sql/virtual_pay_order_guard.sql
Normal file
30
sql/virtual_pay_order_guard.sql
Normal file
@@ -0,0 +1,30 @@
|
||||
-- 资源虚拟支付:同一用户、同一规格有效订单防重
|
||||
-- 前置条件:已经执行 sql/virtual_pay_resource_specs.sql。
|
||||
-- 执行前请先备份数据库。
|
||||
|
||||
-- 下面的查询必须返回空结果。
|
||||
-- 如果存在结果,说明上线防重前已经产生重复待支付/已支付订单,
|
||||
-- 需要先结合微信订单状态人工核对,不能直接批量关闭或删除。
|
||||
SELECT user_id,
|
||||
resource_id,
|
||||
COALESCE(resource_list_id, 0) AS resource_list_key,
|
||||
COUNT(*) AS active_order_count,
|
||||
GROUP_CONCAT(order_no ORDER BY id) AS order_nos
|
||||
FROM app_virtual_order
|
||||
WHERE status IN (0, 1)
|
||||
GROUP BY user_id, resource_id, COALESCE(resource_list_id, 0)
|
||||
HAVING COUNT(*) > 1;
|
||||
|
||||
-- status=0(待支付)和 status=1(已支付)共用一个唯一购买键。
|
||||
-- 退款或关闭后键值自动变为 NULL,允许用户重新购买。
|
||||
ALTER TABLE app_virtual_order
|
||||
ADD COLUMN active_purchase_key VARCHAR(80)
|
||||
GENERATED ALWAYS AS (
|
||||
CASE
|
||||
WHEN status IN (0, 1)
|
||||
THEN CONCAT(user_id, ':', resource_id, ':', COALESCE(resource_list_id, 0))
|
||||
ELSE NULL
|
||||
END
|
||||
) STORED COMMENT '待支付/已支付订单防重键' AFTER last_query_time,
|
||||
ADD UNIQUE KEY uk_virtual_order_active_purchase (active_purchase_key);
|
||||
|
||||
29
sql/virtual_pay_resource_specs.sql
Normal file
29
sql/virtual_pay_resource_specs.sql
Normal file
@@ -0,0 +1,29 @@
|
||||
-- 资源虚拟支付:简版多规格迁移
|
||||
-- 前置条件:已经执行 sql/virtual_pay_resource.sql。
|
||||
-- 约定:app_resource_list 的每一行就是一个可单独购买的规格。
|
||||
-- 执行前请备份数据库。
|
||||
|
||||
ALTER TABLE app_resource_list
|
||||
ADD COLUMN price_fen INT NOT NULL DEFAULT 0 COMMENT '规格价格,单位分' AFTER password,
|
||||
ADD COLUMN status TINYINT NOT NULL DEFAULT 1 COMMENT '1启用 0停用' AFTER price_fen,
|
||||
ADD COLUMN sort_order INT NOT NULL DEFAULT 0 COMMENT '显示顺序' AFTER status;
|
||||
|
||||
-- 现有付费资源的下载项继承原资源价格;非付费资源价格保持0。
|
||||
UPDATE app_resource_list rl
|
||||
INNER JOIN app_resource r ON r.id = rl.app_resource_id
|
||||
SET rl.price_fen = r.price_fen
|
||||
WHERE r.is_ad = 3 AND rl.price_fen = 0;
|
||||
|
||||
ALTER TABLE app_virtual_order
|
||||
ADD COLUMN resource_list_id BIGINT NULL COMMENT '购买的资源规格ID,NULL表示旧版整项购买' AFTER resource_id,
|
||||
ADD COLUMN spec_name_snapshot VARCHAR(255) NULL COMMENT '下单时的规格名称快照' AFTER resource_list_id,
|
||||
ADD KEY idx_virtual_order_resource_list (resource_list_id);
|
||||
|
||||
ALTER TABLE app_resource_entitlement
|
||||
ADD COLUMN resource_list_id BIGINT NULL COMMENT '解锁的资源规格ID,NULL表示旧版整项权益' AFTER resource_id,
|
||||
DROP INDEX uk_resource_entitlement_user_resource,
|
||||
ADD UNIQUE KEY uk_entitlement_user_resource_spec (user_id, resource_id, resource_list_id),
|
||||
ADD KEY idx_entitlement_resource_list (resource_list_id);
|
||||
|
||||
-- 旧订单和旧权益保留 resource_list_id=NULL,继续拥有整项资源访问权限。
|
||||
-- 新订单必须写入具体 resource_list_id,只解锁所购买的规格。
|
||||
Reference in New Issue
Block a user