瀏覽代碼

增加“新增期现套利业务申请”接口

zhou.xiaoning 5 年之前
父節點
當前提交
194aed8347
共有 7 個文件被更改,包括 454 次插入28 次删除
  1. 38 0
      controllers/erms3/business.go
  2. 127 2
      docs/docs.go
  3. 127 2
      docs/swagger.json
  4. 89 2
      docs/swagger.yaml
  5. 69 19
      models/erms3.go
  6. 2 2
      models/serialNumber.go
  7. 2 1
      routers/router.go

+ 38 - 0
controllers/erms3/business.go

@@ -242,3 +242,41 @@ func QueryBusinessInfo(c *gin.Context) {
 	logger.GetLogger().Debugf("QuerySpotContractDetail successed: %v", rsp)
 	appG.Response(http.StatusOK, e.SUCCESS, rsp)
 }
+
+// AddErms2ASApplyReq 新增期现套利业务申请请求参数
+type AddErms2ASApplyReq struct {
+	models.Erms2asapply
+}
+
+// AddErms2ASApply 新增期现套利业务申请
+// @Summary 新增期现套利业务申请
+// @Produce json
+// @Security ApiKeyAuth
+// @Param jsonBody body AddErms2ASApplyReq true "申请参数"
+// @Success 200 {object} app.Response
+// @Failure 500 {object} app.Response
+// @Router /Erms3/AddErms2ASApply [post]
+// @Tags 风险管理v3
+func AddErms2ASApply(c *gin.Context) {
+	appG := app.Gin{C: c}
+
+	// 获取请求参数
+	var req AddErms2ASApplyReq
+	err := appG.C.ShouldBindJSON(&req)
+	if err != nil {
+		logger.GetLogger().Errorf("AddErms2ASApply failed: %s", err.Error())
+		appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
+		return
+	}
+
+	// 插入数据
+	if err := models.InsertErms2AsApply(req.Erms2asapply); err != nil {
+		logger.GetLogger().Errorf("AddErms2ASApply failed: %s", err.Error())
+		appG.Response(http.StatusBadRequest, e.ERROR_OPERATION_FAILED, nil)
+		return
+	}
+
+	// 执行成功
+	logger.GetLogger().Debugf("AddErms2ASApply successed: ok")
+	appG.Response(http.StatusOK, e.SUCCESS, "ok")
+}

+ 127 - 2
docs/docs.go

@@ -814,6 +814,47 @@ var doc = `{
                 }
             }
         },
+        "/Erms3/AddErms2ASApply": {
+            "post": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "风险管理v3"
+                ],
+                "summary": "新增期现套利业务申请",
+                "parameters": [
+                    {
+                        "description": "申请参数",
+                        "name": "jsonBody",
+                        "in": "body",
+                        "required": true,
+                        "schema": {
+                            "$ref": "#/definitions/erms3.AddErms2ASApplyReq"
+                        }
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/Erms3/AddSpotContractApply": {
             "post": {
                 "security": [
@@ -4891,6 +4932,90 @@ var doc = `{
                 }
             }
         },
+        "erms3.AddErms2ASApplyReq": {
+            "type": "object",
+            "required": [
+                "asapplyid"
+            ],
+            "properties": {
+                "applybasis": {
+                    "description": "申请基差",
+                    "type": "number"
+                },
+                "applystatus": {
+                    "description": "申请状态 - 0:待审核 1:审核通过 2:审核中 3:审核失败 4已撤销 5:审核拒绝",
+                    "type": "integer"
+                },
+                "asapplyid": {
+                    "description": "策略申请ID(342+Unix秒时间戳(10位)+xxxxxx)",
+                    "type": "integer"
+                },
+                "asname": {
+                    "description": "策略名称",
+                    "type": "string"
+                },
+                "asno": {
+                    "description": "策略编号",
+                    "type": "string"
+                },
+                "auditid": {
+                    "description": "审核人",
+                    "type": "integer"
+                },
+                "auditremark": {
+                    "description": "审核备注",
+                    "type": "string"
+                },
+                "audittime": {
+                    "description": "审核时间",
+                    "type": "string"
+                },
+                "biztype": {
+                    "description": "业务类型 - 1:正向套利 2:反向套利",
+                    "type": "integer"
+                },
+                "createtime": {
+                    "description": "创建时间",
+                    "type": "string"
+                },
+                "creatorid": {
+                    "description": "创建人",
+                    "type": "integer"
+                },
+                "deliverygoodsid": {
+                    "description": "现货品种ID",
+                    "type": "integer"
+                },
+                "futurequote": {
+                    "description": "期货额度",
+                    "type": "number"
+                },
+                "goodsgroupid": {
+                    "description": "期货品种ID",
+                    "type": "integer"
+                },
+                "marketid": {
+                    "description": "市场ID",
+                    "type": "integer"
+                },
+                "remark": {
+                    "description": "备注",
+                    "type": "string"
+                },
+                "spotquota": {
+                    "description": "现货额度",
+                    "type": "number"
+                },
+                "tradedate": {
+                    "description": "交易日(yyyyMMdd)",
+                    "type": "string"
+                },
+                "userid": {
+                    "description": "所属机构",
+                    "type": "integer"
+                }
+            }
+        },
         "erms3.AddSpotContractApplyReq": {
             "type": "object",
             "required": [
@@ -5721,7 +5846,7 @@ var doc = `{
                     "description": "基差",
                     "type": "number"
                 },
-                "deliveryendtdate": {
+                "deliveryenddate": {
                     "description": "交收结束日期",
                     "type": "string"
                 },
@@ -5763,7 +5888,7 @@ var doc = `{
                     "description": "金额",
                     "type": "number"
                 },
-                "deliveryendtdate": {
+                "deliveryenddate": {
                     "description": "交收结束日期",
                     "type": "string"
                 },

+ 127 - 2
docs/swagger.json

@@ -798,6 +798,47 @@
                 }
             }
         },
+        "/Erms3/AddErms2ASApply": {
+            "post": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "风险管理v3"
+                ],
+                "summary": "新增期现套利业务申请",
+                "parameters": [
+                    {
+                        "description": "申请参数",
+                        "name": "jsonBody",
+                        "in": "body",
+                        "required": true,
+                        "schema": {
+                            "$ref": "#/definitions/erms3.AddErms2ASApplyReq"
+                        }
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/Erms3/AddSpotContractApply": {
             "post": {
                 "security": [
@@ -4875,6 +4916,90 @@
                 }
             }
         },
+        "erms3.AddErms2ASApplyReq": {
+            "type": "object",
+            "required": [
+                "asapplyid"
+            ],
+            "properties": {
+                "applybasis": {
+                    "description": "申请基差",
+                    "type": "number"
+                },
+                "applystatus": {
+                    "description": "申请状态 - 0:待审核 1:审核通过 2:审核中 3:审核失败 4已撤销 5:审核拒绝",
+                    "type": "integer"
+                },
+                "asapplyid": {
+                    "description": "策略申请ID(342+Unix秒时间戳(10位)+xxxxxx)",
+                    "type": "integer"
+                },
+                "asname": {
+                    "description": "策略名称",
+                    "type": "string"
+                },
+                "asno": {
+                    "description": "策略编号",
+                    "type": "string"
+                },
+                "auditid": {
+                    "description": "审核人",
+                    "type": "integer"
+                },
+                "auditremark": {
+                    "description": "审核备注",
+                    "type": "string"
+                },
+                "audittime": {
+                    "description": "审核时间",
+                    "type": "string"
+                },
+                "biztype": {
+                    "description": "业务类型 - 1:正向套利 2:反向套利",
+                    "type": "integer"
+                },
+                "createtime": {
+                    "description": "创建时间",
+                    "type": "string"
+                },
+                "creatorid": {
+                    "description": "创建人",
+                    "type": "integer"
+                },
+                "deliverygoodsid": {
+                    "description": "现货品种ID",
+                    "type": "integer"
+                },
+                "futurequote": {
+                    "description": "期货额度",
+                    "type": "number"
+                },
+                "goodsgroupid": {
+                    "description": "期货品种ID",
+                    "type": "integer"
+                },
+                "marketid": {
+                    "description": "市场ID",
+                    "type": "integer"
+                },
+                "remark": {
+                    "description": "备注",
+                    "type": "string"
+                },
+                "spotquota": {
+                    "description": "现货额度",
+                    "type": "number"
+                },
+                "tradedate": {
+                    "description": "交易日(yyyyMMdd)",
+                    "type": "string"
+                },
+                "userid": {
+                    "description": "所属机构",
+                    "type": "integer"
+                }
+            }
+        },
         "erms3.AddSpotContractApplyReq": {
             "type": "object",
             "required": [
@@ -5705,7 +5830,7 @@
                     "description": "基差",
                     "type": "number"
                 },
-                "deliveryendtdate": {
+                "deliveryenddate": {
                     "description": "交收结束日期",
                     "type": "string"
                 },
@@ -5747,7 +5872,7 @@
                     "description": "金额",
                     "type": "number"
                 },
-                "deliveryendtdate": {
+                "deliveryenddate": {
                     "description": "交收结束日期",
                     "type": "string"
                 },

+ 89 - 2
docs/swagger.yaml

@@ -1203,6 +1203,68 @@ definitions:
     required:
     - spotcontractid
     type: object
+  erms3.AddErms2ASApplyReq:
+    properties:
+      applybasis:
+        description: 申请基差
+        type: number
+      applystatus:
+        description: 申请状态 - 0:待审核 1:审核通过 2:审核中 3:审核失败 4已撤销 5:审核拒绝
+        type: integer
+      asapplyid:
+        description: 策略申请ID(342+Unix秒时间戳(10位)+xxxxxx)
+        type: integer
+      asname:
+        description: 策略名称
+        type: string
+      asno:
+        description: 策略编号
+        type: string
+      auditid:
+        description: 审核人
+        type: integer
+      auditremark:
+        description: 审核备注
+        type: string
+      audittime:
+        description: 审核时间
+        type: string
+      biztype:
+        description: 业务类型 - 1:正向套利 2:反向套利
+        type: integer
+      createtime:
+        description: 创建时间
+        type: string
+      creatorid:
+        description: 创建人
+        type: integer
+      deliverygoodsid:
+        description: 现货品种ID
+        type: integer
+      futurequote:
+        description: 期货额度
+        type: number
+      goodsgroupid:
+        description: 期货品种ID
+        type: integer
+      marketid:
+        description: 市场ID
+        type: integer
+      remark:
+        description: 备注
+        type: string
+      spotquota:
+        description: 现货额度
+        type: number
+      tradedate:
+        description: 交易日(yyyyMMdd)
+        type: string
+      userid:
+        description: 所属机构
+        type: integer
+    required:
+    - asapplyid
+    type: object
   erms3.AddSpotContractApplyReq:
     properties:
       accountid:
@@ -1813,7 +1875,7 @@ definitions:
       basic:
         description: 基差
         type: number
-      deliveryendtdate:
+      deliveryenddate:
         description: 交收结束日期
         type: string
       deliverystartdate:
@@ -1844,7 +1906,7 @@ definitions:
       amount:
         description: 金额
         type: number
-      deliveryendtdate:
+      deliveryenddate:
         description: 交收结束日期
         type: string
       deliverystartdate:
@@ -5212,6 +5274,31 @@ paths:
       summary: 查询现货合同表信息(指定策略ID、未结束的)
       tags:
       - 风险管理
+  /Erms3/AddErms2ASApply:
+    post:
+      parameters:
+      - description: 申请参数
+        in: body
+        name: jsonBody
+        required: true
+        schema:
+          $ref: '#/definitions/erms3.AddErms2ASApplyReq'
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            $ref: '#/definitions/app.Response'
+        "500":
+          description: Internal Server Error
+          schema:
+            $ref: '#/definitions/app.Response'
+      security:
+      - ApiKeyAuth: []
+      summary: 新增期现套利业务申请
+      tags:
+      - 风险管理v3
   /Erms3/AddSpotContractApply:
     post:
       parameters:

+ 69 - 19
models/erms3.go

@@ -136,25 +136,25 @@ func (m *Erms3Biztradedetail) TableName() string {
 
 // Erms2asapply 期现套利业务申请表
 type Erms2asapply struct {
-	Asapplyid       int64     `json:"asapplyid"  xorm:"'ASAPPLYID'" binding:"required"` // 策略申请ID(342+Unix秒时间戳(10位)+xxxxxx)
-	Asno            string    `json:"asno"  xorm:"'ASNO'"`                              // 策略编号
-	Asname          string    `json:"asname"  xorm:"'ASNAME'"`                          // 策略名称
-	Biztype         int32     `json:"biztype"  xorm:"'BIZTYPE'"`                        // 业务类型 - 1:正向套利 2:反向套利
-	Userid          int64     `json:"userid"  xorm:"'USERID'"`                          // 所属机构
-	Deliverygoodsid int64     `json:"deliverygoodsid"  xorm:"'DELIVERYGOODSID'"`        // 现货品种ID
-	Goodsgroupid    int64     `json:"goodsgroupid"  xorm:"'GOODSGROUPID'"`              // 期货品种ID
-	Spotquota       float64   `json:"spotquota"  xorm:"'SPOTQUOTA'"`                    // 现货额度
-	Futurequote     float64   `json:"futurequote"  xorm:"'FUTUREQUOTE'"`                // 期货额度
-	Applybasis      float64   `json:"applybasis"  xorm:"'APPLYBASIS'"`                  // 申请基差
-	Applystatus     int32     `json:"applystatus"  xorm:"'APPLYSTATUS'"`                // 申请状态 - 0:待审核 1:审核通过 2:审核中 3:审核失败 4已撤销 5:审核拒绝
-	Remark          string    `json:"remark"  xorm:"'REMARK'"`                          // 备注
-	Marketid        int64     `json:"marketid"  xorm:"'MARKETID'"`                      // 市场ID
-	Tradedate       string    `json:"tradedate"  xorm:"'TRADEDATE'"`                    // 交易日(yyyyMMdd)
-	Creatorid       int64     `json:"creatorid"  xorm:"'CREATORID'"`                    // 创建人
-	Createtime      time.Time `json:"createtime"  xorm:"'CREATETIME'"`                  // 创建时间
-	Auditid         int64     `json:"auditid"  xorm:"'AUDITID'"`                        // 审核人
-	Audittime       time.Time `json:"audittime"  xorm:"'AUDITTIME'"`                    // 审核时间
-	Auditremark     string    `json:"auditremark"  xorm:"'AUDITREMARK'"`                // 审核备注
+	Asapplyid       int64   `json:"asapplyid"  xorm:"'ASAPPLYID'" binding:"required"` // 策略申请ID(342+Unix秒时间戳(10位)+xxxxxx)
+	Asno            string  `json:"asno"  xorm:"'ASNO'"`                              // 策略编号
+	Asname          string  `json:"asname"  xorm:"'ASNAME'"`                          // 策略名称
+	Biztype         int32   `json:"biztype"  xorm:"'BIZTYPE'"`                        // 业务类型 - 1:正向套利 2:反向套利
+	Userid          int64   `json:"userid"  xorm:"'USERID'"`                          // 所属机构
+	Deliverygoodsid int64   `json:"deliverygoodsid"  xorm:"'DELIVERYGOODSID'"`        // 现货品种ID
+	Goodsgroupid    int64   `json:"goodsgroupid"  xorm:"'GOODSGROUPID'"`              // 期货品种ID
+	Spotquota       float64 `json:"spotquota"  xorm:"'SPOTQUOTA'"`                    // 现货额度
+	Futurequote     float64 `json:"futurequote"  xorm:"'FUTUREQUOTE'"`                // 期货额度
+	Applybasis      float64 `json:"applybasis"  xorm:"'APPLYBASIS'"`                  // 申请基差
+	Applystatus     int32   `json:"applystatus"  xorm:"'APPLYSTATUS'"`                // 申请状态 - 0:待审核 1:审核通过 2:审核中 3:审核失败 4已撤销 5:审核拒绝
+	Remark          string  `json:"remark"  xorm:"'REMARK'"`                          // 备注
+	Marketid        int64   `json:"marketid"  xorm:"'MARKETID'"`                      // 市场ID
+	Tradedate       string  `json:"tradedate"  xorm:"'TRADEDATE'"`                    // 交易日(yyyyMMdd)
+	Creatorid       int64   `json:"creatorid"  xorm:"'CREATORID'"`                    // 创建人
+	Createtime      string  `json:"createtime"  xorm:"'CREATETIME'"`                  // 创建时间
+	Auditid         int64   `json:"auditid"  xorm:"'AUDITID'"`                        // 审核人
+	Audittime       string  `json:"audittime"  xorm:"'AUDITTIME'"`                    // 审核时间
+	Auditremark     string  `json:"auditremark"  xorm:"'AUDITREMARK'"`                // 审核备注
 }
 
 // TableName is ERMS2_ASAPPLY
@@ -241,3 +241,53 @@ to_char(ERMS3_BIZTRADEDETAIL.RELATEDBIZID) RELATEDBIZID, ENUMDICITEM.ENUMDICNAME
 	err := s.Find(&datas)
 	return datas, err
 }
+
+// InsertErms2AsApply 新增期现套利业务申请
+func InsertErms2AsApply(apply Erms2asapply) error {
+	engine := db.GetEngine()
+
+	// 生成ID
+	var err error
+	if apply.Asapplyid, err = GetSerialNumber("342"); err != nil {
+		return err
+	}
+
+	sql := `insert into ERMS2_ASApply (
+		Asapplyid      ,
+		Asno           ,
+		Asname         ,
+		Biztype        ,
+		Userid         ,
+		Deliverygoodsid,
+		Goodsgroupid   ,
+		Spotquota      ,
+		Futurequote    ,
+		Applybasis     ,
+		Applystatus    ,
+		Remark         ,
+		Marketid       ,
+		Tradedate      ,
+		Creatorid      ,
+		Createtime     
+	) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,to_date(?, 'YYYY-MM-DD HH24:MI:SS'))`
+	_, err = engine.Exec(sql,
+		apply.Asapplyid,
+		apply.Asno,
+		apply.Asname,
+		apply.Biztype,
+		apply.Userid,
+		apply.Deliverygoodsid,
+		apply.Goodsgroupid,
+		apply.Spotquota,
+		apply.Futurequote,
+		apply.Applybasis,
+		apply.Applystatus,
+		apply.Remark,
+		apply.Marketid,
+		apply.Tradedate,
+		apply.Creatorid,
+		time.Now().Format("2006-01-02 15:04:05"),
+	)
+
+	return err
+}

+ 2 - 2
models/serialNumber.go

@@ -44,9 +44,9 @@ func repZero(number, digit int) string {
 		return str
 	}
 
-	need := len - digit
+	need := digit - len
 	for i := 0; i < need; i++ {
-		str += "0" + str
+		str = "0" + str
 	}
 
 	return str

+ 2 - 1
routers/router.go

@@ -202,9 +202,10 @@ func InitRouter() *gin.Engine {
 		erms3R.GET("/QueryPendingBusiness", erms3.QueryPendingBusiness)
 		// 业务信息查询
 		erms3R.GET("/QueryBusinessInfo", erms3.QueryBusinessInfo)
-
 		// 客户信息查询
 		erms3R.GET("/QueryUserInfos", erms3.QueryUserInfos)
+		// 新增期现套利业务申请
+		erms3R.POST("/AddErms2ASApply", erms3.AddErms2ASApply)
 	}
 	// ************************ 定制【尚志大宗】 ************************
 	szdzR := apiR.Group("SZDZ")