|
|
@@ -5,7 +5,6 @@ import (
|
|
|
"fmt"
|
|
|
"mtp2_if/db"
|
|
|
"mtp2_if/logger"
|
|
|
- "mtp2_if/mtpcache"
|
|
|
"mtp2_if/utils"
|
|
|
"strconv"
|
|
|
"strings"
|
|
|
@@ -1147,6 +1146,7 @@ type THJPurchaseTradeDetail_Goodsinfo struct {
|
|
|
REFGOODSID int64 `json:"refgoodsid" xorm:"REFGOODSID"` // 参考商品ID
|
|
|
REFGOODSCODE string `json:"refgoodscode" xorm:"REFGOODSCODE"` // 参考商品代码
|
|
|
MINIVALUE int64 `json:"minivalue" xorm:"MINIVALUE"` // 最小变动值
|
|
|
+ MINIVALUEDP int64 `json:"minivaluedp" xorm:"MINIVALUEDP"` // 最小变动值小数位
|
|
|
}
|
|
|
|
|
|
type THJPurchaseTradeDetail_Date struct {
|
|
|
@@ -1182,9 +1182,10 @@ type THJPurchaseTradeDetailReq struct {
|
|
|
|
|
|
// THJPurchaseTradeDetailRsp 合同转让详情
|
|
|
type THJPurchaseTradeDetailRsp struct {
|
|
|
- GoodsInfo THJPurchaseTradeDetail_Goodsinfo `json:"goodsinfo"` // 商品信息
|
|
|
- DeliveryDates []THJPurchaseTradeDetail_Date `json:"deliverydate"` // 交割日期
|
|
|
- History []HistoryData `json:"history"` // 历史价格走势(历史数据日线)
|
|
|
+ GoodsInfo THJPurchaseTradeDetail_Goodsinfo `json:"goodsinfo"` // 商品信息
|
|
|
+ DeliveryDates []THJPurchaseTradeDetail_Date `json:"deliverydate"` // 交割日期
|
|
|
+ SpotGoodsPriceLogs []THJSpotGoodsPriceLog `json:"spotgoodspricelogs"` // 历史价格走势
|
|
|
+ // History []HistoryData `json:"history"` // 历史价格走势(历史数据日线)
|
|
|
}
|
|
|
|
|
|
// GetTHJWrstandardDetail 获取采购商品详情
|
|
|
@@ -1204,7 +1205,8 @@ func (r *THJPurchaseTradeDetailReq) GetData() (rsp *THJPurchaseTradeDetailRsp, e
|
|
|
t.PICTUREURLS ,
|
|
|
t.REFGOODSID ,
|
|
|
t.REFGOODSCODE,
|
|
|
- t.MINIVALUE
|
|
|
+ t.MINIVALUE,
|
|
|
+ t.MINIVALUEDP
|
|
|
from wrstandard t
|
|
|
where t.wrstandardid = %v
|
|
|
`, r.WRSTANDARDID)
|
|
|
@@ -1240,29 +1242,46 @@ func (r *THJPurchaseTradeDetailReq) GetData() (rsp *THJPurchaseTradeDetailRsp, e
|
|
|
rsp.DeliveryDates = deliveryDates
|
|
|
|
|
|
// 历史价格走势
|
|
|
- cycleDatas, err := GetHistoryCycleDatas(CycleTypeMinutesDay, goodsInfo.REFGOODSCODE, nil, nil, 50, true)
|
|
|
- if err != nil {
|
|
|
+ // cycleDatas, err := GetHistoryCycleDatas(CycleTypeMinutesDay, goodsInfo.REFGOODSCODE, nil, nil, 50, true)
|
|
|
+ // if err != nil {
|
|
|
+ // return
|
|
|
+ // }
|
|
|
+ // // 获取目标商品报价小数位
|
|
|
+ // dcplace := mtpcache.GetGoodsDecimalplace(goodsInfo.REFGOODSCODE)
|
|
|
+ // // 计算最终价格
|
|
|
+ // rst := make([]HistoryData, 0)
|
|
|
+ // for _, v := range cycleDatas {
|
|
|
+ // historyData := HistoryData{
|
|
|
+ // Opened: utils.IntToFloat64(v.Open, dcplace),
|
|
|
+ // Highest: utils.IntToFloat64(v.High, dcplace),
|
|
|
+ // Lowest: utils.IntToFloat64(v.Low, dcplace),
|
|
|
+ // Closed: utils.IntToFloat64(v.Close, dcplace),
|
|
|
+ // TotleVolume: v.TV,
|
|
|
+ // TotleTurnover: float64(v.TT),
|
|
|
+ // HoldVolume: v.HV,
|
|
|
+ // Settle: utils.IntToFloat64(v.SP, dcplace),
|
|
|
+ // TimeStamp: time.Unix(int64(v.ST), 0),
|
|
|
+ // }
|
|
|
+ // rst = append(rst, historyData)
|
|
|
+ // }
|
|
|
+ // rsp.History = rst
|
|
|
+
|
|
|
+ // 历史价格走势
|
|
|
+ spotGoodsPriceLogs := make([]THJSpotGoodsPriceLog, 0)
|
|
|
+ sql = fmt.Sprintf(`
|
|
|
+ select
|
|
|
+ t.SPOTGOODSPRICE,
|
|
|
+ t.TRADEDATE
|
|
|
+ from ERMCP_SpotGoodsPriceLog t
|
|
|
+ where t.wrstandardid = %v
|
|
|
+ and t.SPOTGOODSBRANDID = 0
|
|
|
+ and t.CURRENCYID = 1
|
|
|
+ order by t.tradedate
|
|
|
+ `, r.WRSTANDARDID)
|
|
|
+ if err = engine.SQL(sql).Find(&spotGoodsPriceLogs); err != nil {
|
|
|
return
|
|
|
}
|
|
|
- // 获取目标商品报价小数位
|
|
|
- dcplace := mtpcache.GetGoodsDecimalplace(goodsInfo.REFGOODSCODE)
|
|
|
- // 计算最终价格
|
|
|
- rst := make([]HistoryData, 0)
|
|
|
- for _, v := range cycleDatas {
|
|
|
- historyData := HistoryData{
|
|
|
- Opened: utils.IntToFloat64(v.Open, dcplace),
|
|
|
- Highest: utils.IntToFloat64(v.High, dcplace),
|
|
|
- Lowest: utils.IntToFloat64(v.Low, dcplace),
|
|
|
- Closed: utils.IntToFloat64(v.Close, dcplace),
|
|
|
- TotleVolume: v.TV,
|
|
|
- TotleTurnover: float64(v.TT),
|
|
|
- HoldVolume: v.HV,
|
|
|
- Settle: utils.IntToFloat64(v.SP, dcplace),
|
|
|
- TimeStamp: time.Unix(int64(v.ST), 0),
|
|
|
- }
|
|
|
- rst = append(rst, historyData)
|
|
|
- }
|
|
|
- rsp.History = rst
|
|
|
+ rsp.SpotGoodsPriceLogs = spotGoodsPriceLogs
|
|
|
|
|
|
return
|
|
|
}
|