Bladeren bron

新增“查询一级市场(产能预售)商品信息详情”接口

zhou.xiaoning 5 jaren geleden
bovenliggende
commit
b298b7cf1f
6 gewijzigde bestanden met toevoegingen van 432 en 29 verwijderingen
  1. 40 1
      controllers/hsby/hsby.go
  2. 139 1
      docs/docs.go
  3. 139 1
      docs/swagger.json
  4. 99 2
      docs/swagger.yaml
  5. 13 24
      models/hsby.go
  6. 2 0
      routers/router.go

+ 40 - 1
controllers/hsby/hsby.go

@@ -139,7 +139,7 @@ type QueryHsbyGoodsOrderDetailsReq struct {
 
 // QueryHsbyGoodsOrderDetails 查询二级市场(挂牌点选)商品对应的挂牌委托单信息
 // @Summary 查询二级市场(挂牌点选)商品对应的挂牌委托单信息
-// @Description 说明:查询结果已按委托价格和委托时间排序; sellOrderDetails - 转让(卖出)单,buyOrderDetails - 求购(买入)单
+// @Description 说明:查询结果已按委托价格和委托时间排序
 // @Produce json
 // @Security ApiKeyAuth
 // @Param goodsID query int true "商品ID"
@@ -385,3 +385,42 @@ func QueryHsbyPreGoodses(c *gin.Context) {
 		appG.Response(http.StatusOK, e.SUCCESS, preGoodses)
 	}
 }
+
+// QueryHsbyPreGoodsDetailReq 查询一级市场(产能预售)商品信息详情请求参数
+type QueryHsbyPreGoodsDetailReq struct {
+	GoodsID int `form:"goodsID" binding:"required"`
+}
+
+// QueryHsbyPreGoodsDetail 查询一级市场(产能预售)商品信息详情
+// @Summary 查询一级市场(产能预售)商品信息详情
+// @Produce json
+// @Security ApiKeyAuth
+// @Param goodsID query int true "商品ID"
+// @Success 200 {object} models.HsbyPreGoodsDetail
+// @Failure 500 {object} app.Response
+// @Router /HSBY/QueryHsbyPreGoodsDetail [get]
+// @Tags 定制【海商报业】
+func QueryHsbyPreGoodsDetail(c *gin.Context) {
+	appG := app.Gin{C: c}
+
+	// 获取请求参数
+	var req QueryHsbyPreGoodsDetailReq
+	if err := appG.C.ShouldBindQuery(&req); err != nil {
+		logger.GetLogger().Errorf("QueryHsbyPreGoodsDetail failed: %s", err.Error())
+		appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
+		return
+	}
+
+	// 获取数据
+	goodsInfo, err := models.GetHsbyPreGoodsDetail(req.GoodsID)
+	if err != nil {
+		// 查询失败
+		logger.GetLogger().Errorf("QueryHsbyPreGoodsDetail failed: %s", err.Error())
+		appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
+		return
+	}
+
+	// 查询成功返回
+	logger.GetLogger().Debugln("QueryHsbyPreGoodsDetail successed: %v", goodsInfo)
+	appG.Response(http.StatusOK, e.SUCCESS, goodsInfo)
+}

+ 139 - 1
docs/docs.go

@@ -763,7 +763,7 @@ var doc = `{
                         "ApiKeyAuth": []
                     }
                 ],
-                "description": "说明:查询结果已按委托价格和委托时间排序; sellOrderDetails - 转让(卖出)单,buyOrderDetails - 求购(买入)单",
+                "description": "说明:查询结果已按委托价格和委托时间排序",
                 "produces": [
                     "application/json"
                 ],
@@ -938,6 +938,45 @@ var doc = `{
                 }
             }
         },
+        "/HSBY/QueryHsbyPreGoodsDetail": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "定制【海商报业】"
+                ],
+                "summary": "查询一级市场(产能预售)商品信息详情",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "商品ID",
+                        "name": "goodsID",
+                        "in": "query",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "$ref": "#/definitions/models.HsbyPreGoodsDetail"
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/HSBY/QueryHsbyPreGoodses": {
             "get": {
                 "security": [
@@ -3932,6 +3971,105 @@ var doc = `{
                 }
             }
         },
+        "models.HsbyPreGoodsDetail": {
+            "type": "object",
+            "required": [
+                "goodscode",
+                "goodsid",
+                "goodsname",
+                "marketid"
+            ],
+            "properties": {
+                "currency": {
+                    "description": "货币",
+                    "type": "string"
+                },
+                "currencysign": {
+                    "description": "货币符号",
+                    "type": "string"
+                },
+                "decimalplace": {
+                    "description": "报价小数位",
+                    "type": "integer"
+                },
+                "desccityid": {
+                    "description": "目的地(市)ID",
+                    "type": "integer"
+                },
+                "descprovinceid": {
+                    "description": "目的地(省)ID",
+                    "type": "integer"
+                },
+                "endtime": {
+                    "description": "预售结束时间",
+                    "type": "string"
+                },
+                "goodscode": {
+                    "description": "商品代码(内部)",
+                    "type": "string"
+                },
+                "goodsdesc": {
+                    "description": "商品详情",
+                    "type": "string"
+                },
+                "goodsid": {
+                    "description": "商品ID(自增ID SEQ_GOODS)",
+                    "type": "integer"
+                },
+                "goodsname": {
+                    "description": "商品名称",
+                    "type": "string"
+                },
+                "goodsstatus": {
+                    "description": "商品状态- 2:未上市 3:上市",
+                    "type": "integer"
+                },
+                "goodunit": {
+                    "description": "报价单位",
+                    "type": "string"
+                },
+                "marketid": {
+                    "description": "所属市场ID",
+                    "type": "integer"
+                },
+                "picurls": {
+                    "description": "介绍图片[多张用逗号分隔]",
+                    "type": "string"
+                },
+                "presaleqty": {
+                    "description": "预售数量",
+                    "type": "integer"
+                },
+                "refprice": {
+                    "description": "参考价格[一口价]",
+                    "type": "number"
+                },
+                "relatedgoodsid": {
+                    "description": "关联交易合约ID",
+                    "type": "integer"
+                },
+                "starttime": {
+                    "description": "预售开始时间",
+                    "type": "string"
+                },
+                "vendorattr": {
+                    "description": "供应商附件(多张,逗号分隔)",
+                    "type": "string"
+                },
+                "vendorname": {
+                    "description": "供应商名称",
+                    "type": "string"
+                },
+                "vendorphone": {
+                    "description": "供应商客服电话",
+                    "type": "string"
+                },
+                "videourls": {
+                    "description": "介绍视频[多张用逗号分隔]",
+                    "type": "string"
+                }
+            }
+        },
         "models.HsbyTopGoods": {
             "type": "object",
             "required": [

+ 139 - 1
docs/swagger.json

@@ -747,7 +747,7 @@
                         "ApiKeyAuth": []
                     }
                 ],
-                "description": "说明:查询结果已按委托价格和委托时间排序; sellOrderDetails - 转让(卖出)单,buyOrderDetails - 求购(买入)单",
+                "description": "说明:查询结果已按委托价格和委托时间排序",
                 "produces": [
                     "application/json"
                 ],
@@ -922,6 +922,45 @@
                 }
             }
         },
+        "/HSBY/QueryHsbyPreGoodsDetail": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "定制【海商报业】"
+                ],
+                "summary": "查询一级市场(产能预售)商品信息详情",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "商品ID",
+                        "name": "goodsID",
+                        "in": "query",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "$ref": "#/definitions/models.HsbyPreGoodsDetail"
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/HSBY/QueryHsbyPreGoodses": {
             "get": {
                 "security": [
@@ -3916,6 +3955,105 @@
                 }
             }
         },
+        "models.HsbyPreGoodsDetail": {
+            "type": "object",
+            "required": [
+                "goodscode",
+                "goodsid",
+                "goodsname",
+                "marketid"
+            ],
+            "properties": {
+                "currency": {
+                    "description": "货币",
+                    "type": "string"
+                },
+                "currencysign": {
+                    "description": "货币符号",
+                    "type": "string"
+                },
+                "decimalplace": {
+                    "description": "报价小数位",
+                    "type": "integer"
+                },
+                "desccityid": {
+                    "description": "目的地(市)ID",
+                    "type": "integer"
+                },
+                "descprovinceid": {
+                    "description": "目的地(省)ID",
+                    "type": "integer"
+                },
+                "endtime": {
+                    "description": "预售结束时间",
+                    "type": "string"
+                },
+                "goodscode": {
+                    "description": "商品代码(内部)",
+                    "type": "string"
+                },
+                "goodsdesc": {
+                    "description": "商品详情",
+                    "type": "string"
+                },
+                "goodsid": {
+                    "description": "商品ID(自增ID SEQ_GOODS)",
+                    "type": "integer"
+                },
+                "goodsname": {
+                    "description": "商品名称",
+                    "type": "string"
+                },
+                "goodsstatus": {
+                    "description": "商品状态- 2:未上市 3:上市",
+                    "type": "integer"
+                },
+                "goodunit": {
+                    "description": "报价单位",
+                    "type": "string"
+                },
+                "marketid": {
+                    "description": "所属市场ID",
+                    "type": "integer"
+                },
+                "picurls": {
+                    "description": "介绍图片[多张用逗号分隔]",
+                    "type": "string"
+                },
+                "presaleqty": {
+                    "description": "预售数量",
+                    "type": "integer"
+                },
+                "refprice": {
+                    "description": "参考价格[一口价]",
+                    "type": "number"
+                },
+                "relatedgoodsid": {
+                    "description": "关联交易合约ID",
+                    "type": "integer"
+                },
+                "starttime": {
+                    "description": "预售开始时间",
+                    "type": "string"
+                },
+                "vendorattr": {
+                    "description": "供应商附件(多张,逗号分隔)",
+                    "type": "string"
+                },
+                "vendorname": {
+                    "description": "供应商名称",
+                    "type": "string"
+                },
+                "vendorphone": {
+                    "description": "供应商客服电话",
+                    "type": "string"
+                },
+                "videourls": {
+                    "description": "介绍视频[多张用逗号分隔]",
+                    "type": "string"
+                }
+            }
+        },
         "models.HsbyTopGoods": {
             "type": "object",
             "required": [

+ 99 - 2
docs/swagger.yaml

@@ -1429,6 +1429,80 @@ definitions:
     - goodsname
     - marketid
     type: object
+  models.HsbyPreGoodsDetail:
+    properties:
+      currency:
+        description: 货币
+        type: string
+      currencysign:
+        description: 货币符号
+        type: string
+      decimalplace:
+        description: 报价小数位
+        type: integer
+      desccityid:
+        description: 目的地(市)ID
+        type: integer
+      descprovinceid:
+        description: 目的地(省)ID
+        type: integer
+      endtime:
+        description: 预售结束时间
+        type: string
+      goodscode:
+        description: 商品代码(内部)
+        type: string
+      goodsdesc:
+        description: 商品详情
+        type: string
+      goodsid:
+        description: 商品ID(自增ID SEQ_GOODS)
+        type: integer
+      goodsname:
+        description: 商品名称
+        type: string
+      goodsstatus:
+        description: 商品状态- 2:未上市 3:上市
+        type: integer
+      goodunit:
+        description: 报价单位
+        type: string
+      marketid:
+        description: 所属市场ID
+        type: integer
+      picurls:
+        description: 介绍图片[多张用逗号分隔]
+        type: string
+      presaleqty:
+        description: 预售数量
+        type: integer
+      refprice:
+        description: 参考价格[一口价]
+        type: number
+      relatedgoodsid:
+        description: 关联交易合约ID
+        type: integer
+      starttime:
+        description: 预售开始时间
+        type: string
+      vendorattr:
+        description: 供应商附件(多张,逗号分隔)
+        type: string
+      vendorname:
+        description: 供应商名称
+        type: string
+      vendorphone:
+        description: 供应商客服电话
+        type: string
+      videourls:
+        description: 介绍视频[多张用逗号分隔]
+        type: string
+    required:
+    - goodscode
+    - goodsid
+    - goodsname
+    - marketid
+    type: object
   models.HsbyTopGoods:
     properties:
       currency:
@@ -3704,8 +3778,7 @@ paths:
       - 风险管理
   /HSBY/QueryHsbyGoodsOrderDetails:
     get:
-      description: 说明:查询结果已按委托价格和委托时间排序; sellOrderDetails - 转让(卖出)单,buyOrderDetails
-        - 求购(买入)单
+      description: 说明:查询结果已按委托价格和委托时间排序
       parameters:
       - description: 商品ID
         in: query
@@ -3817,6 +3890,30 @@ paths:
       summary: 查询“我的商品”信息
       tags:
       - 定制【海商报业】
+  /HSBY/QueryHsbyPreGoodsDetail:
+    get:
+      parameters:
+      - description: 商品ID
+        in: query
+        name: goodsID
+        required: true
+        type: integer
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            $ref: '#/definitions/models.HsbyPreGoodsDetail'
+        "500":
+          description: Internal Server Error
+          schema:
+            $ref: '#/definitions/app.Response'
+      security:
+      - ApiKeyAuth: []
+      summary: 查询一级市场(产能预售)商品信息详情
+      tags:
+      - 定制【海商报业】
   /HSBY/QueryHsbyPreGoodses:
     get:
       description: 说明:结果已先显示已开始商品(按结束时间顺序排),再显示未开始商品(按开始时间顺序排)

+ 13 - 24
models/hsby.go

@@ -533,6 +533,7 @@ type HsbyPreGoodsDetail struct {
 
 	Currency     string `json:"currency" xorm:"'CURRENCY'"`         // 货币
 	Currencysign string `json:"currencysign" xorm:"'CURRENCYSIGN'"` // 货币符号
+	Goodunit     string `json:"goodunit"  xorm:"GOODUNIT"`          // 报价单位
 
 	Vendorname  string `json:"vendorname"  xorm:"'VENDORNAME'"`   // 供应商名称
 	Vendorphone string `json:"vendorphone"  xorm:"'VENDORPHONE'"` // 供应商客服电话
@@ -543,19 +544,24 @@ type HsbyPreGoodsDetail struct {
 // 参数 goodsID int 目标商品ID
 // 返回 *HsbyListingGoodsDetail 二级市场(挂牌点选)商品信息详情,查询无结果返回nil
 // 返回 error error
-func GetHsbyPreGoodsDetail(goodsID int) (*HsbyListingGoodsDetail, error) {
+func GetHsbyPreGoodsDetail(goodsID int) (*HsbyPreGoodsDetail, error) {
 	engine := db.GetEngine()
 
-	details := make([]HsbyListingGoodsDetail, 0)
+	details := make([]HsbyPreGoodsDetail, 0)
 	// 获取挂牌商品信息,以及扩展表信息
 	// FIXME: - 这里使用Get方法,会造成SQL语句的嵌套出错,后期再研究
 	session := engine.Table("GOODS").
-		Select(`GOODS.GOODSID, GOODS.GOODSCODE, GOODS.GOODSNAME, GOODS.DECIMALPLACE, GOODS.MARKETID,
-				HSBY_GOODSEX.HOTINDEX, HSBY_GOODSEX.VIDEOURLS, HSBY_GOODSEX.PICURLS, HSBY_GOODSEX.DESCPROVINCEID, HSBY_GOODSEX.Desccityid, HSBY_GOODSEX.Goodsdesc,
+		Select(`GOODS.*, 
+				CPTRADE_PRESALEGOODSEX.RELATEDGOODSID, CPTRADE_PRESALEGOODSEX.PRESALEQTY, 
+				CPTRADE_PRESALEGOODSEX.STARTTIME, CPTRADE_PRESALEGOODSEX.ENDTIME, CPTRADE_PRESALEGOODSEX.REFPRICE, 
+				HSBY_GOODSEX.VIDEOURLS, HSBY_GOODSEX.PICURLS, HSBY_GOODSEX.DESCPROVINCEID, HSBY_GOODSEX.Desccityid, HSBY_GOODSEX.Goodsdesc,
 				ENUMDICITEM.ENUMDICNAME CURRENCY, ENUMDICITEM.PARAM2 CURRENCYSIGN, 
+				E1.ENUMDICNAME GOODUNIT, 
 				HSBY_SUPPLIERINFO.VENDORNAME, HSBY_SUPPLIERINFO.VENDORPHONE, HSBY_SUPPLIERINFO.VENDORATTR`).
-		Join("LEFT", "HSBY_GOODSEX", "HSBY_GOODSEX.GOODSID = GOODS.GOODSID").
+		Join("INNER", "CPTRADE_PRESALEGOODSEX", "CPTRADE_PRESALEGOODSEX.GOODSID = GOODS.GOODSID").
+		Join("LEFT", "HSBY_GOODSEX", "HSBY_GOODSEX.GOODSID = CPTRADE_PRESALEGOODSEX.RELATEDGOODSID").
 		Join("LEFT", "ENUMDICITEM", "ENUMDICITEM.ENUMITEMNAME = GOODS.CURRENCYID and ENUMDICITEM.ENUMDICCODE = 'currency'").
+		Join("LEFT", "ENUMDICITEM E1", "E1.ENUMITEMNAME = GOODS.GOODUNITID and E1.ENUMDICCODE = 'goodsunit'").
 		Join("LEFT", "HSBY_SUPPLIERINFO", "HSBY_SUPPLIERINFO.VENDORID = HSBY_GOODSEX.VENDORID").
 		Where("GOODS.GOODSID = ?", goodsID)
 	if err := session.Find(&details); err != nil {
@@ -565,24 +571,7 @@ func GetHsbyPreGoodsDetail(goodsID int) (*HsbyListingGoodsDetail, error) {
 	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))
-		}
-		if quoteDays[0].Limitup != 0 {
-			hsbyListingGoodsDetail.Limitup = utils.IntToFloat64(int(quoteDays[0].Limitup), int(hsbyListingGoodsDetail.Decimalplace))
-		}
-		if quoteDays[0].Limitdown != 0 {
-			hsbyListingGoodsDetail.Limitdown = utils.IntToFloat64(int(quoteDays[0].Limitdown), int(hsbyListingGoodsDetail.Decimalplace))
-		}
-	}
+	preGoodsDetail := details[0]
 
-	return &hsbyListingGoodsDetail, nil
+	return &preGoodsDetail, nil
 }

+ 2 - 0
routers/router.go

@@ -174,6 +174,8 @@ func InitRouter() *gin.Engine {
 		hsbyR.GET("/QueryHsbyMyGoods", hsby.QueryHsbyMyGoods)
 		// 查询新品上市商品列表(一级市场产能预售)
 		hsbyR.GET("/QueryHsbyPreGoodses", hsby.QueryHsbyPreGoodses)
+		// 查询一级市场(产能预售)商品信息详情
+		hsbyR.GET("/QueryHsbyPreGoodsDetail", hsby.QueryHsbyPreGoodsDetail)
 	}
 
 	return r