13平台收支.sql 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. -- Active: xiaoding_test@@192.168.110.85@3306@xiaoding_test
  2. /*
  3. 交易时间是wallet_trans_records表判断wallet_id字段值为1然后获取trans_time字段做为交易时间,
  4. 收入渠道是wallet_trans_records表判断wallet_id字段值为1然后获取owner_type字段做为收入渠道,
  5. 省份、城市、地区以及平台收入字段都是wallet_trans_records表判断wallet_id字段值为1然后分别获取province、city、district、amount字段即可
  6. */
  7. /* 查询平台收入明细 */
  8. DROP TABLE IF EXISTS report_platform_income;
  9. CREATE TABLE report_platform_income AS
  10. DROP VIEW IF EXISTS manage_platform_income;
  11. CREATE OR REPLACE VIEW manage_platform_income AS
  12. SELECT
  13. wtr.role as role /* 交易角色 */,
  14. wtr.trans_type as trans_type /* 交易类型 */,
  15. trans_time as trans_time /* 交易时间 */,
  16. owner_type as owner_type /* 业务类型 */,
  17. wtr.storage_type as storage_type /* 存储类型 */,
  18. wtr.before_recharge_balance as before_recharge_balance /* 交易前余额 */,
  19. amount as amount /* 平台收入 */,
  20. wtr.after_recharge_balance as after_recharge_balance /* 交易后余额 */,
  21. wtr.state as state /* 交易状态 */,
  22. province as province /* 省份 */,
  23. city as city /* 城市 */,
  24. district as district /* 地区 */,
  25. wtr.remark as remark /* 备注 */
  26. FROM wallet_trans_records wtr /* 钱包交易记录表 */
  27. WHERE
  28. wtr.wallet_id = 9 /* 平台钱包ID */
  29. AND wtr.deleted_at IS NULL /* 未删除的记录 */
  30. ORDER BY wtr.trans_time DESC /* 按交易时间倒序排序 */;
  31. select * from manage_platform_income;