[关闭]
@Wahson 2020-09-01T18:45:05.000000Z 字数 9796 阅读 433

资金账户 + 拍卖

Wanbo


资金利息

  1. 充值流程:
  2. 导入银行流水 => 流水认领选择账户充值 => 新建充值申请 => 充值申请审核(自动) => 生成账户充值流水 => 增加账户余额
  3. 提现流程:
  4. 新建提现申请 => 提现申请审核 => 审核成功 => 冻结账户金额 => 生成付款指令 => 付款指令流程 => 导入银行流水 => 流水认领选择账户提现 => 选择充值申请(根据公司名称自动匹配) => 关联充值申请 => 生成解冻流水 => 生成账户提现流水
  5. 取消提现申请:
  6. 审核前,可取消提现申请
  1. use crm_db;
  2. create table company_account
  3. (
  4.     id             bigint                                     not null primary key auto_increment,
  5.     company_id     bigint                                     not null comment '公司id',
  6.     -- type    smallint(2)    default 1    not null comment '账户类型,1:资金账户(CAPITAL);2:贷款账号(CREDIT);3:预付账户(PREPAY)',
  7.     -- 可用金额 = 账户余额 - 冻结余额
  8.     balance        decimal(13, 2) default 0.00                not null comment '账户余额',
  9.     frozen_balance decimal(13, 2) default 0.00                not null comment '账户冻结余额',
  10.     -- 用途,预设密码?
  11.     -- uniq_hash          varchar(32)                 not null comment 'MD5( concat(''预设密码'', company_id, balance,frozen_balance,updated_at,updated_by) )',
  12.     created_at     timestamp      default current_timestamp() not null,
  13.     created_by     int            default 0                   not null,
  14.     updated_at     timestamp      default current_timestamp() not null,
  15.     updated_by     int            default 0                   not null,
  16.     remark         varchar(255)                               null comment '备注',
  17.     constraint vr_2_company foreign key (company_id) references company (id)
  18. ) engine = innoDb
  19.   charset = utf8mb4 comment '公司账户';
  20. create table account_journal
  21. (
  22.     id                 bigint auto_increment primary key,
  23.     company_account_id bigint                                     not null comment '公司账号id',
  24.     company_id         int(10)                                    not null comment '公司id',
  25.     bank_journal_id    bigint         default null comment '银行流水id',
  26.     account_apply_id   bigint default null comment '提现/充值申请id, 业务类型为提现或充值时有值',
  27.     -- order_payment_id  bigint default null comment '订单支付记录id, 业务类型为订单货款时有值',
  28.     trans_type         smallint(2)    default 1                   not null comment '交易类型,1:收入(income);2:支出(expenditure);3:冻结(freeze);4:解冻(unfreeze);',
  29.     business_type      smallint(2)    default 10                   not null comment '业务类型,10:提现(withdrawal);20:充值(recharge);30:订单货款(order_payment);40:拍卖(auction);90:其他(other)',
  30.     amount             decimal(13, 2)                             not null comment '流水金额',
  31.     last_balance       decimal(13, 2) default 0.00                null comment '上一次金额',
  32.     -- balance           decimal(13, 2)                                not null comment '操作后的人民币余额',
  33.     -- frozen_balance    decimal(13, 2)                                not null comment '操作后的人民币冻结余额',
  34.     -- freeze_status         smallint(1)                                   null comment '冻结状态,1:已解冻(THAW);2:冻结中(FROZENIN);3:部分解冻(PARTIALFROZENIN)',
  35.     -- freeze_relate_journal int(10)                                       null comment '冻结关联流水',
  36.     -- freeze_balance        decimal(10, 2)                                null comment '冻结余额(随解冻而变化)',
  37.     -- transaction_id        int                 default 0                 not null comment '全局事务编号',
  38.     -- transaction_sequence  int                 default 0                 not null comment '事务过程序号',
  39.     -- rollback_status       smallint(1)         default 0                 null comment '0:未回滚,1:已回'
  40.     created_at         timestamp      default current_timestamp() not null,
  41.     created_by         int            default 0                   not null,
  42.     updated_at         timestamp      default current_timestamp() not null,
  43.     updated_by         int            default 0                   not null,
  44.     remark             varchar(255)                               null comment '备注'
  45. ) engine = innoDb
  46.   charset = utf8mb4 comment '公司账户变更流水';
  47. create table account_application
  48. (
  49.     id                      bigint auto_increment primary key,
  50.     company_id              bigint                                  not null comment '公司ID',
  51.     company_name            varchar(100)                            not null comment '公司名称',
  52.     -- customer_id        int                                           null comment '客户ID',
  53.     -- account_type       smallint(1)         default 1                 not null comment '账户类型, 1:资金账户(CAPITAL);2:贷款账号(CREDIT);3:预付账户(PREPAY)',
  54.     type                    smallint(2) default 1                   not null comment '申请类型,1:提现(withdraw);2:充值(recharge)',
  55.     status                  smallint(2) default 1                   not null comment '状态,10:待审核(to_be_audited);20:已审核(audited);30:已完成(finished);90:已取消(canceled)',
  56.     amount                  decimal(10, 2)                          not null comment '金额',
  57.     bank_journal_id         bigint      default null comment '银行流水id',
  58. #     冗余字段,来源银行流水表 bank_journal
  59. #     platform_account      varchar(32)                                null comment '平台银行账号',
  60. #     platform_account_name varchar(64)                                not null comment '平台银行户名',
  61. #     bank_account          varchar(32)                                null comment '收付款银行账号',
  62. #     bank_account_name     varchar(64)                                not null comment '收付款银行户名',
  63.     audited_at              datetime                                null comment '审核时间',
  64.     audited_by              int(10)                                 null comment '审核人',
  65.     -- confirmed_at              datetime                                null comment '确认时间',
  66.     -- confirmed_by              int(10)                                 null comment '确认人',
  67.     created_at              timestamp   default current_timestamp() not null,
  68.     created_by              int         default 0                   not null,
  69.     updated_at              timestamp   default current_timestamp() not null,
  70.     updated_by              int         default 0                   not null,
  71.     remark                  varchar(255)                            null comment '备注',
  72.     constraint aa_2_company foreign key (company_id) references company (id)
  73. ) engine = innoDb charset = utf8mb4 comment '充值申请';
  1. 原子方法:
  2. createCompanyAccountApply
  3. createCompanyAccountJournal
  4. createCompanyAccount
  5. // 增加账号余额
  6. increaseAccountBalance(incr_amount) {
  7.     更新balance
  8. createCompanyAccountJournal(type)
  9. }
  10. // 减少账号余额
  11. decreaseAccountBalance(decr_amount) {
  12.     更新balance
  13. createCompanyAccountJournal(type)
  14. }
  15. // 增加账号冻结余额
  16. increaseAccountFrozenBalance {
  17.     更新frozen_balance
  18. createCompanyAccountJournal(type)
  19. }
  20. // 减少账号冻结余额
  21. decreaseAccountFrozenBalance {
  22.     更新frozen_balance
  23. createCompanyAccountJournal(type)
  24. }
  25. // 充值审核
  26. auditRecharge {
  27.    更新状态为已审核
  28.     increaseAccountBalance(充值)
  29. }
  30. // 提现审核
  31. auditWithdrawal {
  32.   更新状态为已审核
  33.   increaseAccountFrozenBalance(提现)
  34. //  TODO:生成付款指令
  35. }
  36. // 充值/提现申请完成
  37. finishAccountApply {
  38. 更新状态为已完成
  39.     if(提现) {
  40.     更新bank_journal_id
  41.     decreaseAccountFrozenBalance(提现)
  42. decreaseAccountBalance(提现)
  43.     }
  44. }
  45. cancelWithdrawal {
  46. // 审核前可操作
  47.     更新状态未已取消
  48. }
  1. 新建充值:
  2. createRecharge {
  3.   修改流水记录
  4.   createCompanyAccountApply
  5.   auditRecharge
  6.   finishWithdrawal
  7. }
  8. 提现:
  9. createWithdrawal {
  10.   createCompanyAccountApply
  11. }

拍卖流程

  1. 运营系统新建标的,关联采购单,填写牌号,拍卖数量,起拍价,起拍数量等,提交审核
  1. 审核通过,等待拍卖开始
  1. -- 拍卖
  2. create table auction_target
  3. (
  4. id bigint auto_increment primary key,
  5. purchase_item_id bigint not null comment '采购子单id',
  6. delivery_type smallint(2) not null comment '送货方式, 10:自提(self_pick);20:供应商配送(supplier_deliver);30:万博配送(wanbo_deliver)',
  7. product_id int not null,
  8. category varchar(12) not null comment '产品分类',
  9. designation varchar(32) not null comment '产品牌号',
  10. manufacturer_id int not null comment '生产商ID',
  11. manufacturer_name varchar(32) not null comment '生产商名称',
  12. supplier_company_id int not null comment '供应商id',
  13. supplier_company_name varchar(32) not null comment '供应商名称',
  14. warehouse_id int not null comment '发货仓库id',
  15. warehouse_name varchar(32) not null comment '发货仓库名称',
  16. status smallint(1) default 1 null comment '状态(1:预提交,2:待审核,3:已审核 4:拍卖中,5:拍卖完成,6:流拍,9:审核不通过,10:取消)',
  17. starting_price decimal(13, 2) default 0.00 not null comment '起拍价',
  18. -- market_price decimal(13, 2) null comment '市场评估价',
  19. weight decimal(8, 3) default 0.000 not null comment '拍卖总吨数',
  20. starting_weight decimal(8, 3) not null comment '起拍吨数',
  21. price_increment decimal(10, 2) not null comment '加价幅度',
  22. weight_increment decimal(8, 3) not null comment '数量增幅(最小变量单位或每次增加吨数)',
  23. -- auction_type smallint(1) default 1 not null comment '竞拍方式,1:升价(priceRise);2:降价(priceCut )',
  24. deposit_ratio decimal(3, 3) not null comment '保证金比例',
  25. -- basic_deposit decimal(10, 2) null comment '保证金基础值',
  26. -- publicity_start_at datetime not null comment '开始公示时间',
  27. auction_start_at datetime not null comment '开始拍卖时间',
  28. expected_auction_end_at datetime not null comment '预定结束拍卖时间',
  29. actual_auction_end_at datetime null comment '实际拍卖结束时间',
  30. -- 期货交货时间?
  31. -- delivery_time datetime null comment '发货时间',
  32. -- trade_addr varchar(50) null comment '交易地点',
  33. -- weight_left decimal(13, 3) null comment '剩余吨数',
  34. is_future smallint(1) default 0 not null comment '是否期货 0为false, 1为true',
  35. execute_start_at date null comment '送货/交付日期开始',
  36. execute_end_at date null comment '送货/交付日期结束',
  37. audited_at datetime null comment '审核时间',
  38. audited_by int(10) null comment '审核人',
  39. created_at timestamp default current_timestamp() not null,
  40. created_by int default 0 not null,
  41. updated_at timestamp default current_timestamp() not null,
  42. updated_by int default 0 not null,
  43. remark varchar(255) null comment '备注'
  44. ) engine = innoDb
  45. charset = utf8mb4 comment '拍卖标的';
  46. create table auction_bid_record
  47. (
  48. id int(10) auto_increment
  49. primary key,
  50. wx_user_id int(10) not null comment '用户id',
  51. company_id int(10) not null,
  52. auction_target_id int(10) not null comment '竞拍标的ID',
  53. price_before_bid decimal(10, 2) default 0.00 not null comment '拍前价格',
  54. -- after_price decimal(10, 2) not null comment '拍后价格',
  55. bid_price decimal(10, 2) not null comment '出价',
  56. weight decimal(8, 3) not null comment '拍卖吨数',
  57. actual_weight decimal(8, 3) default 0.000 not null comment '实际中标吨数(为0则为出局)',
  58. -- account_journal_id int(10) not null comment '账户资金变动流水ID',
  59. -- margin decimal(10, 2) default 0.00 not null comment '冻结保证金',
  60. auction_at datetime not null comment '出价时间',
  61. created_at timestamp default current_timestamp() not null,
  62. created_by int default 0 not null,
  63. updated_at timestamp default current_timestamp() not null,
  64. updated_by int default 0 not null,
  65. remark varchar(255) null comment '备注',
  66. constraint bid_records_fk_target_id
  67. foreign key (auction_target_id) references auction_target (id)
  68. ) engine = innoDb
  69. charset = utf8mb4 comment '出价记录';
  70. -- auto-generated definition
  71. # create table auction_purchase_items
  72. # (
  73. # id int auto_increment
  74. # primary key,
  75. # target_id int not null comment '标的id',
  76. # purchase_item_id int not null comment '采购子单id',
  77. # weight decimal(10, 3) not null comment '分配重量',
  78. # created_by int null,
  79. # created_at datetime null,
  80. # updated_by int null,
  81. # updated_at timestamp default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP
  82. # )
  83. -- auto-generated definition
  84. # create table auction_target_summaries
  85. # (
  86. # id int(10) auto_increment
  87. # primary key,
  88. # target_id int(10) not null comment '竞拍标的ID',
  89. # wined_count int(10) not null comment '中标人数',
  90. # bid_count int(10) not null comment '投注人数',
  91. # bid_times int(10) not null comment '投注次数',
  92. # weight decimal(8, 3) not null comment '成交吨数',
  93. # amount decimal(10, 2) not null comment '成交金额',
  94. # max_price decimal(10, 2) not null comment '最高价',
  95. # min_price decimal(10, 2) not null comment '最低价',
  96. # constraint target_summary_fk_target_id
  97. # foreign key (target_id) references auction_target (id)
  98. # ) engine = innoDb charset = utf8mb4 comment '竞拍商品摘要';
  99. -- auto-generated definition
  100. create table auction_won_record
  101. (
  102. id int(10) auto_increment
  103. primary key,
  104. company_id bigint not null comment '公司id',
  105. auction_bid_record_id bigint not null comment '出价记录',
  106. auction_target_id bigint not null comment '标的id',
  107. price decimal(10, 2) not null comment '中标价',
  108. weight decimal(8, 3) not null comment '中标数量',
  109. total_amount decimal(10, 2) not null comment '中标金额',
  110. -- order_no varchar(32) not null comment '关联销售订单号',
  111. -- status smallint(1) not null comment '状态(1:待确认,2:成功,3:违约,4:违约已处理)',
  112. created_at datetime not null,
  113. created_by int(10) null comment '创建人,只能是StaffID',
  114. updated_at timestamp default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP,
  115. updated_by int(10) null comment '更新人,只能是StaffID',
  116. constraint wined_record_fk_bid_record_id
  117. foreign key (auction_bid_record_id) references auction_bid_record (id),
  118. constraint wined_record_fk_target_id
  119. foreign key (auction_target_id) references auction_target (id)
  120. ) engine = innoDb
  121. charset = utf8mb4 comment '中标记录';

结算:
先按暂定价结算付款,后面按月平均价得出最终结算价,多付部分摞到后续订单,少的部分补付。资金利息如何计算?按照目前数据模型,认领后,需要修改成本重新认领

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注