Bladeren bron

1、登录查询和用户账号信息查询接口增加“今日推荐人数”出参;
2、增加我的推荐列表接口。

zhou.xiaoning 3 jaren geleden
bovenliggende
commit
1deb155f84
8 gewijzigde bestanden met toevoegingen van 295 en 6 verwijderingen
  1. 6 6
      config/config.xml
  2. 20 0
      controllers/user/user.go
  3. 81 0
      docs/docs.go
  4. 81 0
      docs/swagger.json
  5. 51 0
      docs/swagger.yaml
  6. 54 0
      models/account.go
  7. 1 0
      models/ferroalloy.go
  8. 1 0
      routers/router.go

+ 6 - 6
config/config.xml

@@ -13,11 +13,11 @@
     <DbAddress value="192.168.31.88"/>
     <DbName value="orcl"/>
     <DbPort value="1521"/>
-    <DbUser value="mtp2_test167"/>
+    <DbUser value="mtp2_test201"/>
     <DbPwd value="muchinfo"/>
   </DbSetting>
   <RedisSetting>
-    <Address value="192.168.31.167"/>
+    <Address value="192.168.31.201"/>
     <Port value="5007"/>
     <Timeout value="3"/>
     <ConnNum value="1"/>
@@ -25,11 +25,11 @@
     <Pwd value=""/>
   </RedisSetting>
   <MqSetting>
-    <Url value="amqp://guest:guest@192.168.31.167:5020/test"/>
+    <Url value="amqp://guest:guest@192.168.31.201:5020/test"/>
     <Exchange value="entry"/>
   </MqSetting>
   <MongoDBSetting>
-    <HostName value="192.168.31.167"/>
+    <HostName value="192.168.31.201"/>
     <Port value="5025"/>
     <DBName value="HistoryQuote"/>
     <Username value="quote_test01"/>
@@ -38,8 +38,8 @@
   <MySQLSetting>
     <Host value="192.168.30.72"/>
     <Port value="3306"/>
-    <DBName value="historyquote_test167"/>
-    <Username value="quote_test167"/>
+    <DBName value="historyquote_test201"/>
+    <Username value="quote_test201"/>
     <Password value="123456"/>
   </MySQLSetting>
 </Configuration>

+ 20 - 0
controllers/user/user.go

@@ -609,3 +609,23 @@ func UpdateUserAccountStatus(c *gin.Context) {
 	logger.GetLogger().Debugln("UpdateUserAccountStatus successed: %v", "ok")
 	appG.Response(http.StatusOK, e.SUCCESS, "ok")
 }
+
+// QueryMyRefer
+// @Summary  查询我的推荐列表
+// @Produce  json
+// @Security ApiKeyAuth
+// @Security LoginID
+// @Security Group
+// @Param    userid   query    int true  "用户ID"
+// @Param    page     query    int false "页码"
+// @Param    pagesize query    int false "每页条数"
+// @Success  200      {array}  models.MyRefer
+// @Failure  500      {object} app.Response
+// @Router   /User/QueryMyRefer [get]
+// @Tags     用户信息
+func QueryMyRefer(c *gin.Context) {
+	a := app.GinUtils{Gin: app.Gin{C: c}}
+	m := models.MyRefer{}
+	a.DoBindReq(&m)
+	a.DoGetDataByPage(&m)
+}

+ 81 - 0
docs/docs.go

@@ -13984,6 +13984,66 @@ const docTemplate = `{
                 }
             }
         },
+        "/User/QueryMyRefer": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    },
+                    {
+                        "LoginID": []
+                    },
+                    {
+                        "Group": []
+                    }
+                ],
+                "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.MyRefer"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/User/QueryUserFavoriteGoodses": {
             "get": {
                 "security": [
@@ -33167,6 +33227,23 @@ const docTemplate = `{
                 }
             }
         },
+        "models.MyRefer": {
+            "type": "object",
+            "properties": {
+                "accountname": {
+                    "description": "用户名(脱敏)",
+                    "type": "string"
+                },
+                "createtime": {
+                    "description": "时间(yyyy-mm-dd)",
+                    "type": "string"
+                },
+                "score": {
+                    "description": "积分",
+                    "type": "number"
+                }
+            }
+        },
         "models.MySellOrder": {
             "type": "object",
             "required": [
@@ -40736,6 +40813,10 @@ const docTemplate = `{
                     "description": "子机构层级路径(逗号分隔,首尾加逗号)",
                     "type": "string"
                 },
+                "todayrefercount": {
+                    "description": "今日推荐人数",
+                    "type": "integer"
+                },
                 "userid": {
                     "description": "用户ID",
                     "type": "integer"

+ 81 - 0
docs/swagger.json

@@ -13975,6 +13975,66 @@
                 }
             }
         },
+        "/User/QueryMyRefer": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    },
+                    {
+                        "LoginID": []
+                    },
+                    {
+                        "Group": []
+                    }
+                ],
+                "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.MyRefer"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/User/QueryUserFavoriteGoodses": {
             "get": {
                 "security": [
@@ -33158,6 +33218,23 @@
                 }
             }
         },
+        "models.MyRefer": {
+            "type": "object",
+            "properties": {
+                "accountname": {
+                    "description": "用户名(脱敏)",
+                    "type": "string"
+                },
+                "createtime": {
+                    "description": "时间(yyyy-mm-dd)",
+                    "type": "string"
+                },
+                "score": {
+                    "description": "积分",
+                    "type": "number"
+                }
+            }
+        },
         "models.MySellOrder": {
             "type": "object",
             "required": [
@@ -40727,6 +40804,10 @@
                     "description": "子机构层级路径(逗号分隔,首尾加逗号)",
                     "type": "string"
                 },
+                "todayrefercount": {
+                    "description": "今日推荐人数",
+                    "type": "integer"
+                },
                 "userid": {
                     "description": "用户ID",
                     "type": "integer"

+ 51 - 0
docs/swagger.yaml

@@ -12089,6 +12089,18 @@ definitions:
       zssymmetrytype2display:
         type: string
     type: object
+  models.MyRefer:
+    properties:
+      accountname:
+        description: 用户名(脱敏)
+        type: string
+      createtime:
+        description: 时间(yyyy-mm-dd)
+        type: string
+      score:
+        description: 积分
+        type: number
+    type: object
   models.MySellOrder:
     properties:
       accountid:
@@ -17699,6 +17711,9 @@ definitions:
       subarealevelpath:
         description: 子机构层级路径(逗号分隔,首尾加逗号)
         type: string
+      todayrefercount:
+        description: 今日推荐人数
+        type: integer
       userid:
         description: 用户ID
         type: integer
@@ -32208,6 +32223,42 @@ paths:
       summary: 获取用户留言板信息
       tags:
       - 用户信息
+  /User/QueryMyRefer:
+    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.MyRefer'
+            type: array
+        "500":
+          description: Internal Server Error
+          schema:
+            $ref: '#/definitions/app.Response'
+      security:
+      - ApiKeyAuth: []
+      - LoginID: []
+      - Group: []
+      summary: 查询我的推荐列表
+      tags:
+      - 用户信息
   /User/QueryUserFavoriteGoodses:
     get:
       parameters:

+ 54 - 0
models/account.go

@@ -211,6 +211,8 @@ type Useraccount struct {
 	Auditsrc         int32     `json:"auditsrc"  xorm:"AUDITSRC"`                 // 审核来源 - 1:管理端 2:终端
 	Rootuserid       int64     `json:"rootuserid"  xorm:"ROOTUSERID"`             // 根用户ID
 	Canrecommend     int32     `json:"canrecommend"  xorm:"CANRECOMMEND"`         // 是否可推荐 - 0:不可 1;可
+
+	TodayRefercount int `json:"todayrefercount" xorm:"-"` // 今日推荐人数
 }
 
 // TableName is USERACCOUNT
@@ -633,6 +635,17 @@ func GetUserAccount(userID int) (*Useraccount, error) {
 		return nil, nil
 	}
 
+	// 统计今日推荐人数
+	type tmp struct {
+		TodayRefercount int `xorm:"TODAYREFERCOUNT"`
+	}
+	t := new(tmp)
+	sql := fmt.Sprintf("select count(t.userid) TODAYREFERCOUNT from useraccount t where to_char(t.createtime, 'yyyymmdd') = to_char(sysdate, 'yyyymmdd') and t.REFEREEUSERID = %v", userAccount.Userid)
+	if _, err := engine.SQL(sql).Get(t); err != nil {
+		return nil, err
+	}
+	userAccount.TodayRefercount = t.TodayRefercount
+
 	return &userAccount, nil
 }
 
@@ -1196,3 +1209,44 @@ func (r *RelatedTaAccount) GetDataEx() (interface{}, error) {
 	}
 	return sData, err
 }
+
+// 我的推荐列表
+type MyRefer struct {
+	Accountname string  `json:"accountname" xorm:"ACCOUNTNAME"` // 用户名(脱敏)
+	Score       float64 `json:"score" xorm:"SCORE"`             // 积分
+	CREATETIME  string  `json:"createtime" xorm:"CREATETIME"`   // 时间(yyyy-mm-dd)
+
+	UserID int `json:"-" form:"userid" binding:"required"` // 用户ID
+
+	PageEx `xorm:"extends"` // 页码信息
+}
+
+func (r *MyRefer) calc() {
+	r.Accountname = EncryptByStar(r.Accountname)
+}
+
+func (r *MyRefer) buildSql() string {
+	var sqlId utils.SQLVal = `
+	select 
+		u.ACCOUNTNAME,
+		t.SCORE,
+		to_char(t.CREATETIME, 'yyyy-mm-dd') CREATETIME
+	from THJ_USERSCORELOG t
+	inner join useraccount u on u.userid = t.userid
+	where t.RELATEDORDERID = %v
+	order by t.createtime desc
+`
+	sqlId.FormatParam(r.UserID)
+	return sqlId.String()
+}
+
+func (r *MyRefer) GetDataByPage() (interface{}, error, int, int, int) {
+	sData := make([]MyRefer, 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
models/ferroalloy.go

@@ -177,6 +177,7 @@ func (r *THJSigninReq) Signin() (err error) {
 	q.ORISCORE = float64(curscore)
 	q.CURSCORE = float64(t.CURSCORE)
 	q.CREATETIME = time.Now()
+	q.RELATEDORDERID = r.USERID
 	_, err = session.Insert(&q)
 	if err != nil {
 		session.Rollback()

+ 1 - 0
routers/router.go

@@ -97,6 +97,7 @@ func InitRouter() *gin.Engine {
 		userR.Use(token.Auth()).POST("/UpdateUserAccountStatus", user.UpdateUserAccountStatus)
 		// 账户登录后信息查询
 		userR.Use(token.Auth()).GET("/LoginQuery", user.LoginQuery)
+		userR.Use(token.Auth()).GET("/QueryMyRefer", user.QueryMyRefer)
 	}
 	// ************************ 资金账户 ************************
 	taAccountR := apiR.Group("TaAccount")