erms3.go 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371
  1. // Package models 211.3 风险管理系统2020_现货合同
  2. package models
  3. import (
  4. "mtp2_if/db"
  5. "time"
  6. )
  7. // Erms3Spotcontractdetail 合同标的明细表
  8. type Erms3Spotcontractdetail struct {
  9. Spotdetailid string `json:"spotdetailid" xorm:"SPOTDETAILID"` // 标的明细ID(346+Unix秒时间戳(10位)+xxxxxx)
  10. Spotcontractid string `json:"spotcontractid" xorm:"SPOTCONTRACTID"` // 现货合同ID
  11. Wrstandardid int64 `json:"wrstandardid" xorm:"WRSTANDARDID"` // 仓单标准ID
  12. Deliverygoodsid int64 `json:"deliverygoodsid" xorm:"DELIVERYGOODSID"` // 现货品种ID
  13. Tradedate string `json:"tradedate" xorm:"TRADEDATE"` // 交易日(yyyyMMdd)
  14. Contracttype int32 `json:"contracttype" xorm:"CONTRACTTYPE"` // 现货合同类型 - 1:采购 -1:销售
  15. Accountid int64 `json:"accountid" xorm:"ACCOUNTID"` // 资金账户ID
  16. Customeraccountid int64 `json:"customeraccountid" xorm:"CUSTOMERACCOUNTID"` // 客户资金账户ID
  17. Producttype int32 `json:"producttype" xorm:"PRODUCTTYPE"` // 产品类型 - 1:标准仓单 2:等标 3:非标
  18. Deliverygoodsdesc string `json:"deliverygoodsdesc" xorm:"DELIVERYGOODSDESC"` // 产品规格 - 根据此字段生成仓单标准、仓单要素类型
  19. Warehouseid int64 `json:"warehouseid" xorm:"WAREHOUSEID"` // 仓库ID
  20. Pointdesc string `json:"pointdesc" xorm:"POINTDESC"` // 点价描述
  21. Priceqty float64 `json:"priceqty" xorm:"PRICEQTY"` // 指定价类总量
  22. Pointqty float64 `json:"pointqty" xorm:"POINTQTY"` // 点价类总量
  23. Unpricedqty float64 `json:"unpricedqty" xorm:"UNPRICEDQTY"` // 未确定量
  24. Unpricedrelatedqty float64 `json:"unpricedrelatedqty" xorm:"UNPRICEDRELATEDQTY"` // 未确定量关联量
  25. Unpricedavaliableqty float64 `json:"unpricedavaliableqty" xorm:"UNPRICEDAVALIABLEQTY"` // 未确定量可关联量
  26. Unpricedcancelledqty float64 `json:"unpricedcancelledqty" xorm:"UNPRICEDCANCELLEDQTY"` // 未确定量撤销量(非业务)
  27. Pricedqty float64 `json:"pricedqty" xorm:"PRICEDQTY"` // 确定量
  28. Pricedamount float64 `json:"pricedamount" xorm:"PRICEDAMOUNT"` // 确定金额
  29. Pricedrelatedqty float64 `json:"pricedrelatedqty" xorm:"PRICEDRELATEDQTY"` // 确定量关联量
  30. Pricedavaliableqty float64 `json:"pricedavaliableqty" xorm:"PRICEDAVALIABLEQTY"` // 确定量可关联量
  31. Pricedcancelledqty float64 `json:"pricedcancelledqty" xorm:"PRICEDCANCELLEDQTY"` // 确定量撤销量(非业务)
  32. Pricedcancelledamount float64 `json:"pricedcancelledamount" xorm:"PRICEDCANCELLEDAMOUNT"` // 确定量撤销金额(非业务)
  33. Deliveryqty float64 `json:"deliveryqty" xorm:"DELIVERYQTY"` // 交收数量(非业务)
  34. Deliveryamount float64 `json:"deliveryamount" xorm:"DELIVERYAMOUNT"` // 交收金额(非业务)
  35. Deliveryovershortqty float64 `json:"deliveryovershortqty" xorm:"DELIVERYOVERSHORTQTY"` // 交收溢短数量(非业务)
  36. Deliveryactualamount float64 `json:"deliveryactualamount" xorm:"DELIVERYACTUALAMOUNT"` // 交收实际金额(非业务)
  37. Deliveryotheramount float64 `json:"deliveryotheramount" xorm:"DELIVERYOTHERAMOUNT"` // 交收其它费用(非业务)
  38. Curdeliveryqty float64 `json:"curdeliveryqty" xorm:"CURDELIVERYQTY"` // 剩余交收数量
  39. Curdeliveryamount float64 `json:"curdeliveryamount" xorm:"CURDELIVERYAMOUNT"` // 剩余交收金额
  40. Remark string `json:"remark" xorm:"REMARK"` // 备注
  41. Marketid int64 `json:"marketid" xorm:"MARKETID"` // 市场ID
  42. Handlestatus int32 `json:"handlestatus" xorm:"HANDLESTATUS"` // 处理状态
  43. Updatetime time.Time `json:"updatetime" xorm:"UPDATETIME"` // 更新时间
  44. Reckonedamount float64 `json:"reckonedamount" xorm:"RECKONEDAMOUNT"` // 已结金额
  45. Invoicedamount float64 `json:"invoicedamount" xorm:"INVOICEDAMOUNT"` // 已开票金额
  46. }
  47. // TableName is ERMS3_SPOTCONTRACTDETAIL
  48. func (Erms3Spotcontractdetail) TableName() string {
  49. return "ERMS3_SPOTCONTRACTDETAIL"
  50. }
  51. // Erms3SpotContractInfo 合同明细.
  52. type Erms3SpotContractInfo struct {
  53. Erms3Spotcontractdetail `xorm:"extends"`
  54. Areauserid int64 `json:"areauserid" xorm:"AREAUSERID"` // 所属机构
  55. Accountid int64 `json:"accountid" xorm:"ACCOUNTID"` // 资金账户ID
  56. Customeruserid int64 `json:"customeruserid" xorm:"CUSTOMERUSERID"` // 客户ID
  57. Customeraccountid int64 `json:"customeraccountid" xorm:"CUSTOMERACCOUNTID"` // 客户资金账户ID
  58. Signdate time.Time `json:"signdate" xorm:"SIGNDATE"` // 签订日期
  59. Closestatus int32 `json:"closestatus" xorm:"CLOSESTATUS"` // 完结状态 - 0:未完结 1:已完结
  60. Relatedbizid string `json:"relatedbizid" xorm:"RELATEDBIZID"` // 关联业务ID
  61. Goodunit string `json:"goodunit" xorm:"'GOODUNIT'"` // 报价单位
  62. Wrstandardcode string `json:"wrstandardcode" xorm:"'WRSTANDARDCODE'"` // 仓单标准代码
  63. Wrstandardname string `json:"wrstandardname" xorm:"'WRSTANDARDNAME'"` // 仓单标准名称
  64. Deliverygoodscode string `json:"deliverygoodscode" xorm:"'DELIVERYGOODSCODE'"` // 交割商品代码
  65. Deliverygoodsname string `json:"deliverygoodsname" xorm:"'DELIVERYGOODSNAME'"` // 交割商品名称
  66. }
  67. // Erms3SpotContractApply 现货合同申请表
  68. type Erms3SpotContractApply struct {
  69. SpotContractID int64 `json:"spotcontractid" xorm:"'SPOTCONTRACTID'" binging:"required"` // 现货合同ID(345+Unix秒时间戳(10位)+xxxxxx)
  70. TradeDate string `json:"tradedate" xorm:"'TRADEDATE'"` // 交易日(yyyyMMdd)
  71. ContractNo string `json:"contractno" xorm:"'CONTRACTNO'"` // 现货合同编号
  72. ContractType int32 `json:"contracttype" xorm:"'CONTRACTTYPE'"` // 现货合同类型 - 1:采购 -1:销售
  73. AreaUserID int32 `json:"areauserid" xorm:"'AREAUSERID'"` // 所属机构
  74. AccountID int64 `json:"accountid" xorm:"'ACCOUNTID'"` // 资金账户ID
  75. CustomerUserID int32 `json:"customeruserid" xorm:"'CUSTOMERUSERID'"` // 客户ID
  76. CustomerAccountID int64 `json:"customeraccountid" xorm:"'CUSTOMERACCOUNTID'"` // 客户资金账户ID
  77. SignDate string `json:"signdate" xorm:"'SIGNDATE'"` // 签订日期
  78. LastDate string `json:"lastdate" xorm:"'LASTDATE'"` // 交货时间
  79. ContractAttachment string `json:"contractattachment" xorm:"'CONTRACTATTACHMENT'"` // 合同附件
  80. OriMarginPayer int32 `json:"orimarginpayer" xorm:"'ORIMARGINPAYER'"` // 初始保证金支付方 -1:买方 2:卖方
  81. OriMargin float64 `json:"orimargin" xorm:"'ORIMARGIN'"` // 初始保证金
  82. Remark string `json:"remark" xorm:"'REMARK'"` // 备注
  83. DetailJSON string `json:"detailjson" xorm:"'DETAILJSON'"` // 明细JSON
  84. ApplyStatus int32 `json:"applystatus" xorm:"'APPLYSTATUS'"` // 申请状态 - 0:未审核 1:审核通过 2:审核中 3:审核失败 4已撤销 5:审核拒绝
  85. ApplySrc int32 `json:"applysrc" xorm:"'APPLYSRC'"` // 申请来源 - 1:管理端 2:终端
  86. MarketID int32 `json:"marketid" xorm:"'MARKETID'"` // 市场ID
  87. CreatorID int32 `json:"creatorid" xorm:"'CREATORID'"` // 申请人
  88. CreateTime time.Time `json:"createtime" xorm:"'CREATETIME'"` // 申请时间
  89. AuditID int32 `json:"auditid" xorm:"'AUDITID'"` // 审核人
  90. AuditTime time.Time `json:"audittime" xorm:"'AUDITTIME'"` // 审核时间
  91. AuditRemark string `json:"auditremark" xorm:"'AUDITREMARK'"` // 审核备注
  92. }
  93. // TableName is ERMS3_SPOTCONTRACTAPPLY
  94. func (Erms3SpotContractApply) TableName() string {
  95. return "ERMS3_SPOTCONTRACTAPPLY"
  96. }
  97. // Erms3Biztradedetail 业务关联单据明细表
  98. type Erms3Biztradedetail struct {
  99. Biztradedetailid int64 `json:"biztradedetailid" xorm:"BIZTRADEDETAILID"` // 业务关联单据明细ID(352+Unix秒时间戳(10位)+xxxxxx)
  100. Tradedetailid int64 `json:"tradedetailid" xorm:"TRADEDETAILID"` // 单据明细ID
  101. Relatedbiztype int32 `json:"relatedbiztype" xorm:"RELATEDBIZTYPE"` // 关联业务类型 - 1:期现套利 2:仓单回购 3:现货贸易
  102. Relatedbizid int64 `json:"relatedbizid" xorm:"RELATEDBIZID"` // 关联业务ID
  103. Marketid int64 `json:"marketid" xorm:"MARKETID"` // 业务市场ID
  104. Spotdetailid int64 `json:"spotdetailid" xorm:"SPOTDETAILID"` // 标的明细ID
  105. Spotcontractid int64 `json:"spotcontractid" xorm:"SPOTCONTRACTID"` // 现货合同ID
  106. Contracttype int32 `json:"contracttype" xorm:"CONTRACTTYPE"` // 现货合同类型 - 1:采购 -1:销售
  107. Bizaccountid int64 `json:"bizaccountid" xorm:"BIZACCOUNTID"` // 业务现货资金账户
  108. Contractaccountid int64 `json:"contractaccountid" xorm:"CONTRACTACCOUNTID"` // 现货合同资金账户
  109. Tradedate string `json:"tradedate" xorm:"TRADEDATE"` // 交易日(yyyyMMdd)
  110. Relatedqty float64 `json:"relatedqty" xorm:"RELATEDQTY"` // 关联数量
  111. Relatedamount float64 `json:"relatedamount" xorm:"RELATEDAMOUNT"` // 关联金额
  112. Cancelledqty float64 `json:"cancelledqty" xorm:"CANCELLEDQTY"` // 撤销量
  113. Cancelledamount float64 `json:"cancelledamount" xorm:"CANCELLEDAMOUNT"` // 撤销金额
  114. Deliveryqty float64 `json:"deliveryqty" xorm:"DELIVERYQTY"` // 交收数量(业务)
  115. Deliveryamount float64 `json:"deliveryamount" xorm:"DELIVERYAMOUNT"` // 交收金额(业务) - 按比例计算
  116. Deliveryovershortqty float64 `json:"deliveryovershortqty" xorm:"DELIVERYOVERSHORTQTY"` // 交收溢短数量(业务)
  117. Deliveryactualamount float64 `json:"deliveryactualamount" xorm:"DELIVERYACTUALAMOUNT"` // 交收实际金额(业务)
  118. Deliveryotheramount float64 `json:"deliveryotheramount" xorm:"DELIVERYOTHERAMOUNT"` // 交收其它费用(业务)
  119. Closestatus int32 `json:"closestatus" xorm:"CLOSESTATUS"` // 完结状态 - 0:未完结 1:已完结
  120. Closetradedate string `json:"closetradedate" xorm:"CLOSETRADEDATE"` // 完结交易日(yyyyMMdd)
  121. Updatetime time.Time `json:"updatetime" xorm:"UPDATETIME"` // 更新时间
  122. Handlestatus int32 `json:"handlestatus" xorm:"HANDLESTATUS"` // 处理状态
  123. }
  124. // TableName is ERMS3_BIZTRADEDETAIL
  125. func (m *Erms3Biztradedetail) TableName() string {
  126. return "ERMS3_BIZTRADEDETAIL"
  127. }
  128. // Erms2asapply 期现套利业务申请表
  129. type Erms2asapply struct {
  130. Asapplyid int64 `json:"asapplyid" xorm:"'ASAPPLYID'" binding:"required"` // 策略申请ID(342+Unix秒时间戳(10位)+xxxxxx)
  131. Asno string `json:"asno" xorm:"'ASNO'"` // 策略编号
  132. Asname string `json:"asname" xorm:"'ASNAME'"` // 策略名称
  133. Biztype int32 `json:"biztype" xorm:"'BIZTYPE'"` // 业务类型 - 1:正向套利 2:反向套利
  134. Userid int64 `json:"userid" xorm:"'USERID'"` // 所属机构
  135. Deliverygoodsid int64 `json:"deliverygoodsid" xorm:"'DELIVERYGOODSID'"` // 现货品种ID
  136. Goodsgroupid int64 `json:"goodsgroupid" xorm:"'GOODSGROUPID'"` // 期货品种ID
  137. Spotquota float64 `json:"spotquota" xorm:"'SPOTQUOTA'"` // 现货额度
  138. Futurequote float64 `json:"futurequote" xorm:"'FUTUREQUOTE'"` // 期货额度
  139. Applybasis float64 `json:"applybasis" xorm:"'APPLYBASIS'"` // 申请基差
  140. Applystatus int32 `json:"applystatus" xorm:"'APPLYSTATUS'"` // 申请状态 - 0:待审核 1:审核通过 2:审核中 3:审核失败 4已撤销 5:审核拒绝
  141. Remark string `json:"remark" xorm:"'REMARK'"` // 备注
  142. Marketid int64 `json:"marketid" xorm:"'MARKETID'"` // 市场ID
  143. Tradedate string `json:"tradedate" xorm:"'TRADEDATE'"` // 交易日(yyyyMMdd)
  144. Creatorid int64 `json:"creatorid" xorm:"'CREATORID'"` // 创建人
  145. Createtime string `json:"createtime" xorm:"'CREATETIME'"` // 创建时间
  146. Auditid int64 `json:"auditid" xorm:"'AUDITID'"` // 审核人
  147. Audittime string `json:"audittime" xorm:"'AUDITTIME'"` // 审核时间
  148. Auditremark string `json:"auditremark" xorm:"'AUDITREMARK'"` // 审核备注
  149. }
  150. // TableName is ERMS2_ASAPPLY
  151. func (Erms2asapply) TableName() string {
  152. return "ERMS2_ASAPPLY"
  153. }
  154. // Erms2spottradeapply 现货贸易业务申请表
  155. type Erms2spottradeapply struct {
  156. Spottradeid int64 `json:"spottradeid" xorm:"'SPOTTRADEID'" binding:"required"` // 业务ID(341+Unix秒时间戳(10位)+xxxxxx)
  157. Spottradeno string `json:"spottradeno" xorm:"'SPOTTRADENO'"` // 业务编号
  158. Spottradename string `json:"spottradename" xorm:"'SPOTTRADENAME'"` // 业务名称
  159. Areauserid int64 `json:"areauserid" xorm:"'AREAUSERID'"` // 所属机构
  160. Deliverygoodsid int64 `json:"deliverygoodsid" xorm:"'DELIVERYGOODSID'"` // 现货品种ID
  161. Wrstandardid int64 `json:"wrstandardid" xorm:"'WRSTANDARDID'"` // 仓单标准ID
  162. Goodsgroupid int32 `json:"goodsgroupid" xorm:"'GOODSGROUPID'"` // 期货品种
  163. Spotaccountid int64 `json:"spotaccountid" xorm:"'SPOTACCOUNTID'"` // 现货资金账户
  164. Futureaccountid int64 `json:"futureaccountid" xorm:"'FUTUREACCOUNTID'"` // 期货资金账户
  165. Remark string `json:"remark" xorm:"'REMARK'"` // 备注
  166. Applyjsondetail string `json:"applyjsondetail" xorm:"'APPLYJSONDETAIL'"` // 申请明细(JSON)
  167. Applystatus int32 `json:"applystatus" xorm:"'APPLYSTATUS'"` // 申请状态 - 0:待审核 1:审核通过 2:审核中 3:审核失败 4已撤销 5:审核拒绝
  168. Marketid int64 `json:"marketid" xorm:"'MARKETID'"` // 市场ID
  169. Tradedate string `json:"tradedate" xorm:"'TRADEDATE'"` // 交易日(yyyyMMdd)
  170. Creatorid int64 `json:"creatorid" xorm:"'CREATORID'"` // 创建人
  171. Createtime string `json:"createtime" xorm:"'CREATETIME'"` // 创建时间
  172. Auditid int64 `json:"auditid" xorm:"'AUDITID'"` // 审核人
  173. Audittime string `json:"audittime" xorm:"'AUDITTIME'"` // 审核时间
  174. Auditremark string `json:"auditremark" xorm:"'AUDITREMARK'"` // 审核备注
  175. }
  176. // TableName is ERMS2_SPOTTRADEAPPLY
  177. func (Erms2spottradeapply) TableName() string {
  178. return "ERMS2_SPOTTRADEAPPLY"
  179. }
  180. // AddSpotContractApply 插入现货合同记录
  181. func AddSpotContractApply(spotContractApply Erms3SpotContractApply) error {
  182. engine := db.GetEngine()
  183. // 组织sql,插入现货合同申请信息
  184. sql := `INSERT INTO ERMS3_SPOTCONTRACTAPPLY(SPOTCONTRACTID,
  185. TRADEDATE,
  186. CONTRACTNO,
  187. CONTRACTTYPE,
  188. AREAUSERID,
  189. ACCOUNTID,
  190. CUSTOMERUSERID,
  191. CUSTOMERACCOUNTID,
  192. SIGNDATE,
  193. CONTRACTATTACHMENT,
  194. ORIMARGIN,
  195. REMARK,
  196. DETAILJSON,
  197. APPLYSTATUS,
  198. APPLYSRC,
  199. CREATORID,
  200. CREATETIME)
  201. VALUES(?,
  202. ?,
  203. ?,
  204. ?,
  205. ?,
  206. ?,
  207. ?,
  208. ?,
  209. to_date(?, 'YYYY-MM-DD HH24:MI:SS'),
  210. ?,
  211. ?,
  212. ?,
  213. ?,
  214. ?,
  215. ?,
  216. ?,
  217. sysdate)`
  218. _, err := engine.Exec(sql,
  219. spotContractApply.SpotContractID,
  220. spotContractApply.TradeDate,
  221. spotContractApply.ContractNo,
  222. spotContractApply.ContractType,
  223. spotContractApply.AreaUserID,
  224. spotContractApply.AccountID,
  225. spotContractApply.CustomerUserID,
  226. spotContractApply.CustomerAccountID,
  227. spotContractApply.SignDate,
  228. spotContractApply.ContractAttachment,
  229. spotContractApply.OriMargin,
  230. spotContractApply.Remark,
  231. spotContractApply.DetailJSON,
  232. spotContractApply.ApplyStatus,
  233. spotContractApply.ApplySrc,
  234. spotContractApply.CreatorID)
  235. return err
  236. }
  237. // QueryErms3SpotContractInfo 查询现货合同信息
  238. func QueryErms3SpotContractInfo(accountids []int64, contracttype, contractmode, status int32) ([]Erms3SpotContractInfo, error) {
  239. datas := make([]Erms3SpotContractInfo, 0)
  240. engine := db.GetEngine()
  241. s := engine.Table("ERMS3_SPOTCONTRACTDETAIL").
  242. Join("LEFT", "ERMS3_SPOTCONTRACT", "ERMS3_SPOTCONTRACTDETAIL.SPOTCONTRACTID = ERMS3_SPOTCONTRACT.SPOTCONTRACTID").
  243. Join("LEFT", "ERMS3_BIZTRADEDETAIL", "ERMS3_BIZTRADEDETAIL.SPOTDETAILID = ERMS3_SPOTCONTRACTDETAIL.SPOTDETAILID").
  244. Join("LEFT", "WRSTANDARD", "WRSTANDARD.WRSTANDARDID = ERMS3_SPOTCONTRACTDETAIL.WRSTANDARDID").
  245. Join("LEFT", "DELIVERYGOODS", "DELIVERYGOODS.DELIVERYGOODSID = WRSTANDARD.DELIVERYGOODSID").
  246. Join("LEFT", "ENUMDICITEM", "WRSTANDARD.UNITID = ENUMDICITEM.ENUMITEMNAME AND ENUMDICITEM.ENUMDICCODE = 'goodsunit'").
  247. Select(`to_char(ERMS3_SPOTCONTRACTDETAIL.SPOTCONTRACTID) SPOTCONTRACTID, ERMS3_SPOTCONTRACT.AREAUSERID, ERMS3_SPOTCONTRACT.ACCOUNTID, ERMS3_SPOTCONTRACT.CUSTOMERUSERID,
  248. ERMS3_SPOTCONTRACT.CUSTOMERACCOUNTID, ERMS3_SPOTCONTRACT.CLOSESTATUS, ERMS3_SPOTCONTRACT.SIGNDATE, ERMS3_SPOTCONTRACTDETAIL.*, WRSTANDARD.WRSTANDARDNAME, WRSTANDARD.WRSTANDARDCODE, DELIVERYGOODS.DELIVERYGOODSNAME, DELIVERYGOODS.DELIVERYGOODSCODE,
  249. to_char(ERMS3_BIZTRADEDETAIL.RELATEDBIZID) RELATEDBIZID, ENUMDICITEM.ENUMDICNAME GOODUNIT`).
  250. Where("ERMS3_SPOTCONTRACT.CONTRACTTYPE = ? AND ERMS3_SPOTCONTRACT.CONTRACTMODE = ? AND ERMS3_SPOTCONTRACT.CLOSESTATUS = ?", contracttype, contractmode, status).
  251. In("ERMS3_SPOTCONTRACT.ACCOUNTID", accountids).
  252. Desc("ERMS3_SPOTCONTRACTDETAIL.SPOTCONTRACTID")
  253. err := s.Find(&datas)
  254. return datas, err
  255. }
  256. // InsertErms2AsApply 新增期现套利业务申请
  257. func InsertErms2AsApply(apply Erms2asapply) error {
  258. engine := db.GetEngine()
  259. // 生成ID
  260. var err error
  261. if apply.Asapplyid, err = GetSerialNumber("342"); err != nil {
  262. return err
  263. }
  264. sql := `insert into ERMS2_ASApply (
  265. Asapplyid ,
  266. Asno ,
  267. Asname ,
  268. Biztype ,
  269. Userid ,
  270. Deliverygoodsid,
  271. Goodsgroupid ,
  272. Spotquota ,
  273. Futurequote ,
  274. Applybasis ,
  275. Applystatus ,
  276. Remark ,
  277. Marketid ,
  278. Tradedate ,
  279. Creatorid ,
  280. Createtime
  281. ) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,to_date(?, 'YYYY-MM-DD HH24:MI:SS'))`
  282. _, err = engine.Exec(sql,
  283. apply.Asapplyid,
  284. apply.Asno,
  285. apply.Asname,
  286. apply.Biztype,
  287. apply.Userid,
  288. apply.Deliverygoodsid,
  289. apply.Goodsgroupid,
  290. apply.Spotquota,
  291. apply.Futurequote,
  292. apply.Applybasis,
  293. apply.Applystatus,
  294. apply.Remark,
  295. apply.Marketid,
  296. apply.Tradedate,
  297. apply.Creatorid,
  298. time.Now().Format("2006-01-02 15:04:05"),
  299. )
  300. return err
  301. }
  302. // InsertErms2SpotTradeApply 新增现货贸易业务申请
  303. func InsertErms2SpotTradeApply(apply Erms2spottradeapply) error {
  304. engine := db.GetEngine()
  305. // 生成ID
  306. var err error
  307. if apply.Spottradeid, err = GetSerialNumber("341"); err != nil {
  308. return err
  309. }
  310. sql := `insert into ERMS2_SPOTTRADEAPPLY (
  311. Spottradeid ,
  312. Spottradeno ,
  313. Spottradename ,
  314. Areauserid ,
  315. Deliverygoodsid,
  316. Wrstandardid ,
  317. Goodsgroupid ,
  318. Spotaccountid ,
  319. Futureaccountid,
  320. Remark ,
  321. Applyjsondetail,
  322. Applystatus ,
  323. Marketid ,
  324. Tradedate ,
  325. Creatorid ,
  326. Createtime
  327. ) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,to_date(?, 'YYYY-MM-DD HH24:MI:SS'))`
  328. _, err = engine.Exec(sql,
  329. apply.Spottradeid,
  330. apply.Spottradeno,
  331. apply.Spottradename,
  332. apply.Areauserid,
  333. apply.Deliverygoodsid,
  334. apply.Wrstandardid,
  335. apply.Goodsgroupid,
  336. apply.Spotaccountid,
  337. apply.Futureaccountid,
  338. apply.Remark,
  339. apply.Applyjsondetail,
  340. apply.Applystatus,
  341. apply.Marketid,
  342. apply.Tradedate,
  343. apply.Creatorid,
  344. time.Now().Format("2006-01-02 15:04:05"),
  345. )
  346. return err
  347. }