|
|
@@ -28,8 +28,8 @@ func (Hsbygoodsex) TableName() string {
|
|
|
return "HSBY_GOODSEX"
|
|
|
}
|
|
|
|
|
|
-// TopGoods 热门商品列表
|
|
|
-type TopGoods struct {
|
|
|
+// HsbyTopGoods 热门商品列表
|
|
|
+type HsbyTopGoods struct {
|
|
|
Goodsid int64 `json:"goodsid" xorm:"'GOODSID'" binding:"required"` // 商品ID(自增ID SEQ_GOODS)
|
|
|
Goodscode string `json:"goodscode" xorm:"'GOODSCODE'" binding:"required"` // 商品代码(内部)
|
|
|
Goodsname string `json:"goodsname" xorm:"'GOODSNAME'" binding:"required"` // 商品名称
|
|
|
@@ -51,10 +51,12 @@ type TopGoods struct {
|
|
|
// 参数 descCityID int 目标城市ID
|
|
|
// 返回 []TopGoods 热门商品列表
|
|
|
// 返回 error error
|
|
|
-func GetHsbyTopGoods(marketID int, descProvinceID int, descCityID int) ([]TopGoods, error) {
|
|
|
+func GetHsbyTopGoods(marketID int, descProvinceID int, descCityID int) ([]HsbyTopGoods, error) {
|
|
|
+ // 热门商品为二级市场(挂牌点选)下的商品信息
|
|
|
+
|
|
|
engine := db.GetEngine()
|
|
|
|
|
|
- topGoodses := make([]TopGoods, 0)
|
|
|
+ topGoodses := make([]HsbyTopGoods, 0)
|
|
|
// 获取挂牌商品信息,以及扩展表信息
|
|
|
session := engine.Table("GOODS").
|
|
|
Select(`GOODS.*,
|
|
|
@@ -106,3 +108,63 @@ func GetHsbyTopGoods(marketID int, descProvinceID int, descCityID int) ([]TopGoo
|
|
|
|
|
|
return topGoodses, nil
|
|
|
}
|
|
|
+
|
|
|
+// HsbyListingGoodsDetail 二级市场(挂牌点选)商品信息详情
|
|
|
+type HsbyListingGoodsDetail struct {
|
|
|
+ Goodsid int64 `json:"goodsid" xorm:"'GOODSID'" binding:"required"` // 商品ID(自增ID SEQ_GOODS)
|
|
|
+ Goodscode string `json:"goodscode" xorm:"'GOODSCODE'" binding:"required"` // 商品代码(内部)
|
|
|
+ Goodsname string `json:"goodsname" xorm:"'GOODSNAME'" binding:"required"` // 商品名称
|
|
|
+ Decimalplace int64 `json:"decimalplace" xorm:"'DECIMALPLACE'"` // 报价小数位
|
|
|
+
|
|
|
+ Hotindex int32 `json:"hotindex" xorm:"'HOTINDEX'"` // 景点热度
|
|
|
+ Videourls string `json:"videourls" xorm:"'VIDEOURLS'"` // 介绍视频[多张用逗号分隔]
|
|
|
+ Picurls string `json:"picurls" xorm:"'PICURLS'"` // 介绍图片[多张用逗号分隔]
|
|
|
+ Descprovinceid int64 `json:"descprovinceid" xorm:"'DESCPROVINCEID'"` // 目的地(省)ID
|
|
|
+ Desccityid int64 `json:"desccityid" xorm:"'DESCCITYID'"` // 目的地(市)ID
|
|
|
+ Goodsdesc string `json:"goodsdesc" xorm:"'GOODSDESC'"` // 商品详情
|
|
|
+
|
|
|
+ Currency string `json:"currency" xorm:"'CURRENCY'"` // 货币
|
|
|
+ Currencysign string `json:"currencysign" xorm:"'CURRENCYSIGN'"` // 货币符号
|
|
|
+
|
|
|
+ Last float64 `json:"last" xorm:"-"` // 现价
|
|
|
+}
|
|
|
+
|
|
|
+// GetHsbyListingGoodsDetail 获取二级市场(挂牌点选)商品信息详情
|
|
|
+// 参数 goodsID int 目标商品ID
|
|
|
+// 返回 *HsbyListingGoodsDetail 二级市场(挂牌点选)商品信息详情,查询无结果返回nil
|
|
|
+// 返回 error error
|
|
|
+func GetHsbyListingGoodsDetail(goodsID int) (*HsbyListingGoodsDetail, error) {
|
|
|
+ engine := db.GetEngine()
|
|
|
+
|
|
|
+ details := make([]HsbyListingGoodsDetail, 0)
|
|
|
+ // 获取挂牌商品信息,以及扩展表信息
|
|
|
+ // FIXME: - 这里使用Get方法,会造成SQL语句的嵌套出错,后期再研究
|
|
|
+ session := engine.Table("GOODS").
|
|
|
+ Select(`GOODS.GOODSID, GOODS.GOODSCODE, GOODS.GOODSNAME, GOODS.DECIMALPLACE,
|
|
|
+ HSBY_GOODSEX.HOTINDEX, HSBY_GOODSEX.VIDEOURLS, HSBY_GOODSEX.PICURLS, HSBY_GOODSEX.DESCPROVINCEID, HSBY_GOODSEX.Desccityid, HSBY_GOODSEX.Goodsdesc,
|
|
|
+ ENUMDICITEM.ENUMDICNAME CURRENCY, ENUMDICITEM.PARAM2 CURRENCYSIGN`).
|
|
|
+ Join("LEFT", "HSBY_GOODSEX", "HSBY_GOODSEX.GOODSID = GOODS.GOODSID").
|
|
|
+ Join("LEFT", "ENUMDICITEM", "ENUMDICITEM.ENUMITEMNAME = GOODS.CURRENCYID and ENUMDICITEM.ENUMDICCODE = 'currency'").
|
|
|
+ Where("GOODS.GOODSID = ?", goodsID)
|
|
|
+ if err := session.Find(&details); err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+ // 无目标商品
|
|
|
+ if len(details) == 0 {
|
|
|
+ return nil, nil
|
|
|
+ }
|
|
|
+ hsbyListingGoodsDetail := details[0]
|
|
|
+
|
|
|
+ // 获取商品现价
|
|
|
+ quoteDays, err := GetQuoteDays(hsbyListingGoodsDetail.Goodscode)
|
|
|
+ if err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+ if len(quoteDays) > 0 {
|
|
|
+ if quoteDays[0].Last != 0 {
|
|
|
+ hsbyListingGoodsDetail.Last = utils.IntToFloat64(int(quoteDays[0].Last), int(hsbyListingGoodsDetail.Decimalplace))
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return &hsbyListingGoodsDetail, nil
|
|
|
+}
|