Procházet zdrojové kódy

#7100 【Go查询】添加接口"用户积分明细查询": /User/QueryUserScoreDetail, 按到期日顺序

deng.yinping před 3 měsíci
rodič
revize
3bc0dbaa9d
7 změnil soubory, kde provedl 304 přidání a 15 odebrání
  1. 32 0
      controllers/user/user.go
  2. 84 0
      docs/docs.go
  3. 84 0
      docs/swagger.json
  4. 57 0
      docs/swagger.yaml
  5. 16 1
      models/common.go
  6. 29 14
      models/ori.go
  7. 2 0
      routers/router.go

+ 32 - 0
controllers/user/user.go

@@ -795,3 +795,35 @@ func QueryUserScore(c *gin.Context) {
 	// 查询成功
 	appG.Response(http.StatusOK, e.SUCCESS, datas)
 }
+
+// QueryUserScoreDetail 用户积分明细查询
+// @Summary  用户积分明细查询
+// @Produce  json
+// @Security ApiKeyAuth
+// @Param    userID query    int true "用户ID"
+// @Success  200       {object} models.QuerUserScoreDetailRsp
+// @Failure  500    {object} app.Response
+// @Router   /User/QueryUserScoreDetail [get]
+// @Tags     用户信息
+func QueryUserScoreDetail(c *gin.Context) {
+	appG := app.Gin{C: c}
+
+	// 获取请求参数
+	var req QueryUserScoreReq
+	if err := appG.C.ShouldBindQuery(&req); err != nil {
+		logger.GetLogger().Errorf("QueryUserScoreDetail failed: %s", err.Error())
+		appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
+		return
+	}
+
+	datas, err := models.GetUserScoreDetail(req.UserID)
+	if err != nil {
+		// 查询失败
+		logger.GetLogger().Errorf("QueryUserScoreDetail failed: %s", err.Error())
+		appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
+		return
+	}
+
+	// 查询成功
+	appG.Response(http.StatusOK, e.SUCCESS, datas)
+}

+ 84 - 0
docs/docs.go

@@ -20600,6 +20600,45 @@ const docTemplate = `{
                 }
             }
         },
+        "/User/QueryUserScoreDetail": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "用户信息"
+                ],
+                "summary": "用户积分明细查询",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "用户ID",
+                        "name": "userID",
+                        "in": "query",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "$ref": "#/definitions/models.QuerUserScoreDetailRsp"
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/User/RemoveUserFavoriteGoods": {
             "post": {
                 "security": [
@@ -52844,6 +52883,51 @@ const docTemplate = `{
                 }
             }
         },
+        "models.QuerUserScoreDetailRsp": {
+            "type": "object",
+            "properties": {
+                "createdtime": {
+                    "description": "创建时间",
+                    "type": "string"
+                },
+                "detailid": {
+                    "description": "明细单号",
+                    "type": "integer"
+                },
+                "expiredate": {
+                    "description": "到期日期",
+                    "type": "string"
+                },
+                "remainscore": {
+                    "description": "剩余积分",
+                    "type": "integer"
+                },
+                "score": {
+                    "description": "积分",
+                    "type": "integer"
+                },
+                "scoretypeid": {
+                    "description": "积分类型ID",
+                    "type": "integer"
+                },
+                "scoretypename": {
+                    "description": "积分类型名称",
+                    "type": "string"
+                },
+                "tradedate": {
+                    "description": "交易日",
+                    "type": "integer"
+                },
+                "userid": {
+                    "description": "用户ID",
+                    "type": "integer"
+                },
+                "validtype": {
+                    "description": "有效类型(枚举'ValidType')",
+                    "type": "integer"
+                }
+            }
+        },
         "models.QuerUserScoreRsp": {
             "type": "object",
             "properties": {

+ 84 - 0
docs/swagger.json

@@ -20591,6 +20591,45 @@
                 }
             }
         },
+        "/User/QueryUserScoreDetail": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "用户信息"
+                ],
+                "summary": "用户积分明细查询",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "用户ID",
+                        "name": "userID",
+                        "in": "query",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "$ref": "#/definitions/models.QuerUserScoreDetailRsp"
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/User/RemoveUserFavoriteGoods": {
             "post": {
                 "security": [
@@ -52835,6 +52874,51 @@
                 }
             }
         },
+        "models.QuerUserScoreDetailRsp": {
+            "type": "object",
+            "properties": {
+                "createdtime": {
+                    "description": "创建时间",
+                    "type": "string"
+                },
+                "detailid": {
+                    "description": "明细单号",
+                    "type": "integer"
+                },
+                "expiredate": {
+                    "description": "到期日期",
+                    "type": "string"
+                },
+                "remainscore": {
+                    "description": "剩余积分",
+                    "type": "integer"
+                },
+                "score": {
+                    "description": "积分",
+                    "type": "integer"
+                },
+                "scoretypeid": {
+                    "description": "积分类型ID",
+                    "type": "integer"
+                },
+                "scoretypename": {
+                    "description": "积分类型名称",
+                    "type": "string"
+                },
+                "tradedate": {
+                    "description": "交易日",
+                    "type": "integer"
+                },
+                "userid": {
+                    "description": "用户ID",
+                    "type": "integer"
+                },
+                "validtype": {
+                    "description": "有效类型(枚举'ValidType')",
+                    "type": "integer"
+                }
+            }
+        },
         "models.QuerUserScoreRsp": {
             "type": "object",
             "properties": {

+ 57 - 0
docs/swagger.yaml

@@ -21228,6 +21228,39 @@ definitions:
         description: 现货商品ID
         type: integer
     type: object
+  models.QuerUserScoreDetailRsp:
+    properties:
+      createdtime:
+        description: 创建时间
+        type: string
+      detailid:
+        description: 明细单号
+        type: integer
+      expiredate:
+        description: 到期日期
+        type: string
+      remainscore:
+        description: 剩余积分
+        type: integer
+      score:
+        description: 积分
+        type: integer
+      scoretypeid:
+        description: 积分类型ID
+        type: integer
+      scoretypename:
+        description: 积分类型名称
+        type: string
+      tradedate:
+        description: 交易日
+        type: integer
+      userid:
+        description: 用户ID
+        type: integer
+      validtype:
+        description: 有效类型(枚举'ValidType')
+        type: integer
+    type: object
   models.QuerUserScoreRsp:
     properties:
       curscore:
@@ -45341,6 +45374,30 @@ paths:
       summary: 用户积分信息查询
       tags:
       - 用户信息
+  /User/QueryUserScoreDetail:
+    get:
+      parameters:
+      - description: 用户ID
+        in: query
+        name: userID
+        required: true
+        type: integer
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            $ref: '#/definitions/models.QuerUserScoreDetailRsp'
+        "500":
+          description: Internal Server Error
+          schema:
+            $ref: '#/definitions/app.Response'
+      security:
+      - ApiKeyAuth: []
+      summary: 用户积分明细查询
+      tags:
+      - 用户信息
   /User/RemoveUserFavoriteGoods:
     post:
       parameters:

+ 16 - 1
models/common.go

@@ -1634,7 +1634,7 @@ func GetUserScore(userID int) (datas []QuerUserScoreRsp, err error) {
 	engine := db.GetEngine()
 	rspdatas := make([]QuerUserScoreRsp, 0)
 	if err := engine.Table("USERSCORE T").
-		Join("LEFT", "SCORETYPE ST", `T.scoretypeid = ST.SCORETYPEID`).
+		Join("LEFT", "SCORETYPE ST", `T.SCORETYPEID = ST.SCORETYPEID`).
 		Select("T.*, ST.SCORETYPENAME AS SCORETYPENAME").
 		Where("T.USERID = ?", userID).Find(&rspdatas); err != nil {
 		return nil, err
@@ -1642,3 +1642,18 @@ func GetUserScore(userID int) (datas []QuerUserScoreRsp, err error) {
 
 	return rspdatas, nil
 }
+
+func GetUserScoreDetail(userID int) (datas []QuerUserScoreDetailRsp, err error) {
+	engine := db.GetEngine()
+	rspdatas := make([]QuerUserScoreDetailRsp, 0)
+	if err := engine.Table("USERSCOREDETAIL T").
+		Join("LEFT", "SCORETYPE ST", `T.SCORETYPEID = ST.SCORETYPEID`).
+		Select("T.DETAILID, T.TRADEDATE, T.USERID, T.SCORETYPEID, T.SCORE, T.REMAINSCORE, "+
+			"T.VALIDTYPE, CASE WHEN T.VALIDTYPE = 1 OR T.VALIDTYPE = 3 THEN T.EXPIREDATE ELSE '-' END AS EXPIREDATE, "+
+			"TO_CHAR(T.CREATETIME, 'YYYY-MM-DD HH24:MI:SS') CREATETIME, ST.SCORETYPENAME AS SCORETYPENAME").
+		Where("T.USERID = ?", userID).Find(&rspdatas); err != nil {
+		return nil, err
+	}
+
+	return rspdatas, nil
+}

+ 29 - 14
models/ori.go

@@ -1084,20 +1084,6 @@ type ClientDocumentConfig struct {
 
 }
 
-// QuerUserScoreRsp 用户积分查询返回请求
-type QuerUserScoreRsp struct {
-	USERID        int64 `json:"userid" xorm:"USERID"`               // 用户ID
-	SCORETYPEID   int32 `json:"scoretypeid" xorm:"SCORETYPEID"`     // 积分类型ID
-	ORISCORE      int32 `json:"oriscore" xorm:"ORISCORE"`           // 期初积分
-	CURSCORE      int32 `json:"curscore" xorm:"CURSCORE"`           // 期末积分
-	FREEZESCORE   int32 `json:"freezescore" xorm:"FREEZESCORE"`     // 冻结积分
-	TODAYINCREASE int32 `json:"todayincrease" xorm:"TODAYINCREASE"` // 今日增加
-	TODAYDECREASE int32 `json:"todaydecrease" xorm:"TODAYDECREASE"` // 今日减少
-	WITHHOLDSOCRE int32 `json:"withholdsocre" xorm:"WITHHOLDSOCRE"` // 代扣积分[积分服务商]
-
-	SCORETYPENAME string `json:"scoretypename" xorm:"SCORETYPENAME"` // 积分类型名称
-}
-
 // TableName is CLIENT_DOCUMNETCONFIG
 func (r *ClientDocumentConfig) TableName() string {
 	return "CLIENT_DOCUMNETCONFIG"
@@ -1411,3 +1397,32 @@ type Hybridamtrec struct {
 func (r *Hybridamtrec) TableName() string {
 	return "HYBRID_AMT_REC"
 }
+
+// QuerUserScoreRsp 用户积分查询返回请求
+type QuerUserScoreRsp struct {
+	USERID        int64 `json:"userid" xorm:"USERID"`               // 用户ID
+	SCORETYPEID   int32 `json:"scoretypeid" xorm:"SCORETYPEID"`     // 积分类型ID
+	ORISCORE      int32 `json:"oriscore" xorm:"ORISCORE"`           // 期初积分
+	CURSCORE      int32 `json:"curscore" xorm:"CURSCORE"`           // 期末积分
+	FREEZESCORE   int32 `json:"freezescore" xorm:"FREEZESCORE"`     // 冻结积分
+	TODAYINCREASE int32 `json:"todayincrease" xorm:"TODAYINCREASE"` // 今日增加
+	TODAYDECREASE int32 `json:"todaydecrease" xorm:"TODAYDECREASE"` // 今日减少
+	WITHHOLDSOCRE int32 `json:"withholdsocre" xorm:"WITHHOLDSOCRE"` // 代扣积分[积分服务商]
+
+	SCORETYPENAME string `json:"scoretypename" xorm:"SCORETYPENAME"` // 积分类型名称
+}
+
+// QuerUserScoreDetailRsp 用户积分明细查询返回请求
+type QuerUserScoreDetailRsp struct {
+	DETAILID    int64  `json:"detailid" xorm:"DETAILID"`       // 明细单号
+	TRADEDATE   int64  `json:"tradedate" xorm:"TRADEDATE"`     // 交易日
+	USERID      int64  `json:"userid" xorm:"USERID"`           // 用户ID
+	SCORETYPEID int32  `json:"scoretypeid" xorm:"SCORETYPEID"` // 积分类型ID
+	SCORE       int32  `json:"score" xorm:"SCORE"`             // 积分
+	REMAINSCORE int32  `json:"remainscore" xorm:"REMAINSCORE"` // 剩余积分
+	VALIDTYPE   int32  `json:"validtype" xorm:"VALIDTYPE"`     // 有效类型(枚举'ValidType')
+	EXPIREDATE  string `json:"expiredate" xorm:"EXPIREDATE"`   // 到期日期
+	CREATEDTIME string `json:"createdtime" xorm:"CREATEDTIME"` // 创建时间
+
+	SCORETYPENAME string `json:"scoretypename" xorm:"SCORETYPENAME"` // 积分类型名称
+}

+ 2 - 0
routers/router.go

@@ -128,6 +128,8 @@ func InitRouter() *gin.Engine {
 
 		// 用户积分信息查询
 		userR.Use(token.Auth()).GET("/QueryUserScore", user.QueryUserScore)
+		// 用户积分明细查询
+		userR.Use(token.Auth()).GET("/QueryUserScoreDetail", user.QueryUserScoreDetail)
 	}
 	// ************************ 资金账户 ************************
 	taAccountR := apiR.Group("TaAccount")