Переглянути джерело

增加"获取我的订单与包裹数量"接口

zhou.xiaoning 5 роки тому
батько
коміт
d7ec245876
5 змінених файлів з 245 додано та 3 видалено
  1. 78 0
      controllers/hsby/hsby.go
  2. 62 1
      docs/docs.go
  3. 62 1
      docs/swagger.json
  4. 41 1
      docs/swagger.yaml
  5. 2 0
      routers/router.go

+ 78 - 0
controllers/hsby/hsby.go

@@ -773,3 +773,81 @@ func QueryHsbyBuyMyTradeDetail(c *gin.Context) {
 		appG.Response(http.StatusOK, e.SUCCESS, orders)
 	}
 }
+
+// GetHsbyMyCountReq 获取我的订单与包裹数量请求参数模型
+type GetHsbyMyCountReq struct {
+	AccountIDs string `form:"accountIDs" binding:"required"`
+}
+
+// GetHsbyMyCountRsp 获取我的订单与包裹数量返回模型
+type GetHsbyMyCountRsp struct {
+	MyOrderDetailPreCount     int `json:"myOrderDetailPreCount"`     // 我的订单抢购中数量
+	MyOrderDetailListingCount int `json:"myOrderDetailListingCount"` // 我的订单求购中数量
+	MyPackageUnSendCount      int `json:"myPackageUnSendCount"`      // 我的包裹待发货数量
+	MyPackageUnReceiveCount   int `json:"myPackageUnReceiveCount"`   // 我的包裹待收货数量
+}
+
+// GetHsbyMyCount 获取我的订单与包裹数量
+// @Summary 获取我的订单与包裹数量
+// @Description 说明: 不包括已完成的数量。
+// @Produce json
+// @Security ApiKeyAuth
+// @Param accountIDs query string true "资金账户列表,格式:1,2,3"
+// @Success 200 {object} GetHsbyMyCountRsp
+// @Failure 500 {object} app.Response
+// @Router /HSBY/GetHsbyMyCount [get]
+// @Tags 定制【海商报业】
+func GetHsbyMyCount(c *gin.Context) {
+	appG := app.Gin{C: c}
+
+	// 获取请求参数
+	var req GetHsbyMyCountReq
+	if err := appG.C.ShouldBindQuery(&req); err != nil {
+		logger.GetLogger().Errorf("GetHsbyMyCount failed: %s", err.Error())
+		appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
+		return
+	}
+
+	// 获取我的订单数据
+	myOrderDetails, err := models.GetHsbyBuyMyOrderDetails(req.AccountIDs, 0)
+	if err != nil {
+		// 查询失败
+		logger.GetLogger().Errorf("GetHsbyMyCount failed: %s", err.Error())
+		appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
+		return
+	}
+
+	// 获取数据
+	myPackages, err := models.GetHsbyMyPackages(req.AccountIDs, 0)
+	if err != nil {
+		// 查询失败
+		logger.GetLogger().Errorf("GetHsbyMyCount failed: %s", err.Error())
+		appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
+		return
+	}
+
+	// 统计数量
+	rsp := GetHsbyMyCountRsp{}
+	for _, v := range myOrderDetails {
+		if v.MyBuyStatus == 1 {
+			// 抢购中
+			rsp.MyOrderDetailPreCount++
+		} else if v.MyBuyStatus == 2 {
+			// 求购中
+			rsp.MyOrderDetailListingCount++
+		}
+	}
+	for _, v := range myPackages {
+		if v.Takeorderstatus == 1 {
+			// 待发货
+			rsp.MyPackageUnSendCount++
+		} else if v.Takeorderstatus == 2 {
+			// 待收货
+			rsp.MyPackageUnReceiveCount++
+		}
+	}
+
+	// 查询成功返回
+	logger.GetLogger().Debugln("GetHsbyMyCount successed: %v", rsp)
+	appG.Response(http.StatusOK, e.SUCCESS, rsp)
+}

+ 62 - 1
docs/docs.go

@@ -806,7 +806,7 @@ var doc = `{
                 "parameters": [
                     {
                         "description": "申请参数",
-                        "name": "AddSpotContractApplyReq",
+                        "name": "jsonBody",
                         "in": "body",
                         "required": true,
                         "schema": {
@@ -869,6 +869,46 @@ var doc = `{
                 }
             }
         },
+        "/HSBY/GetHsbyMyCount": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "description": "说明: 不包括已完成的数量。",
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "定制【海商报业】"
+                ],
+                "summary": "获取我的订单与包裹数量",
+                "parameters": [
+                    {
+                        "type": "string",
+                        "description": "资金账户列表,格式:1,2,3",
+                        "name": "accountIDs",
+                        "in": "query",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "$ref": "#/definitions/hsby.GetHsbyMyCountRsp"
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/HSBY/QueryHsbyBuyMyTradeDetail": {
             "get": {
                 "security": [
@@ -4640,6 +4680,27 @@ var doc = `{
                 }
             }
         },
+        "hsby.GetHsbyMyCountRsp": {
+            "type": "object",
+            "properties": {
+                "myOrderDetailListingCount": {
+                    "description": "我的订单求购中数量",
+                    "type": "integer"
+                },
+                "myOrderDetailPreCount": {
+                    "description": "我的订单抢购中数量",
+                    "type": "integer"
+                },
+                "myPackageUnReceiveCount": {
+                    "description": "我的包裹待收货数量",
+                    "type": "integer"
+                },
+                "myPackageUnSendCount": {
+                    "description": "我的包裹待发货数量",
+                    "type": "integer"
+                }
+            }
+        },
         "hsby.QueryProvincesAndCitiesRsp": {
             "type": "object",
             "properties": {

+ 62 - 1
docs/swagger.json

@@ -790,7 +790,7 @@
                 "parameters": [
                     {
                         "description": "申请参数",
-                        "name": "AddSpotContractApplyReq",
+                        "name": "jsonBody",
                         "in": "body",
                         "required": true,
                         "schema": {
@@ -853,6 +853,46 @@
                 }
             }
         },
+        "/HSBY/GetHsbyMyCount": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "description": "说明: 不包括已完成的数量。",
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "定制【海商报业】"
+                ],
+                "summary": "获取我的订单与包裹数量",
+                "parameters": [
+                    {
+                        "type": "string",
+                        "description": "资金账户列表,格式:1,2,3",
+                        "name": "accountIDs",
+                        "in": "query",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "$ref": "#/definitions/hsby.GetHsbyMyCountRsp"
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/HSBY/QueryHsbyBuyMyTradeDetail": {
             "get": {
                 "security": [
@@ -4624,6 +4664,27 @@
                 }
             }
         },
+        "hsby.GetHsbyMyCountRsp": {
+            "type": "object",
+            "properties": {
+                "myOrderDetailListingCount": {
+                    "description": "我的订单求购中数量",
+                    "type": "integer"
+                },
+                "myOrderDetailPreCount": {
+                    "description": "我的订单抢购中数量",
+                    "type": "integer"
+                },
+                "myPackageUnReceiveCount": {
+                    "description": "我的包裹待收货数量",
+                    "type": "integer"
+                },
+                "myPackageUnSendCount": {
+                    "description": "我的包裹待发货数量",
+                    "type": "integer"
+                }
+            }
+        },
         "hsby.QueryProvincesAndCitiesRsp": {
             "type": "object",
             "properties": {

+ 41 - 1
docs/swagger.yaml

@@ -1410,6 +1410,21 @@ definitions:
     - price
     - qty
     type: object
+  hsby.GetHsbyMyCountRsp:
+    properties:
+      myOrderDetailListingCount:
+        description: 我的订单求购中数量
+        type: integer
+      myOrderDetailPreCount:
+        description: 我的订单抢购中数量
+        type: integer
+      myPackageUnReceiveCount:
+        description: 我的包裹待收货数量
+        type: integer
+      myPackageUnSendCount:
+        description: 我的包裹待发货数量
+        type: integer
+    type: object
   hsby.QueryProvincesAndCitiesRsp:
     properties:
       cities:
@@ -4542,7 +4557,7 @@ paths:
       parameters:
       - description: 申请参数
         in: body
-        name: AddSpotContractApplyReq
+        name: jsonBody
         required: true
         schema:
           $ref: '#/definitions/erms3.AddSpotContractApplyReq'
@@ -4586,6 +4601,31 @@ paths:
       summary: 查询合同申请表单数据
       tags:
       - 风险管理v3
+  /HSBY/GetHsbyMyCount:
+    get:
+      description: 说明: 不包括已完成的数量。
+      parameters:
+      - description: 资金账户列表,格式:1,2,3
+        in: query
+        name: accountIDs
+        required: true
+        type: string
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            $ref: '#/definitions/hsby.GetHsbyMyCountRsp'
+        "500":
+          description: Internal Server Error
+          schema:
+            $ref: '#/definitions/app.Response'
+      security:
+      - ApiKeyAuth: []
+      summary: 获取我的订单与包裹数量
+      tags:
+      - 定制【海商报业】
   /HSBY/QueryHsbyBuyMyTradeDetail:
     get:
       parameters:

+ 2 - 0
routers/router.go

@@ -225,6 +225,8 @@ func InitRouter() *gin.Engine {
 		hsbyR.GET("/QueryProvincesAndCities", hsby.QueryProvincesAndCities)
 		// 查询"我的订单 - 已完成"单据信息
 		hsbyR.GET("/QueryHsbyBuyMyTradeDetail", hsby.QueryHsbyBuyMyTradeDetail)
+		// 获取我的订单与包裹数量
+		hsbyR.GET("/GetHsbyMyCount", hsby.GetHsbyMyCount)
 	}
 
 	return r