新增数据库相关语句脚本
This commit is contained in:
46
codes/games/sql/game/scripts/transfer_detail.sql
Normal file
46
codes/games/sql/game/scripts/transfer_detail.sql
Normal file
@@ -0,0 +1,46 @@
|
||||
-- ============================================================
|
||||
-- 脚本名称: transfer_detail.sql
|
||||
-- 功 能: 指定年月的转卡明细流水(每笔转卡一行)
|
||||
-- 数据库 : agent_db
|
||||
-- 用 法:
|
||||
-- 1. 修改下方【参数设置】中的变量值
|
||||
-- 2. 在 Navicat 中执行全部脚本
|
||||
-- 3. 结果集右键 → Export → Excel 可导出表格
|
||||
-- ============================================================
|
||||
|
||||
|
||||
-- ============================================================
|
||||
-- 【参数设置】 ← 修改这里
|
||||
-- ============================================================
|
||||
SET @p_year = 2026; -- 年份
|
||||
SET @p_month = 3; -- 月份(1-12)
|
||||
SET @p_from_sales = 10437216; -- 发卡来源代理ID(上级代理)
|
||||
SET @p_agent_id = 'veRa0qrBf0df2K1G4de2tgfmVxB2jxpv'; -- 代理商ID
|
||||
|
||||
|
||||
-- ============================================================
|
||||
-- 【明细报表】每一笔转卡流水记录,按转卡时间升序排列
|
||||
-- ============================================================
|
||||
SELECT
|
||||
t.from_sales AS '发卡代理ID',
|
||||
su_from.saus_nickname AS '发卡代理昵称',
|
||||
t.satr_salesid AS '接收代理ID',
|
||||
su_to.saus_nickname AS '接收代理昵称',
|
||||
t.satr_amount AS '转卡数量',
|
||||
DATE_FORMAT(t.satr_transfertime, '%Y-%m-%d %H:%i:%s') AS '转卡时间'
|
||||
FROM
|
||||
sales_transferbill t
|
||||
LEFT JOIN sales_user su_to
|
||||
ON t.satr_agentid = su_to.saus_agentid
|
||||
AND t.channel_id = su_to.saus_channelid
|
||||
AND t.satr_salesid = su_to.saus_salesid
|
||||
LEFT JOIN sales_user su_from
|
||||
ON t.satr_agentid = su_from.saus_agentid
|
||||
AND t.from_sales = su_from.saus_salesid
|
||||
WHERE
|
||||
t.satr_agentid = @p_agent_id
|
||||
AND t.from_sales = @p_from_sales
|
||||
AND YEAR(t.satr_transfertime) = @p_year
|
||||
AND MONTH(t.satr_transfertime) = @p_month
|
||||
ORDER BY
|
||||
t.satr_transfertime ASC;
|
||||
Reference in New Issue
Block a user