Ver código fonte

增加“查询汇率信息”接口

zhou.xiaoning 3 anos atrás
pai
commit
0bdc67ee0b
7 arquivos alterados com 327 adições e 16 exclusões
  1. 29 0
      controllers/common/rate.go
  2. 90 4
      docs/docs.go
  3. 90 4
      docs/swagger.json
  4. 57 3
      docs/swagger.yaml
  5. 41 0
      models/common.go
  6. 18 5
      models/guangzuan.go
  7. 2 0
      routers/router.go

+ 29 - 0
controllers/common/rate.go

@@ -0,0 +1,29 @@
+package common
+
+import (
+	"mtp2_if/global/app"
+	"mtp2_if/models"
+
+	"github.com/gin-gonic/gin"
+)
+
+// QueryRates
+// @Summary  查询汇率信息
+// @Produce  json
+// @Security ApiKeyAuth
+// @Security LoginID
+// @Security Group
+// @Param    page          query    int false "页码"
+// @Param    pagesize      query    int false "每页条数"
+// @Param    oricurrencyid query    int false "源币种ID"
+// @Param    descurrencyid query    int false "目标币种ID"
+// @Success  200           {array}  models.Exchangerateconfig
+// @Failure  500           {object} app.Response
+// @Router   /Common/QueryRates [get]
+// @Tags     通用服务
+func QueryRates(c *gin.Context) {
+	a := app.GinUtils{Gin: app.Gin{C: c}}
+	m := models.Exchangerateconfig{}
+	a.DoBindReq(&m)
+	a.DoGetDataByPage(&m)
+}

+ 90 - 4
docs/docs.go

@@ -963,6 +963,71 @@ const docTemplate = `{
                 }
             }
         },
+        "/Common/QueryRates": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    },
+                    {
+                        "LoginID": []
+                    },
+                    {
+                        "Group": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "通用服务"
+                ],
+                "summary": "查询汇率信息",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "页码",
+                        "name": "page",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "每页条数",
+                        "name": "pagesize",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "源币种ID",
+                        "name": "oricurrencyid",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "目标币种ID",
+                        "name": "descurrencyid",
+                        "in": "query"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.Exchangerateconfig"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/Common/QueryTableDefine": {
             "get": {
                 "produces": [
@@ -26045,6 +26110,27 @@ const docTemplate = `{
                 }
             }
         },
+        "models.Exchangerateconfig": {
+            "type": "object",
+            "properties": {
+                "descurrencyid": {
+                    "description": "目标币种ID",
+                    "type": "integer"
+                },
+                "exchangerate": {
+                    "description": "汇率",
+                    "type": "number"
+                },
+                "oricurrencyid": {
+                    "description": "源币种ID",
+                    "type": "integer"
+                },
+                "remark": {
+                    "description": "备注",
+                    "type": "string"
+                }
+            }
+        },
         "models.Externalexchange": {
             "type": "object",
             "required": [
@@ -26167,6 +26253,10 @@ const docTemplate = `{
                     "description": "市场价",
                     "type": "string"
                 },
+                "mobile": {
+                    "description": "手机号码",
+                    "type": "string"
+                },
                 "origin": {
                     "description": "原产地 - 类型:3",
                     "type": "string"
@@ -26183,10 +26273,6 @@ const docTemplate = `{
                     "description": "备注",
                     "type": "string"
                 },
-                "sellmobile": {
-                    "description": "手机号码(加密存储)",
-                    "type": "string"
-                },
                 "sellusername": {
                     "description": "账户名称(机构名称)",
                     "type": "string"

+ 90 - 4
docs/swagger.json

@@ -954,6 +954,71 @@
                 }
             }
         },
+        "/Common/QueryRates": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    },
+                    {
+                        "LoginID": []
+                    },
+                    {
+                        "Group": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "通用服务"
+                ],
+                "summary": "查询汇率信息",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "页码",
+                        "name": "page",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "每页条数",
+                        "name": "pagesize",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "源币种ID",
+                        "name": "oricurrencyid",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "目标币种ID",
+                        "name": "descurrencyid",
+                        "in": "query"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.Exchangerateconfig"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/Common/QueryTableDefine": {
             "get": {
                 "produces": [
@@ -26036,6 +26101,27 @@
                 }
             }
         },
+        "models.Exchangerateconfig": {
+            "type": "object",
+            "properties": {
+                "descurrencyid": {
+                    "description": "目标币种ID",
+                    "type": "integer"
+                },
+                "exchangerate": {
+                    "description": "汇率",
+                    "type": "number"
+                },
+                "oricurrencyid": {
+                    "description": "源币种ID",
+                    "type": "integer"
+                },
+                "remark": {
+                    "description": "备注",
+                    "type": "string"
+                }
+            }
+        },
         "models.Externalexchange": {
             "type": "object",
             "required": [
@@ -26158,6 +26244,10 @@
                     "description": "市场价",
                     "type": "string"
                 },
+                "mobile": {
+                    "description": "手机号码",
+                    "type": "string"
+                },
                 "origin": {
                     "description": "原产地 - 类型:3",
                     "type": "string"
@@ -26174,10 +26264,6 @@
                     "description": "备注",
                     "type": "string"
                 },
-                "sellmobile": {
-                    "description": "手机号码(加密存储)",
-                    "type": "string"
-                },
                 "sellusername": {
                     "description": "账户名称(机构名称)",
                     "type": "string"

+ 57 - 3
docs/swagger.yaml

@@ -9564,6 +9564,21 @@ definitions:
     required:
     - hedgeditemid
     type: object
+  models.Exchangerateconfig:
+    properties:
+      descurrencyid:
+        description: 目标币种ID
+        type: integer
+      exchangerate:
+        description: 汇率
+        type: number
+      oricurrencyid:
+        description: 源币种ID
+        type: integer
+      remark:
+        description: 备注
+        type: string
+    type: object
   models.Externalexchange:
     properties:
       autoid:
@@ -9651,6 +9666,9 @@ definitions:
       marketprice:
         description: 市场价
         type: string
+      mobile:
+        description: 手机号码
+        type: string
       origin:
         description: 原产地 - 类型:3
         type: string
@@ -9663,9 +9681,6 @@ definitions:
       remark:
         description: 备注
         type: string
-      sellmobile:
-        description: 手机号码(加密存储)
-        type: string
       sellusername:
         description: 账户名称(机构名称)
         type: string
@@ -19513,6 +19528,45 @@ paths:
       summary: 查询省市信息(不包括区)
       tags:
       - 通用服务
+  /Common/QueryRates:
+    get:
+      parameters:
+      - description: 页码
+        in: query
+        name: page
+        type: integer
+      - description: 每页条数
+        in: query
+        name: pagesize
+        type: integer
+      - description: 源币种ID
+        in: query
+        name: oricurrencyid
+        type: integer
+      - description: 目标币种ID
+        in: query
+        name: descurrencyid
+        type: integer
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            items:
+              $ref: '#/definitions/models.Exchangerateconfig'
+            type: array
+        "500":
+          description: Internal Server Error
+          schema:
+            $ref: '#/definitions/app.Response'
+      security:
+      - ApiKeyAuth: []
+      - LoginID: []
+      - Group: []
+      summary: 查询汇率信息
+      tags:
+      - 通用服务
   /Common/QueryTableDefine:
     get:
       parameters:

+ 41 - 0
models/common.go

@@ -1140,3 +1140,44 @@ func GetNewErmcpRoleFuncMenuLists(loginID int, menuType int) ([]NewFuncmenulist,
 
 	return funcMenuLists, nil
 }
+
+// Exchangerateconfig 汇率配置表
+type Exchangerateconfig struct {
+	ORICURRENCYID int32     `json:"oricurrencyid" xorm:"ORICURRENCYID" form:"oricurrencyid"` // 源币种ID
+	DESCURRENCYID int32     `json:"descurrencyid" xorm:"DESCURRENCYID" form:"descurrencyid"` // 目标币种ID
+	EXCHANGERATE  float64   `json:"exchangerate" xorm:"EXCHANGERATE"`                        // 汇率
+	REMARK        string    `json:"remark" xorm:"REMARK"`                                    // 备注
+	UPDATEBY      int64     `json:"-" xorm:"UPDATEBY"`                                       // 更新人
+	UPDATETIME    time.Time `json:"-" xorm:"UPDATETIME"`                                     // 更新时间
+
+	PageEx `xorm:"extends"` // 页码信息
+}
+
+func (r *Exchangerateconfig) calc() {
+
+}
+
+func (r *Exchangerateconfig) buildSql() string {
+	var sqlId utils.SQLVal = `
+	SELECT 
+		t.*
+	FROM ExchangeRateConfig t
+	`
+
+	sqlId.AndEx("t.ORICURRENCYID", r.ORICURRENCYID, r.ORICURRENCYID > 0)
+	sqlId.AndEx("t.DESCURRENCYID", r.DESCURRENCYID, r.DESCURRENCYID > 0)
+
+	sqlId.Page(r.Page, r.PageSize)
+	return sqlId.String()
+}
+
+func (r *Exchangerateconfig) GetDataByPage() (interface{}, error, int, int, int) {
+	sData := make([]Exchangerateconfig, 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
+}

+ 18 - 5
models/guangzuan.go

@@ -1,6 +1,7 @@
 package models
 
 import (
+	"encoding/hex"
 	"mtp2_if/db"
 	"mtp2_if/utils"
 	"strings"
@@ -960,7 +961,7 @@ func (r *MyBargainApply) buildSql() string {
 		(t.APPLYQTY / 100) QTY,
 		to_char(t.APPLYTIME, 'yyyy-mm-dd hh24:mi:ss') APPLYTIME1,
 		to_char(t.WRBARGAINID) WRBARGAINID1,
-		t.*,
+		t.*
 	FROM WRTrade_BargainApply t
 	LEFT JOIN UserAccount ua ON t.MATCHUSERID = ua.userid
 	WHERE t.marketid=67201
@@ -1020,7 +1021,7 @@ func (r *MyDelistingApply) buildSql() string {
 	SELECT 
 		ua.accountname BUYUSERNAME,
 		to_char(t.APPLYTIME, 'yyyy-mm-dd hh24:mi:ss') APPLYTIME1,
-		t.*,
+		t.*
 	FROM GZ_SellDelistingApply t
 	LEFT JOIN UserAccount ua ON t.BUYUSERID = ua.userid
 	WHERE t.marketid=67201
@@ -1049,7 +1050,7 @@ func (r *MyDelistingApply) GetDataByPage() (interface{}, error, int, int, int) {
 type GZGoods struct {
 	ZSALLPROPERTIES            string `json:"-" xorm:"ZSALLPROPERTIES"`                                     // 商品(查询字段-模糊查询)
 	SELLUSERNAME               string `json:"sellusername" xorm:"SELLUSERNAME"`                             // 账户名称(机构名称)
-	SELLMOBILE                 string `json:"sellmobile" xorm:"SELLMOBILE"`                                 // 手机号码(加密存储)
+	SELLMOBILE                 string `json:"-" xorm:"SELLMOBILE"`                                          // 手机号码(加密存储)
 	ZSCATEGORYDISPLAY          string `json:"zscategorydisplay" xorm:"ZSCATEGORYDISPLAY"`                   //
 	ZSCURRENCYTYPEDISPLAY      string `json:"zscurrencytypedisplay" xorm:"ZSCURRENCYTYPEDISPLAY"`           //
 	ZSCURRENCYTYPEDISPLAYUNIT  string `json:"zscurrencytypedisplayunit" xorm:"ZSCURRENCYTYPEDISPLAYUNIT"`   //
@@ -1118,17 +1119,29 @@ type GZGoods struct {
 	ZSCZCOLOR2TYPE      int32   `json:"zsczcolor2type" xorm:"ZSCZCOLOR2TYPE"`                     // 彩钻颜色2 - 枚举”ZSCZColor2Type“ - 类型:5
 	ZSCZCOLOR3TYPE      int32   `json:"zsczcolor3type" xorm:"ZSCZCOLOR3TYPE"`                     // 彩钻颜色3 - 枚举”ZSCZColor3Type“ - 类型:5
 	ISVALID             int32   `json:"isvalid" xorm:"ISVALID"`                                   // 是否有效 - 0:无效 1:有效
+
+	MOBILE string `json:"mobile"` // 手机号码
 }
 
 func (r *GZGoods) calc() {
-
+	key, _ := hex.DecodeString(utils.AESSecretKey)
+	if len(r.SELLMOBILE) > 0 {
+		// 手机号码解密
+		if phonenum, err := hex.DecodeString(r.SELLMOBILE); err == nil { // hex -> []byte
+			if mobile, err := utils.AESDecrypt(phonenum, key); err == nil {
+				r.MOBILE = string(mobile)
+			}
+		}
+	}
 }
 
 func (r *GZGoods) buildSql() string {
 	var sqlId utils.SQLVal = `
 	SELECT 
-		t.*
+		t.*,
+		u.MOBILE
 	FROM View_GZ_WRStandard_Ex_Query t
+	LEFT JOIN userinfo u ON u.USERID = t.USERID
 	WHERE GOODSNO = '%v'
 	`
 	sqlId.FormatParam(r.GOODSNO)

+ 2 - 0
routers/router.go

@@ -146,6 +146,8 @@ func InitRouter() *gin.Engine {
 		commonR.Use(token.Auth()).DELETE("/DeleteNewFuncmenu", common.DeleteNewFuncmenu)
 
 		commonR.Use(token.Auth()).GET("/GetClientNewFuncmenu", common.GetClientNewFuncmenu)
+
+		commonR.Use(token.Auth()).GET("/QueryRates", common.QueryRates)
 	}
 	// ************************ 通用市场 ************************
 	marketR := apiR.Group("Market")