Prechádzať zdrojové kódy

增加查询基差贸易待审核业务接口

zou.yingbin 5 rokov pred
rodič
commit
36fbae5aa0

+ 39 - 0
controllers/erms3/qryContract.go

@@ -312,3 +312,42 @@ func QueryPendingAuditContract(c *gin.Context) {
 		appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
 	}
 }
+
+// 查询待审核业务请求
+type QryPendingBizReq struct{
+	AccountIDs   string `form:"accountids" binding:"required"`    // 请求资金账号列表,逗号隔开
+}
+
+// 查询待审核业务响应
+type QryPendingBizRsp models.PendingAuditBizModel
+
+// QueryPendingBusiness  查询待审核基差贸易业务
+// @Summary 查询待审核基差贸易业务
+// @Produce json
+// @Security ApiKeyAuth
+// @Param accountids query string true "资金账号ID列表,逗号隔开"
+// @Success 200 {array} QryPendingBizRsp
+// @Failure 500 {object} app.Response
+// @Router /Erms3/QueryPendingBusiness [get]
+// @Tags 风险管理v3
+func QueryPendingBusiness(c *gin.Context) {
+	appG := app.Gin{C: c}
+	var req QryPendingBizReq
+	if err := c.ShouldBind(&req); err != nil {
+		logger.GetLogger().Errorf("bind QryAuditContractReq, %v", err)
+		appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
+		return
+	}
+
+	// 去除最后的逗号
+	if len(req.AccountIDs) > 0 && req.AccountIDs[len(req.AccountIDs)-1] == ',' {
+		req.AccountIDs = req.AccountIDs[0 : len(req.AccountIDs)-1]
+	}
+
+	var m models.PendingAuditBizModel
+	if d, err := m.GetData(req.AccountIDs); err == nil{
+		appG.Response(http.StatusOK, e.SUCCESS, d)
+	}else {
+		appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
+	}
+}

+ 78 - 0
docs/docs.go

@@ -20,6 +20,7 @@ var doc = `{
         "title": "{{.Title}}",
         "termsOfService": "http://muchinfo.cn",
         "contact": {},
+        "license": {},
         "version": "{{.Version}}"
     },
     "host": "{{.Host}}",
@@ -1001,6 +1002,48 @@ var doc = `{
                 }
             }
         },
+        "/Erms3/QueryPendingBusiness": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "风险管理v3"
+                ],
+                "summary": "查询待审核基差贸易业务",
+                "parameters": [
+                    {
+                        "type": "string",
+                        "description": "资金账号ID列表,逗号隔开",
+                        "name": "accountids",
+                        "in": "query",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/erms3.QryPendingBizRsp"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/Erms3/QuerySpotContractAppleForm": {
             "get": {
                 "security": [
@@ -3289,6 +3332,7 @@ var doc = `{
                 },
                 "province": {
                     "description": "省",
+                    "type": "object",
                     "$ref": "#/definitions/models.Division"
                 }
             }
@@ -5257,6 +5301,9 @@ var doc = `{
                 }
             }
         },
+        "erms3.QryPendingBizRsp": {
+            "$ref": "#/definitions/models.PendingAuditBizModel"
+        },
         "erms3.QueryBusinessInfoRsp": {
             "type": "object",
             "properties": {
@@ -5345,6 +5392,7 @@ var doc = `{
                 },
                 "ouruser": {
                     "description": "我方账号",
+                    "type": "object",
                     "$ref": "#/definitions/erms3.CustomerInfo"
                 },
                 "warehouseinfos": {
@@ -5672,6 +5720,7 @@ var doc = `{
                 },
                 "province": {
                     "description": "省",
+                    "type": "object",
                     "$ref": "#/definitions/models.Division"
                 }
             }
@@ -6818,6 +6867,35 @@ var doc = `{
                 }
             }
         },
+        "models.PendingAuditBizModel": {
+            "type": "object",
+            "properties": {
+                "accountid": {
+                    "description": "现货账户",
+                    "type": "string"
+                },
+                "areaname": {
+                    "description": "所属部门",
+                    "type": "string"
+                },
+                "businessid": {
+                    "description": "业务ID",
+                    "type": "string"
+                },
+                "businessname": {
+                    "description": "业务名称",
+                    "type": "string"
+                },
+                "statu": {
+                    "description": "状态,0:待审核 1:审核通过 2:审核中 3:审核失败 4已撤销 5:审核拒绝",
+                    "type": "integer"
+                },
+                "type": {
+                    "description": "业务类型,1-期现套利,2-仓单回购,3-现货贸易",
+                    "type": "integer"
+                }
+            }
+        },
         "models.QuotePrimaryMenu": {
             "type": "object",
             "properties": {

+ 78 - 0
docs/swagger.json

@@ -5,6 +5,7 @@
         "title": "MTP2.0 查询服务 API",
         "termsOfService": "http://muchinfo.cn",
         "contact": {},
+        "license": {},
         "version": "1.0"
     },
     "basePath": "/api",
@@ -985,6 +986,48 @@
                 }
             }
         },
+        "/Erms3/QueryPendingBusiness": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "风险管理v3"
+                ],
+                "summary": "查询待审核基差贸易业务",
+                "parameters": [
+                    {
+                        "type": "string",
+                        "description": "资金账号ID列表,逗号隔开",
+                        "name": "accountids",
+                        "in": "query",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/erms3.QryPendingBizRsp"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/Erms3/QuerySpotContractAppleForm": {
             "get": {
                 "security": [
@@ -3273,6 +3316,7 @@
                 },
                 "province": {
                     "description": "省",
+                    "type": "object",
                     "$ref": "#/definitions/models.Division"
                 }
             }
@@ -5241,6 +5285,9 @@
                 }
             }
         },
+        "erms3.QryPendingBizRsp": {
+            "$ref": "#/definitions/models.PendingAuditBizModel"
+        },
         "erms3.QueryBusinessInfoRsp": {
             "type": "object",
             "properties": {
@@ -5329,6 +5376,7 @@
                 },
                 "ouruser": {
                     "description": "我方账号",
+                    "type": "object",
                     "$ref": "#/definitions/erms3.CustomerInfo"
                 },
                 "warehouseinfos": {
@@ -5656,6 +5704,7 @@
                 },
                 "province": {
                     "description": "省",
+                    "type": "object",
                     "$ref": "#/definitions/models.Division"
                 }
             }
@@ -6802,6 +6851,35 @@
                 }
             }
         },
+        "models.PendingAuditBizModel": {
+            "type": "object",
+            "properties": {
+                "accountid": {
+                    "description": "现货账户",
+                    "type": "string"
+                },
+                "areaname": {
+                    "description": "所属部门",
+                    "type": "string"
+                },
+                "businessid": {
+                    "description": "业务ID",
+                    "type": "string"
+                },
+                "businessname": {
+                    "description": "业务名称",
+                    "type": "string"
+                },
+                "statu": {
+                    "description": "状态,0:待审核 1:审核通过 2:审核中 3:审核失败 4已撤销 5:审核拒绝",
+                    "type": "integer"
+                },
+                "type": {
+                    "description": "业务类型,1-期现套利,2-仓单回购,3-现货贸易",
+                    "type": "integer"
+                }
+            }
+        },
         "models.QuotePrimaryMenu": {
             "type": "object",
             "properties": {

+ 53 - 0
docs/swagger.yaml

@@ -87,6 +87,7 @@ definitions:
       province:
         $ref: '#/definitions/models.Division'
         description: 省
+        type: object
     type: object
   common.QueryTableDefineRsp:
     properties:
@@ -1560,6 +1561,8 @@ definitions:
     - matchcustomername
     - spotcontractid
     type: object
+  erms3.QryPendingBizRsp:
+    $ref: '#/definitions/models.PendingAuditBizModel'
   erms3.QueryBusinessInfoRsp:
     properties:
       businessid:
@@ -1626,6 +1629,7 @@ definitions:
       ouruser:
         $ref: '#/definitions/erms3.CustomerInfo'
         description: 我方账号
+        type: object
       warehouseinfos:
         description: 仓库信息列表
         items:
@@ -1865,6 +1869,7 @@ definitions:
       province:
         $ref: '#/definitions/models.Division'
         description: 省
+        type: object
     type: object
   models.Division:
     properties:
@@ -2729,6 +2734,27 @@ definitions:
         description: 菜单标题
         type: string
     type: object
+  models.PendingAuditBizModel:
+    properties:
+      accountid:
+        description: 现货账户
+        type: string
+      areaname:
+        description: 所属部门
+        type: string
+      businessid:
+        description: 业务ID
+        type: string
+      businessname:
+        description: 业务名称
+        type: string
+      statu:
+        description: 状态,0:待审核 1:审核通过 2:审核中 3:审核失败 4已撤销 5:审核拒绝
+        type: integer
+      type:
+        description: 业务类型,1-期现套利,2-仓单回购,3-现货贸易
+        type: integer
+    type: object
   models.QuotePrimaryMenu:
     properties:
       Index:
@@ -4649,6 +4675,7 @@ definitions:
 info:
   contact: {}
   description: 新的查询服务,替代原通用查询服务。
+  license: {}
   termsOfService: http://muchinfo.cn
   title: MTP2.0 查询服务 API
   version: "1.0"
@@ -5265,6 +5292,32 @@ paths:
       summary: 查询待审核合同
       tags:
       - 风险管理v3
+  /Erms3/QueryPendingBusiness:
+    get:
+      parameters:
+      - description: 资金账号ID列表,逗号隔开
+        in: query
+        name: accountids
+        required: true
+        type: string
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            items:
+              $ref: '#/definitions/erms3.QryPendingBizRsp'
+            type: array
+        "500":
+          description: Internal Server Error
+          schema:
+            $ref: '#/definitions/app.Response'
+      security:
+      - ApiKeyAuth: []
+      summary: 查询待审核基差贸易业务
+      tags:
+      - 风险管理v3
   /Erms3/QuerySpotContractAppleForm:
     get:
       parameters:

+ 73 - 14
models/contractModel.go

@@ -1,7 +1,7 @@
 /**
 * @Author: zou.yingbin
 * @Create  : 2020/12/2 9:17
-* @Modify  : 2020/12/2 9:17
+* @Modify  : 2020/12/10 10:45
  */
 
 // 查询待审核的合同
@@ -61,17 +61,17 @@ func (r *AuditContractModel) GetData(accountIDs string, contractType int32) ([]A
 
 // 待审核合同(回购)
 type AutditContractHGModel struct {
-	SpotContractId    string `json:"spotcontractid"  xorm:"'SPOTCONTRACTID'" binding:"required"`       // 合同ID
-	MatchCustomerName string `json:"matchcustomername"  xorm:"'MATCHCUSTOMERNAME'" binding:"required"` // 销售方ID
-	MatchAccountId    string `json:"matchaccountid"  xorm:"'MATCHACCOUNTID'"`                          // 业务员ID
-	AccountId         string `json:"accountid"  xorm:"'ACCOUNTID'"`                                    // 交易员ID
-	CustomerName      string `json:"customername"  xorm:"'CUSTOMERNAME'"`                              // 采购方ID
-	WrstandardName    string `json:"wrstandardname"  xorm:"'WRSTANDARDNAME'"`                          // 商品名称
-	Wrstandardcode    string `json:"wrstandardcode"  xorm:"'WRSTANDARDCODE'"`                          // 商品代码
-	ApplyStatus       uint32 `json:"applystatus"  xorm:"'APPLYSTATUS'"`                                // 状态
-	EnumdicName       string `json:"enumdicname"  xorm:"'ENUMDICNAME'"`                                // 单位名称
-	ContractQty       float64 `json:"contractqty"  xorm:"'CONTRACTQTY'"`                               // 合同量
-	SignDate          string `json:"signdate"  xorm:"'SIGNDATE'"`                                      // 签订日期
+	SpotContractId    string  `json:"spotcontractid"  xorm:"'SPOTCONTRACTID'" binding:"required"`       // 合同ID
+	MatchCustomerName string  `json:"matchcustomername"  xorm:"'MATCHCUSTOMERNAME'" binding:"required"` // 销售方ID
+	MatchAccountId    string  `json:"matchaccountid"  xorm:"'MATCHACCOUNTID'"`                          // 业务员ID
+	AccountId         string  `json:"accountid"  xorm:"'ACCOUNTID'"`                                    // 交易员ID
+	CustomerName      string  `json:"customername"  xorm:"'CUSTOMERNAME'"`                              // 采购方ID
+	WrstandardName    string  `json:"wrstandardname"  xorm:"'WRSTANDARDNAME'"`                          // 商品名称
+	Wrstandardcode    string  `json:"wrstandardcode"  xorm:"'WRSTANDARDCODE'"`                          // 商品代码
+	ApplyStatus       uint32  `json:"applystatus"  xorm:"'APPLYSTATUS'"`                                // 状态
+	EnumdicName       string  `json:"enumdicname"  xorm:"'ENUMDICNAME'"`                                // 单位名称
+	ContractQty       float64 `json:"contractqty"  xorm:"'CONTRACTQTY'"`                                // 合同量
+	SignDate          string  `json:"signdate"  xorm:"'SIGNDATE'"`                                      // 签订日期
 }
 
 func (r *AutditContractHGModel) buildSql(accountIDs string) string {
@@ -102,13 +102,72 @@ func (r *AutditContractHGModel) buildSql(accountIDs string) string {
 	return fmt.Sprintf(sqlId, accountIDs)
 }
 
+// 从数据库获取待审核合同
 func (r *AutditContractHGModel) GetData(accountIDs string) ([]AutditContractHGModel, error) {
 	sAC := make([]AutditContractHGModel, 0)
 	e := db.GetEngine()
 	s := e.SQL(r.buildSql(accountIDs))
-	if err := s.Find(&sAC); err != nil{
+	if err := s.Find(&sAC); err != nil {
 		logger.GetLogger().Errorf("query hg pending contract fail:%v", err)
 		return sAC, err
 	}
 	return sAC, nil
-}
+}
+
+// 待审核基差贸易业务
+type PendingAuditBizModel struct {
+	BizID     string `json:"bizid"  xorm:"'BIZID'"`         // 业务ID
+	AccountID string `json:"accountid"  xorm:"'ACCOUNTID'"` // 现货账户
+	Type      int32  `json:"type"  xorm:"'TYPE'"`           // 业务类型,1-期现套利,2-仓单回购,3-现货贸易
+	BizName   string `json:"bizname"  xorm:"'BIZNAME'"`     // 业务名称
+	AreaName  string `json:"areaname"  xorm:"'AREANAME'"`   // 所属部门
+	Status    int32  `json:"status"  xorm:"'STATUS'"`       // 状态,0:待审核 1:审核通过 2:审核中 3:审核失败 4已撤销 5:审核拒绝
+}
+
+func (r *PendingAuditBizModel) buildSql(accIDs string) string {
+	sqlId := "select t.*, u.accountname AreaName" +
+		"  from (select spottradeid   BizID," +
+		"               spottradename BizName," +
+		"               spotaccountid AccountID," +
+		"               3               as Type," +
+		"               areauserid    userId," +
+		"               applystatus   Status" +
+		"          from erms2_spottradeapply" +
+		"        union all" +
+		"        select wrrcontractid   BizID," +
+		"               wrrcontractname BizName," +
+		"               accountid," +
+		"               2                 as Type," +
+		"               areauserid      userId," +
+		"               applystatus     Status" +
+		"          from erms2_wrrapply t" +
+		"        union all" +
+		"        select a.asapplyid   BizID," +
+		"               a.asname      BizName," +
+		"               b.accountid," +
+		"               1             as Type," +
+		"               a.userid," +
+		"               a.applystatus Status" +
+		"          from erms2_asapply a" +
+		"         inner join erms2_asaccount b" +
+		"            on a.asapplyid = b.asapplyid" +
+		"           and b.taaccountbiztype = 1) t" +
+		"  left join useraccount u" +
+		"    on t.userId = u.userid" +
+		" where t.Status in (0, 2, 5) and t.accountid in(%v)"
+
+	return fmt.Sprintf(sqlId, accIDs)
+}
+
+// 从数据库获取待审核基差贸易业务
+func (r *PendingAuditBizModel) GetData(accIDs string) ([]PendingAuditBizModel, error) {
+	sRet := make([]PendingAuditBizModel, 0)
+	e := db.GetEngine()
+	s := e.SQL(r.buildSql(accIDs))
+	if err := s.Find(&sRet); err != nil {
+		logger.GetLogger().Errorf("query pending biz fail: %v", err)
+		return nil, err
+	}
+
+	return sRet, nil
+}

+ 2 - 0
routers/router.go

@@ -190,6 +190,8 @@ func InitRouter() *gin.Engine {
 		erms3R.POST("/AddUserInfoApply", erms3.AddUserInfoApply)
 		// 客户申请信息查询
 		erms3R.GET("/QueryUserInfoApplies", erms3.QueryUserInfoApplies)
+		// 待审核业务查询
+		erms3R.GET("/QueryPendingBusiness", erms3.QueryPendingBusiness)
 		// 业务信息查询
 		erms3R.GET("/QueryBusinessInfo", erms3.QueryBusinessInfo)