erms3.go 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. // Package models 211.3 风险管理系统2020_现货合同
  2. package models
  3. import (
  4. "mtp2_if/db"
  5. "time"
  6. )
  7. // Erms3SpotContractApply 现货合同申请表
  8. type Erms3SpotContractApply struct {
  9. SpotContractID int64 `json:"spotcontractid" xorm:"'SPOTCONTRACTID'" binging:"required"` // 现货合同ID(345+Unix秒时间戳(10位)+xxxxxx)
  10. TradeDate string `json:"tradedate" xorm:"'TRADEDATE'"` // 交易日(yyyyMMdd)
  11. ContractNo string `json:"contractno" xorm:"'CONTRACTNO'"` // 现货合同编号
  12. ContractType int32 `json:"contracttype" xorm:"'CONTRACTTYPE'"` // 现货合同类型 - 1:采购 -1:销售
  13. AreaUserID int32 `json:"areauserid" xorm:"'AREAUSERID'"` // 所属机构
  14. AccountID int64 `json:"accountid" xorm:"'ACCOUNTID'"` // 资金账户ID
  15. CustomerUserID int32 `json:"customeruserid" xorm:"'CUSTOMERUSERID'"` // 客户ID
  16. CustomerAccountID int64 `json:"customeraccountid" xorm:"'CUSTOMERACCOUNTID'"` // 客户资金账户ID
  17. SignDate time.Time `json:"signdate" xorm:"'SIGNDATE'"` // 签订日期
  18. LastDate time.Time `json:"lastdate" xorm:"'LASTDATE'"` // 交货时间
  19. ContractAttachment string `json:"contractattachment" xorm:"'CONTRACTATTACHMENT'"` // 合同附件
  20. OriMarginPayer int32 `json:"orimarginpayer" xorm:"'ORIMARGINPAYER'"` // 初始保证金支付方 -1:买方 2:卖方
  21. OriMargin float64 `json:"orimargin" xorm:"'ORIMARGIN'"` // 初始保证金
  22. Remark string `json:"remark" xorm:"'REMARK'"` // 备注
  23. DetailJSON string `json:"detailjson" xorm:"'DETAILJSON'"` // 明细JSON
  24. ApplyStatus int32 `json:"applystatus" xorm:"'APPLYSTATUS'"` // 申请状态 - 0:未审核 1:审核通过 2:审核中 3:审核失败 4已撤销 5:审核拒绝
  25. ApplySrc int32 `json:"applysrc" xorm:"'APPLYSRC'"` // 申请来源 - 1:管理端 2:终端
  26. MarketID int32 `json:"marketid" xorm:"'MARKETID'"` // 市场ID
  27. CreatorID int32 `json:"creatorid" xorm:"'CREATORID'"` // 申请人
  28. CreateTime time.Time `json:"createtime" xorm:"'CREATETIME'"` // 申请时间
  29. AuditID int32 `json:"auditid" xorm:"'AUDITID'"` // 审核人
  30. AuditTime time.Time `json:"audittime" xorm:"'AUDITTIME'"` // 审核时间
  31. AuditRemark string `json:"auditremark" xorm:"'AUDITREMARK'"` // 审核备注
  32. }
  33. // TableName is ERMS3_SPOTCONTRACTAPPLY
  34. func (Erms3SpotContractApply) TableName() string {
  35. return "ERMS3_SPOTCONTRACTAPPLY"
  36. }
  37. // AddSpotContractApply 插入现货合同记录
  38. func AddSpotContractApply(spotContractApply Erms3SpotContractApply) error {
  39. engine := db.GetEngine()
  40. // 组织sql,插入现货合同申请信息
  41. sql := `INSERT INTO ERMS3_SPOTCONTRACTAPPLY(SPOTCONTRACTID,
  42. TRADEDATE,
  43. CONTRACTNO,
  44. CONTRACTTYPE,
  45. AREAUSERID,
  46. ACCOUNTID,
  47. CUSTOMERUSERID,
  48. CUSTOMERACCOUNTID,
  49. SIGNDATE,
  50. LASTDATE,
  51. CONTRACTATTACHMENT,
  52. ORIMARGINPAYER,
  53. ORIMARGIN,
  54. REMARK,
  55. DETAILJSON,
  56. APPLYSTATUS,
  57. APPLYSRC,
  58. MARKETID,
  59. CREATORID,
  60. CREATETIME)
  61. VALUES(?,
  62. ?,
  63. ?,
  64. ?,
  65. ?,
  66. ?,
  67. ?,
  68. ?,
  69. to_date(?, 'YYYY-MM-DD HH24:MI:SS'),
  70. to_date(?, 'YYYY-MM-DD HH24:MI:SS'),
  71. ?,
  72. ?,
  73. ?,
  74. ?,
  75. ?,
  76. ?,
  77. ?,
  78. ?,
  79. ?,
  80. sysdate)`
  81. _, err := engine.Exec(sql,
  82. spotContractApply.SpotContractID,
  83. spotContractApply.TradeDate,
  84. spotContractApply.ContractNo,
  85. spotContractApply.ContractType,
  86. spotContractApply.AreaUserID,
  87. spotContractApply.AccountID,
  88. spotContractApply.CustomerUserID,
  89. spotContractApply.CustomerAccountID,
  90. spotContractApply.SignDate,
  91. spotContractApply.LastDate,
  92. spotContractApply.ContractAttachment,
  93. spotContractApply.OriMarginPayer,
  94. spotContractApply.OriMargin,
  95. spotContractApply.Remark,
  96. spotContractApply.DetailJSON,
  97. spotContractApply.ApplyStatus,
  98. spotContractApply.ApplySrc,
  99. spotContractApply.MarketID,
  100. spotContractApply.CreatorID)
  101. return err
  102. }