ソースを参照

已使用优惠卷查询

zhou.xiaoning 4 年 前
コミット
cd8d06e6be
6 ファイル変更415 行追加9 行削除
  1. 39 0
      controllers/hsby/hsby.go
  2. 115 3
      docs/docs.go
  3. 115 3
      docs/swagger.json
  4. 81 3
      docs/swagger.yaml
  5. 63 0
      models/hsby.go
  6. 2 0
      routers/router.go

+ 39 - 0
controllers/hsby/hsby.go

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

+ 115 - 3
docs/docs.go

@@ -2268,6 +2268,45 @@ var doc = `{
                 }
             }
         },
+        "/HSBY/QueryMyUsedCoupon": {
+            "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.MyUsedCoupon"
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/HSBY/QueryProvincesAndCities": {
             "get": {
                 "security": [
@@ -8197,7 +8236,7 @@ var doc = `{
                 },
                 "coupontypeid": {
                     "description": "优惠券类型ID",
-                    "type": "integer"
+                    "type": "string"
                 },
                 "couponvalue": {
                     "description": "面值[1:现金券 - 抵扣值 2:折扣券-折扣值]",
@@ -8277,7 +8316,7 @@ var doc = `{
                 },
                 "couponholdid": {
                     "description": "优惠券持仓ID(229+Unix秒时间戳(10位)+xxxxxx)",
-                    "type": "integer"
+                    "type": "string"
                 },
                 "couponname": {
                     "description": "优惠券名称",
@@ -8285,7 +8324,7 @@ var doc = `{
                 },
                 "coupontypeid": {
                     "description": "优惠券类型ID - SEQ_COUPONTYPE",
-                    "type": "integer"
+                    "type": "string"
                 },
                 "couponvalue": {
                     "description": "面值[1:现金券 - 抵扣值 2:折扣券-折扣值]",
@@ -8337,6 +8376,79 @@ var doc = `{
                 }
             }
         },
+        "models.MyUsedCoupon": {
+            "type": "object",
+            "required": [
+                "coupontypeid",
+                "orderid"
+            ],
+            "properties": {
+                "accountid": {
+                    "description": "资金账户ID(买方)",
+                    "type": "integer"
+                },
+                "conditionvalue": {
+                    "description": "条件阈值(可为0)",
+                    "type": "number"
+                },
+                "couponcategroy": {
+                    "description": "种类 - 1:现金券 2:折扣券",
+                    "type": "integer"
+                },
+                "couponname": {
+                    "description": "优惠券名称",
+                    "type": "string"
+                },
+                "coupontypeid": {
+                    "description": "优惠券类型ID(买方)",
+                    "type": "string"
+                },
+                "couponvalue": {
+                    "description": "面值[1:现金券 - 抵扣值 2:折扣券-折扣值(0-100)]",
+                    "type": "number"
+                },
+                "createtime": {
+                    "description": "创建时间",
+                    "type": "string"
+                },
+                "goodsid": {
+                    "description": "商品ID",
+                    "type": "integer"
+                },
+                "handlestatus": {
+                    "description": "处理状态",
+                    "type": "integer"
+                },
+                "marketid": {
+                    "description": "市场ID",
+                    "type": "integer"
+                },
+                "offamount": {
+                    "description": "优惠金额",
+                    "type": "number"
+                },
+                "orderid": {
+                    "description": "委托单号(100+Unix秒时间戳(10位)+2位(MarketServiceID)+xxxx)",
+                    "type": "string"
+                },
+                "sellaccountid": {
+                    "description": "资金账户ID(卖方)",
+                    "type": "integer"
+                },
+                "tradeamount": {
+                    "description": "成交金额",
+                    "type": "number"
+                },
+                "tradeid": {
+                    "description": "成交单号(101+Unix秒时间戳(10位)+2位(MarketServiceID)+xxxx)",
+                    "type": "string"
+                },
+                "usedqty": {
+                    "description": "使用数量",
+                    "type": "integer"
+                }
+            }
+        },
         "models.OperationPrimaryMenu": {
             "type": "object",
             "properties": {

+ 115 - 3
docs/swagger.json

@@ -2252,6 +2252,45 @@
                 }
             }
         },
+        "/HSBY/QueryMyUsedCoupon": {
+            "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.MyUsedCoupon"
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/HSBY/QueryProvincesAndCities": {
             "get": {
                 "security": [
@@ -8181,7 +8220,7 @@
                 },
                 "coupontypeid": {
                     "description": "优惠券类型ID",
-                    "type": "integer"
+                    "type": "string"
                 },
                 "couponvalue": {
                     "description": "面值[1:现金券 - 抵扣值 2:折扣券-折扣值]",
@@ -8261,7 +8300,7 @@
                 },
                 "couponholdid": {
                     "description": "优惠券持仓ID(229+Unix秒时间戳(10位)+xxxxxx)",
-                    "type": "integer"
+                    "type": "string"
                 },
                 "couponname": {
                     "description": "优惠券名称",
@@ -8269,7 +8308,7 @@
                 },
                 "coupontypeid": {
                     "description": "优惠券类型ID - SEQ_COUPONTYPE",
-                    "type": "integer"
+                    "type": "string"
                 },
                 "couponvalue": {
                     "description": "面值[1:现金券 - 抵扣值 2:折扣券-折扣值]",
@@ -8321,6 +8360,79 @@
                 }
             }
         },
+        "models.MyUsedCoupon": {
+            "type": "object",
+            "required": [
+                "coupontypeid",
+                "orderid"
+            ],
+            "properties": {
+                "accountid": {
+                    "description": "资金账户ID(买方)",
+                    "type": "integer"
+                },
+                "conditionvalue": {
+                    "description": "条件阈值(可为0)",
+                    "type": "number"
+                },
+                "couponcategroy": {
+                    "description": "种类 - 1:现金券 2:折扣券",
+                    "type": "integer"
+                },
+                "couponname": {
+                    "description": "优惠券名称",
+                    "type": "string"
+                },
+                "coupontypeid": {
+                    "description": "优惠券类型ID(买方)",
+                    "type": "string"
+                },
+                "couponvalue": {
+                    "description": "面值[1:现金券 - 抵扣值 2:折扣券-折扣值(0-100)]",
+                    "type": "number"
+                },
+                "createtime": {
+                    "description": "创建时间",
+                    "type": "string"
+                },
+                "goodsid": {
+                    "description": "商品ID",
+                    "type": "integer"
+                },
+                "handlestatus": {
+                    "description": "处理状态",
+                    "type": "integer"
+                },
+                "marketid": {
+                    "description": "市场ID",
+                    "type": "integer"
+                },
+                "offamount": {
+                    "description": "优惠金额",
+                    "type": "number"
+                },
+                "orderid": {
+                    "description": "委托单号(100+Unix秒时间戳(10位)+2位(MarketServiceID)+xxxx)",
+                    "type": "string"
+                },
+                "sellaccountid": {
+                    "description": "资金账户ID(卖方)",
+                    "type": "integer"
+                },
+                "tradeamount": {
+                    "description": "成交金额",
+                    "type": "number"
+                },
+                "tradeid": {
+                    "description": "成交单号(101+Unix秒时间戳(10位)+2位(MarketServiceID)+xxxx)",
+                    "type": "string"
+                },
+                "usedqty": {
+                    "description": "使用数量",
+                    "type": "integer"
+                }
+            }
+        },
         "models.OperationPrimaryMenu": {
             "type": "object",
             "properties": {

+ 81 - 3
docs/swagger.yaml

@@ -3296,7 +3296,7 @@ definitions:
         type: string
       coupontypeid:
         description: 优惠券类型ID
-        type: integer
+        type: string
       couponvalue:
         description: 面值[1:现金券 - 抵扣值 2:折扣券-折扣值]
         type: number
@@ -3356,13 +3356,13 @@ definitions:
         type: integer
       couponholdid:
         description: 优惠券持仓ID(229+Unix秒时间戳(10位)+xxxxxx)
-        type: integer
+        type: string
       couponname:
         description: 优惠券名称
         type: string
       coupontypeid:
         description: 优惠券类型ID - SEQ_COUPONTYPE
-        type: integer
+        type: string
       couponvalue:
         description: 面值[1:现金券 - 抵扣值 2:折扣券-折扣值]
         type: number
@@ -3402,6 +3402,60 @@ definitions:
     required:
     - couponholdid
     type: object
+  models.MyUsedCoupon:
+    properties:
+      accountid:
+        description: 资金账户ID(买方)
+        type: integer
+      conditionvalue:
+        description: 条件阈值(可为0)
+        type: number
+      couponcategroy:
+        description: 种类 - 1:现金券 2:折扣券
+        type: integer
+      couponname:
+        description: 优惠券名称
+        type: string
+      coupontypeid:
+        description: 优惠券类型ID(买方)
+        type: string
+      couponvalue:
+        description: 面值[1:现金券 - 抵扣值 2:折扣券-折扣值(0-100)]
+        type: number
+      createtime:
+        description: 创建时间
+        type: string
+      goodsid:
+        description: 商品ID
+        type: integer
+      handlestatus:
+        description: 处理状态
+        type: integer
+      marketid:
+        description: 市场ID
+        type: integer
+      offamount:
+        description: 优惠金额
+        type: number
+      orderid:
+        description: 委托单号(100+Unix秒时间戳(10位)+2位(MarketServiceID)+xxxx)
+        type: string
+      sellaccountid:
+        description: 资金账户ID(卖方)
+        type: integer
+      tradeamount:
+        description: 成交金额
+        type: number
+      tradeid:
+        description: 成交单号(101+Unix秒时间戳(10位)+2位(MarketServiceID)+xxxx)
+        type: string
+      usedqty:
+        description: 使用数量
+        type: integer
+    required:
+    - coupontypeid
+    - orderid
+    type: object
   models.OperationPrimaryMenu:
     properties:
       Children:
@@ -6845,6 +6899,30 @@ paths:
       summary: 获取我的订单中待付款信息
       tags:
       - 定制【海商报业】
+  /HSBY/QueryMyUsedCoupon:
+    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.MyUsedCoupon'
+        "500":
+          description: Internal Server Error
+          schema:
+            $ref: '#/definitions/app.Response'
+      security:
+      - ApiKeyAuth: []
+      summary: 已使用优惠卷查询
+      tags:
+      - 定制【海商报业】
   /HSBY/QueryProvincesAndCities:
     get:
       description: 查询结果只包括二级市场商品已关连的省市信息。

+ 63 - 0
models/hsby.go

@@ -152,6 +152,30 @@ func (Couponhold) TableName() string {
 	return "COUPONHOLD"
 }
 
+// Tradeordercoupon 交易委托优惠券表
+type Tradeordercoupon struct {
+	Orderid        string    `json:"orderid"  xorm:"'ORDERIDSTR'" binding:"required"`           // 委托单号(100+Unix秒时间戳(10位)+2位(MarketServiceID)+xxxx)
+	Coupontypeid   string    `json:"coupontypeid"  xorm:"'COUPONTYPEIDSTR'" binding:"required"` // 优惠券类型ID(买方)
+	Accountid      int64     `json:"accountid"  xorm:"'ACCOUNTID'"`                             // 资金账户ID(买方)
+	Usedqty        int64     `json:"usedqty"  xorm:"'USEDQTY'"`                                 // 使用数量
+	Couponcategroy int32     `json:"couponcategroy"  xorm:"'COUPONCATEGROY'"`                   // 种类 - 1:现金券 2:折扣券
+	Conditionvalue float64   `json:"conditionvalue"  xorm:"'CONDITIONVALUE'"`                   // 条件阈值(可为0)
+	Couponvalue    float64   `json:"couponvalue"  xorm:"'COUPONVALUE'"`                         // 面值[1:现金券 - 抵扣值 2:折扣券-折扣值(0-100)]
+	Sellaccountid  int64     `json:"sellaccountid"  xorm:"'SELLACCOUNTID'"`                     // 资金账户ID(卖方)
+	Marketid       int32     `json:"marketid"  xorm:"'MARKETID'"`                               // 市场ID
+	Goodsid        int32     `json:"goodsid"  xorm:"'GOODSID'"`                                 // 商品ID
+	Tradeid        string    `json:"tradeid"  xorm:"'TRADEIDSTR'"`                              // 成交单号(101+Unix秒时间戳(10位)+2位(MarketServiceID)+xxxx)
+	Tradeamount    float64   `json:"tradeamount"  xorm:"'TRADEAMOUNT'"`                         // 成交金额
+	Offamount      float64   `json:"offamount"  xorm:"'OFFAMOUNT'"`                             // 优惠金额
+	Handlestatus   int32     `json:"handlestatus"  xorm:"'HANDLESTATUS'"`                       // 处理状态
+	Createtime     time.Time `json:"createtime"  xorm:"'CREATETIME'"`                           // 创建时间
+}
+
+// TableName is TRADE_ORDERCOUPON
+func (Tradeordercoupon) TableName() string {
+	return "TRADE_ORDERCOUPON"
+}
+
 // HsbyTopGoods 热卖商品(二级市场挂牌点选)
 type HsbyTopGoods struct {
 	Goodsid      int64   `json:"goodsid"  xorm:"'GOODSID'" binding:"required"`     // 商品ID(自增ID SEQ_GOODS)
@@ -1755,3 +1779,42 @@ func GetMyCouponHolds(accountIDs string, holdStatus string) ([]MyCouponHold, err
 
 	return myCouponHolds, nil
 }
+
+// MyUsedCoupon 已使用优惠卷
+type MyUsedCoupon struct {
+	Orderid        string    `json:"orderid"  xorm:"'ORDERIDSTR'" binding:"required"`           // 委托单号(100+Unix秒时间戳(10位)+2位(MarketServiceID)+xxxx)
+	Coupontypeid   string    `json:"coupontypeid"  xorm:"'COUPONTYPEIDSTR'" binding:"required"` // 优惠券类型ID(买方)
+	Accountid      int64     `json:"accountid"  xorm:"'ACCOUNTID'"`                             // 资金账户ID(买方)
+	Usedqty        int64     `json:"usedqty"  xorm:"'USEDQTY'"`                                 // 使用数量
+	Couponcategroy int32     `json:"couponcategroy"  xorm:"'COUPONCATEGROY'"`                   // 种类 - 1:现金券 2:折扣券
+	Conditionvalue float64   `json:"conditionvalue"  xorm:"'CONDITIONVALUE'"`                   // 条件阈值(可为0)
+	Couponvalue    float64   `json:"couponvalue"  xorm:"'COUPONVALUE'"`                         // 面值[1:现金券 - 抵扣值 2:折扣券-折扣值(0-100)]
+	Sellaccountid  int64     `json:"sellaccountid"  xorm:"'SELLACCOUNTID'"`                     // 资金账户ID(卖方)
+	Marketid       int32     `json:"marketid"  xorm:"'MARKETID'"`                               // 市场ID
+	Goodsid        int32     `json:"goodsid"  xorm:"'GOODSID'"`                                 // 商品ID
+	Tradeid        string    `json:"tradeid"  xorm:"'TRADEIDSTR'"`                              // 成交单号(101+Unix秒时间戳(10位)+2位(MarketServiceID)+xxxx)
+	Tradeamount    float64   `json:"tradeamount"  xorm:"'TRADEAMOUNT'"`                         // 成交金额
+	Offamount      float64   `json:"offamount"  xorm:"'OFFAMOUNT'"`                             // 优惠金额
+	Handlestatus   int32     `json:"handlestatus"  xorm:"'HANDLESTATUS'"`                       // 处理状态
+	Createtime     time.Time `json:"createtime"  xorm:"'CREATETIME'"`                           // 创建时间
+
+	Couponname string `json:"couponname"  xorm:"'COUPONNAME'"` // 优惠券名称
+}
+
+// GetMyUsedCoupon 获取已使用优惠卷
+func GetMyUsedCoupon(accountIDs string) ([]MyUsedCoupon, error) {
+	engine := db.GetEngine()
+
+	myUsedCoupons := make([]MyUsedCoupon, 0)
+	if err := engine.Table("TRADE_ORDERCOUPON T").
+		Select(`to_char(T.ORDERID) ORDERIDSTR, to_char(T.COUPONTYPEID) COUPONTYPEIDSTR, to_char(T.TRADEID) TRADEIDSTR, T.*, 
+				C.COUPONNAME`).
+		Join("INNER", "COUPONTYPE C", "C.COUPONTYPEID = T.COUPONTYPEID").
+		Where(fmt.Sprintf("T.ACCOUNTID in (%s)", accountIDs)).
+		Desc("T.CREATETIME").
+		Find(&myUsedCoupons); err != nil {
+		return nil, err
+	}
+
+	return myUsedCoupons, nil
+}

+ 2 - 0
routers/router.go

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