cpTrade.go 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. package cptrade
  2. import (
  3. "mtp2_if/db"
  4. "mtp2_if/global/app"
  5. "mtp2_if/global/e"
  6. "mtp2_if/logger"
  7. "net/http"
  8. "time"
  9. "github.com/gin-gonic/gin"
  10. )
  11. // QueryPresaleApplyReq 产能预售申请表请求参数
  12. type QueryPresaleApplyReq struct {
  13. UserID int `form:"userid" binding:"required"`
  14. ApplyID int `form:"applyid"`
  15. AccountID int `form:"accountid"`
  16. }
  17. // Cptradepresaleapply CPTRADE_PRESALEAPPLY 产能预售申请表
  18. type Cptradepresaleapply struct {
  19. Applyid int64 `json:"applyid" xorm:"'APPLYID'" binding:"required"` // 申请ID(181+Unix秒时间戳(10位)+xxxxxx)
  20. Userid int64 `json:"userid" xorm:"'USERID'"` // 申请人ID
  21. Accountid int64 `json:"accountid" xorm:"'ACCOUNTID'"` // 申请人账户ID
  22. Goodscode string `json:"goodscode" xorm:"'GOODSCODE'"` // 商品代码
  23. Goodsname string `json:"goodsname" xorm:"'GOODSNAME'"` // 商品名称
  24. Relatedgoodsid int64 `json:"relatedgoodsid" xorm:"'RELATEDGOODSID'"` // 关联交易合约ID
  25. Presaleqty int64 `json:"presaleqty" xorm:"'PRESALEQTY'"` // 预售数量
  26. Starttime time.Time `json:"starttime" xorm:"'STARTTIME'"` // 预售开始时间
  27. Endtime time.Time `json:"endtime" xorm:"'ENDTIME'"` // 预售结束时间
  28. Attachmenturl string `json:"attachmenturl" xorm:"'ATTACHMENTURL'"` // 附件地址
  29. Applystatus int64 `json:"applystatus" xorm:"'APPLYSTATUS'"` // 申请状态 - 1:已提交 2:初审通过 3:初审拒绝 4:初审失败 5复审通过 6:复审拒绝 7:复审失败 8:已撤销
  30. Handlestatus int64 `json:"handlestatus" xorm:"'HANDLESTATUS'"` // 处理状态
  31. Applytime time.Time `json:"applytime" xorm:"'APPLYTIME'"` // 申请时间
  32. Firstremark string `json:"firstremark" xorm:"'FIRSTREMARK'"` // 初审备注
  33. Marketid int64 `json:"marketid" xorm:"'MARKETID'"` // 预售市场ID
  34. Secondremark string `json:"secondremark" xorm:"'SECONDREMARK'"` // 复审备注
  35. Tradedate string `json:"tradedate" xorm:"'TRADEDATE'"` // 交易日(yyyyMMdd)
  36. }
  37. // TableName is
  38. func (Cptradepresaleapply) TableName() string {
  39. return "CPTRADE_PRESALEAPPLY"
  40. }
  41. // QueryPreasleApply 查询产能预售申请表信息
  42. // @Summary 查询产能预售申请表信息
  43. // @Produce json
  44. // @Param userid query int true "账户ID"
  45. // @Param applyid query int false "申请ID"
  46. // @Param accountid query int false "资金账户ID"
  47. // @Success 200 {object} Cptradepresaleapply
  48. // @Failure 500 {object} app.Response
  49. // @Router /CPTrade/QueryPreasleApply [get]
  50. // @Tags 产能预售
  51. func QueryPreasleApply(c *gin.Context) {
  52. appG := app.Gin{C: c}
  53. // 获取请求参数
  54. var queryPresaleApplyReq QueryPresaleApplyReq
  55. if err := appG.C.ShouldBindQuery(&queryPresaleApplyReq); err != nil {
  56. logger.GetLogger().Errorf("QueryPreasleApply failed: %s", err.Error())
  57. appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
  58. return
  59. }
  60. // 查询数据
  61. engine := db.GetEngine()
  62. cptradepresaleapplys := make([]Cptradepresaleapply, 0)
  63. s := engine.Where("userid=?", queryPresaleApplyReq.UserID)
  64. if queryPresaleApplyReq.AccountID != 0 {
  65. s = s.And("accountid=?", queryPresaleApplyReq.AccountID)
  66. }
  67. if queryPresaleApplyReq.ApplyID != 0 {
  68. s = s.And("applyid=?", queryPresaleApplyReq.ApplyID)
  69. }
  70. // 执行查询
  71. err := s.Find(&cptradepresaleapplys)
  72. if err != nil {
  73. // 查询失败
  74. logger.GetLogger().Errorf("QueryPreasleApply failed: %s", err.Error())
  75. appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
  76. return
  77. }
  78. appG.Response(http.StatusOK, e.SUCCESS, cptradepresaleapplys)
  79. }