|
|
@@ -6,6 +6,7 @@ import (
|
|
|
"mtp2_if/mtpcache"
|
|
|
"mtp2_if/pb"
|
|
|
"mtp2_if/rediscli"
|
|
|
+ "mtp2_if/utils"
|
|
|
"sort"
|
|
|
"time"
|
|
|
|
|
|
@@ -211,3 +212,226 @@ func (r *RedisTradeHolderDetailEx) ParseFromProto(p *pb.RedisTradeHolderDetailEx
|
|
|
// 单位
|
|
|
r.GoodsUnit = mtpcache.GetEnumDicitemName(int32(r.GoodsUnitID))
|
|
|
}
|
|
|
+
|
|
|
+type MyTradegoodsdeliveryoffline struct {
|
|
|
+ DELIVERYORDERID int64 `json:"deliveryorderid" xorm:"DELIVERYORDERID"` // 交收单号(905+Unix秒时间戳(10位)+2位(MarketServiceID)+xxxx)
|
|
|
+ USERID int64 `json:"userid" xorm:"USERID" form:"userid" binding:"required"` // 申请用户ID
|
|
|
+ ACCOUNTID int64 `json:"accountid" xorm:"ACCOUNTID"` // 账户ID
|
|
|
+ GOODSID int64 `json:"goodsid" xorm:"GOODSID"` // 商品ID
|
|
|
+ MARKETID int32 `json:"marketid" xorm:"MARKETID"` // 市场ID
|
|
|
+ BUYORSELL int32 `json:"buyorsell" xorm:"BUYORSELL"` // 交收方向 - 0:买 1:卖
|
|
|
+ DELIVERYLOT int64 `json:"deliverylot" xorm:"DELIVERYLOT"` // 交收手数
|
|
|
+ DELIVERYQTY int64 `json:"deliveryqty" xorm:"DELIVERYQTY"` // 交收数量 (手数*合约乘数)
|
|
|
+ DELIVERYINFO string `json:"deliveryinfo" xorm:"DELIVERYINFO"` // 交收信息
|
|
|
+ MATCHUSERID int64 `json:"matchuserid" xorm:"MATCHUSERID"` // 对手方UserID
|
|
|
+ MATCHACCOUNTID int64 `json:"matchaccountid" xorm:"MATCHACCOUNTID"` // 对手方AccountID
|
|
|
+ REQTIME time.Time `json:"reqtime" xorm:"REQTIME"` // 申请时间
|
|
|
+ REQTRADEDATE string `json:"reqtradedate" xorm:"REQTRADEDATE"` // 申请交易日
|
|
|
+ ORDERSTATUS int32 `json:"orderstatus" xorm:"ORDERSTATUS"` // 线下交收单状态 - 1:待处理 2:交收中 3:已完成 4:申请失败 枚举deliveryOrderStatus
|
|
|
+ DELIVERYPRICE float64 `json:"deliveryprice" xorm:"DELIVERYPRICE"` // 交收价格
|
|
|
+ DELIVERYAMOUNT float64 `json:"deliveryamount" xorm:"DELIVERYAMOUNT"` // 交收货款
|
|
|
+ CLOSETIME time.Time `json:"closetime" xorm:"CLOSETIME"` // 完成时间
|
|
|
+ CLOSETRADEDATE string `json:"closetradedate" xorm:"CLOSETRADEDATE"` // 完成交易日
|
|
|
+ DELIVERYCHARGE float64 `json:"deliverycharge" xorm:"DELIVERYCHARGE"` // 交割手续费
|
|
|
+ FEEALGORITHM int32 `json:"feealgorithm" xorm:"FEEALGORITHM"` // 手续费收取方式 1:比率 2:固定
|
|
|
+ MEMBERCHARGEVALUE float64 `json:"memberchargevalue" xorm:"MEMBERCHARGEVALUE"` // 会员手续费设置值
|
|
|
+ EXCHCHARGEVALUE float64 `json:"exchchargevalue" xorm:"EXCHCHARGEVALUE"` // 交易所手续费设置值
|
|
|
+ HANDLESTATUS int32 `json:"handlestatus" xorm:"HANDLESTATUS"` // 处理状态
|
|
|
+ DELIVERYPREMIUM float64 `json:"deliverypremium" xorm:"DELIVERYPREMIUM"` // 交收升贴水(每单位)
|
|
|
+ DELIVERYTOTALAMOUNT float64 `json:"deliverytotalamount" xorm:"DELIVERYTOTALAMOUNT"` // 交收总货款 = 交收货款 + 交收升贴水 * 交收数量
|
|
|
+ DELIVERYSTATUS int32 `json:"deliverystatus" xorm:"DELIVERYSTATUS" form:"deliverystatus"` // 交收单状态2(52模式使用) - 1:待审核 2:待确认 3:待付款 4:付款中 5:已完成付款 6:处理中 20:交收完成 21:审核拒绝 22:确认过期 23:付款过期 24:财务撤销 -- 枚举deliveryStatus
|
|
|
+ TOCONFIRMTIME time.Time `json:"toconfirmtime" xorm:"TOCONFIRMTIME"` // 确认截止时间(买交收)
|
|
|
+ TOPAYTIME time.Time `json:"topaytime" xorm:"TOPAYTIME"` // 付款截止时间(买交收)
|
|
|
+ PAYEDAMOUNT float64 `json:"payedamount" xorm:"PAYEDAMOUNT"` // 已付货款
|
|
|
+ FREEZEAMOUNT float64 `json:"freezeamount" xorm:"FREEZEAMOUNT"` // 冻结货款
|
|
|
+
|
|
|
+ PageEx `xorm:"extends"` // 页码信息
|
|
|
+}
|
|
|
+
|
|
|
+func (r *MyTradegoodsdeliveryoffline) calc() {
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+func (r *MyTradegoodsdeliveryoffline) buildSql() string {
|
|
|
+ var sqlId utils.SQLVal = `
|
|
|
+ SELECT
|
|
|
+ t.deliveryorderid,
|
|
|
+ t.userid,
|
|
|
+ t.accountid,
|
|
|
+ t.goodsid,
|
|
|
+ t.marketid,
|
|
|
+ t.buyorsell,
|
|
|
+ t.deliverylot,
|
|
|
+ t.deliveryqty,
|
|
|
+ t.deliveryinfo,
|
|
|
+ t.matchuserid,
|
|
|
+ t.matchaccountid,
|
|
|
+ t.reqtime,
|
|
|
+ t.reqtradedate,
|
|
|
+ t.orderstatus,
|
|
|
+ t.deliveryprice,
|
|
|
+ t.deliveryamount,
|
|
|
+ t.closetime,
|
|
|
+ t.closetradedate,
|
|
|
+ t.deliverycharge,
|
|
|
+ t.feealgorithm,
|
|
|
+ t.memberchargevalue,
|
|
|
+ t.exchchargevalue,
|
|
|
+ t.handlestatus,
|
|
|
+ t.deliverypremium,
|
|
|
+ t.deliverytotalamount,
|
|
|
+ t.deliverystatus,
|
|
|
+ t.toconfirmtime,
|
|
|
+ t.topaytime,
|
|
|
+ t.payedamount,
|
|
|
+ t.freezeamount
|
|
|
+ FROM TRADE_GOODSDELIVERYOFFLINE t
|
|
|
+ WHERE t.userid = %v
|
|
|
+ `
|
|
|
+ sqlId.FormatParam(r.USERID)
|
|
|
+ sqlId.AndEx("t.DELIVERYSTATUS", r.DELIVERYSTATUS, r.DELIVERYSTATUS > 0)
|
|
|
+
|
|
|
+ sqlId.Page(r.Page, r.PageSize)
|
|
|
+ return sqlId.String()
|
|
|
+}
|
|
|
+
|
|
|
+func (r *MyTradegoodsdeliveryoffline) GetDataByPage() (interface{}, error, int, int, int) {
|
|
|
+ sData := make([]MyTradegoodsdeliveryoffline, 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
|
|
|
+}
|
|
|
+
|
|
|
+// Deliveryofflinedetail 交易合约线下交收明细表
|
|
|
+type MyDeliveryofflinedetail struct {
|
|
|
+ DELIVERYDETAILID int64 `json:"deliverydetailid" xorm:"DELIVERYDETAILID"` // 明细单号(906+Unix秒时间戳(10位)+2位(MarketServiceID)+xxxx)
|
|
|
+ DELIVERYORDERID int64 `json:"deliveryorderid" xorm:"DELIVERYORDERID" form:"deliveryorderid" binding:"required"` // 交收单号(905+Unix秒时间戳(10位)+2位(MarketServiceID)+xxxx)
|
|
|
+ TRADEID int64 `json:"tradeid" xorm:"TRADEID"` // 成交单号(101+Unix秒时间戳(10位)+2位(MarketServiceID)+xxxx)
|
|
|
+ BUYORSELL int32 `json:"buyorsell" xorm:"BUYORSELL"` // 方向 - 0:买 1:卖
|
|
|
+ USERID int64 `json:"userid" xorm:"USERID" form:"userid" binding:"required"` // 用户ID
|
|
|
+ ACCOUNTID int64 `json:"accountid" xorm:"ACCOUNTID"` // 账号ID
|
|
|
+ HOLDLOT int64 `json:"holdlot" xorm:"HOLDLOT"` // 持仓手数
|
|
|
+ HOLDQTY int64 `json:"holdqty" xorm:"HOLDQTY"` // 持仓数量(手数*合约乘数)
|
|
|
+ DELIVERYLOT int64 `json:"deliverylot" xorm:"DELIVERYLOT"` // 申请交收手数
|
|
|
+ DELIVERYQTY int64 `json:"deliveryqty" xorm:"DELIVERYQTY"` // 申请交收数量 (手数*合约乘数)
|
|
|
+ DELIVERYPRICE float64 `json:"deliveryprice" xorm:"DELIVERYPRICE"` // 交收价格
|
|
|
+ DELIVERYAMOUNT float64 `json:"deliveryamount" xorm:"DELIVERYAMOUNT"` // 交收货款
|
|
|
+ CREATETIME time.Time `json:"createtime" xorm:"CREATETIME"` // 创建时间
|
|
|
+
|
|
|
+ PageEx `xorm:"extends"` // 页码信息
|
|
|
+}
|
|
|
+
|
|
|
+func (r *MyDeliveryofflinedetail) calc() {
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+func (r *MyDeliveryofflinedetail) buildSql() string {
|
|
|
+ var sqlId utils.SQLVal = `
|
|
|
+ SELECT
|
|
|
+ t.deliverydetailid,
|
|
|
+ t.deliveryorderid,
|
|
|
+ t.tradeid,
|
|
|
+ t.buyorsell,
|
|
|
+ t.userid,
|
|
|
+ t.accountid,
|
|
|
+ t.holdlot,
|
|
|
+ t.holdqty,
|
|
|
+ t.deliverylot,
|
|
|
+ t.deliveryqty,
|
|
|
+ t.deliveryprice,
|
|
|
+ t.deliveryamount,
|
|
|
+ t.createtime
|
|
|
+ FROM DELIVERYOFFLINEDETAIL t
|
|
|
+ WHERE t.userid = %v AND t.deliveryorderid = %v
|
|
|
+ `
|
|
|
+ sqlId.FormatParam(r.USERID, r.DELIVERYORDERID)
|
|
|
+
|
|
|
+ sqlId.Page(r.Page, r.PageSize)
|
|
|
+ return sqlId.String()
|
|
|
+}
|
|
|
+
|
|
|
+func (r *MyDeliveryofflinedetail) GetDataByPage() (interface{}, error, int, int, int) {
|
|
|
+ sData := make([]MyDeliveryofflinedetail, 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
|
|
|
+}
|
|
|
+
|
|
|
+// Deliveryofflineoperatelog 交易合约线下交收操作流水表
|
|
|
+type MyDeliveryofflineoperatelog struct {
|
|
|
+ OPERATELOGID int64 `json:"operatelogid" xorm:"OPERATELOGID"` // 明细单号(907+Unix秒时间戳(10位)+2位(MarketServiceID)+xxxx)
|
|
|
+ DELIVERYORDERID int64 `json:"deliveryorderid" xorm:"DELIVERYORDERID" form:"deliveryorderid" binding:"required"` // 交收单ID
|
|
|
+ OPERATETYPE int32 `json:"operatetype" xorm:"OPERATETYPE" form:"operatetype"` // 操作类型 - 1:交收流程 2:付款流水
|
|
|
+ CURDELIVERYSTATUS int32 `json:"curdeliverystatus" xorm:"CURDELIVERYSTATUS"` // 当前交收状态(OperateType=1时) - 枚举deliveryStatus
|
|
|
+ AFTDELIVERYSTATUS int32 `json:"aftdeliverystatus" xorm:"AFTDELIVERYSTATUS"` // 操作后交收状态(OperateType=1时) - 枚举deliveryStatus
|
|
|
+ OPERATORSRC int32 `json:"operatorsrc" xorm:"OPERATORSRC"` // 操作人来源 - 1:管理端 2:终端 3:系统
|
|
|
+ OPERATORID int64 `json:"operatorid" xorm:"OPERATORID"` // 操作人ID - systemmanager的autoid 或 loginaccount的loginid
|
|
|
+ OPERATORACCOUNT string `json:"operatoraccount" xorm:"OPERATORACCOUNT"` // 操作人账号 - systemmanager的logincode 或 loginaccount的logincode,无则用loginid
|
|
|
+ OPERATORNAME string `json:"operatorname" xorm:"OPERATORNAME"` // 操作人名称 - systemmanager的username 或 loginaccount的logincode,无则用loginid
|
|
|
+ REMARK string `json:"remark" xorm:"REMARK"` // 操作备注
|
|
|
+ OPERATETIME time.Time `json:"operatetime" xorm:"OPERATETIME"` // 操作时间
|
|
|
+ FILENAME string `json:"filename" xorm:"FILENAME"` // 文件名称
|
|
|
+ FILEADDRESS string `json:"fileaddress" xorm:"FILEADDRESS"` // 文件地址
|
|
|
+ DELIVERYPAYMODE int32 `json:"deliverypaymode" xorm:"DELIVERYPAYMODE" form:"deliverypaymode"` // 付款方式 - 1:线上支付2:线下支付 - 枚举deliveryPayMode
|
|
|
+ PAYAMOUNT float64 `json:"payamount" xorm:"PAYAMOUNT"` // 付款金额
|
|
|
+ CONFIRMSTATUS int32 `json:"confirmstatus" xorm:"CONFIRMSTATUS" form:"confirmstatus"` // 确认状态 - 1:未确认 2:已确认 - 枚举confirmStatus
|
|
|
+ CONFIRMID int64 `json:"confirmid" xorm:"CONFIRMID"` // 确认人
|
|
|
+ CONFIRMTIME time.Time `json:"confirmtime" xorm:"CONFIRMTIME"` // 确认时间
|
|
|
+
|
|
|
+ PageEx `xorm:"extends"` // 页码信息
|
|
|
+}
|
|
|
+
|
|
|
+func (r *MyDeliveryofflineoperatelog) calc() {
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+func (r *MyDeliveryofflineoperatelog) buildSql() string {
|
|
|
+ var sqlId utils.SQLVal = `
|
|
|
+ SELECT
|
|
|
+ t.operatelogid,
|
|
|
+ t.deliveryorderid,
|
|
|
+ t.operatetype,
|
|
|
+ t.curdeliverystatus,
|
|
|
+ t.aftdeliverystatus,
|
|
|
+ t.operatorsrc,
|
|
|
+ t.operatorid,
|
|
|
+ t.operatoraccount,
|
|
|
+ t.operatorname,
|
|
|
+ t.remark,
|
|
|
+ t.operatetime,
|
|
|
+ t.filename,
|
|
|
+ t.fileaddress,
|
|
|
+ t.deliverypaymode,
|
|
|
+ t.payamount,
|
|
|
+ t.confirmstatus,
|
|
|
+ t.confirmid,
|
|
|
+ t.confirmtime
|
|
|
+ FROM DELIVERYOFFLINEOPERATELOG t
|
|
|
+ WHERE t.deliveryorderid = %v
|
|
|
+ `
|
|
|
+ sqlId.FormatParam(r.DELIVERYORDERID)
|
|
|
+ sqlId.AndEx("t.operatetype", r.OPERATETYPE, r.OPERATETYPE > 0)
|
|
|
+ sqlId.OrderByDesc("t.operatetime")
|
|
|
+
|
|
|
+ sqlId.Page(r.Page, r.PageSize)
|
|
|
+ return sqlId.String()
|
|
|
+}
|
|
|
+
|
|
|
+func (r *MyDeliveryofflineoperatelog) GetDataByPage() (interface{}, error, int, int, int) {
|
|
|
+ sData := make([]MyDeliveryofflineoperatelog, 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
|
|
|
+}
|