package cptrade import ( "mtp2_if/db" "mtp2_if/global/app" "mtp2_if/global/e" "mtp2_if/logger" "net/http" "time" "github.com/gin-gonic/gin" ) // QueryPresaleApplyReq 产能预售申请表请求参数 type QueryPresaleApplyReq struct { UserID int `form:"userid" binding:"required"` ApplyID int `form:"applyid"` AccountID int `form:"accountid"` } // Cptradepresaleapply CPTRADE_PRESALEAPPLY 产能预售申请表 type Cptradepresaleapply struct { Applyid int64 `json:"applyid" xorm:"'APPLYID'" binding:"required"` // 申请ID(181+Unix秒时间戳(10位)+xxxxxx) Userid int64 `json:"userid" xorm:"'USERID'"` // 申请人ID Accountid int64 `json:"accountid" xorm:"'ACCOUNTID'"` // 申请人账户ID Goodscode string `json:"goodscode" xorm:"'GOODSCODE'"` // 商品代码 Goodsname string `json:"goodsname" xorm:"'GOODSNAME'"` // 商品名称 Relatedgoodsid int64 `json:"relatedgoodsid" xorm:"'RELATEDGOODSID'"` // 关联交易合约ID Presaleqty int64 `json:"presaleqty" xorm:"'PRESALEQTY'"` // 预售数量 Starttime time.Time `json:"starttime" xorm:"'STARTTIME'"` // 预售开始时间 Endtime time.Time `json:"endtime" xorm:"'ENDTIME'"` // 预售结束时间 Attachmenturl string `json:"attachmenturl" xorm:"'ATTACHMENTURL'"` // 附件地址 Applystatus int64 `json:"applystatus" xorm:"'APPLYSTATUS'"` // 申请状态 - 1:已提交 2:初审通过 3:初审拒绝 4:初审失败 5复审通过 6:复审拒绝 7:复审失败 8:已撤销 Handlestatus int64 `json:"handlestatus" xorm:"'HANDLESTATUS'"` // 处理状态 Applytime time.Time `json:"applytime" xorm:"'APPLYTIME'"` // 申请时间 Firstremark string `json:"firstremark" xorm:"'FIRSTREMARK'"` // 初审备注 Marketid int64 `json:"marketid" xorm:"'MARKETID'"` // 预售市场ID Secondauditid int64 `json:"secondauditid" xorm:"'SECONDAUDITID'"` // 复审人 Secondaudittime time.Time `json:"secondaudittime" xorm:"'SECONDAUDITTIME'"` // 复审时间 Secondremark string `json:"secondremark" xorm:"'SECONDREMARK'"` // 复审备注 Tradedate string `json:"tradedate" xorm:"'TRADEDATE'"` // 交易日(yyyyMMdd) } // TableName is func (Cptradepresaleapply) TableName() string { return "CPTRADE_PRESALEAPPLY" } // QueryPreasleApply 查询产能预售申请表信息 // @Summary 查询产能预售申请表信息 // @Produce json // @Param userid query int true "账户ID" // @Param applyid query int false "申请ID" // @Param accountid query int false "资金账户ID" // @Success 0 {object} app.Response // @Failure 500 {object} app.Response // @Router /CPTrade/QueryPreasleApply [get] // @Tags 产能预售 func QueryPreasleApply(c *gin.Context) { appG := app.Gin{C: c} // 获取请求参数 var queryPresaleApplyReq QueryPresaleApplyReq if err := appG.C.ShouldBindQuery(&queryPresaleApplyReq); err != nil { logger.GetLogger().Errorf("QueryPreasleApply failed: %s", err.Error()) appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil) return } // 查询数据 engine := db.GetEngine() cptradepresaleapplys := make([]Cptradepresaleapply, 0) s := engine.Where("userid=?", queryPresaleApplyReq.UserID) if queryPresaleApplyReq.AccountID != 0 { s = s.And("accountid=?", queryPresaleApplyReq.AccountID) } if queryPresaleApplyReq.ApplyID != 0 { s = s.And("applyid=?", queryPresaleApplyReq.ApplyID) } // 执行查询 err := s.Find(&cptradepresaleapplys) if err != nil { // 查询失败 logger.GetLogger().Errorf("QueryPreasleApply failed: %s", err.Error()) appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil) return } appG.Response(http.StatusOK, e.SUCCESS, cptradepresaleapplys) }