|
|
@@ -2,6 +2,7 @@ package models
|
|
|
|
|
|
import (
|
|
|
"fmt"
|
|
|
+ "math"
|
|
|
"mtp2_if/db"
|
|
|
"mtp2_if/utils"
|
|
|
"strconv"
|
|
|
@@ -55,6 +56,7 @@ type HsbyTopGoods struct {
|
|
|
Goodsname string `json:"goodsname" xorm:"'GOODSNAME'" binding:"required"` // 商品名称
|
|
|
Decimalplace int64 `json:"decimalplace" xorm:"'DECIMALPLACE'"` // 报价小数位
|
|
|
Marketid int64 `json:"marketid" xorm:"'MARKETID'" binding:"required"` // 所属市场ID
|
|
|
+ Quoteminunit int64 `json:"quoteminunit" xorm:"'QUOTEMINUNIT'"` // 行情最小变动单位 [整数,报价小数位一起使用]
|
|
|
|
|
|
Hotindex int32 `json:"hotindex" xorm:"'HOTINDEX'"` // 景点热度
|
|
|
Videourls string `json:"videourls" xorm:"'VIDEOURLS'"` // 介绍视频[多张用逗号分隔]
|
|
|
@@ -63,7 +65,8 @@ type HsbyTopGoods struct {
|
|
|
Currency string `json:"currency" xorm:"'CURRENCY'"` // 货币
|
|
|
Currencysign string `json:"currencysign" xorm:"'CURRENCYSIGN'"` // 货币符号
|
|
|
|
|
|
- Last float64 `json:"last" xorm:"-"` // 现价
|
|
|
+ Last float64 `json:"last" xorm:"-"` // 现价
|
|
|
+ LotSize float64 `json:"lotsize" xorm:"-"` // 最小变动单位
|
|
|
}
|
|
|
|
|
|
// GetHsbyTopGoodses 获取热门商品列表
|
|
|
@@ -115,10 +118,15 @@ func GetHsbyTopGoodses(marketIDs string, descProvinceID, descCityID int) ([]Hsby
|
|
|
return nil, err
|
|
|
}
|
|
|
for i, g := range topGoodses {
|
|
|
+ topGoods := &topGoodses[i]
|
|
|
+ // FIXME: - 这里应该使用 Duck Typing,后期再处理
|
|
|
+ // 计算最小变动单位
|
|
|
+ lotSize := float64(topGoods.Quoteminunit) * math.Pow(0.1, float64(topGoods.Decimalplace))
|
|
|
+ topGoods.LotSize, _ = strconv.ParseFloat(utils.FormatFloat(lotSize, int(topGoods.Decimalplace)), 64)
|
|
|
+
|
|
|
for _, q := range quoteDays {
|
|
|
if g.Goodscode == q.Goodscode {
|
|
|
if q.Last != 0 {
|
|
|
- topGoods := &topGoodses[i]
|
|
|
topGoods.Last = utils.IntToFloat64(int(q.Last), int(g.Decimalplace))
|
|
|
}
|
|
|
|
|
|
@@ -137,6 +145,7 @@ type HsbyListingGoodsDetail struct {
|
|
|
Goodsname string `json:"goodsname" xorm:"'GOODSNAME'" binding:"required"` // 商品名称
|
|
|
Decimalplace int64 `json:"decimalplace" xorm:"'DECIMALPLACE'"` // 报价小数位
|
|
|
Marketid int64 `json:"marketid" xorm:"'MARKETID'" binding:"required"` // 所属市场ID
|
|
|
+ Quoteminunit int64 `json:"quoteminunit" xorm:"'QUOTEMINUNIT'"` // 行情最小变动单位 [整数,报价小数位一起使用]
|
|
|
|
|
|
Hotindex int32 `json:"hotindex" xorm:"'HOTINDEX'"` // 景点热度
|
|
|
Videourls string `json:"videourls" xorm:"'VIDEOURLS'"` // 介绍视频[多张用逗号分隔]
|
|
|
@@ -155,6 +164,7 @@ type HsbyListingGoodsDetail struct {
|
|
|
Last float64 `json:"last" xorm:"-"` // 现价
|
|
|
Limitup float64 `json:"limitup" xorm:"-"` // 涨停价
|
|
|
Limitdown float64 `json:"limitdown" xorm:"-"` // 跌停价
|
|
|
+ LotSize float64 `json:"lotsize" xorm:"-"` // 最小变动单位
|
|
|
}
|
|
|
|
|
|
// GetHsbyListingGoodsDetail 获取二级市场(挂牌点选)商品信息详情
|
|
|
@@ -168,7 +178,7 @@ func GetHsbyListingGoodsDetail(goodsID int) (*HsbyListingGoodsDetail, error) {
|
|
|
// 获取挂牌商品信息,以及扩展表信息
|
|
|
// FIXME: - 这里使用Get方法,会造成SQL语句的嵌套出错,后期再研究
|
|
|
session := engine.Table("GOODS").
|
|
|
- Select(`GOODS.GOODSID, GOODS.GOODSCODE, GOODS.GOODSNAME, GOODS.DECIMALPLACE, GOODS.MARKETID,
|
|
|
+ Select(`GOODS.GOODSID, GOODS.GOODSCODE, GOODS.GOODSNAME, GOODS.DECIMALPLACE, GOODS.MARKETID, GOODS.QUOTEMINUNIT,
|
|
|
HSBY_GOODSEX.HOTINDEX, HSBY_GOODSEX.VIDEOURLS, HSBY_GOODSEX.PICURLS, HSBY_GOODSEX.DESCPROVINCEID, HSBY_GOODSEX.Desccityid, HSBY_GOODSEX.Goodsdesc,
|
|
|
ENUMDICITEM.ENUMDICNAME CURRENCY, ENUMDICITEM.PARAM2 CURRENCYSIGN,
|
|
|
HSBY_SUPPLIERINFO.VENDORNAME, HSBY_SUPPLIERINFO.VENDORPHONE, HSBY_SUPPLIERINFO.VENDORATTR`).
|
|
|
@@ -202,6 +212,11 @@ func GetHsbyListingGoodsDetail(goodsID int) (*HsbyListingGoodsDetail, error) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ // FIXME: - 这里应该使用 Duck Typing,后期再处理
|
|
|
+ // 计算最小变动单位
|
|
|
+ lotSize := float64(hsbyListingGoodsDetail.Quoteminunit) * math.Pow(0.1, float64(hsbyListingGoodsDetail.Decimalplace))
|
|
|
+ hsbyListingGoodsDetail.LotSize, _ = strconv.ParseFloat(utils.FormatFloat(lotSize, int(hsbyListingGoodsDetail.Decimalplace)), 64)
|
|
|
+
|
|
|
return &hsbyListingGoodsDetail, nil
|
|
|
}
|
|
|
|
|
|
@@ -232,7 +247,7 @@ func GetHsbyGoodsOrderDetails(goodsID, buyOrSell int, price float64) ([]HsbyGood
|
|
|
hsbyGoodsOrderDetails := make([]HsbyGoodsOrderDetail, 0)
|
|
|
session := engine.Table("TRADE_ORDERDETAIL").
|
|
|
Select(`to_char(TRADE_ORDERDETAIL.ORDERID) ORDERID, TRADE_ORDERDETAIL.BUYORSELL, TRADE_ORDERDETAIL.ORDERTIME, TRADE_ORDERDETAIL.ORDERPRICE, (TRADE_ORDERDETAIL.ORDERQTY - TRADE_ORDERDETAIL.TRADEQTY - TRADE_ORDERDETAIL.CANCELQTY) ENABLEQTY,
|
|
|
- substr(USERINFO.CUSTOMERNAME,0,1)||'****' as CUSTOMERNAME`).
|
|
|
+ substr(USERINFO.CUSTOMERNAME,0,1)||'****' as CUSTOMERNAME`).
|
|
|
Join("LEFT", "TAACCOUNT", "TAACCOUNT.ACCOUNTID = TRADE_ORDERDETAIL.ACCOUNTID").
|
|
|
Join("LEFT", "USERINFO", "USERINFO.USERID = TAACCOUNT.RELATEDUSERID").
|
|
|
Where("(TRADE_ORDERDETAIL.LISTINGSELECTTYPE = 1 or TRADE_ORDERDETAIL.LISTINGSELECTTYPE = 3) and (TRADE_ORDERDETAIL.ORDERSTATUS = 3 or TRADE_ORDERDETAIL.ORDERSTATUS = 7)").
|
|
|
@@ -299,9 +314,10 @@ type HybsMyBuyOrderDetail struct {
|
|
|
Listingselecttype int32 `json:"listingselecttype" xorm:"'LISTINGSELECTTYPE'"` // 挂牌点选类型 - 1:挂牌 2:摘牌 3:先摘后挂
|
|
|
Orderstatus int32 `json:"orderstatus" xorm:"'ORDERSTATUS'"` // 委托状态 - 1: 委托请求 2:待冻结 3:委托成功 4: 委托失败 5:配对成功 6: 已撤销 7:部分成交 8:已成交 9:部成部撤 10:成交失败 11:已拒绝 12:经过摘牌(先摘后挂专用-先摘后挂已摘过) 13:冻结成功(通道交易专用) 14:通道已撤 15:通道部成部撤 16:成交失败违约(荷兰式竞拍专用)
|
|
|
|
|
|
- Goodscode string `json:"goodscode" xorm:"'GOODSCODE'" binding:"required"` // 商品代码(内部)
|
|
|
- Goodsname string `json:"goodsname" xorm:"'GOODSNAME'" binding:"required"` // 商品名称
|
|
|
- Decimalplace int64 `json:"decimalplace" xorm:"'DECIMALPLACE'"` // 报价小数位
|
|
|
+ Goodscode string `json:"goodscode" xorm:"'GOODSCODE'" binding:"required"` // 商品代码(内部)
|
|
|
+ Goodsname string `json:"goodsname" xorm:"'GOODSNAME'" binding:"required"` // 商品名称
|
|
|
+ Decimalplace int64 `json:"decimalplace" xorm:"'DECIMALPLACE'"` // 报价小数位
|
|
|
+ Agreeunit float64 `json:"agreeunit" xorm:"'AGREEUNIT'"` // 合约单位
|
|
|
|
|
|
Picurls string `json:"picurls" xorm:"'PICURLS'"` // 介绍图片[多张用逗号分隔]
|
|
|
|
|
|
@@ -311,7 +327,8 @@ type HybsMyBuyOrderDetail struct {
|
|
|
|
|
|
Vendorname string `json:"vendorname" xorm:"'VENDORNAME'"` // 供应商名称
|
|
|
|
|
|
- MyBuyStatus int `json:"mybuystatus" xorm:"-"` // "我的订单"显示状态- 1:抢购中 2:求购中 3:已完成 4:已撤消 5:委托失败
|
|
|
+ MyBuyStatus int `json:"mybuystatus" xorm:"-"` // "我的订单"显示状态- 1:抢购中 2:求购中 3:已完成 4:已撤消 5:委托失败
|
|
|
+ Orderamount float64 `json:"" xorm:"-"` // 委托金额
|
|
|
}
|
|
|
|
|
|
// GetHsbyBuyMyOrderDetails 获取“我的订单”数据(包括一二级市场)
|
|
|
@@ -356,7 +373,7 @@ func GetHsbyBuyMyOrderDetails(accountIDs string, myBuyStatus int) ([]HybsMyBuyOr
|
|
|
hybsMyBuyOrderDetails := make([]HybsMyBuyOrderDetail, 0)
|
|
|
session := engine.Table("TRADE_ORDERDETAIL").
|
|
|
Select(`to_char(TRADE_ORDERDETAIL.ORDERID) ORDERID, TRADE_ORDERDETAIL.*,
|
|
|
- GOODS.GOODSCODE, GOODS.GOODSNAME, GOODS.DECIMALPLACE,
|
|
|
+ GOODS.GOODSCODE, GOODS.GOODSNAME, GOODS.DECIMALPLACE, GOODS.AGREEUNIT,
|
|
|
HSBY_GOODSEX.PICURLS,
|
|
|
MARKET.TRADEMODE,
|
|
|
ENUMDICITEM.PARAM2 CURRENCYSIGN,
|
|
|
@@ -383,6 +400,9 @@ func GetHsbyBuyMyOrderDetails(accountIDs string, myBuyStatus int) ([]HybsMyBuyOr
|
|
|
for i := range hybsMyBuyOrderDetails {
|
|
|
detail := &hybsMyBuyOrderDetails[i]
|
|
|
|
|
|
+ // 委托金额 = 委托价格 * 委托数量 * 合约单位
|
|
|
+ detail.Orderamount = detail.Orderprice * float64(detail.Orderqty) * float64(detail.Agreeunit)
|
|
|
+
|
|
|
if detail.Trademode == 71 && (detail.Orderstatus == 3 || detail.Orderstatus == 7) {
|
|
|
// 抢购中
|
|
|
detail.MyBuyStatus = 1
|
|
|
@@ -431,6 +451,7 @@ func GetHsbyMyGoods(accountIDs string) ([]HsbyMyGoods, error) {
|
|
|
engine := db.GetEngine()
|
|
|
|
|
|
hsbyMyGoodses := make([]HsbyMyGoods, 0)
|
|
|
+ // 此定制版本,只查询出当前手数(期末)大于0的数据 (TRADEPOSITION.BUYCURPOSITIONQTY > 0)
|
|
|
if err := engine.Table("TRADEPOSITION").
|
|
|
Select(`TRADEPOSITION.*,
|
|
|
GOODS.GOODSCODE, GOODS.GOODSNAME, GOODS.DECIMALPLACE, GOODS.AGREEUNIT,
|
|
|
@@ -439,7 +460,7 @@ func GetHsbyMyGoods(accountIDs string) ([]HsbyMyGoods, error) {
|
|
|
Join("LEFT", "GOODS", "GOODS.GOODSID = TRADEPOSITION.GOODSID").
|
|
|
Join("INNER", "HSBY_GOODSEX", "HSBY_GOODSEX.GOODSID = GOODS.GOODSID").
|
|
|
Join("LEFT", "ENUMDICITEM", "GOODS.CURRENCYID = ENUMDICITEM.ENUMITEMNAME and ENUMDICITEM.ENUMDICCODE = 'currency'").
|
|
|
- Where(fmt.Sprintf("TRADEPOSITION.ACCOUNTID in (%s)", accountIDs)).Find(&hsbyMyGoodses); err != nil {
|
|
|
+ Where(fmt.Sprintf("TRADEPOSITION.BUYCURPOSITIONQTY > 0 and TRADEPOSITION.ACCOUNTID in (%s)", accountIDs)).Find(&hsbyMyGoodses); err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
|
|
|
@@ -462,6 +483,7 @@ type HsbyPreGoods struct {
|
|
|
Decimalplace int64 `json:"decimalplace" xorm:"'DECIMALPLACE'"` // 报价小数位
|
|
|
Marketid int64 `json:"marketid" xorm:"'MARKETID'" binding:"required"` // 所属市场ID
|
|
|
Goodsstatus int64 `json:"goodsstatus" xorm:"'GOODSSTATUS'"` // 商品状态- 2:未上市 3:上市
|
|
|
+ Quoteminunit int64 `json:"quoteminunit" xorm:"'QUOTEMINUNIT'"` // 行情最小变动单位 [整数,报价小数位一起使用]
|
|
|
|
|
|
Relatedgoodsid int64 `json:"relatedgoodsid" xorm:"'RELATEDGOODSID'"` // 关联交易合约ID
|
|
|
Presaleqty int64 `json:"presaleqty" xorm:"'PRESALEQTY'"` // 预售数量
|
|
|
@@ -474,6 +496,8 @@ type HsbyPreGoods struct {
|
|
|
|
|
|
Videourls string `json:"videourls" xorm:"'VIDEOURLS'"` // 介绍视频[多张用逗号分隔]
|
|
|
Picurls string `json:"picurls" xorm:"'PICURLS'"` // 介绍图片[多张用逗号分隔]
|
|
|
+
|
|
|
+ LotSize float64 `json:"lotsize" xorm:"-"` // 最小变动单位
|
|
|
}
|
|
|
|
|
|
// GetHsbyPreGoodses 获取“新品上市”商品列表(一级市场产能预售)
|
|
|
@@ -507,6 +531,15 @@ func GetHsbyPreGoodses(marketIDs string, descProvinceID, descCityID int) ([]Hsby
|
|
|
return nil, err
|
|
|
}
|
|
|
|
|
|
+ for i := range preGoodses {
|
|
|
+ preGoods := &preGoodses[i]
|
|
|
+
|
|
|
+ // FIXME: - 这里应该使用 Duck Typing,后期再处理
|
|
|
+ // 计算最小变动单位
|
|
|
+ lotSize := float64(preGoods.Quoteminunit) * math.Pow(0.1, float64(preGoods.Decimalplace))
|
|
|
+ preGoods.LotSize, _ = strconv.ParseFloat(utils.FormatFloat(lotSize, int(preGoods.Decimalplace)), 64)
|
|
|
+ }
|
|
|
+
|
|
|
return preGoodses, nil
|
|
|
}
|
|
|
|
|
|
@@ -518,6 +551,7 @@ type HsbyPreGoodsDetail struct {
|
|
|
Decimalplace int64 `json:"decimalplace" xorm:"'DECIMALPLACE'"` // 报价小数位
|
|
|
Marketid int64 `json:"marketid" xorm:"'MARKETID'" binding:"required"` // 所属市场ID
|
|
|
Goodsstatus int64 `json:"goodsstatus" xorm:"'GOODSSTATUS'"` // 商品状态- 2:未上市 3:上市
|
|
|
+ Quoteminunit int64 `json:"quoteminunit" xorm:"'QUOTEMINUNIT'"` // 行情最小变动单位 [整数,报价小数位一起使用]
|
|
|
|
|
|
Relatedgoodsid int64 `json:"relatedgoodsid" xorm:"'RELATEDGOODSID'"` // 关联交易合约ID
|
|
|
Presaleqty int64 `json:"presaleqty" xorm:"'PRESALEQTY'"` // 预售数量
|
|
|
@@ -538,6 +572,8 @@ type HsbyPreGoodsDetail struct {
|
|
|
Vendorname string `json:"vendorname" xorm:"'VENDORNAME'"` // 供应商名称
|
|
|
Vendorphone string `json:"vendorphone" xorm:"'VENDORPHONE'"` // 供应商客服电话
|
|
|
Vendorattr string `json:"vendorattr" xorm:"'VENDORATTR'"` // 供应商附件(多张,逗号分隔)
|
|
|
+
|
|
|
+ LotSize float64 `json:"lotsize" xorm:"-"` // 最小变动单位
|
|
|
}
|
|
|
|
|
|
// GetHsbyPreGoodsDetail 获取一级市场(产能预售)商品信息详情
|
|
|
@@ -573,5 +609,10 @@ func GetHsbyPreGoodsDetail(goodsID int) (*HsbyPreGoodsDetail, error) {
|
|
|
}
|
|
|
preGoodsDetail := details[0]
|
|
|
|
|
|
+ // FIXME: - 这里应该使用 Duck Typing,后期再处理
|
|
|
+ // 计算最小变动单位
|
|
|
+ lotSize := float64(preGoodsDetail.Quoteminunit) * math.Pow(0.1, float64(preGoodsDetail.Decimalplace))
|
|
|
+ preGoodsDetail.LotSize, _ = strconv.ParseFloat(utils.FormatFloat(lotSize, int(preGoodsDetail.Decimalplace)), 64)
|
|
|
+
|
|
|
return &preGoodsDetail, nil
|
|
|
}
|