94 lines
2.5 KiB
Go
94 lines
2.5 KiB
Go
package model
|
|
|
|
import (
|
|
"github.com/iapologizewhenimwrong/Vestmore_GO/proto"
|
|
"github.com/iapologizewhenimwrong/Vestmore_GO/utils/constants"
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
type KillaraStockModel struct {
|
|
// fields ...
|
|
db *gorm.DB
|
|
TableName string // 表名
|
|
}
|
|
|
|
// , stockLocalHistoryID uint64, source string
|
|
func (m *KillaraStockModel) StockDetail(tx *gorm.DB, market string, stockType int, stockSymbol string) (map[string]interface{}, error) {
|
|
// var db *gorm.DB
|
|
// if tx != nil {
|
|
// db = tx
|
|
// } else {
|
|
// db = m.db
|
|
// }
|
|
|
|
trueStockSymbol := stockSymbol
|
|
|
|
// var localData *KillaraStockLocal
|
|
|
|
// if stockLocalHistoryID != 0 {
|
|
// localData = StockLocalHistoryMapLocalModel.Find(stockLocalHistoryID)
|
|
// } else {
|
|
// localData = StockLocalDao.FindSymbolWithTrashed(market, stockSymbol)
|
|
// }
|
|
|
|
// if localData != nil {
|
|
// trueStockSymbol = *localData.OriginStockSymbol
|
|
// }
|
|
|
|
// modelStockTool := &StockTool{}
|
|
|
|
marketForSearch := market
|
|
if market == "HK" {
|
|
marketForSearch = constants.HKEX
|
|
}
|
|
|
|
// data := modelStockTool.Info(fmt.Sprintf("%s|%d|%s", marketForSearch, stockType, trueStockSymbol))
|
|
data, err := proto.StockDetail(marketForSearch, stockType, trueStockSymbol)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
data["symbol_empty"] = data["symbol"] == nil // 空
|
|
|
|
data["symbol"] = stockSymbol // 覆盖
|
|
data["true_symbol"] = trueStockSymbol // 真实
|
|
|
|
// if localData != nil && !localData.DeleteDate.IsZero() {
|
|
// // 这个已经删除了
|
|
// data["local_delete_date"] = localData.DeleteDate
|
|
// }
|
|
|
|
// 空股票也会返回数据
|
|
if data["symbol_empty"].(bool) {
|
|
return data, nil
|
|
}
|
|
|
|
// if localData != nil {
|
|
// if source == "app" {
|
|
// data["name"] = localData.LanguageAppName
|
|
// } else {
|
|
// data["name"] = localData.LanguageAdminName
|
|
// }
|
|
// data["origin_price"] = data["price"]
|
|
// price, _ := decimal.NewFromString(fmt.Sprintf("%v", data["price"]))
|
|
// data["price"] = StockLocalLogic.CalPrice(price, localData.Diff, market).String()
|
|
|
|
// if localData.Stop == StockLocalModel.StopNo {
|
|
// data["securityStatus"] = 1
|
|
// } else {
|
|
// data["securityStatus"] = 3
|
|
// }
|
|
// data["msgs"] = localData.GroupNum
|
|
|
|
// data["local_stock_symbol"] = localData.StockSymbol
|
|
// data["local_origin_stock_symbol"] = localData.OriginStockSymbol
|
|
// data["local_stock_market"] = localData.Market
|
|
// data["stock_local_id"] = localData.ID
|
|
// data["stock_local_diff"] = localData.Diff
|
|
// data["stock_group_num"] = localData.GroupNum
|
|
// data["stock_name_json"] = localData.StockNameJSON
|
|
// }
|
|
|
|
return data, nil
|
|
}
|