/** * @Author: zou.yingbin * @Create : 2021/4/16 18:40 * @Modify : 2021/4/16 18:40 */ package ermcp3 import ( "github.com/gin-gonic/gin" "mtp2_if/global/app" "mtp2_if/global/e" "mtp2_if/models" "net/http" "strconv" ) // 查询日期 type QueryDate string // IsNumberic 判断是否为数字, func (v QueryDate) IsNumberic(queryType int32) bool { if queryType == 1 { // 日报表 日期长度YYYYMMDD if len(v) != 8 { return false } } else if queryType == 2 { // 月报表 日期长度YYYYMM if len(v) != 6 { return false } } // 判断是否为数字 if _, err := strconv.ParseInt(string(v), 10, 32); err != nil { return false } return true } // @Summary 查询现货日报表详情(菜单:报表查询/现货报表/现货日报表详情) // @Produce json // @Security ApiKeyAuth // @Param userid query int true "用户ID" // @Param deliverygoodsid query int true "现货商品id" // @Param tradedate query string true "交易日(格式:yyyyMMdd)" // @Success 200 {array} models.Ermcp3ReportOPLog // @Failure 500 {object} app.Response // @Router /Ermcp3/QryReportDaySpotDetail [get] // @Tags 企业风险管理v3(app) func QryReportDaySpotDetail(c *gin.Context) { a := app.GinUtils{Gin: app.Gin{C: c}} req := struct { USERID int64 `form:"userid" binding:"required"` // 用户id DELIVERYGOODSID int32 `form:"deliverygoodsid" binding:"required"` // 现货商品id TRADEDATE string `form:"tradedate" binding:"required"` // 交易日 }{} a.DoBindReq(&req) m := models.Ermcp3ReportOPLog{USERID: req.USERID, DELIVERYGOODSID: req.DELIVERYGOODSID, TRADEDATE: req.TRADEDATE, LogTypeFilter: "2,3"} a.DoGetDataI(&m) } // @Summary 查询财务日报表款项(菜单:报表查询/财务报表/日报表/款项) // @Produce json // @Security ApiKeyAuth // @Param userid query int true "用户ID" // @Param tradedate query string true "交易日(格式:yyyyMMdd)" // @Success 200 {array} models.Ermcp3ReportOPLog // @Failure 500 {object} app.Response // @Router /Ermcp3/QryReportDayFinanceKx [get] // @Tags 企业风险管理v3(app) func QryReportDayFinanceKx(c *gin.Context) { a := app.GinUtils{Gin: app.Gin{C: c}} req := struct { USERID int64 `form:"userid" binding:"required"` // 用户id TRADEDATE string `form:"tradedate" binding:"required"` // 交易日 }{} a.DoBindReq(&req) m := models.Ermcp3ReportOPLog{USERID: req.USERID, TRADEDATE: req.TRADEDATE, LogTypeFilter: "8,9,10"} a.DoGetDataI(&m) } // @Summary 查询财务日报表发票(菜单:报表查询/财务报表/日报表/发票) // @Produce json // @Security ApiKeyAuth // @Param userid query int true "用户ID" // @Param tradedate query string true "交易日(格式:yyyyMMdd)" // @Success 200 {array} models.Ermcp3ReportOPLog // @Failure 500 {object} app.Response // @Router /Ermcp3/QryReportDayFinanceFp [get] // @Tags 企业风险管理v3(app) func QryReportDayFinanceFp(c *gin.Context) { a := app.GinUtils{Gin: app.Gin{C: c}} req := struct { USERID int64 `form:"userid" binding:"required"` // 用户id TRADEDATE string `form:"tradedate" binding:"required"` // 交易日 }{} a.DoBindReq(&req) m := models.ErmcpReportOPLog{USERID: req.USERID, TRADEDATE: req.TRADEDATE, LogTypeFilter: "11, 12"} a.DoGetDataI(&m) } // @Summary 查询现货日报表(菜单:报表查询/现货报表/现货日报表) // @Produce json // @Security ApiKeyAuth // @Param userid query int true "用户ID" // @Param tradedate query string true "交易日(格式:yyyyMMdd)" // @Success 200 {array} models.Ermcp3ReportDaySpot // @Failure 500 {object} app.Response // @Router /Ermcp3/QryReportDaySpot [get] // @Tags 企业风险管理v3(app) func QryReportDaySpot(c *gin.Context) { a := app.GinUtils{Gin: app.Gin{C: c}} req := struct { USERID int64 `form:"userid" binding:"required"` // 用户id TRADEDATE string `form:"tradedate" binding:"required"` // 交易日 }{} a.DoBindReq(&req) m := models.Ermcp3ReportDaySpot{AREAUSERID: req.USERID, RECKONDATE: req.TRADEDATE} a.DoGetDataI(&m) } // QryReportMonthSpot // @Summary 查询现货月报表(菜单:报表查询/现货报表/现货月报表) // @Produce json // @Security ApiKeyAuth // @Param userid query int true "用户ID" // @Param cycletime query string true "周期时间:月(格式:yyyyMM)" // @Success 200 {array} models.Ermcp3ReportMonSpot // @Failure 500 {object} app.Response // @Router /Ermcp3/QryReportMonthSpot [get] // @Tags 企业风险管理v3(app) func QryReportMonthSpot(c *gin.Context) { a := app.GinUtils{Gin: app.Gin{C: c}} req := struct { UserId int64 `form:"userid" binding:"required"` //用户ID CycleTime string `form:"cycletime" binding:"required"` // 周期时间:月(格式:yyyyMM) }{} a.DoBindReq(&req) m := models.Ermcp3ReportMonSpot{AREAUSERID: req.UserId, CYCLETIME: req.CycleTime} a.DoGetDataI(&m) } // @Summary 查询现货月报表详情(菜单:报表查询/现货月报表/现货月报表详情) // @Produce json // @Security ApiKeyAuth // @Param userid query int true "用户ID" // @Param wrstandardid query int true "现货商品id" // @Param cycletime query string true "周期时间:月(格式:yyyyMM)" // @Success 200 {array} models.Ermcp3ReportDaySpot // @Failure 500 {object} app.Response // @Router /Ermcp3/QryReportMonthSpotDetail [get] // @Tags 企业风险管理v3(app) func QryReportMonthSpotDetail(c *gin.Context) { a := app.GinUtils{Gin: app.Gin{C: c}} req := struct { UserId int64 `form:"userid" binding:"required"` // 用户ID DELIVERYGOODSID int32 `form:"deliverygoodsid" binding:"required"` // 现货商品id CycleTime string `form:"cycletime" binding:"required"` // 周期时间:月(格式:yyyyMM) }{} a.DoBindReq(&req) if len(req.CycleTime) != 6 { // 月报表的日期应是6位,如 202101 a.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil) return } t1 := req.CycleTime + "01" t2 := req.CycleTime + "31" m := models.Ermcp3ReportDaySpot{AREAUSERID: req.UserId, DELIVERYGOODSID: req.DELIVERYGOODSID, BeginDate: t1, EndDate: t2} a.DoGetDataI(&m) } // QryReportAreaSpotPL // @Summary 查询现货损益报表(现货损益报表) // @Produce json // @Security ApiKeyAuth // @Param userid query int true "用户ID" // @Param querytype query int true "查询类型 1-日报表 2-月报表" // @Param querydate query string true "查询日期(格式 日报表YYYYMMDD, 月报表YYYYMM)" // @Param deliverygoodsid query int false "现货商品ID" // @Param spotgoodsbrandid query int false "品牌ID" // @Param wrstandardid query int false "品类ID" // @Success 200 {array} models.Ermcp3ReportAreaSpotPL // @Failure 500 {object} app.Response // @Router /Ermcp3/QryReportAreaSpotPL [get] // @Tags 企业风险管理v3(app) func QryReportAreaSpotPL(c *gin.Context) { a := app.GinUtils{Gin: app.Gin{C: c}} req := struct { USERID int64 `form:"userid" binding:"required"` // 用户id QUERYTYPE int32 `form:"querytype" binding:"required"` // 查询类型 QUERYDATE string `form:"querydate" binding:"required"` // 交易日 DELIVERYGOODSID int32 `form:"deliverygoodsid"` // 现货商品id SPOTGOODSBRANDID int32 `form:"spotgoodsbrandid"` // 现货品牌id WRSTANDARDID int64 `form:"wrstandardid"` // 品类id }{} a.DoBindReq(&req) if QueryDate(req.QUERYDATE).IsNumberic(req.QUERYTYPE) { m := models.Ermcp3ReportAreaSpotPL{AREAUSERID: req.USERID, WRSTANDARDID: req.WRSTANDARDID, SPOTGOODSBRANDID: req.SPOTGOODSBRANDID, DELIVERYGOODSID: req.DELIVERYGOODSID, ReportDate: req.QUERYDATE, ReportType: req.QUERYTYPE} a.DoGetDataI(&m) } else { a.Gin.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil) } }