create_tables.sql 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. CREATE TABLE IF NOT EXISTS "pay_app" (
  2. "id" number NOT NULL GENERATED BY DEFAULT AS IDENTITY,
  3. "name" varchar(64) NOT NULL,
  4. "status" tinyint NOT NULL,
  5. "remark" varchar(255) DEFAULT NULL,
  6. `pay_notify_url` varchar(1024) NOT NULL,
  7. `refund_notify_url` varchar(1024) NOT NULL,
  8. "creator" varchar(64) DEFAULT '',
  9. "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  10. "updater" varchar(64) DEFAULT '',
  11. "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  12. "deleted" bit(1) NOT NULL DEFAULT FALSE,
  13. PRIMARY KEY ("id")
  14. ) COMMENT = '支付应用';
  15. CREATE TABLE IF NOT EXISTS "pay_channel" (
  16. "id" number NOT NULL GENERATED BY DEFAULT AS IDENTITY,
  17. "code" varchar(32) NOT NULL,
  18. "status" tinyint(4) NOT NULL,
  19. "remark" varchar(255) DEFAULT NULL,
  20. "fee_rate" double NOT NULL DEFAULT 0,
  21. "app_id" bigint(20) NOT NULL,
  22. "config" varchar(10240) NOT NULL,
  23. "creator" varchar(64) NULL DEFAULT '',
  24. "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  25. "updater" varchar(64) NULL DEFAULT '',
  26. "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  27. "deleted" bit(1) NOT NULL DEFAULT FALSE,
  28. "tenant_id" bigint not null default '0',
  29. PRIMARY KEY ("id")
  30. ) COMMENT = '支付渠道';
  31. CREATE TABLE IF NOT EXISTS `pay_order` (
  32. "id" number NOT NULL GENERATED BY DEFAULT AS IDENTITY,
  33. `app_id` bigint(20) NOT NULL,
  34. `channel_id` bigint(20) DEFAULT NULL,
  35. `channel_code` varchar(32) DEFAULT NULL,
  36. `merchant_order_id` varchar(64) NOT NULL,
  37. `subject` varchar(32) NOT NULL,
  38. `body` varchar(128) NOT NULL,
  39. `notify_url` varchar(1024) NOT NULL,
  40. `notify_status` tinyint(4) NOT NULL,
  41. `price` bigint(20) NOT NULL,
  42. `channel_fee_rate` double DEFAULT 0,
  43. `channel_fee_price` bigint(20) DEFAULT 0,
  44. `status` tinyint(4) NOT NULL,
  45. `user_ip` varchar(50) NOT NULL,
  46. `expire_time` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP,
  47. `success_time` datetime(0) DEFAULT CURRENT_TIMESTAMP,
  48. `notify_time` datetime(0) DEFAULT CURRENT_TIMESTAMP,
  49. `success_extension_id` bigint(20) DEFAULT NULL COMMENT '支付成功的订单拓展单编号',
  50. `refund_status` tinyint(4) NOT NULL,
  51. `refund_times` int NOT NULL,
  52. `refund_price` bigint(20) NOT NULL,
  53. `channel_user_id` varchar(255) DEFAULT NULL,
  54. `channel_order_no` varchar(64) DEFAULT NULL,
  55. `creator` varchar(64) DEFAULT '',
  56. `create_time` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP,
  57. `updater` varchar(64) DEFAULT '',
  58. `update_time` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  59. `deleted` bit(1) NOT NULL DEFAULT FALSE,
  60. PRIMARY KEY ("id")
  61. ) COMMENT = '支付订单';
  62. CREATE TABLE IF NOT EXISTS `pay_order_extension` (
  63. "id" number NOT NULL GENERATED BY DEFAULT AS IDENTITY,
  64. `no` varchar(64) NOT NULL,
  65. `order_id` bigint(20) NOT NULL,
  66. `channel_id` bigint(20) NOT NULL,
  67. `channel_code` varchar(32) NOT NULL,
  68. `user_ip` varchar(50) NULL DEFAULT NULL,
  69. `status` tinyint(4) NOT NULL,
  70. `channel_extras` varchar(1024) NULL DEFAULT NULL,
  71. `channel_error_code` varchar(64) NULL,
  72. `channel_error_msg` varchar(64) NULL,
  73. `channel_notify_data` varchar(64) NULL,
  74. `creator` varchar(64) NULL DEFAULT '',
  75. `create_time` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP,
  76. `updater` varchar(64) NULL DEFAULT '',
  77. `update_time` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  78. `deleted` bit(1) NOT NULL DEFAULT FALSE,
  79. PRIMARY KEY ("id")
  80. ) COMMENT = '支付订单拓展';
  81. CREATE TABLE IF NOT EXISTS `pay_refund` (
  82. "id" number NOT NULL GENERATED BY DEFAULT AS IDENTITY,
  83. `app_id` bigint(20) NOT NULL,
  84. `channel_id` bigint(20) NOT NULL,
  85. `channel_code` varchar(32) NOT NULL,
  86. `order_id` bigint(20) NOT NULL,
  87. `trade_no` varchar(64) NOT NULL,
  88. `merchant_order_id` varchar(64) NOT NULL,
  89. `merchant_refund_no` varchar(64) NOT NULL,
  90. `notify_url` varchar(1024) NOT NULL,
  91. `notify_status` tinyint(4) NOT NULL,
  92. `status` tinyint(4) NOT NULL,
  93. `type` tinyint(4) NOT NULL,
  94. `pay_amount` bigint(20) NOT NULL,
  95. `refund_amount` bigint(20) NOT NULL,
  96. `reason` varchar(256) NOT NULL,
  97. `user_ip` varchar(50) NULL DEFAULT NULL,
  98. `channel_order_no` varchar(64) NOT NULL,
  99. `channel_refund_no` varchar(64) NULL DEFAULT NULL,
  100. `channel_error_code` varchar(128) NULL DEFAULT NULL,
  101. `channel_error_msg` varchar(256) NULL DEFAULT NULL,
  102. `channel_extras` varchar(1024) NULL DEFAULT NULL,
  103. `expire_time` datetime(0) NULL DEFAULT NULL,
  104. `success_time` datetime(0) NULL DEFAULT NULL,
  105. `notify_time` datetime(0) NULL DEFAULT NULL,
  106. `creator` varchar(64) NULL DEFAULT '',
  107. `create_time` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP,
  108. `updater` varchar(64) NULL DEFAULT '',
  109. `update_time` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  110. `deleted` bit(1) NOT NULL DEFAULT FALSE,
  111. PRIMARY KEY ("id")
  112. ) COMMENT = '退款订单';