qryErmcp3Report.go 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. /**
  2. * @Author: zou.yingbin
  3. * @Create : 2021/4/16 18:40
  4. * @Modify : 2021/4/16 18:40
  5. */
  6. package ermcp3
  7. import (
  8. "github.com/gin-gonic/gin"
  9. "mtp2_if/global/app"
  10. "mtp2_if/global/e"
  11. "mtp2_if/models"
  12. "net/http"
  13. "strconv"
  14. )
  15. // 查询日期
  16. type QueryDate string
  17. // IsNumberic 判断是否为数字,
  18. func (v QueryDate) IsNumberic(queryType int32) bool {
  19. if queryType == 1 {
  20. // 日报表 日期长度YYYYMMDD
  21. if len(v) != 8 {
  22. return false
  23. }
  24. } else if queryType == 2 {
  25. // 月报表 日期长度YYYYMM
  26. if len(v) != 6 {
  27. return false
  28. }
  29. }
  30. // 判断是否为数字
  31. if _, err := strconv.ParseInt(string(v), 10, 32); err != nil {
  32. return false
  33. }
  34. return true
  35. }
  36. // @Summary 查询现货日报表详情(菜单:报表查询/现货报表/现货日报表详情)
  37. // @Produce json
  38. // @Security ApiKeyAuth
  39. // @Param userid query int true "用户ID"
  40. // @Param deliverygoodsid query int true "现货商品id"
  41. // @Param tradedate query string true "交易日(格式:yyyyMMdd)"
  42. // @Param wrstandardid query int false "品类ID"
  43. // @Param spotgoodsbrandid query int false "现货品牌ID"
  44. // @Success 200 {array} models.Ermcp3ReportOPLog
  45. // @Failure 500 {object} app.Response
  46. // @Router /Ermcp3/QryReportDaySpotDetail [get]
  47. // @Tags 企业风险管理v3(app)
  48. func QryReportDaySpotDetail(c *gin.Context) {
  49. a := app.GinUtils{Gin: app.Gin{C: c}}
  50. req := struct {
  51. USERID int64 `form:"userid" binding:"required"` // 用户id
  52. TRADEDATE string `form:"tradedate" binding:"required"` // 交易日
  53. DELIVERYGOODSID int32 `form:"deliverygoodsid" binding:"required"` // 现货商品id
  54. SPOTGOODSBRANDID int32 `form:"spotgoodsbrandid"` // 品牌id
  55. WRSTANDARDID int32 `form:"wrstandardid"` // 品类id
  56. }{}
  57. a.DoBindReq(&req)
  58. m := models.Ermcp3ReportOPLog{USERID: req.USERID, DELIVERYGOODSID: req.DELIVERYGOODSID,
  59. TRADEDATE: req.TRADEDATE, SPOTGOODSBRANDID: req.SPOTGOODSBRANDID, WRSTANDARDID: req.WRSTANDARDID,
  60. LogTypeFilter: "2,3,24,25,26,27"}
  61. a.DoGetDataI(&m)
  62. }
  63. // @Summary 查询财务日报表款项(菜单:报表查询/财务报表/日报表/款项)
  64. // @Produce json
  65. // @Security ApiKeyAuth
  66. // @Param userid query int true "用户ID"
  67. // @Param tradedate query string true "交易日(格式:yyyyMMdd)"
  68. // @Success 200 {array} models.Ermcp3ReportOPLog
  69. // @Failure 500 {object} app.Response
  70. // @Router /Ermcp3/QryReportDayFinanceKx [get]
  71. // @Tags 企业风险管理v3(app)
  72. func QryReportDayFinanceKx(c *gin.Context) {
  73. a := app.GinUtils{Gin: app.Gin{C: c}}
  74. req := struct {
  75. USERID int64 `form:"userid" binding:"required"` // 用户id
  76. TRADEDATE string `form:"tradedate" binding:"required"` // 交易日
  77. }{}
  78. a.DoBindReq(&req)
  79. m := models.Ermcp3ReportOPLog{USERID: req.USERID, TRADEDATE: req.TRADEDATE, LogTypeFilter: "8,9,10"}
  80. a.DoGetDataI(&m)
  81. }
  82. // @Summary 查询财务日报表发票(菜单:报表查询/财务报表/日报表/发票)
  83. // @Produce json
  84. // @Security ApiKeyAuth
  85. // @Param userid query int true "用户ID"
  86. // @Param tradedate query string true "交易日(格式:yyyyMMdd)"
  87. // @Success 200 {array} models.Ermcp3ReportOPLog
  88. // @Failure 500 {object} app.Response
  89. // @Router /Ermcp3/QryReportDayFinanceFp [get]
  90. // @Tags 企业风险管理v3(app)
  91. func QryReportDayFinanceFp(c *gin.Context) {
  92. a := app.GinUtils{Gin: app.Gin{C: c}}
  93. req := struct {
  94. USERID int64 `form:"userid" binding:"required"` // 用户id
  95. TRADEDATE string `form:"tradedate" binding:"required"` // 交易日
  96. }{}
  97. a.DoBindReq(&req)
  98. m := models.Ermcp3ReportOPLog{USERID: req.USERID, TRADEDATE: req.TRADEDATE, LogTypeFilter: "11, 12"}
  99. a.DoGetDataI(&m)
  100. }
  101. // @Summary 查询现货日报表(菜单:报表查询/现货报表/现货日报表)
  102. // @Produce json
  103. // @Security ApiKeyAuth
  104. // @Param userid query int true "用户id"
  105. // @Param reckondate query string true "交易日(格式:yyyyMMdd)"
  106. // @Param accountid query int false "期货账户ID"
  107. // @Param deliverygoodsid query int false "现货品种ID"
  108. // @Param wrstandardid query int false "品类ID"
  109. // @Param spotgoodsbrandid query int false "现货品牌ID"
  110. // @Success 200 {array} models.Ermcp3ReckonAreaSpotSub
  111. // @Failure 500 {object} app.Response
  112. // @Router /Ermcp3/QryReportDaySpot [get]
  113. // @Tags 企业风险管理v3(app)
  114. func QryReportDaySpot(c *gin.Context) {
  115. a := app.GinUtils{Gin: app.Gin{C: c}}
  116. m := models.Ermcp3ReckonAreaSpotSub{}
  117. a.DoBindReq(&m)
  118. a.DoGetDataI(&m)
  119. }
  120. // QryReportMonthSpot
  121. // @Summary 查询现货月报表(菜单:报表查询/现货报表/现货月报表)
  122. // @Produce json
  123. // @Security ApiKeyAuth
  124. // @Param userid query int true "用户id"
  125. // @Param cycletype query int true "周期类型 - 1:月 2:季 3:年 4:周 5:全报表【原值】"
  126. // @Param cycletime query string true "周期时间 月(YYYYMM) 季(YYYYQ) 年(YYYY) 周(YYYYIW) 全(0)【原值】"
  127. // @Param accountid query int false "期货账户ID"
  128. // @Param deliverygoodsid query int false "现货品种ID"
  129. // @Param wrstandardid query int false "品类ID"
  130. // @Param spotgoodsbrandid query int false "现货品牌ID"
  131. // @Success 200 {array} models.Ermcp3ReportAreaSpotSub
  132. // @Failure 500 {object} app.Response
  133. // @Router /Ermcp3/QryReportMonthSpot [get]
  134. // @Tags 企业风险管理v3(app)
  135. func QryReportMonthSpot(c *gin.Context) {
  136. a := app.GinUtils{Gin: app.Gin{C: c}}
  137. m := models.Ermcp3ReportAreaSpotSub{}
  138. a.DoBindReq(&m)
  139. a.DoGetDataI(&m)
  140. }
  141. // @Summary 查询现货月报表详情(菜单:报表查询/现货月报表/现货月报表详情)
  142. // @Produce json
  143. // @Security ApiKeyAuth
  144. // @Param userid query int true "用户id"
  145. // @Param cycletype query int true "周期类型 - 1:月 2:季 3:年 4:周 5:全报表【原值】"
  146. // @Param cycletime query string true "周期时间 月(YYYYMM) 季(YYYYQ) 年(YYYY) 周(YYYYIW) 全(0)【原值】"
  147. // @Param accountid query int false "期货账户ID"
  148. // @Param deliverygoodsid query int false "现货品种ID"
  149. // @Param wrstandardid query int false "品类ID"
  150. // @Param spotgoodsbrandid query int false "现货品牌ID"
  151. // @Success 200 {array} models.Ermcp3ReportAreaSpotSub
  152. // @Failure 500 {object} app.Response
  153. // @Router /Ermcp3/QryReportMonthSpotDetail [get]
  154. // @Tags 企业风险管理v3(app)
  155. func QryReportMonthSpotDetail(c *gin.Context) {
  156. a := app.GinUtils{Gin: app.Gin{C: c}}
  157. req := models.Ermcp3ReportAreaSpotSub{}
  158. a.DoBindReq(&req)
  159. if req.CYCLETYPE != 1 || len(req.CYCLETIME) != 6 {
  160. // 目前仅支持月报表明细, 月报表的日期应是6位,如 202101
  161. a.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
  162. return
  163. }
  164. t1 := req.CYCLETIME + "01"
  165. t2 := req.CYCLETIME + "31"
  166. // 月报表明细 = 01~31 日报表
  167. m := models.Ermcp3ReckonAreaSpotSub{
  168. AREAUSERID: req.AREAUSERID, DELIVERYGOODSID: req.DELIVERYGOODSID, ACCOUNTID: req.ACCOUNTID,
  169. WRSTANDARDID: req.WRSTANDARDID, SPOTGOODSBRANDID: req.SPOTGOODSBRANDID, BeginDate: t1, EndDate: t2}
  170. a.DoGetDataI(&m)
  171. }
  172. // QryReportAreaSpotPL
  173. // @Summary 查询现货损益报表(现货损益报表)
  174. // @Produce json
  175. // @Security ApiKeyAuth
  176. // @Param userid query int true "用户ID"
  177. // @Param querytype query int true "查询类型 1-日报表 2-月报表"
  178. // @Param querydate query string true "查询日期(格式 日报表YYYYMMDD, 月报表YYYYMM)"
  179. // @Param deliverygoodsid query int false "现货商品ID"
  180. // @Param spotgoodsbrandid query int false "品牌ID"
  181. // @Param wrstandardid query int false "品类ID"
  182. // @Success 200 {array} models.Ermcp3ReportAreaSpotPL
  183. // @Failure 500 {object} app.Response
  184. // @Router /Ermcp3/QryReportAreaSpotPL [get]
  185. // @Tags 企业风险管理v3(app)
  186. func QryReportAreaSpotPL(c *gin.Context) {
  187. a := app.GinUtils{Gin: app.Gin{C: c}}
  188. req := struct {
  189. USERID int64 `form:"userid" binding:"required"` // 用户id
  190. QUERYTYPE int32 `form:"querytype" binding:"required"` // 查询类型
  191. QUERYDATE string `form:"querydate" binding:"required"` // 交易日
  192. DELIVERYGOODSID int32 `form:"deliverygoodsid"` // 现货商品id
  193. SPOTGOODSBRANDID int32 `form:"spotgoodsbrandid"` // 现货品牌id
  194. WRSTANDARDID int64 `form:"wrstandardid"` // 品类id
  195. }{}
  196. a.DoBindReq(&req)
  197. if QueryDate(req.QUERYDATE).IsNumberic(req.QUERYTYPE) {
  198. m := models.Ermcp3ReportAreaSpotPL{AREAUSERID: req.USERID, WRSTANDARDID: req.WRSTANDARDID,
  199. SPOTGOODSBRANDID: req.SPOTGOODSBRANDID, DELIVERYGOODSID: req.DELIVERYGOODSID,
  200. ReportDate: req.QUERYDATE, ReportType: req.QUERYTYPE}
  201. a.DoGetDataI(&m)
  202. } else {
  203. a.Gin.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
  204. }
  205. }