Przeglądaj źródła

海商游客功能

zhou.xiaoning 5 lat temu
rodzic
commit
73c08ea54c
8 zmienionych plików z 334 dodań i 65 usunięć
  1. 41 14
      controllers/hsby/hsby.go
  2. 54 11
      docs/docs.go
  3. 54 11
      docs/swagger.json
  4. 36 9
      docs/swagger.yaml
  5. 46 17
      models/hsby.go
  6. 12 0
      playground/main.go
  7. 5 3
      routers/router.go
  8. 86 0
      token/token.go

+ 41 - 14
controllers/hsby/hsby.go

@@ -159,7 +159,7 @@ func QueryHsbyListingGoodsDetail(c *gin.Context) {
 // QueryHsbyGoodsOrderDetailsReq 查询二级市场(挂牌点选)商品对应的挂牌委托单信息请求参数
 type QueryHsbyGoodsOrderDetailsReq struct {
 	GoodsID    int     `form:"goodsID" binding:"required"`
-	AccountIDs string  `form:"accountIDs" binding:"required"`
+	AccountIDs string  `form:"accountIDs"`
 	BuyOrSell  int     `form:"buyOrSell"`
 	Price      float64 `form:"price"`
 	Speed      int     `form:"speed"`
@@ -171,7 +171,7 @@ type QueryHsbyGoodsOrderDetailsReq struct {
 // @Produce json
 // @Security ApiKeyAuth
 // @Param goodsID query int true "商品ID"
-// @Param accountIDs query string true "摘牌方资金账户列表,格式:1,2,3。主要用于过滤自己的挂牌单"
+// @Param accountIDs query string false "摘牌方资金账户列表,格式:1,2,3。主要用于过滤自己的挂牌单"
 // @Param buyOrSell query int false "挂牌委托单方向(对手单方向),0:买 1:卖"
 // @Param price query number false " 参考价格。对手单买方向委托单则价格大于等于(站在摘牌人的角度,摘牌方面是卖,我的闲置下单);对手单卖方向委托单则价格小于等于(站在摘牌人的角度,摘牌方面是买,热门商品下单)"
 // @Param speed query int false "档位,不传则默认为3档"
@@ -333,8 +333,8 @@ type QueryHsbyPreGoodsesReq struct {
 	DescCityID     int    `form:"descCityID"`
 }
 
-// QueryHsbyPreGoodses 查询新品上市商品列表(一级市场产能预售)
-// @Summary 查询新品上市商品列表(一级市场产能预售)
+// QueryHsbyPreGoodses 查询新品上市商品列表(一级市场预售)
+// @Summary 查询新品上市商品列表(一级市场预售)
 // @Description 说明:结果已先显示已开始商品(按结束时间顺序排),再显示未开始商品(按开始时间顺序排)
 // @Produce json
 // @Security ApiKeyAuth
@@ -415,18 +415,18 @@ func QueryHsbyPreGoodses(c *gin.Context) {
 	}
 }
 
-// QueryHsbyPreGoodsDetailReq 查询一级市场(产能预售)商品信息详情请求参数
+// QueryHsbyPreGoodsDetailReq 查询一级市场(预售)商品信息详情请求参数
 type QueryHsbyPreGoodsDetailReq struct {
 	GoodsID   int `form:"goodsID" binding:"required"`
-	AccountID int `form:"accountID" binding:"required"`
+	AccountID int `form:"accountID"`
 }
 
-// QueryHsbyPreGoodsDetail 查询一级市场(产能预售)商品信息详情
-// @Summary 查询一级市场(产能预售)商品信息详情
+// QueryHsbyPreGoodsDetail 查询一级市场(预售)商品信息详情
+// @Summary 查询一级市场(预售)商品信息详情
 // @Produce json
 // @Security ApiKeyAuth
 // @Param goodsID query int true "商品ID"
-// @Param accountID query int true "资金账户,主要用于获取预售商品购买上限"
+// @Param accountID query int false "资金账户,主要用于获取预售商品购买上限"
 // @Success 200 {object} models.HsbyPreGoodsDetail
 // @Failure 500 {object} app.Response
 // @Router /HSBY/QueryHsbyPreGoodsDetail [get]
@@ -465,13 +465,13 @@ type QueryHsbySellMyDetailReq struct {
 
 // QueryHsbySellMyDetails 查询"我的闲置"单据信息
 // @Summary 查询"我的闲置"单据信息
-// @Description 说明:发布 - 二级市场卖挂,3:委托成功、7:部分成交; 已完成 - 二级市场成交单,包括历史数据。查询结果已按时间从近到远排序
+// @Description 说明:发布 - 二级市场卖挂,3:委托成功、7:部分成交; 已完成 - 二级市场成交单,包括历史数据。查询结果已按时间从近到远排序
 // @Produce json
 // @Security ApiKeyAuth
 // @Param page query int false "页码"
 // @Param pagesize query int false "每页条数"
 // @Param accountIDs query string true "资金账户列表,格式:1,2,3"
-// @Param orderType query int false "单据类型:0 - 发布(默认), 1 - 已完成"
+// @Param orderType query int false "单据类型:0 - 发布(默认), 1 - 已完成"
 // @Success 200 {object} models.HsbySellMyDetail
 // @Failure 500 {object} app.Response
 // @Router /HSBY/QueryHsbySellMyDetails [get]
@@ -490,7 +490,7 @@ func QueryHsbySellMyDetails(c *gin.Context) {
 	// 获取数据
 	var orders []models.HsbySellMyDetail
 	if req.OrderType == 0 {
-		// 发布
+		// 发布
 		var err error
 		orders, err = models.GetHsbySellMyOrderDetails(req.AccountIDs)
 		if err != nil {
@@ -855,6 +855,7 @@ func GetHsbyMyCount(c *gin.Context) {
 // QueryTradePayOrdersReq 待付款信息查询请求参数
 type QueryTradePayOrdersReq struct {
 	app.PageInfo
+	PayFlag       string `form:"payFlag" binding:"required"`
 	AccountIDs    string `form:"accountIDs"`
 	SellOrderID   int    `form:"sellOrderID"`
 	SellAccountID int    `form:"sellAccountID"`
@@ -862,11 +863,12 @@ type QueryTradePayOrdersReq struct {
 
 // QueryTradePayOrders 获取待付款信息
 // @Summary 获取待付款信息
-// @Description 说明:"我的订单-待付款"请传入accountIDs;"我的闲置-待收款"请传入sellOrderID和sellAccountID。
+// @Description 说明:"我的订单-待付款"请传入accountIDs,同时payFlag传入1;"我的闲置-待收款"请传入sellOrderID和sellAccountID,同时payFlag传入1,2
 // @Produce json
 // @Security ApiKeyAuth
 // @Param page query int false "页码"
 // @Param pagesize query int false "每页条数"
+// @Param payFlag query string true "付款标识 - 1:未支付 2:已支付 3:已过期 4:已撤销 5:结算过期,格式:1,2,3"
 // @Param accountIDs query string false "资金账户列表,格式:1,2,3"
 // @Param sellOrderID query int false "卖方委托单号"
 // @Param sellAccountID query int false "卖方账号ID[报价币种]"
@@ -891,7 +893,7 @@ func QueryTradePayOrders(c *gin.Context) {
 	}
 
 	// 获取数据
-	orders, err := models.GetHsbyBuyMyPayOrders(req.AccountIDs, req.SellOrderID, req.SellAccountID)
+	orders, err := models.GetHsbyBuyMyPayOrders(req.AccountIDs, req.PayFlag, req.SellOrderID, req.SellAccountID)
 	if err != nil {
 		// 查询失败
 		logger.GetLogger().Errorf("QueryTradePayOrders failed: %s", err.Error())
@@ -935,3 +937,28 @@ func QueryTradePayOrders(c *gin.Context) {
 		appG.Response(http.StatusOK, e.SUCCESS, orders)
 	}
 }
+
+// QueryHsbyMarkets 查询海商报业相关市场信息
+// @Summary 查询海商报业相关市场信息
+// @Produce json
+// @Security ApiKeyAuth
+// @Success 200 {object} models.HsbyMyGoods
+// @Failure 500 {object} app.Response
+// @Router /HSBY/QueryHsbyMarkets [get]
+// @Tags 定制【海商报业】
+func QueryHsbyMarkets(c *gin.Context) {
+	appG := app.Gin{C: c}
+
+	// 获取数据
+	markets, err := models.GetHsbyMarketInfos()
+	if err != nil {
+		// 查询失败
+		logger.GetLogger().Errorf("QueryHsbyMarkets failed: %s", err.Error())
+		appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
+		return
+	}
+
+	// 查询成功返回
+	logger.GetLogger().Debugln("QueryHsbyMarkets successed: %v", markets)
+	appG.Response(http.StatusOK, e.SUCCESS, markets)
+}

+ 54 - 11
docs/docs.go

@@ -1445,8 +1445,7 @@ var doc = `{
                         "type": "string",
                         "description": "摘牌方资金账户列表,格式:1,2,3。主要用于过滤自己的挂牌单",
                         "name": "accountIDs",
-                        "in": "query",
-                        "required": true
+                        "in": "query"
                     },
                     {
                         "type": "integer",
@@ -1528,6 +1527,36 @@ var doc = `{
                 }
             }
         },
+        "/HSBY/QueryHsbyMarkets": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "定制【海商报业】"
+                ],
+                "summary": "查询海商报业相关市场信息",
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "$ref": "#/definitions/models.HsbyMyGoods"
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/HSBY/QueryHsbyMyBuyOrderDetails": {
             "get": {
                 "security": [
@@ -1671,7 +1700,7 @@ var doc = `{
                 "tags": [
                     "定制【海商报业】"
                 ],
-                "summary": "查询一级市场(产能预售)商品信息详情",
+                "summary": "查询一级市场(预售)商品信息详情",
                 "parameters": [
                     {
                         "type": "integer",
@@ -1684,8 +1713,7 @@ var doc = `{
                         "type": "integer",
                         "description": "资金账户,主要用于获取预售商品购买上限",
                         "name": "accountID",
-                        "in": "query",
-                        "required": true
+                        "in": "query"
                     }
                 ],
                 "responses": {
@@ -1718,7 +1746,7 @@ var doc = `{
                 "tags": [
                     "定制【海商报业】"
                 ],
-                "summary": "查询新品上市商品列表(一级市场产能预售)",
+                "summary": "查询新品上市商品列表(一级市场预售)",
                 "parameters": [
                     {
                         "type": "integer",
@@ -1775,7 +1803,7 @@ var doc = `{
                         "ApiKeyAuth": []
                     }
                 ],
-                "description": "说明:发布 - 二级市场卖挂,3:委托成功、7:部分成交; 已完成 - 二级市场成交单,包括历史数据。查询结果已按时间从近到远排序",
+                "description": "说明:发布 - 二级市场卖挂,3:委托成功、7:部分成交; 已完成 - 二级市场成交单,包括历史数据。查询结果已按时间从近到远排序",
                 "produces": [
                     "application/json"
                 ],
@@ -1805,7 +1833,7 @@ var doc = `{
                     },
                     {
                         "type": "integer",
-                        "description": "单据类型:0 - 发布(默认), 1 - 已完成",
+                        "description": "单据类型:0 - 发布(默认), 1 - 已完成",
                         "name": "orderType",
                         "in": "query"
                     }
@@ -1936,7 +1964,7 @@ var doc = `{
                         "ApiKeyAuth": []
                     }
                 ],
-                "description": "说明:\"我的订单-待付款\"请传入accountIDs;\"我的闲置-待收款\"请传入sellOrderID和sellAccountID。",
+                "description": "说明:\"我的订单-待付款\"请传入accountIDs,同时payFlag传入1;\"我的闲置-待收款\"请传入sellOrderID和sellAccountID,同时payFlag传入1,2。",
                 "produces": [
                     "application/json"
                 ],
@@ -1959,6 +1987,13 @@ var doc = `{
                     },
                     {
                         "type": "string",
+                        "description": "付款标识 - 1:未支付 2:已支付 3:已过期 4:已撤销 5:结算过期,格式:1,2,3",
+                        "name": "payFlag",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "string",
                         "description": "资金账户列表,格式:1,2,3",
                         "name": "accountIDs",
                         "in": "query"
@@ -7093,11 +7128,15 @@ var doc = `{
                     "type": "integer"
                 },
                 "orderid": {
-                    "description": "单号(发布 - 委托单号;已完成 - 成交单号)",
+                    "description": "单号(发布 - 委托单号;已完成 - 成交单号)",
                     "type": "string"
                 },
                 "ordertype": {
-                    "description": "单据类型:0 - 已发布, 1 - 已完成",
+                    "description": "单据类型:0 - 发布中, 1 - 已完成",
+                    "type": "integer"
+                },
+                "payedcount": {
+                    "description": "已付款数量",
                     "type": "integer"
                 },
                 "picurls": {
@@ -7120,6 +7159,10 @@ var doc = `{
                     "description": "交易模式 - 10:做市 13:竞价 15:通道交易 16:挂牌点选 17:仓单贸易 18:期权 19:竞拍-降价式 20:竞拍-竞价式 21:竞拍-大宗式 22:受托竞价",
                     "type": "integer"
                 },
+                "unPayCount": {
+                    "description": "待付款数量",
+                    "type": "integer"
+                },
                 "vendorname": {
                     "description": "供应商名称",
                     "type": "string"

+ 54 - 11
docs/swagger.json

@@ -1429,8 +1429,7 @@
                         "type": "string",
                         "description": "摘牌方资金账户列表,格式:1,2,3。主要用于过滤自己的挂牌单",
                         "name": "accountIDs",
-                        "in": "query",
-                        "required": true
+                        "in": "query"
                     },
                     {
                         "type": "integer",
@@ -1512,6 +1511,36 @@
                 }
             }
         },
+        "/HSBY/QueryHsbyMarkets": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "定制【海商报业】"
+                ],
+                "summary": "查询海商报业相关市场信息",
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "$ref": "#/definitions/models.HsbyMyGoods"
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/HSBY/QueryHsbyMyBuyOrderDetails": {
             "get": {
                 "security": [
@@ -1655,7 +1684,7 @@
                 "tags": [
                     "定制【海商报业】"
                 ],
-                "summary": "查询一级市场(产能预售)商品信息详情",
+                "summary": "查询一级市场(预售)商品信息详情",
                 "parameters": [
                     {
                         "type": "integer",
@@ -1668,8 +1697,7 @@
                         "type": "integer",
                         "description": "资金账户,主要用于获取预售商品购买上限",
                         "name": "accountID",
-                        "in": "query",
-                        "required": true
+                        "in": "query"
                     }
                 ],
                 "responses": {
@@ -1702,7 +1730,7 @@
                 "tags": [
                     "定制【海商报业】"
                 ],
-                "summary": "查询新品上市商品列表(一级市场产能预售)",
+                "summary": "查询新品上市商品列表(一级市场预售)",
                 "parameters": [
                     {
                         "type": "integer",
@@ -1759,7 +1787,7 @@
                         "ApiKeyAuth": []
                     }
                 ],
-                "description": "说明:发布 - 二级市场卖挂,3:委托成功、7:部分成交; 已完成 - 二级市场成交单,包括历史数据。查询结果已按时间从近到远排序",
+                "description": "说明:发布 - 二级市场卖挂,3:委托成功、7:部分成交; 已完成 - 二级市场成交单,包括历史数据。查询结果已按时间从近到远排序",
                 "produces": [
                     "application/json"
                 ],
@@ -1789,7 +1817,7 @@
                     },
                     {
                         "type": "integer",
-                        "description": "单据类型:0 - 发布(默认), 1 - 已完成",
+                        "description": "单据类型:0 - 发布(默认), 1 - 已完成",
                         "name": "orderType",
                         "in": "query"
                     }
@@ -1920,7 +1948,7 @@
                         "ApiKeyAuth": []
                     }
                 ],
-                "description": "说明:\"我的订单-待付款\"请传入accountIDs;\"我的闲置-待收款\"请传入sellOrderID和sellAccountID。",
+                "description": "说明:\"我的订单-待付款\"请传入accountIDs,同时payFlag传入1;\"我的闲置-待收款\"请传入sellOrderID和sellAccountID,同时payFlag传入1,2。",
                 "produces": [
                     "application/json"
                 ],
@@ -1943,6 +1971,13 @@
                     },
                     {
                         "type": "string",
+                        "description": "付款标识 - 1:未支付 2:已支付 3:已过期 4:已撤销 5:结算过期,格式:1,2,3",
+                        "name": "payFlag",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "string",
                         "description": "资金账户列表,格式:1,2,3",
                         "name": "accountIDs",
                         "in": "query"
@@ -7077,11 +7112,15 @@
                     "type": "integer"
                 },
                 "orderid": {
-                    "description": "单号(发布 - 委托单号;已完成 - 成交单号)",
+                    "description": "单号(发布 - 委托单号;已完成 - 成交单号)",
                     "type": "string"
                 },
                 "ordertype": {
-                    "description": "单据类型:0 - 已发布, 1 - 已完成",
+                    "description": "单据类型:0 - 发布中, 1 - 已完成",
+                    "type": "integer"
+                },
+                "payedcount": {
+                    "description": "已付款数量",
                     "type": "integer"
                 },
                 "picurls": {
@@ -7104,6 +7143,10 @@
                     "description": "交易模式 - 10:做市 13:竞价 15:通道交易 16:挂牌点选 17:仓单贸易 18:期权 19:竞拍-降价式 20:竞拍-竞价式 21:竞拍-大宗式 22:受托竞价",
                     "type": "integer"
                 },
+                "unPayCount": {
+                    "description": "待付款数量",
+                    "type": "integer"
+                },
                 "vendorname": {
                     "description": "供应商名称",
                     "type": "string"

+ 36 - 9
docs/swagger.yaml

@@ -2728,10 +2728,13 @@ definitions:
         description: 市场ID
         type: integer
       orderid:
-        description: 单号(发布 - 委托单号;已完成 - 成交单号)
+        description: 单号(发布 - 委托单号;已完成 - 成交单号)
         type: string
       ordertype:
-        description: 单据类型:0 - 已发布, 1 - 已完成
+        description: 单据类型:0 - 发布中, 1 - 已完成
+        type: integer
+      payedcount:
+        description: 已付款数量
         type: integer
       picurls:
         description: 介绍图片[多张用逗号分隔]
@@ -2749,6 +2752,9 @@ definitions:
         description: 交易模式 - 10:做市 13:竞价 15:通道交易 16:挂牌点选 17:仓单贸易 18:期权 19:竞拍-降价式 20:竞拍-竞价式
           21:竞拍-大宗式 22:受托竞价
         type: integer
+      unPayCount:
+        description: 待付款数量
+        type: integer
       vendorname:
         description: 供应商名称
         type: string
@@ -5810,7 +5816,6 @@ paths:
       - description: 摘牌方资金账户列表,格式:1,2,3。主要用于过滤自己的挂牌单
         in: query
         name: accountIDs
-        required: true
         type: string
       - description: 挂牌委托单方向(对手单方向),0:买 1:卖
         in: query
@@ -5868,6 +5873,24 @@ paths:
       summary: 查询二级市场(挂牌点选)商品信息详情
       tags:
       - 定制【海商报业】
+  /HSBY/QueryHsbyMarkets:
+    get:
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            $ref: '#/definitions/models.HsbyMyGoods'
+        "500":
+          description: Internal Server Error
+          schema:
+            $ref: '#/definitions/app.Response'
+      security:
+      - ApiKeyAuth: []
+      summary: 查询海商报业相关市场信息
+      tags:
+      - 定制【海商报业】
   /HSBY/QueryHsbyMyBuyOrderDetails:
     get:
       description: 说明: 全部:一二级市场买委托;抢购中:一级市场买摘; 求购中:二级市场买挂; 3:已完成:一二级市场已完成买委托;
@@ -5960,7 +5983,6 @@ paths:
       - description: 资金账户,主要用于获取预售商品购买上限
         in: query
         name: accountID
-        required: true
         type: integer
       produces:
       - application/json
@@ -5975,7 +5997,7 @@ paths:
             $ref: '#/definitions/app.Response'
       security:
       - ApiKeyAuth: []
-      summary: 查询一级市场(产能预售)商品信息详情
+      summary: 查询一级市场(预售)商品信息详情
       tags:
       - 定制【海商报业】
   /HSBY/QueryHsbyPreGoodses:
@@ -6016,12 +6038,12 @@ paths:
             $ref: '#/definitions/app.Response'
       security:
       - ApiKeyAuth: []
-      summary: 查询新品上市商品列表(一级市场产能预售)
+      summary: 查询新品上市商品列表(一级市场预售)
       tags:
       - 定制【海商报业】
   /HSBY/QueryHsbySellMyDetails:
     get:
-      description: 说明:发布 - 二级市场卖挂,3:委托成功、7:部分成交; 已完成 - 二级市场成交单,包括历史数据。查询结果已按时间从近到远排序
+      description: 说明:发布 - 二级市场卖挂,3:委托成功、7:部分成交; 已完成 - 二级市场成交单,包括历史数据。查询结果已按时间从近到远排序
       parameters:
       - description: 页码
         in: query
@@ -6036,7 +6058,7 @@ paths:
         name: accountIDs
         required: true
         type: string
-      - description: 单据类型:0 - 发布(默认), 1 - 已完成
+      - description: 单据类型:0 - 发布(默认), 1 - 已完成
         in: query
         name: orderType
         type: integer
@@ -6123,7 +6145,7 @@ paths:
       - 定制【海商报业】
   /HSBY/QueryTradePayOrders:
     get:
-      description: 说明:"我的订单-待付款"请传入accountIDs;"我的闲置-待收款"请传入sellOrderID和sellAccountID。
+      description: 说明:"我的订单-待付款"请传入accountIDs,同时payFlag传入1;"我的闲置-待收款"请传入sellOrderID和sellAccountID,同时payFlag传入1,2
       parameters:
       - description: 页码
         in: query
@@ -6133,6 +6155,11 @@ paths:
         in: query
         name: pagesize
         type: integer
+      - description: 付款标识 - 1:未支付 2:已支付 3:已过期 4:已撤销 5:结算过期,格式:1,2,3
+        in: query
+        name: payFlag
+        required: true
+        type: string
       - description: 资金账户列表,格式:1,2,3
         in: query
         name: accountIDs

+ 46 - 17
models/hsby.go

@@ -299,8 +299,10 @@ func GetHsbyGoodsOrderDetails(goodsID, buyOrSell int, price float64, accountIDs
 		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)").
 		And("TRADE_ORDERDETAIL.GOODSID = ?", goodsID).
-		And("TRADE_ORDERDETAIL.BUYORSELL = ?", buyOrSell).
-		And(fmt.Sprintf("TRADE_ORDERDETAIL.ACCOUNTID not in (%s)", accountIDs))
+		And("TRADE_ORDERDETAIL.BUYORSELL = ?", buyOrSell)
+	if len(accountIDs) > 0 {
+		session = session.And(fmt.Sprintf("TRADE_ORDERDETAIL.ACCOUNTID not in (%s)", accountIDs))
+	}
 	if price > 0 {
 		if buyOrSell == 0 {
 			// 对手单买方向委托单则价格大于等于(站在摘牌人的角度,摘牌方面是卖,我的闲置下单)
@@ -710,18 +712,20 @@ func GetHsbyPreGoodsDetail(goodsID, accountID int) (*HsbyPreGoodsDetail, error)
 	preGoodsDetail.LotSize = 1
 
 	// 获取购买上限
-	buyMaxQty, err := GetCPTradeBuyLimit(goodsID, accountID)
-	if err != nil {
-		return nil, err
+	if accountID != 0 {
+		buyMaxQty, err := GetCPTradeBuyLimit(goodsID, accountID)
+		if err != nil {
+			return nil, err
+		}
+		preGoodsDetail.Buymaxqty = buyMaxQty
 	}
-	preGoodsDetail.Buymaxqty = buyMaxQty
 
 	return &preGoodsDetail, nil
 }
 
-// HsbySellMyDetail "我的闲置"单据信息(发布 - 二级市场卖挂,3:委托成功、7:部分成交; 已完成 - 二级市场成交单,包括历史数据)
+// HsbySellMyDetail "我的闲置"单据信息(发布 - 二级市场卖挂,3:委托成功、7:部分成交; 已完成 - 二级市场成交单,包括历史数据)
 type HsbySellMyDetail struct {
-	Orderid   string    `json:"orderid"  xorm:"'ORDERID'" binding:"required"`     // 单号(发布 - 委托单号;已完成 - 成交单号)
+	Orderid   string    `json:"orderid"  xorm:"'ORDERID'" binding:"required"`     // 单号(发布 - 委托单号;已完成 - 成交单号)
 	Marketid  int32     `json:"marketid"  xorm:"'MARKETID'" binding:"required"`   // 市场ID
 	Goodsid   int32     `json:"goodsid"  xorm:"'GOODSID'" binding:"required"`     // 商品ID
 	Accountid int64     `json:"accountid"  xorm:"'ACCOUNTID'" binding:"required"` // 账户ID[报价币种]
@@ -744,12 +748,15 @@ type HsbySellMyDetail struct {
 
 	Vendorname string `json:"vendorname"  xorm:"'VENDORNAME'"` // 供应商名称
 
-	OrderType int32 `json:"ordertype" xorm:"'ORDERTYPE'"` // 单据类型:0 - 已发布, 1 - 已完成
+	OrderType int32 `json:"ordertype" xorm:"'ORDERTYPE'"` // 单据类型:0 - 发布中, 1 - 已完成
+
+	PayedCount int `json:"payedcount" xorm:"PAYEDCOUNT"` // 已付款数量
+	UnPayCount int `json:"unPayCount" xorm:"UNPAYCOUNT"` // 待付款数量
 }
 
-// GetHsbySellMyOrderDetails 获取"我的闲置 - 已发布"单据信息
+// GetHsbySellMyOrderDetails 获取"我的闲置 - 发布"单据信息
 // 输入 accountIDs string 资金账户列表
-// 输出 []HsbySellMyDetail "我的闲置 - 发布"单据信息
+// 输出 []HsbySellMyDetail "我的闲置 - 发布"单据信息
 // 输出 error error
 func GetHsbySellMyOrderDetails(accountIDs string) ([]HsbySellMyDetail, error) {
 	// 获取市场信息
@@ -759,7 +766,7 @@ func GetHsbySellMyOrderDetails(accountIDs string) ([]HsbySellMyDetail, error) {
 	}
 
 	engine := db.GetEngine()
-	marketIDs := "" // 我的闲置-发布: 二级市场卖挂牌
+	marketIDs := "" // 我的闲置-发布: 二级市场卖挂牌
 	// 默认取 TradeMode = 16
 	for _, v := range markets {
 		if v.Trademode == 16 {
@@ -772,7 +779,7 @@ func GetHsbySellMyOrderDetails(accountIDs string) ([]HsbySellMyDetail, error) {
 	}
 
 	orderDetails := make([]HsbySellMyDetail, 0)
-	// “我的闲置 - 发布”都是卖挂委托
+	// “我的闲置 - 发布”都是卖挂委托
 	session := engine.Table("TRADE_ORDERDETAIL").
 		Select(`to_char(TRADE_ORDERDETAIL.ORDERID) ORDERID, 
 				TRADE_ORDERDETAIL.MARKETID, TRADE_ORDERDETAIL.GOODSID, TRADE_ORDERDETAIL.ACCOUNTID, TRADE_ORDERDETAIL.BUYORSELL,
@@ -783,12 +790,15 @@ func GetHsbySellMyOrderDetails(accountIDs string) ([]HsbySellMyDetail, error) {
 				MARKET.TRADEMODE, 
 				ENUMDICITEM.PARAM2 CURRENCYSIGN, 
 				HSBY_SUPPLIERINFO.VENDORNAME, 
-				0 ORDERTYPE`).
+				0 ORDERTYPE, 
+				(select count(TR1.*) from TRADE_PAYORDER TR1 where TR1.PAYFLAG = 2 and TR1.TRADEID = TD.TRADEID) PAYEDCOUNT, 
+				(select count(TR2.*) from TRADE_PAYORDER TR2 where TR2.PAYFLAG = 1 and TR2.TRADEID = TD.TRADEID) UNPAYCOUNT`).
 		Join("LEFT", "GOODS", "GOODS.GOODSID = TRADE_ORDERDETAIL.GOODSID").
 		Join("LEFT", "HSBY_GOODSEX", "HSBY_GOODSEX.GOODSID = GOODS.GOODSID").
 		Join("LEFT", "ENUMDICITEM", "GOODS.CURRENCYID = ENUMDICITEM.ENUMITEMNAME and ENUMDICITEM.ENUMDICCODE = 'currency'").
 		Join("LEFT", "MARKET", "MARKET.MARKETID = TRADE_ORDERDETAIL.MARKETID").
 		Join("LEFT", "HSBY_SUPPLIERINFO", "HSBY_SUPPLIERINFO.VENDORID = HSBY_GOODSEX.VENDORID").
+		Join("LEFT", "TRADE_TRADEDETAIL TD", "TD.ORDERID = TRADE_ORDERDETAIL.ORDERID").
 		Where(fmt.Sprintf(`TRADE_ORDERDETAIL.BUYORSELL = 1 and TRADE_ORDERDETAIL.LISTINGSELECTTYPE = 1 and (TRADE_ORDERDETAIL.ORDERSTATUS = 3 or TRADE_ORDERDETAIL.ORDERSTATUS = 7) 
 						   and TRADE_ORDERDETAIL.ACCOUNTID in (%s)`, accountIDs)).
 		And(fmt.Sprintf("TRADE_ORDERDETAIL.MARKETID in (%s)", marketIDs))
@@ -811,7 +821,7 @@ func GetHsbySellMyTradeDetails(accountIDs string) ([]HsbySellMyDetail, error) {
 	}
 
 	engine := db.GetEngine()
-	marketIDs := "" // 我的闲置-发布: 二级市场卖方向成交单(包括历史成交单)
+	marketIDs := "" // 我的闲置-发布: 二级市场卖方向成交单(包括历史成交单)
 	// 默认取 TradeMode = 16
 	for _, v := range markets {
 		if v.Trademode == 16 {
@@ -1145,7 +1155,7 @@ type HsbyBuyMyPayOrder struct {
 }
 
 // GetHsbyBuyMyPayOrders 获取待付款信息
-func GetHsbyBuyMyPayOrders(accountIDs string, sellOrderID, sellAccountID int) ([]HsbyBuyMyPayOrder, error) {
+func GetHsbyBuyMyPayOrders(accountIDs, payFlag string, sellOrderID, sellAccountID int) ([]HsbyBuyMyPayOrder, error) {
 	// 获取市场信息
 	markets, err := GetMarkets()
 	if err != nil {
@@ -1184,7 +1194,7 @@ func GetHsbyBuyMyPayOrders(accountIDs string, sellOrderID, sellAccountID int) ([
 		Join("LEFT", "MARKET", "MARKET.MARKETID = TRADE_TRADEDETAIL.MARKETID").
 		Join("LEFT", "HSBY_SUPPLIERINFO HS1", "HS1.VENDORID = HG1.VENDORID").
 		Join("LEFT", "HSBY_SUPPLIERINFO HS2", "HS2.VENDORID = HG2.VENDORID").
-		Join("INNER", "TRADE_PAYORDER TP", "TP.TRADEID = TRADE_TRADEDETAIL.TRADEID and TP.PAYFLAG = 1").
+		Join("INNER", "TRADE_PAYORDER TP", fmt.Sprintf("TP.TRADEID = TRADE_TRADEDETAIL.TRADEID and TP.PAYFLAG in (%s)", payFlag)).
 		Join("LEFT", "TAACCOUNT TA", "TA.ACCOUNTID = TP.BUYACCOUNTID").
 		Join("LEFT", "USERACCOUNT U", "U.USERID = TA.RELATEDUSERID").
 		Where(`TRADE_TRADEDETAIL.BUYORSELL = 0`).
@@ -1204,3 +1214,22 @@ func GetHsbyBuyMyPayOrders(accountIDs string, sellOrderID, sellAccountID int) ([
 
 	return orders, nil
 }
+
+// HsbyMarketInfo 海商报业相关市场信息
+type HsbyMarketInfo struct {
+	Marketid   int32  `json:"marketid"  xorm:"'MARKETID'" binding:"required"`   // 市场ID正常5位,前三位固定:两位表示交易模式, 一位表示交易属性(1:收益权,2:所有权) 其它特殊市场:0-系统 1-交割服务 2-账户服务3-履约服务 4-仓单服务 5-积分服务 6-银行服务
+	Marketname string `json:"marketname"  xorm:"'MARKETNAME'"`                  // 市场名称
+	Trademode  int32  `json:"trademode"  xorm:"'TRADEMODE'" binding:"required"` // 交易模式 - 10:做市 13:竞价 15:通道交易 16:挂牌点选 17:仓单贸易 18:期权 19:竞拍-降价式 20:竞拍-竞价式 21:竞拍-大宗式 22:受托竞价
+}
+
+// GetHsbyMarketInfos 获取海商报业相关市场信息
+func GetHsbyMarketInfos() ([]HsbyMarketInfo, error) {
+	engine := db.GetEngine()
+
+	markets := make([]HsbyMarketInfo, 0)
+	if err := engine.Table("MARKET").Where("TRADEMODE in (71,16,70)").Find(&markets); err != nil {
+		return nil, err
+	}
+
+	return markets, nil
+}

+ 12 - 0
playground/main.go

@@ -0,0 +1,12 @@
+package main
+
+import (
+	"encoding/hex"
+	"fmt"
+	"mtp2_if/utils"
+)
+
+func main() {
+	s, _ := utils.AESEncrypt([]byte("小曹是SB"), []byte(utils.AESSecretKey))
+	fmt.Println(hex.EncodeToString(s))
+}

+ 5 - 3
routers/router.go

@@ -228,7 +228,7 @@ func InitRouter() *gin.Engine {
 	}
 	// ************************ 定制【海商报业】 ************************
 	hsbyR := apiR.Group("HSBY")
-	hsbyR.Use(token.Auth())
+	hsbyR.Use(token.AuthByHsby())
 	{
 		// 查询热门商品列表(二级市场,挂牌点选)
 		hsbyR.GET("/QueryHsbyTopGoodses", hsby.QueryHsbyTopGoodses)
@@ -240,9 +240,9 @@ func InitRouter() *gin.Engine {
 		hsbyR.GET("/QueryHsbyMyBuyOrderDetails", hsby.QueryHsbyMyBuyOrderDetails)
 		// 查询“我的商品”信息
 		hsbyR.GET("/QueryHsbyMyGoods", hsby.QueryHsbyMyGoods)
-		// 查询新品上市商品列表(一级市场产能预售)
+		// 查询新品上市商品列表(一级市场预售)
 		hsbyR.GET("/QueryHsbyPreGoodses", hsby.QueryHsbyPreGoodses)
-		// 查询一级市场(产能预售)商品信息详情
+		// 查询一级市场(预售)商品信息详情
 		hsbyR.GET("/QueryHsbyPreGoodsDetail", hsby.QueryHsbyPreGoodsDetail)
 		// 查询"我的闲置"单据信息
 		hsbyR.GET("/QueryHsbySellMyDetails", hsby.QueryHsbySellMyDetails)
@@ -258,6 +258,8 @@ func InitRouter() *gin.Engine {
 		hsbyR.GET("/GetHsbyMyCount", hsby.GetHsbyMyCount)
 		// 获取待付款信息
 		hsbyR.GET("/QueryTradePayOrders", hsby.QueryTradePayOrders)
+		// 查询海商报业相关市场信息
+		hsbyR.GET("/QueryHsbyMarkets", hsby.QueryHsbyMarkets)
 	}
 
 	return r

+ 86 - 0
token/token.go

@@ -12,6 +12,9 @@ import (
 	"github.com/gin-gonic/gin"
 )
 
+// TouristToken 游客Token
+var TouristToken string = "c886a057f3d820d4dbc41473686c7c2d"
+
 // CheckToken Token校验
 func CheckToken(loginid string, token string) error {
 	key := fmt.Sprintf("monitor:online_loginid::%s", loginid)
@@ -73,3 +76,86 @@ func Auth() gin.HandlerFunc {
 		c.Next()
 	}
 }
+
+// AuthByHsby 游客鉴权
+func AuthByHsby() gin.HandlerFunc {
+	return func(c *gin.Context) {
+		// 包含accountID、accountIDs、userID和userIDs等参数需要走正常鉴权
+		accountID := c.Query("accountID")
+		accountIDs := c.Query("accountIDs")
+		userID := c.Query("userID")
+		userIDs := c.Query("userIDs")
+		if len(accountID) != 0 || len(accountIDs) != 0 || len(userID) != 0 || len(userIDs) != 0 {
+			if config.SerCfg.GetDebugMode() {
+				c.Next()
+				return
+			}
+
+			var code int
+			var data interface{}
+
+			code = e.SUCCESS
+			token := c.GetHeader("Authorization")
+			if token == "" {
+				// Token缺失
+				code = e.ERROR_AUTH_CHECK_TOKEN_MISSING
+			} else {
+				// 获取loginid
+				s := strings.Split(token, "_")
+				loginid := s[0]
+				if err := CheckToken(loginid, token); err != nil {
+					// Token错误
+					code = e.ERROR_AUTH_CHECK_TOKEN_FAIL
+				}
+			}
+
+			// Token检验失败
+			if code != e.SUCCESS {
+				c.JSON(http.StatusUnauthorized, gin.H{
+					"code": code,
+					"msg":  e.GetMsg(code),
+					"data": data,
+				})
+
+				c.Abort()
+				return
+			}
+
+			// FIXME: - 针对POST接口,应判断传入TOKEN对应的用户是否正确(比如判断UserID或AccountID是否对得上等),后期处理
+
+			// Token检验成功
+			c.Next()
+			return
+		}
+
+		var code int
+		var data interface{}
+
+		code = e.SUCCESS
+		token := c.GetHeader("Authorization")
+		if token == "" {
+			// Token缺失
+			code = e.ERROR_AUTH_CHECK_TOKEN_MISSING
+		} else {
+			if token != TouristToken {
+				// Token错误
+				code = e.ERROR_AUTH_CHECK_TOKEN_FAIL
+			}
+		}
+
+		// Token检验失败
+		if code != e.SUCCESS {
+			c.JSON(http.StatusUnauthorized, gin.H{
+				"code": code,
+				"msg":  e.GetMsg(code),
+				"data": data,
+			})
+
+			c.Abort()
+			return
+		}
+
+		// Token检验成功
+		c.Next()
+	}
+}