Sfoglia il codice sorgente

增加我的优惠卷持仓查询接口

zhou.xiaoning 4 anni fa
parent
commit
48a786deb4
6 ha cambiato i file con 389 aggiunte e 0 eliminazioni
  1. 39 0
      controllers/hsby/hsby.go
  2. 115 0
      docs/docs.go
  3. 115 0
      docs/swagger.json
  4. 80 0
      docs/swagger.yaml
  5. 38 0
      models/hsby.go
  6. 2 0
      routers/router.go

+ 39 - 0
controllers/hsby/hsby.go

@@ -1204,3 +1204,42 @@ func QueryMyCoupons(c *gin.Context) {
 	logger.GetLogger().Debugln("QueryMyCoupons successed: %v", myCoupons)
 	appG.Response(http.StatusOK, e.SUCCESS, myCoupons)
 }
+
+// QueryMyCouponHoldsReq 我的优惠卷持仓查询请求参数
+type QueryMyCouponHoldsReq struct {
+	AccountIDs string `form:"accountIDs" binding:"required"`
+}
+
+// QueryMyCouponHolds 我的优惠卷持仓查询
+// @Summary 我的优惠卷持仓查询
+// @Produce json
+// @Security ApiKeyAuth
+// @Param accountIDs query string true "资金账户列表,格式:1,2,3"
+// @Success 200 {object} models.Couponhold
+// @Failure 500 {object} app.Response
+// @Router /HSBY/QueryMyCouponHolds [get]
+// @Tags 定制【海商报业】
+func QueryMyCouponHolds(c *gin.Context) {
+	appG := app.Gin{C: c}
+
+	// 获取请求参数
+	var req QueryMyCouponHoldsReq
+	if err := appG.C.ShouldBindQuery(&req); err != nil {
+		logger.GetLogger().Errorf("QueryMyCouponHolds failed: %s", err.Error())
+		appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
+		return
+	}
+
+	// 获取数据
+	myCoupons, err := models.GetMyCouponHolds(req.AccountIDs)
+	if err != nil {
+		// 查询失败
+		logger.GetLogger().Errorf("QueryMyCouponHolds failed: %s", err.Error())
+		appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
+		return
+	}
+
+	// 查询成功返回
+	logger.GetLogger().Debugln("QueryMyCouponHolds successed: %v", myCoupons)
+	appG.Response(http.StatusOK, e.SUCCESS, myCoupons)
+}

+ 115 - 0
docs/docs.go

@@ -2103,6 +2103,45 @@ var doc = `{
                 }
             }
         },
+        "/HSBY/QueryMyCouponHolds": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "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/models.Couponhold"
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/HSBY/QueryMyCoupons": {
             "get": {
                 "security": [
@@ -6430,6 +6469,82 @@ var doc = `{
                 }
             }
         },
+        "models.Couponhold": {
+            "type": "object",
+            "required": [
+                "couponholdid"
+            ],
+            "properties": {
+                "accountid": {
+                    "description": "资金账户ID",
+                    "type": "integer"
+                },
+                "conditionvalue": {
+                    "description": "条件阈值(可为0)",
+                    "type": "number"
+                },
+                "couponcategroy": {
+                    "description": "种类 - 1:现金券 2:折扣券 3:折扣券(单个商品)",
+                    "type": "integer"
+                },
+                "couponholdid": {
+                    "description": "优惠券持仓ID(229+Unix秒时间戳(10位)+xxxxxx)",
+                    "type": "integer"
+                },
+                "coupontypeid": {
+                    "description": "优惠券类型ID - SEQ_COUPONTYPE",
+                    "type": "integer"
+                },
+                "couponvalue": {
+                    "description": "面值[1:现金券 - 抵扣值 2:折扣券-折扣值]",
+                    "type": "number"
+                },
+                "createtime": {
+                    "description": "创建时间",
+                    "type": "string"
+                },
+                "enddate": {
+                    "description": "结束日期",
+                    "type": "string"
+                },
+                "giveapplyid": {
+                    "description": "发放申请ID(SEQ_COUPONGIVEAPPLY)",
+                    "type": "integer"
+                },
+                "holdstatus": {
+                    "description": "持仓状态 - 1:未生效 2:已生效 3:已使用 4:已过期",
+                    "type": "integer"
+                },
+                "isgeneral": {
+                    "description": "是否通用券 - 0:否 1:是",
+                    "type": "integer"
+                },
+                "limitedflag": {
+                    "description": "是否指定商品 - 0:不限 1:限制",
+                    "type": "integer"
+                },
+                "limitedgoodsids": {
+                    "description": "指定商品IDs[逗号分隔]",
+                    "type": "string"
+                },
+                "qty": {
+                    "description": "数量(按1平铺)",
+                    "type": "integer"
+                },
+                "startdate": {
+                    "description": "开始日期",
+                    "type": "string"
+                },
+                "userid": {
+                    "description": "用户ID",
+                    "type": "integer"
+                },
+                "userscope": {
+                    "description": "卖家范围(用户ID,逗号分隔) [IsGeneral =0时使用]",
+                    "type": "string"
+                }
+            }
+        },
         "models.Division": {
             "type": "object",
             "required": [

+ 115 - 0
docs/swagger.json

@@ -2087,6 +2087,45 @@
                 }
             }
         },
+        "/HSBY/QueryMyCouponHolds": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "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/models.Couponhold"
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/HSBY/QueryMyCoupons": {
             "get": {
                 "security": [
@@ -6414,6 +6453,82 @@
                 }
             }
         },
+        "models.Couponhold": {
+            "type": "object",
+            "required": [
+                "couponholdid"
+            ],
+            "properties": {
+                "accountid": {
+                    "description": "资金账户ID",
+                    "type": "integer"
+                },
+                "conditionvalue": {
+                    "description": "条件阈值(可为0)",
+                    "type": "number"
+                },
+                "couponcategroy": {
+                    "description": "种类 - 1:现金券 2:折扣券 3:折扣券(单个商品)",
+                    "type": "integer"
+                },
+                "couponholdid": {
+                    "description": "优惠券持仓ID(229+Unix秒时间戳(10位)+xxxxxx)",
+                    "type": "integer"
+                },
+                "coupontypeid": {
+                    "description": "优惠券类型ID - SEQ_COUPONTYPE",
+                    "type": "integer"
+                },
+                "couponvalue": {
+                    "description": "面值[1:现金券 - 抵扣值 2:折扣券-折扣值]",
+                    "type": "number"
+                },
+                "createtime": {
+                    "description": "创建时间",
+                    "type": "string"
+                },
+                "enddate": {
+                    "description": "结束日期",
+                    "type": "string"
+                },
+                "giveapplyid": {
+                    "description": "发放申请ID(SEQ_COUPONGIVEAPPLY)",
+                    "type": "integer"
+                },
+                "holdstatus": {
+                    "description": "持仓状态 - 1:未生效 2:已生效 3:已使用 4:已过期",
+                    "type": "integer"
+                },
+                "isgeneral": {
+                    "description": "是否通用券 - 0:否 1:是",
+                    "type": "integer"
+                },
+                "limitedflag": {
+                    "description": "是否指定商品 - 0:不限 1:限制",
+                    "type": "integer"
+                },
+                "limitedgoodsids": {
+                    "description": "指定商品IDs[逗号分隔]",
+                    "type": "string"
+                },
+                "qty": {
+                    "description": "数量(按1平铺)",
+                    "type": "integer"
+                },
+                "startdate": {
+                    "description": "开始日期",
+                    "type": "string"
+                },
+                "userid": {
+                    "description": "用户ID",
+                    "type": "integer"
+                },
+                "userscope": {
+                    "description": "卖家范围(用户ID,逗号分隔) [IsGeneral =0时使用]",
+                    "type": "string"
+                }
+            }
+        },
         "models.Division": {
             "type": "object",
             "required": [

+ 80 - 0
docs/swagger.yaml

@@ -2014,6 +2014,62 @@ definitions:
         $ref: '#/definitions/models.Division'
         description: 省
     type: object
+  models.Couponhold:
+    properties:
+      accountid:
+        description: 资金账户ID
+        type: integer
+      conditionvalue:
+        description: 条件阈值(可为0)
+        type: number
+      couponcategroy:
+        description: 种类 - 1:现金券 2:折扣券 3:折扣券(单个商品)
+        type: integer
+      couponholdid:
+        description: 优惠券持仓ID(229+Unix秒时间戳(10位)+xxxxxx)
+        type: integer
+      coupontypeid:
+        description: 优惠券类型ID - SEQ_COUPONTYPE
+        type: integer
+      couponvalue:
+        description: 面值[1:现金券 - 抵扣值 2:折扣券-折扣值]
+        type: number
+      createtime:
+        description: 创建时间
+        type: string
+      enddate:
+        description: 结束日期
+        type: string
+      giveapplyid:
+        description: 发放申请ID(SEQ_COUPONGIVEAPPLY)
+        type: integer
+      holdstatus:
+        description: 持仓状态 - 1:未生效 2:已生效 3:已使用 4:已过期
+        type: integer
+      isgeneral:
+        description: 是否通用券 - 0:否 1:是
+        type: integer
+      limitedflag:
+        description: 是否指定商品 - 0:不限 1:限制
+        type: integer
+      limitedgoodsids:
+        description: 指定商品IDs[逗号分隔]
+        type: string
+      qty:
+        description: 数量(按1平铺)
+        type: integer
+      startdate:
+        description: 开始日期
+        type: string
+      userid:
+        description: 用户ID
+        type: integer
+      userscope:
+        description: 卖家范围(用户ID,逗号分隔) [IsGeneral =0时使用]
+        type: string
+    required:
+    - couponholdid
+    type: object
   models.Division:
     properties:
       autoid:
@@ -6622,6 +6678,30 @@ paths:
       summary: 我的闲置中收款信息查询
       tags:
       - 定制【海商报业】
+  /HSBY/QueryMyCouponHolds:
+    get:
+      parameters:
+      - description: 资金账户列表,格式:1,2,3
+        in: query
+        name: accountIDs
+        required: true
+        type: string
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            $ref: '#/definitions/models.Couponhold'
+        "500":
+          description: Internal Server Error
+          schema:
+            $ref: '#/definitions/app.Response'
+      security:
+      - ApiKeyAuth: []
+      summary: 我的优惠卷持仓查询
+      tags:
+      - 定制【海商报业】
   /HSBY/QueryMyCoupons:
     get:
       parameters:

+ 38 - 0
models/hsby.go

@@ -126,6 +126,32 @@ func (Couponposition) TableName() string {
 	return "COUPONPOSITION"
 }
 
+// Couponhold 优惠券持仓表 - 导历史(不清当前表) - 每一个数量一条记录
+type Couponhold struct {
+	Couponholdid    int64     `json:"couponholdid"  xorm:"'COUPONHOLDID'" binding:"required"` // 优惠券持仓ID(229+Unix秒时间戳(10位)+xxxxxx)
+	Giveapplyid     int64     `json:"giveapplyid"  xorm:"'GIVEAPPLYID'"`                      // 发放申请ID(SEQ_COUPONGIVEAPPLY)
+	Accountid       int64     `json:"accountid"  xorm:"'ACCOUNTID'"`                          // 资金账户ID
+	Coupontypeid    int32     `json:"coupontypeid"  xorm:"'COUPONTYPEID'"`                    // 优惠券类型ID - SEQ_COUPONTYPE
+	Couponcategroy  int32     `json:"couponcategroy"  xorm:"'COUPONCATEGROY'"`                // 种类 - 1:现金券 2:折扣券 3:折扣券(单个商品)
+	Conditionvalue  float64   `json:"conditionvalue"  xorm:"'CONDITIONVALUE'"`                // 条件阈值(可为0)
+	Couponvalue     float64   `json:"couponvalue"  xorm:"'COUPONVALUE'"`                      // 面值[1:现金券 - 抵扣值 2:折扣券-折扣值]
+	Limitedflag     int32     `json:"limitedflag"  xorm:"'LIMITEDFLAG'"`                      // 是否指定商品 - 0:不限 1:限制
+	Limitedgoodsids string    `json:"limitedgoodsids"  xorm:"'LIMITEDGOODSIDS'"`              // 指定商品IDs[逗号分隔]
+	Isgeneral       int32     `json:"isgeneral"  xorm:"'ISGENERAL'"`                          // 是否通用券 - 0:否 1:是
+	Userscope       string    `json:"userscope"  xorm:"'USERSCOPE'"`                          // 卖家范围(用户ID,逗号分隔) [IsGeneral =0时使用]
+	Userid          int64     `json:"userid"  xorm:"'USERID'"`                                // 用户ID
+	Qty             int64     `json:"qty"  xorm:"'QTY'"`                                      // 数量(按1平铺)
+	Startdate       time.Time `json:"startdate"  xorm:"'STARTDATE'"`                          // 开始日期
+	Holdstatus      int32     `json:"holdstatus"  xorm:"'HOLDSTATUS'"`                        // 持仓状态 - 1:未生效 2:已生效 3:已使用 4:已过期
+	Enddate         time.Time `json:"enddate"  xorm:"'ENDDATE'"`                              // 结束日期
+	Createtime      time.Time `json:"createtime"  xorm:"'CREATETIME'"`                        // 创建时间
+}
+
+// TableName is COUPONHOLD
+func (Couponhold) TableName() string {
+	return "COUPONHOLD"
+}
+
 // HsbyTopGoods 热卖商品(二级市场挂牌点选)
 type HsbyTopGoods struct {
 	Goodsid      int64   `json:"goodsid"  xorm:"'GOODSID'" binding:"required"`     // 商品ID(自增ID SEQ_GOODS)
@@ -1641,3 +1667,15 @@ func GetMyCoupons(accountIDs string, goodsID, sellUserID int) ([]MyCoupon, error
 
 	return myCoupons, nil
 }
+
+// GetMyCouponHolds 获取优惠卷明细
+func GetMyCouponHolds(accountIDs string) ([]Couponhold, error) {
+	engine := db.GetEngine()
+
+	myCouponHolds := make([]Couponhold, 0)
+	if err := engine.Where(fmt.Sprintf("ACCOUNTID in (%s)", accountIDs)).Find(&myCouponHolds); err != nil {
+		return nil, err
+	}
+
+	return myCouponHolds, nil
+}

+ 2 - 0
routers/router.go

@@ -278,6 +278,8 @@ func InitRouter() *gin.Engine {
 		hsbyR.GET("/QueryHsbyMarketGoodsDetail", hsby.QueryHsbyMarketGoodsDetail)
 		// 我的优惠卷查询
 		hsbyR.GET("/QueryMyCoupons", hsby.QueryMyCoupons)
+		// 我的优惠卷持仓查询
+		hsbyR.GET("/QueryMyCouponHolds", hsby.QueryMyCouponHolds)
 	}
 
 	return r