Browse Source

1.增加查询“我的积分”接口
2.修改查询团队订单接口(增加交易模式过滤)
3.修改菜单权限获取接口(角色20按0查找,如有多个角色去除20再查)

zou.yingbin 4 years ago
parent
commit
9750275244
7 changed files with 489 additions and 7 deletions
  1. 21 1
      controllers/qhj/qryQhj.go
  2. 139 2
      docs/docs.go
  3. 139 2
      docs/swagger.json
  4. 96 2
      docs/swagger.yaml
  5. 23 0
      models/ermcpAccMgr.go
  6. 70 0
      models/qhj.go
  7. 1 0
      routers/router.go

+ 21 - 1
controllers/qhj/qryQhj.go

@@ -450,7 +450,7 @@ func QueryAreaFinanceConfig(c *gin.Context) {
 // @Produce json
 // @Security ApiKeyAuth
 // @Param userid query int true "用户ID"
-// @Success 200 {array} models.QhjMyTeam
+// @Success 200 {array} models.QhjMyTeamEx
 // @Failure 500 {object} app.Response
 // @Router /Qhj/QueryMyTeam [get]
 // @Tags 大连千海金
@@ -471,6 +471,7 @@ func QueryMyTeam(c *gin.Context) {
 // @Param page query int false "页码"
 // @Param pagesize query int false "每页条数"
 // @Param userid query int true "用户ID"
+// @Param trademode query int false "交易模式"
 // @Param filtername query string false "名称(模糊搜索账户)"
 // @Success 200 {array} models.QhjTeamOrder
 // @Failure 500 {object} app.Response
@@ -500,3 +501,22 @@ func QueryBrokerRewardLog(c *gin.Context) {
 	a.DoBindReq(&m)
 	a.DoGetDataI(&m)
 }
+
+// QueryScoreLog
+// @Summary 查询积分流水(我的积分)
+// @Produce json
+// @Security ApiKeyAuth
+// @Param userid query int true "用户ID"
+// @Param begindate query string false "开始交易日(yyyymmdd)"
+// @Param enddate query string false "结束交易日(yyyymmdd)"
+// @Param lastnum query int false "最近多少条"
+// @Success 200 {array} models.QhjScoreLog
+// @Failure 500 {object} app.Response
+// @Router /Qhj/QueryScoreLog [get]
+// @Tags 大连千海金
+func QueryScoreLog(c *gin.Context) {
+	a := app.GinUtils{Gin: app.Gin{C: c}}
+	m := models.QhjScoreLog{}
+	a.DoBindReq(&m)
+	a.DoGetDataI(&m)
+}

+ 139 - 2
docs/docs.go

@@ -7555,7 +7555,7 @@ var doc = `{
                         "schema": {
                             "type": "array",
                             "items": {
-                                "$ref": "#/definitions/models.QhjMyTeam"
+                                "$ref": "#/definitions/models.QhjMyTeamEx"
                             }
                         }
                     },
@@ -7603,6 +7603,12 @@ var doc = `{
                         "required": true
                     },
                     {
+                        "type": "integer",
+                        "description": "交易模式",
+                        "name": "trademode",
+                        "in": "query"
+                    },
+                    {
                         "type": "string",
                         "description": "名称(模糊搜索账户)",
                         "name": "filtername",
@@ -7990,6 +7996,66 @@ var doc = `{
                 }
             }
         },
+        "/Qhj/QueryScoreLog": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "大连千海金"
+                ],
+                "summary": "查询积分流水(我的积分)",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "用户ID",
+                        "name": "userid",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "string",
+                        "description": "开始交易日(yyyymmdd)",
+                        "name": "begindate",
+                        "in": "query"
+                    },
+                    {
+                        "type": "string",
+                        "description": "结束交易日(yyyymmdd)",
+                        "name": "enddate",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "最近多少条",
+                        "name": "lastnum",
+                        "in": "query"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.QhjScoreLog"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/Qhj/QuerySiteColumnDetail": {
             "get": {
                 "security": [
@@ -25452,7 +25518,7 @@ var doc = `{
                 }
             }
         },
-        "models.QhjMyTeam": {
+        "models.QhjMyTeamEx": {
             "type": "object",
             "properties": {
                 "accountname": {
@@ -25479,6 +25545,12 @@ var doc = `{
                     "description": "推荐码",
                     "type": "string"
                 },
+                "subList": {
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/models.QhjMyTeamEx"
+                    }
+                },
                 "userid": {
                     "description": "用户id",
                     "type": "integer"
@@ -26129,6 +26201,71 @@ var doc = `{
                 }
             }
         },
+        "models.QhjScoreLog": {
+            "type": "object",
+            "properties": {
+                "accountid": {
+                    "description": "账户ID",
+                    "type": "integer"
+                },
+                "createtime": {
+                    "description": "创建时间(时间)",
+                    "type": "string"
+                },
+                "goodsid": {
+                    "description": "商品ID",
+                    "type": "integer"
+                },
+                "hasuploaded": {
+                    "description": "是否已同步(千海金) 0:未同步 1;已同步",
+                    "type": "integer"
+                },
+                "logid": {
+                    "description": "流水ID(211+Unix秒时间戳(10位)+2位(MarketServiceID)+xxxx)",
+                    "type": "string"
+                },
+                "marketid": {
+                    "description": "市场ID",
+                    "type": "integer"
+                },
+                "relatedamount": {
+                    "description": "关联金额",
+                    "type": "number"
+                },
+                "relatedorderid": {
+                    "description": "关联单号(ScoreType=1为Trade_GoodsPickup)",
+                    "type": "string"
+                },
+                "scoreconfigvalue1": {
+                    "description": "积分配置1",
+                    "type": "integer"
+                },
+                "scoreconfigvalue2": {
+                    "description": "积分配置1",
+                    "type": "integer"
+                },
+                "scoretype": {
+                    "description": "积分类型 - 1:提货积分",
+                    "type": "integer"
+                },
+                "scorevalue": {
+                    "description": "积分",
+                    "type": "number"
+                },
+                "tradedate": {
+                    "description": "交易日(yyyyMMdd)",
+                    "type": "string"
+                },
+                "uploadedtime": {
+                    "description": "同步时间",
+                    "type": "string"
+                },
+                "userid": {
+                    "description": "用户ID",
+                    "type": "integer"
+                }
+            }
+        },
         "models.QhjSiteColumnDetail": {
             "type": "object",
             "properties": {

+ 139 - 2
docs/swagger.json

@@ -7539,7 +7539,7 @@
                         "schema": {
                             "type": "array",
                             "items": {
-                                "$ref": "#/definitions/models.QhjMyTeam"
+                                "$ref": "#/definitions/models.QhjMyTeamEx"
                             }
                         }
                     },
@@ -7587,6 +7587,12 @@
                         "required": true
                     },
                     {
+                        "type": "integer",
+                        "description": "交易模式",
+                        "name": "trademode",
+                        "in": "query"
+                    },
+                    {
                         "type": "string",
                         "description": "名称(模糊搜索账户)",
                         "name": "filtername",
@@ -7974,6 +7980,66 @@
                 }
             }
         },
+        "/Qhj/QueryScoreLog": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "大连千海金"
+                ],
+                "summary": "查询积分流水(我的积分)",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "用户ID",
+                        "name": "userid",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "string",
+                        "description": "开始交易日(yyyymmdd)",
+                        "name": "begindate",
+                        "in": "query"
+                    },
+                    {
+                        "type": "string",
+                        "description": "结束交易日(yyyymmdd)",
+                        "name": "enddate",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "最近多少条",
+                        "name": "lastnum",
+                        "in": "query"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.QhjScoreLog"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/Qhj/QuerySiteColumnDetail": {
             "get": {
                 "security": [
@@ -25436,7 +25502,7 @@
                 }
             }
         },
-        "models.QhjMyTeam": {
+        "models.QhjMyTeamEx": {
             "type": "object",
             "properties": {
                 "accountname": {
@@ -25463,6 +25529,12 @@
                     "description": "推荐码",
                     "type": "string"
                 },
+                "subList": {
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/models.QhjMyTeamEx"
+                    }
+                },
                 "userid": {
                     "description": "用户id",
                     "type": "integer"
@@ -26113,6 +26185,71 @@
                 }
             }
         },
+        "models.QhjScoreLog": {
+            "type": "object",
+            "properties": {
+                "accountid": {
+                    "description": "账户ID",
+                    "type": "integer"
+                },
+                "createtime": {
+                    "description": "创建时间(时间)",
+                    "type": "string"
+                },
+                "goodsid": {
+                    "description": "商品ID",
+                    "type": "integer"
+                },
+                "hasuploaded": {
+                    "description": "是否已同步(千海金) 0:未同步 1;已同步",
+                    "type": "integer"
+                },
+                "logid": {
+                    "description": "流水ID(211+Unix秒时间戳(10位)+2位(MarketServiceID)+xxxx)",
+                    "type": "string"
+                },
+                "marketid": {
+                    "description": "市场ID",
+                    "type": "integer"
+                },
+                "relatedamount": {
+                    "description": "关联金额",
+                    "type": "number"
+                },
+                "relatedorderid": {
+                    "description": "关联单号(ScoreType=1为Trade_GoodsPickup)",
+                    "type": "string"
+                },
+                "scoreconfigvalue1": {
+                    "description": "积分配置1",
+                    "type": "integer"
+                },
+                "scoreconfigvalue2": {
+                    "description": "积分配置1",
+                    "type": "integer"
+                },
+                "scoretype": {
+                    "description": "积分类型 - 1:提货积分",
+                    "type": "integer"
+                },
+                "scorevalue": {
+                    "description": "积分",
+                    "type": "number"
+                },
+                "tradedate": {
+                    "description": "交易日(yyyyMMdd)",
+                    "type": "string"
+                },
+                "uploadedtime": {
+                    "description": "同步时间",
+                    "type": "string"
+                },
+                "userid": {
+                    "description": "用户ID",
+                    "type": "integer"
+                }
+            }
+        },
         "models.QhjSiteColumnDetail": {
             "type": "object",
             "properties": {

+ 96 - 2
docs/swagger.yaml

@@ -11007,7 +11007,7 @@ definitions:
         description: 账户类型 1-个人 2-企业
         type: integer
     type: object
-  models.QhjMyTeam:
+  models.QhjMyTeamEx:
     properties:
       accountname:
         description: 用户名称
@@ -11027,6 +11027,10 @@ definitions:
       refernum:
         description: 推荐码
         type: string
+      subList:
+        items:
+          $ref: '#/definitions/models.QhjMyTeamEx'
+        type: array
       userid:
         description: 用户id
         type: integer
@@ -11508,6 +11512,54 @@ definitions:
         description: 连续三日涨跌幅
         type: number
     type: object
+  models.QhjScoreLog:
+    properties:
+      accountid:
+        description: 账户ID
+        type: integer
+      createtime:
+        description: 创建时间(时间)
+        type: string
+      goodsid:
+        description: 商品ID
+        type: integer
+      hasuploaded:
+        description: 是否已同步(千海金) 0:未同步 1;已同步
+        type: integer
+      logid:
+        description: 流水ID(211+Unix秒时间戳(10位)+2位(MarketServiceID)+xxxx)
+        type: string
+      marketid:
+        description: 市场ID
+        type: integer
+      relatedamount:
+        description: 关联金额
+        type: number
+      relatedorderid:
+        description: 关联单号(ScoreType=1为Trade_GoodsPickup)
+        type: string
+      scoreconfigvalue1:
+        description: 积分配置1
+        type: integer
+      scoreconfigvalue2:
+        description: 积分配置1
+        type: integer
+      scoretype:
+        description: 积分类型 - 1:提货积分
+        type: integer
+      scorevalue:
+        description: 积分
+        type: number
+      tradedate:
+        description: 交易日(yyyyMMdd)
+        type: string
+      uploadedtime:
+        description: 同步时间
+        type: string
+      userid:
+        description: 用户ID
+        type: integer
+    type: object
   models.QhjSiteColumnDetail:
     properties:
       author:
@@ -19689,7 +19741,7 @@ paths:
           description: OK
           schema:
             items:
-              $ref: '#/definitions/models.QhjMyTeam'
+              $ref: '#/definitions/models.QhjMyTeamEx'
             type: array
         "500":
           description: Internal Server Error
@@ -19716,6 +19768,10 @@ paths:
         name: userid
         required: true
         type: integer
+      - description: 交易模式
+        in: query
+        name: trademode
+        type: integer
       - description: 名称(模糊搜索账户)
         in: query
         name: filtername
@@ -19964,6 +20020,44 @@ paths:
       summary: 查询定投价(结算价)
       tags:
       - 大连千海金
+  /Qhj/QueryScoreLog:
+    get:
+      parameters:
+      - description: 用户ID
+        in: query
+        name: userid
+        required: true
+        type: integer
+      - description: 开始交易日(yyyymmdd)
+        in: query
+        name: begindate
+        type: string
+      - description: 结束交易日(yyyymmdd)
+        in: query
+        name: enddate
+        type: string
+      - description: 最近多少条
+        in: query
+        name: lastnum
+        type: integer
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            items:
+              $ref: '#/definitions/models.QhjScoreLog'
+            type: array
+        "500":
+          description: Internal Server Error
+          schema:
+            $ref: '#/definitions/app.Response'
+      security:
+      - ApiKeyAuth: []
+      summary: 查询积分流水(我的积分)
+      tags:
+      - 大连千海金
   /Qhj/QuerySiteColumnDetail:
     get:
       parameters:

+ 23 - 0
models/ermcpAccMgr.go

@@ -12,6 +12,7 @@ import (
 	"mtp2_if/db"
 	"mtp2_if/mtpcache"
 	"mtp2_if/utils"
+	"strconv"
 	"strings"
 )
 
@@ -638,6 +639,28 @@ func (r *ErmcpRoleMenu) GetDataEx() (interface{}, error) {
 		v.addEx(sData)
 	}
 
+	// 替换角色id, 20变为0, 如果多个角色, 则不要20
+	if len(r.FilterRoleId) > 0 {
+		var newRoleId string
+		sRole := strings.Split(r.FilterRoleId, ",")
+		// 把不是20的取出来, 去除20角色
+		for _, v := range sRole {
+			if d, err := strconv.ParseInt(v, 10, 32); err == nil {
+				if d != 20 {
+					if len(newRoleId) > 0 {
+						newRoleId += ","
+					}
+					newRoleId += v
+				}
+			}
+		}
+		// 只有20的角色, 则变为0角色
+		if len(newRoleId) == 0 {
+			newRoleId = "0"
+		}
+		r.FilterRoleId = newRoleId
+	}
+
 	// 获取有权限的菜单
 	var err error
 	if len(r.FilterRoleId) > 0 {

+ 70 - 0
models/qhj.go

@@ -2031,6 +2031,7 @@ func (r *QhjTeamOrder) buildSql() string {
 		"   and e.enumdiccode = 'goodsunit'" +
 		" where 1 = 1"
 	sqlId.AndEx("u.refereeuserid", r.USERID, r.USERID > 0)
+	sqlId.AndEx("m.trademode", r.TRADEMODE, r.TRADEMODE > 0)
 	sqlCur := fmt.Sprintf(sqlId.String(), "trade_tradedetail")
 	sqlHis := fmt.Sprintf(sqlId.String(), "his_trade_tradedetail")
 	if len(r.FilterName) > 0 {
@@ -2140,3 +2141,72 @@ func (r *QhjBrokerRewardLog) GetDataEx() (interface{}, error) {
 	}
 	return sData, err
 }
+
+// QhjScoreLog 积分流水
+type QhjScoreLog struct {
+	LOGID             string  `json:"logid"  xorm:"LOGID" form:"logid"`                                     // 流水ID(211+Unix秒时间戳(10位)+2位(MarketServiceID)+xxxx)
+	TRADEDATE         string  `json:"tradedate"  xorm:"TRADEDATE" form:"tradedate"`                         // 交易日(yyyyMMdd)
+	USERID            int64   `json:"userid"  xorm:"USERID" form:"userid"`                                  // 用户ID
+	SCORETYPE         int32   `json:"scoretype"  xorm:"SCORETYPE" form:"scoretype"`                         // 积分类型 - 1:提货积分
+	SCOREVALUE        float64 `json:"scorevalue"  xorm:"SCOREVALUE" form:"scorevalue"`                      // 积分
+	RELATEDORDERID    string  `json:"relatedorderid"  xorm:"RELATEDORDERID" form:"relatedorderid"`          // 关联单号(ScoreType=1为Trade_GoodsPickup)
+	RELATEDAMOUNT     float64 `json:"relatedamount"  xorm:"RELATEDAMOUNT" form:"relatedamount"`             // 关联金额
+	SCORECONFIGVALUE1 int32   `json:"scoreconfigvalue1"  xorm:"SCORECONFIGVALUE1" form:"scoreconfigvalue1"` // 积分配置1
+	SCORECONFIGVALUE2 int32   `json:"scoreconfigvalue2"  xorm:"SCORECONFIGVALUE2" form:"scoreconfigvalue2"` // 积分配置1
+	GOODSID           int64   `json:"goodsid"  xorm:"GOODSID" form:"goodsid"`                               // 商品ID
+	ACCOUNTID         int64   `json:"accountid"  xorm:"ACCOUNTID" form:"accountid"`                         // 账户ID
+	MARKETID          int32   `json:"marketid"  xorm:"MARKETID" form:"marketid"`                            // 市场ID
+	CREATETIME        string  `json:"createtime"  xorm:"CREATETIME" form:"createtime"`                      // 创建时间(时间)
+	HASUPLOADED       int32   `json:"hasuploaded"  xorm:"HASUPLOADED" form:"hasuploaded"`                   // 是否已同步(千海金) 0:未同步 1;已同步
+	UPLOADEDTIME      string  `json:"uploadedtime"  xorm:"UPLOADEDTIME" form:"uploadedtime"`                // 同步时间
+
+	BeginDate string `json:"-" form:"begindate"` // 开始交易日
+	EndDate   string `json:"-" form:"enddate"`   // 结束交易日
+	LastNum   int    `json:"-" form:"lastnum"`   // 最近多少条
+}
+
+func (r *QhjScoreLog) calc() {
+
+}
+
+func (r *QhjScoreLog) buildSql() string {
+	var sqlId utils.SQLVal = "SELECT t.LOGID," +
+		"       t.TRADEDATE," +
+		"       t.USERID," +
+		"       t.SCORETYPE," +
+		"       t.SCOREVALUE," +
+		"       to_char(t.RELATEDORDERID) RELATEDORDERID," +
+		"       t.RELATEDAMOUNT," +
+		"       t.SCORECONFIGVALUE1," +
+		"       t.SCORECONFIGVALUE2," +
+		"       t.GOODSID," +
+		"       t.ACCOUNTID," +
+		"       t.MARKETID," +
+		"       to_char(t.CREATETIME, 'yyyy-mm-dd hh24:mi:ss') CREATETIME," +
+		"       t.HASUPLOADED," +
+		"       to_char(t.UPLOADEDTIME, 'yyyy-mm-dd hh24:mi:ss') UPLOADEDTIME" +
+		"  FROM QHJ_SCORELOG t" +
+		" WHERE 1 = 1"
+	sqlId.AndEx("t.USERID", r.USERID, r.USERID > 0)
+	if r.BeginDate != "" {
+		sqlId.JoinFormat(" and to_char(t.CREATETIME, 'yyyymmdd') >= '%v'", r.BeginDate)
+	}
+	if r.EndDate != "" {
+		sqlId.JoinFormat(" and to_char(t.CREATETIME, 'yyyymmdd') <= '%v'", r.EndDate)
+	}
+	sqlId.Join(" order by t.CREATETIME desc")
+	if r.LastNum > 0 {
+		sqlId.Page(1, r.LastNum)
+	}
+	return sqlId.String()
+}
+
+// GetDataEx 获取积分流水
+func (r *QhjScoreLog) GetDataEx() (interface{}, error) {
+	sData := make([]QhjScoreLog, 0)
+	err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
+	for i := range sData {
+		sData[i].calc()
+	}
+	return sData, err
+}

+ 1 - 0
routers/router.go

@@ -477,6 +477,7 @@ func InitRouter() *gin.Engine {
 		qhjR.GET("QueryMyTeam", qhj.QueryMyTeam)
 		qhjR.GET("QueryMyTeamOrder", qhj.QueryTeamOrder)
 		qhjR.GET("QueryBrokerRewardLog", qhj.QueryBrokerRewardLog)
+		qhjR.GET("QueryScoreLog", qhj.QueryScoreLog)
 	}
 
 	// *************************千海金(PCWeb)*****************************