| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216 |
- /**
- * @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)"
- // @Param wrstandardid query int false "品类ID"
- // @Param spotgoodsbrandid query int false "现货品牌ID"
- // @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
- TRADEDATE string `form:"tradedate" binding:"required"` // 交易日
- DELIVERYGOODSID int32 `form:"deliverygoodsid" binding:"required"` // 现货商品id
- SPOTGOODSBRANDID int32 `form:"spotgoodsbrandid"` // 品牌id
- WRSTANDARDID int32 `form:"wrstandardid"` // 品类id
- }{}
- a.DoBindReq(&req)
- m := models.Ermcp3ReportOPLog{USERID: req.USERID, DELIVERYGOODSID: req.DELIVERYGOODSID,
- TRADEDATE: req.TRADEDATE, SPOTGOODSBRANDID: req.SPOTGOODSBRANDID, WRSTANDARDID: req.WRSTANDARDID,
- LogTypeFilter: "2,3,24,25,26,27"}
- 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.Ermcp3ReportOPLog{USERID: req.USERID, TRADEDATE: req.TRADEDATE, LogTypeFilter: "11, 12"}
- a.DoGetDataI(&m)
- }
- // @Summary 查询现货日报表(菜单:报表查询/现货报表/现货日报表)
- // @Produce json
- // @Security ApiKeyAuth
- // @Param userid query int true "用户id"
- // @Param reckondate query string true "交易日(格式:yyyyMMdd)"
- // @Param accountid query int false "期货账户ID"
- // @Param deliverygoodsid query int false "现货品种ID"
- // @Param wrstandardid query int false "品类ID"
- // @Param spotgoodsbrandid query int false "现货品牌ID"
- // @Success 200 {array} models.Ermcp3ReckonAreaSpotSub
- // @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}}
- m := models.Ermcp3ReckonAreaSpotSub{}
- a.DoBindReq(&m)
- a.DoGetDataI(&m)
- }
- // QryReportMonthSpot
- // @Summary 查询现货月报表(菜单:报表查询/现货报表/现货月报表)
- // @Produce json
- // @Security ApiKeyAuth
- // @Param userid query int true "用户id"
- // @Param cycletype query int true "周期类型 - 1:月 2:季 3:年 4:周 5:全报表【原值】"
- // @Param cycletime query string true "周期时间 月(YYYYMM) 季(YYYYQ) 年(YYYY) 周(YYYYIW) 全(0)【原值】"
- // @Param accountid query int false "期货账户ID"
- // @Param deliverygoodsid query int false "现货品种ID"
- // @Param wrstandardid query int false "品类ID"
- // @Param spotgoodsbrandid query int false "现货品牌ID"
- // @Success 200 {array} models.Ermcp3ReportAreaSpotSub
- // @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}}
- m := models.Ermcp3ReportAreaSpotSub{}
- a.DoBindReq(&m)
- a.DoGetDataI(&m)
- }
- // @Summary 查询现货月报表详情(菜单:报表查询/现货月报表/现货月报表详情)
- // @Produce json
- // @Security ApiKeyAuth
- // @Param userid query int true "用户id"
- // @Param cycletype query int true "周期类型 - 1:月 2:季 3:年 4:周 5:全报表【原值】"
- // @Param cycletime query string true "周期时间 月(YYYYMM) 季(YYYYQ) 年(YYYY) 周(YYYYIW) 全(0)【原值】"
- // @Param accountid query int false "期货账户ID"
- // @Param deliverygoodsid query int false "现货品种ID"
- // @Param wrstandardid query int false "品类ID"
- // @Param spotgoodsbrandid query int false "现货品牌ID"
- // @Success 200 {array} models.Ermcp3ReportAreaSpotSub
- // @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 := models.Ermcp3ReportAreaSpotSub{}
- a.DoBindReq(&req)
- if req.CYCLETYPE != 1 || len(req.CYCLETIME) != 6 {
- // 目前仅支持月报表明细, 月报表的日期应是6位,如 202101
- a.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
- return
- }
- t1 := req.CYCLETIME + "01"
- t2 := req.CYCLETIME + "31"
- // 月报表明细 = 01~31 日报表
- m := models.Ermcp3ReckonAreaSpotSub{
- AREAUSERID: req.AREAUSERID, DELIVERYGOODSID: req.DELIVERYGOODSID, ACCOUNTID: req.ACCOUNTID,
- WRSTANDARDID: req.WRSTANDARDID, SPOTGOODSBRANDID: req.SPOTGOODSBRANDID, 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)
- }
- }
|