ソースを参照

增加查询我的积分流水接口

zhou.xiaoning 3 年 前
コミット
8aa908697c
6 ファイル変更250 行追加0 行削除
  1. 18 0
      controllers/ferroalloy/score.go
  2. 71 0
      docs/docs.go
  3. 71 0
      docs/swagger.json
  4. 47 0
      docs/swagger.yaml
  5. 42 0
      models/ferroalloy.go
  6. 1 0
      routers/router.go

+ 18 - 0
controllers/ferroalloy/score.go

@@ -39,3 +39,21 @@ func Signin(c *gin.Context) {
 		a.Response(http.StatusBadRequest, e.ERROR_OPERATION_FAILED, nil)
 	}
 }
+
+// QueryUserScoreLog
+// @Summary  查询我的积分流水
+// @Produce  json
+// @Security ApiKeyAuth
+// @Param    userid   query    int true  "用户ID"
+// @Param    page     query    int false "页码"
+// @Param    pagesize query    int false "每页条数"
+// @Success  200      {array}  models.GThjuserscorelog
+// @Failure  500      {object} app.Response
+// @Router   /Ferroalloy/QueryUserScoreLog [get]
+// @Tags     铁合金
+func QueryUserScoreLog(c *gin.Context) {
+	a := app.GinUtils{Gin: app.Gin{C: c}}
+	m := models.GThjuserscorelog{}
+	a.DoBindReq(&m)
+	a.DoGetDataByPage(&m)
+}

+ 71 - 0
docs/docs.go

@@ -7650,6 +7650,60 @@ const docTemplate = `{
                 }
             }
         },
+        "/Ferroalloy/QueryUserScoreLog": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "铁合金"
+                ],
+                "summary": "查询我的积分流水",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "用户ID",
+                        "name": "userid",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "页码",
+                        "name": "page",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "每页条数",
+                        "name": "pagesize",
+                        "in": "query"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.GThjuserscorelog"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/Ferroalloy/Signin": {
             "post": {
                 "security": [
@@ -29957,6 +30011,23 @@ const docTemplate = `{
                 }
             }
         },
+        "models.GThjuserscorelog": {
+            "type": "object",
+            "properties": {
+                "createtime": {
+                    "description": "记账时间",
+                    "type": "string"
+                },
+                "score": {
+                    "description": "变动积分",
+                    "type": "number"
+                },
+                "scoreconfigtype": {
+                    "description": "配置类型 - 1:注册红包 2:签到积分 3:推广积分 4:下级用户下单积分 5:自己采购下单积分 6:自己供求下单积分 7:抽奖配置",
+                    "type": "integer"
+                }
+            }
+        },
         "models.GZGoods": {
             "type": "object",
             "required": [

+ 71 - 0
docs/swagger.json

@@ -7641,6 +7641,60 @@
                 }
             }
         },
+        "/Ferroalloy/QueryUserScoreLog": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "铁合金"
+                ],
+                "summary": "查询我的积分流水",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "用户ID",
+                        "name": "userid",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "页码",
+                        "name": "page",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "每页条数",
+                        "name": "pagesize",
+                        "in": "query"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.GThjuserscorelog"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/Ferroalloy/Signin": {
             "post": {
                 "security": [
@@ -29948,6 +30002,23 @@
                 }
             }
         },
+        "models.GThjuserscorelog": {
+            "type": "object",
+            "properties": {
+                "createtime": {
+                    "description": "记账时间",
+                    "type": "string"
+                },
+                "score": {
+                    "description": "变动积分",
+                    "type": "number"
+                },
+                "scoreconfigtype": {
+                    "description": "配置类型 - 1:注册红包 2:签到积分 3:推广积分 4:下级用户下单积分 5:自己采购下单积分 6:自己供求下单积分 7:抽奖配置",
+                    "type": "integer"
+                }
+            }
+        },
         "models.GZGoods": {
             "type": "object",
             "required": [

+ 47 - 0
docs/swagger.yaml

@@ -9685,6 +9685,19 @@ definitions:
         description: 昨价
         type: number
     type: object
+  models.GThjuserscorelog:
+    properties:
+      createtime:
+        description: 记账时间
+        type: string
+      score:
+        description: 变动积分
+        type: number
+      scoreconfigtype:
+        description: 配置类型 - 1:注册红包 2:签到积分 3:推广积分 4:下级用户下单积分 5:自己采购下单积分 6:自己供求下单积分
+          7:抽奖配置
+        type: integer
+    type: object
   models.GZGoods:
     properties:
       address:
@@ -28273,6 +28286,40 @@ paths:
       summary: 查询我的推荐列表
       tags:
       - 铁合金
+  /Ferroalloy/QueryUserScoreLog:
+    get:
+      parameters:
+      - description: 用户ID
+        in: query
+        name: userid
+        required: true
+        type: integer
+      - description: 页码
+        in: query
+        name: page
+        type: integer
+      - description: 每页条数
+        in: query
+        name: pagesize
+        type: integer
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            items:
+              $ref: '#/definitions/models.GThjuserscorelog'
+            type: array
+        "500":
+          description: Internal Server Error
+          schema:
+            $ref: '#/definitions/app.Response'
+      security:
+      - ApiKeyAuth: []
+      summary: 查询我的积分流水
+      tags:
+      - 铁合金
   /Ferroalloy/Signin:
     post:
       parameters:

+ 42 - 0
models/ferroalloy.go

@@ -275,3 +275,45 @@ func (r *MyRefer) GetDataByPage() (interface{}, error, int, int, int) {
 	}
 	return sData, err, r.Page, r.PageSize, total
 }
+
+type GThjuserscorelog struct {
+	USERID          int64   `json:"-" xorm:"USERID" form:"userid" binding:"required"` // 用户ID
+	SCORECONFIGTYPE int32   `json:"scoreconfigtype" xorm:"SCORECONFIGTYPE"`           // 配置类型 - 1:注册红包 2:签到积分 3:推广积分 4:下级用户下单积分 5:自己采购下单积分 6:自己供求下单积分 7:抽奖配置
+	SCORE           float64 `json:"score" xorm:"SCORE"`                               // 变动积分
+	ORISCORE        float64 `json:"-" xorm:"ORISCORE"`                                // 期初积分(变动前积)
+	CURSCORE        float64 `json:"-" xorm:"CURSCORE"`                                // 期末积分(变动后积)
+	CREATETIME      string  `json:"createtime" xorm:"CREATETIME"`                     // 记账时间
+	REMARK          string  `json:"-" xorm:"REMARK"`                                  // 备注
+	RELATEDORDERID  int64   `json:"-" xorm:"RELATEDORDERID"`                          // 关联单号
+
+	PageEx `xorm:"extends"` // 页码信息
+}
+
+func (r *GThjuserscorelog) calc() {
+
+}
+
+func (r *GThjuserscorelog) buildSql() string {
+	var sqlId utils.SQLVal = `
+	select 
+		t.SCORECONFIGTYPE,
+		t.SCORE,
+		to_char(t.CREATETIME, 'yyyy-mm-dd hh24:mi:ss') CREATETIME
+	from THJ_USERSCORELOG t
+	where t.USERID = %v
+	order by t.CREATETIME desc
+`
+	sqlId.FormatParam(r.USERID)
+	return sqlId.String()
+}
+
+func (r *GThjuserscorelog) GetDataByPage() (interface{}, error, int, int, int) {
+	sData := make([]GThjuserscorelog, 0)
+	err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
+	total := 0
+	for i := range sData {
+		sData[i].calc()
+		total = sData[i].Total
+	}
+	return sData, err, r.Page, r.PageSize, total
+}

+ 1 - 0
routers/router.go

@@ -692,6 +692,7 @@ func InitRouter() *gin.Engine {
 		ferroalloyR.GET("GetSpotGoodsPrice", ferroalloy.GetSpotGoodsPrice)
 		ferroalloyR.POST("Signin", ferroalloy.Signin)
 		ferroalloyR.GET("QueryMyRefer", ferroalloy.QueryMyRefer)
+		ferroalloyR.GET("QueryUserScoreLog", ferroalloy.QueryUserScoreLog)
 	}
 
 	return r