Переглянути джерело

1.文档整理, 2.表结构

liaoxxxx 2 роки тому
батько
коміт
ff1e8f7990

+ 6 - 0
doc/model/README.md

@@ -12,3 +12,9 @@
 
 
 ### [交易订单记录](./payment_order.md)
+
+
+### [交易订单日志](./payment_order_log.md)
+
+
+### [商户系统帐户](./merchant_account_sys.md)

+ 27 - 0
doc/model/merchant_account_sys.md

@@ -0,0 +1,27 @@
+
+###商户系统账户表 `merchant_account_out`
+>  sys_account_id :关联系统的银行帐户id 
+> 
+> 
+```mysql
+CREATE TABLE `merchant_account_sys` (
+   `id` int NOT NULL AUTO_INCREMENT,
+   `created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
+   `updated_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
+   `deleted_at` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
+   `merchant_id` int NOT NULL DEFAULT '0' COMMENT '商户ID',
+   `sys_account_id` int DEFAULT NULL COMMENT '关联的平台账户的id',
+   `account_num` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '银行的账户编号',
+   `balance_amount` decimal(10,2) NOT NULL COMMENT '余额',
+   `freeze_amount` decimal(10,2) NOT NULL COMMENT '冻结的余额',
+   `currency_id` int DEFAULT '0' COMMENT '关联的币种id',
+   `capital_prop` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '资金的属性',
+   `currency_type` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '币种',
+   `remark` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '备注',
+   PRIMARY KEY (`id`) USING BTREE
+) ENGINE=InnoDB AUTO_INCREMENT=67 DEFAULT CHARSET=utf8mb3 ROW_FORMAT=DYNAMIC COMMENT='商户外部账户表';
+```
+
+> merchant_id 关联 [merchant.id](./merchant_struct.md) 
+
+> `currency_id` 关联 [currency.id](./currency.md),   `currency_type`  关联 [currency.currency_type](./currency.md)

+ 36 - 22
doc/model/payment_order.md

@@ -1,31 +1,45 @@
 
 ### 交易订单记录表 `payment_order`
 
-
+> merchant_id 关联 [merchant.id](./merchant_struct.md)
+> 
+> trade_no: 由平台生成的交易单号
+> 
+> from_account_no []
+> 
+> 
+> 
+> 
+> 
+> 
+> 
+> 
+> 
 
 
 ```mysql
 CREATE TABLE `payment_order` (
-    `id` int NOT NULL AUTO_INCREMENT,
-    `created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
-    `updated_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
-    `deleted_at` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
-    `merchant_id` int NOT NULL DEFAULT '0' COMMENT '商户ID',
-    `from_account_no` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '来自银行的账户编号',
-    `from_account_id` int DEFAULT '0' COMMENT '来自账户的id',
-    `to_account_id` int DEFAULT '0' COMMENT '转到账户的id',
-    `to_account_no` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '转到银行的账户编号',
-    `exchange_rate` decimal(10,10) DEFAULT NULL COMMENT '汇率',
-    `amount` decimal(10,2) NOT NULL COMMENT '交易的金额',
-    `from_currency_id` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '来自币种',
-    `to_currency_id` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '目标币种',
-    `transfer_type` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '交易类型(汇兑、结汇、充值)',
-    `transfer_state` tinyint(1) NOT NULL DEFAULT '0' COMMENT '交易状态',
-    `remark` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '备注',
-    `loan_mark` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '借贷标识',
-    `trade_org_id` varchar(64) DEFAULT NULL COMMENT '交易机构的id',
-    `trade_org_code` varchar(64) DEFAULT NULL COMMENT '交易机构代码',
-    `org_trade_no` varchar(64) DEFAULT NULL COMMENT '交易机构的交易单号',
-    PRIMARY KEY (`id`) USING BTREE
+  `id` int NOT NULL AUTO_INCREMENT,
+  `created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
+  `updated_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
+  `deleted_at` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
+  `merchant_id` int NOT NULL DEFAULT '0' COMMENT '商户ID',
+  `trade_no` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '平台生成的交易单号',
+  `from_account_no` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '来自银行的账户编号',
+  `from_account_id` int DEFAULT '0' COMMENT '来自账户的id',
+  `to_account_id` int DEFAULT '0' COMMENT '转到账户的id',
+  `to_account_no` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '转到银行的账户编号',
+  `exchange_rate` decimal(10,10) DEFAULT NULL COMMENT '汇率',
+  `amount` decimal(10,2) NOT NULL COMMENT '交易的金额',
+  `from_currency_id` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '来自币种',
+  `to_currency_id` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '目标币种',
+  `transfer_type` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '交易类型(汇兑、结汇、充值)',
+  `transfer_state` tinyint(1) NOT NULL DEFAULT '0' COMMENT '交易状态',
+  `remark` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '备注',
+  `loan_mark` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '借贷标识',
+  `trade_org_id` varchar(64) DEFAULT NULL COMMENT '交易机构的id',
+  `trade_org_code` varchar(64) DEFAULT NULL COMMENT '交易机构代码',
+  `org_trade_no` varchar(64) DEFAULT NULL COMMENT '交易机构的交易单号',
+  PRIMARY KEY (`id`) USING BTREE
 ) ENGINE=InnoDB AUTO_INCREMENT=67 DEFAULT CHARSET=utf8mb3 ROW_FORMAT=DYNAMIC COMMENT='商户外部账户余额明细记录';
 ```

+ 33 - 0
doc/model/payment_order_log.md

@@ -0,0 +1,33 @@
+
+### 交易订单日志表 `payment_order`
+
+>  order_id:本地交易单号的id [payment_order.id](payment_order.md)
+> 
+>  local_trade_no:本地交易单号 [payment_order.trade_no](payment_order.md)
+>
+>  out_trade_no:交易单号,银行方 [payment_order.out_trade_no](payment_order.md)
+> 
+> step_r  :交易的步骤 数字,从小到大排序 ,需要定义 如 `0: 发起交易`; `1:生成单号`;..... ; `10:交易成功` 
+> 
+> step_name : 交易的步骤映射的英文单词  `0:init` , `1:orderno_create` , `10:trade_success`
+>
+> local_msg: 本地的请求; 如发起结汇的body ; 响应银行方的 success信息
+> 
+> org_msg: 银行方响应 , 如发起结汇时银行方的预生成订单的body ; 银行方通知到账的信息
+
+```mysql
+CREATE TABLE `payment_order_log` (
+  `id` int NOT NULL AUTO_INCREMENT,
+  `created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
+  `updated_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
+  `deleted_at` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
+  `local_trade_no` int NOT NULL DEFAULT '0' COMMENT '本地交易单号',
+  `order_id` int NOT NULL DEFAULT '0' COMMENT '本地交易单号',
+  `out_trade_no` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '交易单号,银行方',
+  `step_r` int DEFAULT '0' COMMENT '交易的步骤',
+  `step_name` varchar(10) NOT NULL COMMENT '交易的步骤名称',
+  `local_request` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '本地向银行机构发起的请求信息',
+  `notify_msg` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '银行机构通知的消息',
+  PRIMARY KEY (`id`) USING BTREE
+) ENGINE=InnoDB AUTO_INCREMENT=67 DEFAULT CHARSET=utf8mb3 ROW_FORMAT=DYNAMIC COMMENT='商户支付订单记录';
+```

+ 2 - 2
doc/process/payment/结汇.md

@@ -44,9 +44,9 @@ accountID,err:=repo.PaymentOrderDao.Save(order)  //保存订单
 payLog:=&entity.PaymentOoderLog{
     OrderSN:orderSN,
     StepR:0    ,        //步骤
-    StepR:"order_create", //步骤 init
+    StepName:"order_create", //步骤 init
     TradeType:"settlement", //交易类型 结汇
-    CallBack:""      //回调信息
+    notify_msg:""      //回调信息
 }
 err:=repo.PaymentOrderLogDao.Save(payLog)  //保存订单日志
 ```

+ 18 - 25
doc/sql/crossbordercoll.sql

@@ -11,7 +11,7 @@
  Target Server Version : 80024
  File Encoding         : 65001
 
- Date: 24/04/2022 15:43:42
+ Date: 24/04/2022 16:20:04
 */
 
 SET NAMES utf8mb4;
@@ -239,20 +239,16 @@ CREATE TABLE `merchant_account_sys`  (
   `updated_at` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0) ON UPDATE CURRENT_TIMESTAMP(0) COMMENT '修改时间',
   `deleted_at` datetime(0) NOT NULL ON UPDATE CURRENT_TIMESTAMP(0) COMMENT '修改时间',
   `merchant_id` int(0) NOT NULL DEFAULT 0 COMMENT '商户ID',
-  `bank_name` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '银行名称',
-  `bank_code` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '0' COMMENT '银行代码',
-  `account_code` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '账户编号',
-  `account_name` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '账户名',
-  `account_name_en` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '账户名 英文',
-  `country` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '账户所属的国家/地区',
-  `province` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '账户所属的省/州',
-  `city` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '账户所属的省/州城市',
-  `address` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '详细地址',
-  `postal_code` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '邮政编码',
-  `swift_code` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '0' COMMENT 'SWIFT CODE',
-  `sys_account_id` int(0) NOT NULL COMMENT '关联的系统账户的子账户 id ',
+  `sys_account_id` int(0) NULL DEFAULT NULL COMMENT '关联的平台账户的id',
+  `account_num` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '银行的账户编号',
+  `balance_amount` decimal(10, 2) NOT NULL COMMENT '余额',
+  `freeze_amount` decimal(10, 2) NOT NULL COMMENT '冻结的余额',
+  `currency_id` int(0) NULL DEFAULT 0 COMMENT '关联的币种id',
+  `capital_prop` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '资金的属性',
+  `currency_type` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '币种',
+  `remark` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '备注',
   PRIMARY KEY (`id`) USING BTREE
-) ENGINE = InnoDB AUTO_INCREMENT = 67 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '商户外部账户交易明细' ROW_FORMAT = Dynamic;
+) ENGINE = InnoDB AUTO_INCREMENT = 67 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '商户外部账户表' ROW_FORMAT = Dynamic;
 
 -- ----------------------------
 -- Records of merchant_account_sys
@@ -316,6 +312,7 @@ CREATE TABLE `payment_order`  (
   `updated_at` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0) ON UPDATE CURRENT_TIMESTAMP(0) COMMENT '修改时间',
   `deleted_at` datetime(0) NOT NULL ON UPDATE CURRENT_TIMESTAMP(0) COMMENT '修改时间',
   `merchant_id` int(0) NOT NULL DEFAULT 0 COMMENT '商户ID',
+  `trade_no` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '品台生成的交易单号',
   `from_account_no` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '来自银行的账户编号',
   `from_account_id` int(0) NULL DEFAULT 0 COMMENT '来自账户的id',
   `to_account_id` int(0) NULL DEFAULT 0 COMMENT '转到账户的id',
@@ -374,17 +371,13 @@ CREATE TABLE `payment_order_log`  (
   `created_at` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0) COMMENT '创建时间',
   `updated_at` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0) ON UPDATE CURRENT_TIMESTAMP(0) COMMENT '修改时间',
   `deleted_at` datetime(0) NOT NULL ON UPDATE CURRENT_TIMESTAMP(0) COMMENT '修改时间',
-  `merchant_id` int(0) NOT NULL DEFAULT 0 COMMENT '商户ID',
-  `accout_num` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '账户关联的银行的账户编号',
-  `accout_id` int(0) NULL DEFAULT 0 COMMENT '账户记录的id',
-  `before` decimal(10, 2) NOT NULL COMMENT '交易前的余额',
-  `after` decimal(10, 2) NOT NULL COMMENT '交易后的余额',
-  `amount` decimal(10, 2) NOT NULL COMMENT '交易的金额',
-  `currency_type` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '币种',
-  `transfer_type` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '交易类型(汇兑、结汇、充值)',
-  `transfer_state` tinyint(1) NOT NULL DEFAULT 0 COMMENT '交易状态',
-  `remark` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '备注',
-  `notify_msg` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '银行机构通知的消息',
+  `local_trade_no` int(0) NOT NULL DEFAULT 0 COMMENT '本地交易单号',
+  `order_id` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '本地交易单号的id',
+  `out_trade_no` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '交易单号,银行方',
+  `step_r` int(0) NULL DEFAULT 0 COMMENT '交易的步骤',
+  `step_name` varchar(10) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '交易的步骤名称',
+  `local_msg` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '本地向银行机构发起的请求信息',
+  `org_msg` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '银行机构通知的消息',
   PRIMARY KEY (`id`) USING BTREE
 ) ENGINE = InnoDB AUTO_INCREMENT = 67 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '商户支付订单记录' ROW_FORMAT = Dynamic;