|
|
@@ -52,23 +52,24 @@ func (Hsbysupplierinfo) TableName() string {
|
|
|
|
|
|
// Tradepayorder 交易待付款表
|
|
|
type Tradepayorder struct {
|
|
|
- Tradeid string `json:"tradeid" xorm:"'TRADEID'" binding:"required"` // 成交单号(101+Unix秒时间戳(10位)+2位(MarketServiceID)+xxxx)
|
|
|
+ Tradeid int64 `json:"tradeid" xorm:"'TRADEID'" binding:"required"` // 成交单号(101+Unix秒时间戳(10位)+2位(MarketServiceID)+xxxx)
|
|
|
Tradedate string `json:"tradedate" xorm:"'TRADEDATE'"` // 交易日(yyyyMMdd)
|
|
|
Marketid int32 `json:"marketid" xorm:"'MARKETID'"` // 市场ID
|
|
|
Goodsid int32 `json:"goodsid" xorm:"'GOODSID'"` // 商品ID
|
|
|
- Buyorderid string `json:"buyorderid" xorm:"'BUYORDERID'"` // 买方委托单号
|
|
|
+ Buyorderid int64 `json:"buyorderid" xorm:"'BUYORDERID'"` // 买方委托单号
|
|
|
Buyaccountid int64 `json:"buyaccountid" xorm:"'BUYACCOUNTID'"` // 买方账号ID[报价币种]
|
|
|
- Sellorderid string `json:"sellorderid" xorm:"'SELLORDERID'"` // 卖方委托单号
|
|
|
+ Sellorderid int64 `json:"sellorderid" xorm:"'SELLORDERID'"` // 卖方委托单号
|
|
|
Sellaccountid int64 `json:"sellaccountid" xorm:"'SELLACCOUNTID'"` // 卖方账号ID[报价币种]
|
|
|
Tradeamount float64 `json:"tradeamount" xorm:"'TRADEAMOUNT'"` // 成交金额
|
|
|
Tradecharge float64 `json:"tradecharge" xorm:"'TRADECHARGE'"` // 成交手续费(买方)
|
|
|
- Payflag int32 `json:"payflag" xorm:"'PAYFLAG'"` // 付款标识 - 1:未支付 2:已支付 3:已过期 4:已撤销 5:结算过期
|
|
|
+ Payflag int32 `json:"payflag" xorm:"'PAYFLAG'"` // 付款标识 - 1:未支付 2:已支付 3:已过期 4:已撤销 5:结算过期 6:预售终止
|
|
|
Createtime time.Time `json:"createtime" xorm:"'CREATETIME'"` // 创建时间
|
|
|
Paytime time.Time `json:"paytime" xorm:"'PAYTIME'"` // 付款时间
|
|
|
Paylimitedtime time.Time `json:"paylimitedtime" xorm:"'PAYLIMITEDTIME'"` // 支付期限
|
|
|
Offamount float64 `json:"offamount" xorm:"'OFFAMOUNT'"` // 优惠金额
|
|
|
Tradeprice float64 `json:"tradeprice" xorm:"'TRADEPRICE'"` // 成交价格
|
|
|
Tradeqty int64 `json:"tradeqty" xorm:"'TRADEQTY'"` // 成交数量
|
|
|
+ Payamount float64 `json:"payamount" xorm:"'PAYAMOUNT'"` // 支付金额 = TradeAmount + TradeCharge - OffAmount
|
|
|
}
|
|
|
|
|
|
// TableName is TRADE_PAYORDER
|
|
|
@@ -1121,11 +1122,24 @@ func GetHsbyBuyMyTradeDetails(accountIDs string) ([]HsbyBuyMyTradeDetail, error)
|
|
|
|
|
|
// HsbyBuyMyPayOrder "我的订单 - 待付款"单据信息(一二级市场成交单和待付款信息)
|
|
|
type HsbyBuyMyPayOrder struct {
|
|
|
- Orderid string `json:"orderid" xorm:"'ORDERID'" binding:"required"` // 单号(成交单号)
|
|
|
- Marketid int32 `json:"marketid" xorm:"'MARKETID'" binding:"required"` // 市场ID
|
|
|
- Goodsid int32 `json:"goodsid" xorm:"'GOODSID'" binding:"required"` // 商品ID
|
|
|
- Accountid int64 `json:"accountid" xorm:"'ACCOUNTID'" binding:"required"` // 账户ID[报价币种]
|
|
|
- Buyorsell int32 `json:"buyorsell" xorm:"'BUYORSELL'" binding:"required"` // 买卖 - 0:买 1:卖
|
|
|
+ Tradeid string `json:"tradeid" xorm:"'TRADEIDSTR'" binding:"required"` // 成交单号(101+Unix秒时间戳(10位)+2位(MarketServiceID)+xxxx)
|
|
|
+ Tradedate string `json:"tradedate" xorm:"'TRADEDATE'"` // 交易日(yyyyMMdd)
|
|
|
+ Marketid int32 `json:"marketid" xorm:"'MARKETID'"` // 市场ID
|
|
|
+ Goodsid int32 `json:"goodsid" xorm:"'GOODSID'"` // 商品ID
|
|
|
+ Buyorderid string `json:"buyorderid" xorm:"'BUYORDERIDSTR'"` // 买方委托单号
|
|
|
+ Buyaccountid int64 `json:"buyaccountid" xorm:"'BUYACCOUNTID'"` // 买方账号ID[报价币种]
|
|
|
+ Sellorderid string `json:"sellorderid" xorm:"'SELLORDERIDSTR'"` // 卖方委托单号
|
|
|
+ Sellaccountid int64 `json:"sellaccountid" xorm:"'SELLACCOUNTID'"` // 卖方账号ID[报价币种]
|
|
|
+ Tradeamount float64 `json:"tradeamount" xorm:"'TRADEAMOUNT'"` // 成交金额
|
|
|
+ Tradecharge float64 `json:"tradecharge" xorm:"'TRADECHARGE'"` // 成交手续费(买方)
|
|
|
+ Payflag int32 `json:"payflag" xorm:"'PAYFLAG'"` // 付款标识 - 1:未支付 2:已支付 3:已过期 4:已撤销 5:结算过期 6:预售终止
|
|
|
+ Createtime time.Time `json:"createtime" xorm:"'CREATETIME'"` // 创建时间
|
|
|
+ Paytime time.Time `json:"paytime" xorm:"'PAYTIME'"` // 付款时间
|
|
|
+ Paylimitedtime time.Time `json:"paylimitedtime" xorm:"'PAYLIMITEDTIME'"` // 支付期限
|
|
|
+ Offamount float64 `json:"offamount" xorm:"'OFFAMOUNT'"` // 优惠金额
|
|
|
+ Tradeprice float64 `json:"tradeprice" xorm:"'TRADEPRICE'"` // 成交价格
|
|
|
+ Tradeqty int64 `json:"tradeqty" xorm:"'TRADEQTY'"` // 成交数量
|
|
|
+ Payamount float64 `json:"payamount" xorm:"'PAYAMOUNT'"` // 支付金额 = TradeAmount + TradeCharge - OffAmount
|
|
|
|
|
|
Goodscode string `json:"goodscode" xorm:"'GOODSCODE'" binding:"required"` // 商品代码(内部)
|
|
|
Goodsname string `json:"goodsname" xorm:"'GOODSNAME'" binding:"required"` // 商品名称
|
|
|
@@ -1141,21 +1155,10 @@ type HsbyBuyMyPayOrder struct {
|
|
|
|
|
|
Vendorname1 string `json:"vendorname1" xorm:"'VENDORNAME1'"` // 预售商品供应商名称
|
|
|
Vendorname2 string `json:"vendorname2" xorm:"'VENDORNAME2'"` // 挂牌商品供应商名称
|
|
|
-
|
|
|
- Tradeamount float64 `json:"tradeamount" xorm:"'TRADEAMOUNT'"` // 成交金额
|
|
|
- Tradecharge float64 `json:"tradecharge" xorm:"'TRADECHARGE'"` // 成交手续费(买方)
|
|
|
- Payflag int32 `json:"payflag" xorm:"'PAYFLAG'"` // 付款标识 - 1:未支付 2:已支付 3:已过期 4:已撤销 5:结算过期
|
|
|
- Createtime time.Time `json:"createtime" xorm:"'CREATETIME'"` // 创建时间
|
|
|
- Paylimitedtime time.Time `json:"paylimitedtime" xorm:"'PAYLIMITEDTIME'"` // 支付期限
|
|
|
- Offamount float64 `json:"offamount" xorm:"'OFFAMOUNT'"` // 优惠金额
|
|
|
- Tradeprice float64 `json:"tradeprice" xorm:"'TRADEPRICE'"` // 成交价格
|
|
|
- Tradeqty int64 `json:"tradeqty" xorm:"'TRADEQTY'"` // 成交数量
|
|
|
-
|
|
|
- Accountname string `json:"accountname" xorm:"'ACCOUNTNAME'"` // 购买方名称
|
|
|
}
|
|
|
|
|
|
// GetHsbyBuyMyPayOrders 获取待付款信息
|
|
|
-func GetHsbyBuyMyPayOrders(accountIDs, payFlag string, sellOrderID, sellAccountID int) ([]HsbyBuyMyPayOrder, error) {
|
|
|
+func GetHsbyBuyMyPayOrders(accountIDs string) ([]HsbyBuyMyPayOrder, error) {
|
|
|
// 获取市场信息
|
|
|
markets, err := GetMarkets()
|
|
|
if err != nil {
|
|
|
@@ -1176,38 +1179,23 @@ func GetHsbyBuyMyPayOrders(accountIDs, payFlag string, sellOrderID, sellAccountI
|
|
|
}
|
|
|
|
|
|
orders := make([]HsbyBuyMyPayOrder, 0)
|
|
|
- session := engine.Table("TRADE_TRADEDETAIL").
|
|
|
- Select(`to_char(TRADE_TRADEDETAIL.TRADEID) ORDERID,
|
|
|
- TRADE_TRADEDETAIL.MARKETID, TRADE_TRADEDETAIL.GOODSID, TRADE_TRADEDETAIL.ACCOUNTID, TRADE_TRADEDETAIL.BUYORSELL,
|
|
|
+ session := engine.Table("TRADE_PAYORDER TP").
|
|
|
+ Select(`to_char(TP.TRADEID) TRADEIDSTR, to_char(TP.BUYORDERID) BUYORDERIDSTR, to_char(TP.SELLORDERID) SELLORDERIDSTR, TP.*,
|
|
|
GOODS.GOODSCODE, GOODS.GOODSNAME, GOODS.DECIMALPLACE, GOODS.AGREEUNIT,
|
|
|
HG1.PICURLS PICURLS1, HG2.PICURLS PICURLS2,
|
|
|
MARKET.TRADEMODE,
|
|
|
ENUMDICITEM.PARAM2 CURRENCYSIGN,
|
|
|
- HS1.VENDORNAME VENDORNAME1, HS2.VENDORNAME VENDORNAME2,
|
|
|
- TP.TRADEAMOUNT, TP.TRADECHARGE, TP.PAYFLAG, TP.CREATETIME, TP.PAYLIMITEDTIME, TP.OFFAMOUNT, TP.TRADEPRICE, TP.TRADEQTY,
|
|
|
- U.ACCOUNTNAME`).
|
|
|
- Join("LEFT", "GOODS", "GOODS.GOODSID = TRADE_TRADEDETAIL.GOODSID").
|
|
|
- Join("LEFT", "CPTRADE_PRESALEGOODSEX", "CPTRADE_PRESALEGOODSEX.GOODSID = TRADE_TRADEDETAIL.GOODSID").
|
|
|
- Join("LEFT", "HSBY_GOODSEX HG1", "HG1.GOODSID = CPTRADE_PRESALEGOODSEX.RELATEDGOODSID").
|
|
|
+ HS1.VENDORNAME VENDORNAME1, HS2.VENDORNAME VENDORNAME2`).
|
|
|
+ Join("LEFT", "GOODS", "GOODS.GOODSID = TP.GOODSID").
|
|
|
+ Join("LEFT", "CPTRADE_PRESALEGOODSEX CP", "CP.GOODSID = TP.GOODSID").
|
|
|
+ Join("LEFT", "HSBY_GOODSEX HG1", "HG1.GOODSID = CP.RELATEDGOODSID").
|
|
|
Join("LEFT", "HSBY_GOODSEX HG2", "HG2.GOODSID = GOODS.GOODSID").
|
|
|
Join("LEFT", "ENUMDICITEM", "GOODS.CURRENCYID = ENUMDICITEM.ENUMITEMNAME and ENUMDICITEM.ENUMDICCODE = 'currency'").
|
|
|
- Join("LEFT", "MARKET", "MARKET.MARKETID = TRADE_TRADEDETAIL.MARKETID").
|
|
|
+ Join("LEFT", "MARKET", "MARKET.MARKETID = TP.MARKETID").
|
|
|
Join("LEFT", "HSBY_SUPPLIERINFO HS1", "HS1.VENDORID = HG1.VENDORID").
|
|
|
Join("LEFT", "HSBY_SUPPLIERINFO HS2", "HS2.VENDORID = HG2.VENDORID").
|
|
|
- Join("INNER", "TRADE_PAYORDER TP", fmt.Sprintf("TP.TRADEID = TRADE_TRADEDETAIL.TRADEID and TP.PAYFLAG in (%s)", payFlag)).
|
|
|
- Join("LEFT", "TAACCOUNT TA", "TA.ACCOUNTID = TP.BUYACCOUNTID").
|
|
|
- Join("LEFT", "USERACCOUNT U", "U.USERID = TA.RELATEDUSERID").
|
|
|
- Where(`TRADE_TRADEDETAIL.BUYORSELL = 0`).
|
|
|
- And(fmt.Sprintf("TRADE_TRADEDETAIL.MARKETID in (%s)", marketIDs))
|
|
|
- if len(accountIDs) > 0 {
|
|
|
- session = session.And(fmt.Sprintf("TRADE_TRADEDETAIL.ACCOUNTID in (%s)", accountIDs))
|
|
|
- }
|
|
|
- if sellOrderID != 0 {
|
|
|
- session = session.And("TP.SELLORDERID = ?", sellOrderID)
|
|
|
- }
|
|
|
- if sellAccountID != 0 {
|
|
|
- session = session.And("TP.SELLACCOUNTID = ?", sellAccountID)
|
|
|
- }
|
|
|
+ Where(fmt.Sprintf(`TP.PAYFLAG = 1 and TP.BUYACCOUNTID in (%s)`, accountIDs)).
|
|
|
+ And(fmt.Sprintf("TP.MARKETID in (%s)", marketIDs))
|
|
|
if err := session.Find(&orders); err != nil {
|
|
|
return nil, err
|
|
|
}
|