|
@@ -0,0 +1,278 @@
|
|
|
|
|
+package models
|
|
|
|
|
+
|
|
|
|
|
+import (
|
|
|
|
|
+ "encoding/hex"
|
|
|
|
|
+ "fmt"
|
|
|
|
|
+ "mtp2_if/db"
|
|
|
|
|
+ "mtp2_if/utils"
|
|
|
|
|
+ "time"
|
|
|
|
|
+)
|
|
|
|
|
+
|
|
|
|
|
+// Tradepositiontransfer 持仓过户申请表 - 16所有权(中融需求)
|
|
|
|
|
+type InTradepositiontransfer struct {
|
|
|
|
|
+ APPLYID int64 `json:"applyid" xorm:"APPLYID"` // 申请ID(185+Unix秒时间戳(10位)+2位(MarketServiceID)+xxxx)
|
|
|
|
|
+ OUTUSERID int64 `json:"outuserid" xorm:"OUTUSERID"` // 转出方用户ID(申请方)
|
|
|
|
|
+ OUTLOGINID int64 `json:"outloginid" xorm:"OUTLOGINID"` // 转出方登录账号
|
|
|
|
|
+ OUTACCOUNTID int64 `json:"outaccountid" xorm:"OUTACCOUNTID"` // 转出方资金ID(申请方)
|
|
|
|
|
+ INUSERID int64 `json:"inuserid" xorm:"INUSERID" form:"userid" binding:"required"` // 转入方用户ID(确认方)
|
|
|
|
|
+ INACCOUNTID int64 `json:"inaccountid" xorm:"INACCOUNTID"` // 转入方资金ID(确认方)
|
|
|
|
|
+ INLOGINID int64 `json:"inloginid" xorm:"INLOGINID"` // 转入方登录账号
|
|
|
|
|
+ GOODSID int32 `json:"goodsid" xorm:"GOODSID"` // 商品ID
|
|
|
|
|
+ MARKETID int32 `json:"marketid" xorm:"MARKETID"` // 市场ID
|
|
|
|
|
+ BUYORSELL int32 `json:"buyorsell" xorm:"BUYORSELL"` // 买卖 - 0:买 1:卖
|
|
|
|
|
+ QTY int64 `json:"qty" xorm:"QTY"` // 转让数量
|
|
|
|
|
+ TRANSFERPRICE float64 `json:"transferprice" xorm:"TRANSFERPRICE"` // 转让价格
|
|
|
|
|
+ TRANSFERAPPLYSTATUS int32 `json:"transferapplystatus" xorm:"TRANSFERAPPLYSTATUS"` // 过户申请状态 - 1: 待审核 2:待确认 3:确认处理中 4:已确认 5:申请失败 6:系统撤销 7:审核拒绝- 枚举"transferapplystatus"
|
|
|
|
|
+ FREEZEDAYS int64 `json:"freezedays" xorm:"FREEZEDAYS"` // 冻结天数(T+N)
|
|
|
|
|
+ APPLYREMARK string `json:"applyremark" xorm:"APPLYREMARK"` // 申请备注
|
|
|
|
|
+ RETREMARK string `json:"retremark" xorm:"RETREMARK"` // 返回信息
|
|
|
|
|
+ RETCODE int32 `json:"retcode" xorm:"RETCODE"` // 错误代码
|
|
|
|
|
+ TRADEDATE string `json:"tradedate" xorm:"TRADEDATE"` // 交易日
|
|
|
|
|
+ APPLICANTID int64 `json:"applicantid" xorm:"APPLICANTID"` // 申请人ID
|
|
|
|
|
+ APPLYTIME string `json:"applytime" xorm:"APPLYTIME"` // 申请时间
|
|
|
|
|
+ TRANSFERTYPE int32 `json:"transfertype" xorm:"TRANSFERTYPE"` // 转让类型 - 1.协议转让
|
|
|
|
|
+ TRANSFERAMOUNT float64 `json:"transferamount" xorm:"TRANSFERAMOUNT"` // 转让总金额
|
|
|
|
|
+ GOODSCURPRICE float64 `json:"goodscurprice" xorm:"GOODSCURPRICE"` // 商品实时价格
|
|
|
|
|
+ GOODSCURAMOUNT float64 `json:"goodscuramount" xorm:"GOODSCURAMOUNT"` // 商品实时价金额
|
|
|
|
|
+ OPENFEEALGORITHM int32 `json:"openfeealgorithm" xorm:"OPENFEEALGORITHM"` // 建仓手续费收取方式 1:比率 2:固定
|
|
|
|
|
+ OPENMEMBERCHARGEVALUE float64 `json:"openmemberchargevalue" xorm:"OPENMEMBERCHARGEVALUE"` // 建仓会员手续费设置值
|
|
|
|
|
+ OPENEXCHAGECHARGEVALUE float64 `json:"openexchagechargevalue" xorm:"OPENEXCHAGECHARGEVALUE"` // 建仓交易所手续费设置值
|
|
|
|
|
+ CLOSEFEEALGORITHM int32 `json:"closefeealgorithm" xorm:"CLOSEFEEALGORITHM"` // 平仓手续费收取方式(转出方) 1:比率 2:固定
|
|
|
|
|
+ CLOSEMEMBERCHARGEVALUE float64 `json:"closememberchargevalue" xorm:"CLOSEMEMBERCHARGEVALUE"` // 平仓会员手续费设置值(转出方)
|
|
|
|
|
+ CLOSEEXCHAGECHARGEVALUE float64 `json:"closeexchagechargevalue" xorm:"CLOSEEXCHAGECHARGEVALUE"` // 平仓交易所手续费设置值(转出方)
|
|
|
|
|
+ OUTCHARGE float64 `json:"outcharge" xorm:"OUTCHARGE"` // 转出方手续费
|
|
|
|
|
+ INCHARGE float64 `json:"incharge" xorm:"INCHARGE"` // 转入方手续费
|
|
|
|
|
+ CONFIRMDATE time.Time `json:"confirmdate" xorm:"CONFIRMDATE"` // 确认时间
|
|
|
|
|
+ AUDITORID int64 `json:"auditorid" xorm:"AUDITORID"` // 审核人
|
|
|
|
|
+ AUDITTIME time.Time `json:"audittime" xorm:"AUDITTIME"` // 审核时间
|
|
|
|
|
+ AUDITREMARK string `json:"auditremark" xorm:"AUDITREMARK"` // 审核备注
|
|
|
|
|
+ CLIENTTICKET string `json:"clientticket" xorm:"CLIENTTICKET"` // 客户端流水号
|
|
|
|
|
+
|
|
|
|
|
+ GOODSDISPLAY string `json:"goodsdisplay" xorm:"GOODSDISPLAY"` // 商品名称
|
|
|
|
|
+ OUTUSERNAME string `json:"outusername" xorm:"OUTUSERNAME"` // 转出方
|
|
|
|
|
+ APPLYSTATUS string `json:"applystatus" xorm:"APPLYSTATUS"` // 状态
|
|
|
|
|
+
|
|
|
|
|
+ PageEx `xorm:"extends"` // 页码信息
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+func (r *InTradepositiontransfer) calc() {
|
|
|
|
|
+
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+func (r *InTradepositiontransfer) buildSql() string {
|
|
|
|
|
+ var sqlId utils.SQLVal = `
|
|
|
|
|
+ select
|
|
|
|
|
+ g.goodscode || '/' || g.goodsname as GOODSDISPLAY,
|
|
|
|
|
+ vlogin.LOGINIDS || '/' || ui.customername as OUTUSERNAME,
|
|
|
|
|
+ en.enumdicname as APPLYSTATUS,
|
|
|
|
|
+ t.applyid,
|
|
|
|
|
+ t.outaccountid,
|
|
|
|
|
+ t.inaccountid,
|
|
|
|
|
+ t.marketid,
|
|
|
|
|
+ t.transferprice,
|
|
|
|
|
+ t.transferapplystatus,
|
|
|
|
|
+ t.freezedays,
|
|
|
|
|
+ t.applyremark,
|
|
|
|
|
+ t.retremark,
|
|
|
|
|
+ t.tradedate,
|
|
|
|
|
+ t.applicantid,
|
|
|
|
|
+ to_char(t.applytime, 'yyyy-mm-dd hh24:mi:ss') APPLYTIME,
|
|
|
|
|
+ t.transfertype,
|
|
|
|
|
+ t.transferamount,
|
|
|
|
|
+ t.goodscuramount,
|
|
|
|
|
+ t.openfeealgorithm,
|
|
|
|
|
+ t.openmemberchargevalue,
|
|
|
|
|
+ t.openexchagechargevalue,
|
|
|
|
|
+ t.closefeealgorithm,
|
|
|
|
|
+ t.closememberchargevalue,
|
|
|
|
|
+ t.closeexchagechargevalue,
|
|
|
|
|
+ t.outcharge,
|
|
|
|
|
+ t.incharge,
|
|
|
|
|
+ t.confirmdate,
|
|
|
|
|
+ t.auditorid,
|
|
|
|
|
+ t.audittime,
|
|
|
|
|
+ t.auditremark
|
|
|
|
|
+ from Trade_PositionTransfer t
|
|
|
|
|
+ left join goods g
|
|
|
|
|
+ on t.goodsid = g.goodsid
|
|
|
|
|
+ left join userinfo ui
|
|
|
|
|
+ on t.outuserid = ui.userid
|
|
|
|
|
+ left join VIEW_USER_LOGINIDS vlogin
|
|
|
|
|
+ on t.outuserid = vlogin.USERID
|
|
|
|
|
+ left join enumdicitem en
|
|
|
|
|
+ on en.enumdiccode = 'transferapplystatus'
|
|
|
|
|
+ and en.enumitemname = t.transferapplystatus
|
|
|
|
|
+ where t.inuserid = %v
|
|
|
|
|
+ and t.transferapplystatus not in (1, 5)
|
|
|
|
|
+ order by t.applytime desc
|
|
|
|
|
+`
|
|
|
|
|
+
|
|
|
|
|
+ sqlId.FormatParam(r.INUSERID)
|
|
|
|
|
+
|
|
|
|
|
+ sqlId.Page(r.Page, r.PageSize)
|
|
|
|
|
+ return sqlId.String()
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+func (r *InTradepositiontransfer) GetDataByPage() (interface{}, error, int, int, int) {
|
|
|
|
|
+ sData := make([]InTradepositiontransfer, 0)
|
|
|
|
|
+ err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
|
|
|
|
|
+ total := 0
|
|
|
|
|
+ for i := range sData {
|
|
|
|
|
+ sData[i].calc()
|
|
|
|
|
+ total = sData[i].Total
|
|
|
|
|
+ }
|
|
|
|
|
+ return sData, err, r.Page, r.PageSize, total
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+// OutTradepositiontransfer 持仓过户申请表 - 16所有权(中融需求)
|
|
|
|
|
+type OutTradepositiontransfer struct {
|
|
|
|
|
+ APPLYID int64 `json:"applyid" xorm:"APPLYID"` // 申请ID(185+Unix秒时间戳(10位)+2位(MarketServiceID)+xxxx)
|
|
|
|
|
+ OUTUSERID int64 `json:"outuserid" xorm:"OUTUSERID" form:"userid" binding:"required"` // 转出方用户ID(申请方)
|
|
|
|
|
+ OUTLOGINID int64 `json:"outloginid" xorm:"OUTLOGINID"` // 转出方登录账号
|
|
|
|
|
+ OUTACCOUNTID int64 `json:"outaccountid" xorm:"OUTACCOUNTID"` // 转出方资金ID(申请方)
|
|
|
|
|
+ INUSERID int64 `json:"inuserid" xorm:"INUSERID"` // 转入方用户ID(确认方)
|
|
|
|
|
+ INACCOUNTID int64 `json:"inaccountid" xorm:"INACCOUNTID"` // 转入方资金ID(确认方)
|
|
|
|
|
+ INLOGINID int64 `json:"inloginid" xorm:"INLOGINID"` // 转入方登录账号
|
|
|
|
|
+ GOODSID int32 `json:"goodsid" xorm:"GOODSID"` // 商品ID
|
|
|
|
|
+ MARKETID int32 `json:"marketid" xorm:"MARKETID"` // 市场ID
|
|
|
|
|
+ BUYORSELL int32 `json:"buyorsell" xorm:"BUYORSELL"` // 买卖 - 0:买 1:卖
|
|
|
|
|
+ QTY int64 `json:"qty" xorm:"QTY"` // 转让数量
|
|
|
|
|
+ TRANSFERPRICE float64 `json:"transferprice" xorm:"TRANSFERPRICE"` // 转让价格
|
|
|
|
|
+ TRANSFERAPPLYSTATUS int32 `json:"transferapplystatus" xorm:"TRANSFERAPPLYSTATUS"` // 过户申请状态 - 1: 待审核 2:待确认 3:确认处理中 4:已确认 5:申请失败 6:系统撤销 7:审核拒绝- 枚举"transferapplystatus"
|
|
|
|
|
+ FREEZEDAYS int64 `json:"freezedays" xorm:"FREEZEDAYS"` // 冻结天数(T+N)
|
|
|
|
|
+ APPLYREMARK string `json:"applyremark" xorm:"APPLYREMARK"` // 申请备注
|
|
|
|
|
+ RETREMARK string `json:"retremark" xorm:"RETREMARK"` // 返回信息
|
|
|
|
|
+ RETCODE int32 `json:"retcode" xorm:"RETCODE"` // 错误代码
|
|
|
|
|
+ TRADEDATE string `json:"tradedate" xorm:"TRADEDATE"` // 交易日
|
|
|
|
|
+ APPLICANTID int64 `json:"applicantid" xorm:"APPLICANTID"` // 申请人ID
|
|
|
|
|
+ APPLYTIME string `json:"applytime" xorm:"APPLYTIME"` // 申请时间
|
|
|
|
|
+ TRANSFERTYPE int32 `json:"transfertype" xorm:"TRANSFERTYPE"` // 转让类型 - 1.协议转让
|
|
|
|
|
+ TRANSFERAMOUNT float64 `json:"transferamount" xorm:"TRANSFERAMOUNT"` // 转让总金额
|
|
|
|
|
+ GOODSCURPRICE float64 `json:"goodscurprice" xorm:"GOODSCURPRICE"` // 商品实时价格
|
|
|
|
|
+ GOODSCURAMOUNT float64 `json:"goodscuramount" xorm:"GOODSCURAMOUNT"` // 商品实时价金额
|
|
|
|
|
+ OPENFEEALGORITHM int32 `json:"openfeealgorithm" xorm:"OPENFEEALGORITHM"` // 建仓手续费收取方式 1:比率 2:固定
|
|
|
|
|
+ OPENMEMBERCHARGEVALUE float64 `json:"openmemberchargevalue" xorm:"OPENMEMBERCHARGEVALUE"` // 建仓会员手续费设置值
|
|
|
|
|
+ OPENEXCHAGECHARGEVALUE float64 `json:"openexchagechargevalue" xorm:"OPENEXCHAGECHARGEVALUE"` // 建仓交易所手续费设置值
|
|
|
|
|
+ CLOSEFEEALGORITHM int32 `json:"closefeealgorithm" xorm:"CLOSEFEEALGORITHM"` // 平仓手续费收取方式(转出方) 1:比率 2:固定
|
|
|
|
|
+ CLOSEMEMBERCHARGEVALUE float64 `json:"closememberchargevalue" xorm:"CLOSEMEMBERCHARGEVALUE"` // 平仓会员手续费设置值(转出方)
|
|
|
|
|
+ CLOSEEXCHAGECHARGEVALUE float64 `json:"closeexchagechargevalue" xorm:"CLOSEEXCHAGECHARGEVALUE"` // 平仓交易所手续费设置值(转出方)
|
|
|
|
|
+ OUTCHARGE float64 `json:"outcharge" xorm:"OUTCHARGE"` // 转出方手续费
|
|
|
|
|
+ INCHARGE float64 `json:"incharge" xorm:"INCHARGE"` // 转入方手续费
|
|
|
|
|
+ CONFIRMDATE time.Time `json:"confirmdate" xorm:"CONFIRMDATE"` // 确认时间
|
|
|
|
|
+ AUDITORID int64 `json:"auditorid" xorm:"AUDITORID"` // 审核人
|
|
|
|
|
+ AUDITTIME time.Time `json:"audittime" xorm:"AUDITTIME"` // 审核时间
|
|
|
|
|
+ AUDITREMARK string `json:"auditremark" xorm:"AUDITREMARK"` // 审核备注
|
|
|
|
|
+ CLIENTTICKET string `json:"clientticket" xorm:"CLIENTTICKET"` // 客户端流水号
|
|
|
|
|
+
|
|
|
|
|
+ GOODSDISPLAY string `json:"goodsdisplay" xorm:"GOODSDISPLAY"` // 商品名称
|
|
|
|
|
+ INUSERNAME string `json:"inusername" xorm:"INUSERNAME"` // 转入方
|
|
|
|
|
+ APPLYSTATUS string `json:"applystatus" xorm:"APPLYSTATUS"` // 状态
|
|
|
|
|
+
|
|
|
|
|
+ PageEx `xorm:"extends"` // 页码信息
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+func (r *OutTradepositiontransfer) calc() {
|
|
|
|
|
+
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+func (r *OutTradepositiontransfer) buildSql() string {
|
|
|
|
|
+ var sqlId utils.SQLVal = `
|
|
|
|
|
+ select
|
|
|
|
|
+ g.goodscode || '/' || g.goodsname as GOODSDISPLAY,
|
|
|
|
|
+ vlogin.LOGINIDS || '/' || ui.customername as INUSERNAME,
|
|
|
|
|
+ en.enumdicname as APPLYSTATUS,
|
|
|
|
|
+ t.applyid,
|
|
|
|
|
+ t.outuserid,
|
|
|
|
|
+ t.outloginid,
|
|
|
|
|
+ t.outaccountid,
|
|
|
|
|
+ t.inuserid,
|
|
|
|
|
+ t.inaccountid,
|
|
|
|
|
+ t.inloginid,
|
|
|
|
|
+ t.goodsid,
|
|
|
|
|
+ t.marketid,
|
|
|
|
|
+ t.buyorsell,
|
|
|
|
|
+ t.qty,
|
|
|
|
|
+ t.transferprice,
|
|
|
|
|
+ t.transferapplystatus,
|
|
|
|
|
+ t.freezedays,
|
|
|
|
|
+ t.applyremark,
|
|
|
|
|
+ t.retremark,
|
|
|
|
|
+ t.retcode,
|
|
|
|
|
+ t.tradedate,
|
|
|
|
|
+ t.applicantid,
|
|
|
|
|
+ to_char(t.applytime, 'yyyy-mm-dd hh24:mi:ss') APPLYTIME,
|
|
|
|
|
+ t.transfertype,
|
|
|
|
|
+ t.transferamount,
|
|
|
|
|
+ t.goodscurprice,
|
|
|
|
|
+ t.goodscuramount,
|
|
|
|
|
+ t.openfeealgorithm,
|
|
|
|
|
+ t.openmemberchargevalue,
|
|
|
|
|
+ t.openexchagechargevalue,
|
|
|
|
|
+ t.closefeealgorithm,
|
|
|
|
|
+ t.closememberchargevalue,
|
|
|
|
|
+ t.closeexchagechargevalue,
|
|
|
|
|
+ t.outcharge,
|
|
|
|
|
+ t.incharge,
|
|
|
|
|
+ t.confirmdate,
|
|
|
|
|
+ t.auditorid,
|
|
|
|
|
+ t.audittime,
|
|
|
|
|
+ t.auditremark,
|
|
|
|
|
+ t.clientticket
|
|
|
|
|
+ from Trade_PositionTransfer t
|
|
|
|
|
+ left join goods g
|
|
|
|
|
+ on t.goodsid = g.goodsid
|
|
|
|
|
+ left join userinfo ui
|
|
|
|
|
+ on t.inuserid = ui.userid
|
|
|
|
|
+ left join VIEW_USER_LOGINIDS vlogin
|
|
|
|
|
+ on t.inuserid = vlogin.USERID
|
|
|
|
|
+ left join enumdicitem en
|
|
|
|
|
+ on en.enumdiccode = 'transferapplystatus'
|
|
|
|
|
+ and en.enumitemname = t.transferapplystatus
|
|
|
|
|
+ where t.outuserid = %v
|
|
|
|
|
+ order by t.applytime desc
|
|
|
|
|
+`
|
|
|
|
|
+
|
|
|
|
|
+ sqlId.FormatParam(r.OUTUSERID)
|
|
|
|
|
+
|
|
|
|
|
+ sqlId.Page(r.Page, r.PageSize)
|
|
|
|
|
+ return sqlId.String()
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+func (r *OutTradepositiontransfer) GetDataByPage() (interface{}, error, int, int, int) {
|
|
|
|
|
+ sData := make([]OutTradepositiontransfer, 0)
|
|
|
|
|
+ err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
|
|
|
|
|
+ total := 0
|
|
|
|
|
+ for i := range sData {
|
|
|
|
|
+ sData[i].calc()
|
|
|
|
|
+ total = sData[i].Total
|
|
|
|
|
+ }
|
|
|
|
|
+ return sData, err, r.Page, r.PageSize, total
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+func GetUserInfoByUserIDorMobile(param string) (userinfo *Userinfo, err error) {
|
|
|
|
|
+ // 先尝试加密手机号码,手机号码需要AES加密
|
|
|
|
|
+ mobile := ""
|
|
|
|
|
+ key, _ := hex.DecodeString(utils.AESSecretKey)
|
|
|
|
|
+ if mobileEncrypted, err := utils.AESEncrypt([]byte(param), key); err == nil {
|
|
|
|
|
+ mobile = hex.EncodeToString(mobileEncrypted)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ userinfos := make([]Userinfo, 0)
|
|
|
|
|
+ sql := fmt.Sprintf(`
|
|
|
|
|
+ SELECT
|
|
|
|
|
+ t.*
|
|
|
|
|
+ FROM userinfo t
|
|
|
|
|
+ INNER JOIN loginaccount l
|
|
|
|
|
+ ON l.userid = t.userid
|
|
|
|
|
+ WHERE l.loginid = %v
|
|
|
|
|
+ `, param)
|
|
|
|
|
+ if mobile != "" {
|
|
|
|
|
+ sql = fmt.Sprintf("%v OR t.mobile = '%v'", sql, mobile)
|
|
|
|
|
+ }
|
|
|
|
|
+ err = db.GetEngine().SQL(sql).Find(&userinfos)
|
|
|
|
|
+ if len(userinfos) > 0 {
|
|
|
|
|
+ userinfo = &userinfos[0]
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return
|
|
|
|
|
+}
|