wrTrade.go 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. // Package wrtrade 仓单贸易
  2. package wrtrade
  3. import (
  4. "mtp2_if/db"
  5. "mtp2_if/global/app"
  6. "mtp2_if/global/e"
  7. "mtp2_if/logger"
  8. "net/http"
  9. "github.com/gin-gonic/gin"
  10. )
  11. // Deliverygoods 现货品种表
  12. type Deliverygoods struct {
  13. Deliverygoodsid int64 `json:"deliverygoodsid" xorm:"'DELIVERYGOODSID'" binding:"required"` // 交割商品ID(SEQ_DELIVERYGOODS)
  14. Deliverygoodscode string `json:"deliverygoodscode" xorm:"'DELIVERYGOODSCODE'" binding:"required"` // 交割商品代码
  15. Deliverygoodsname string `json:"deliverygoodsname" xorm:"'DELIVERYGOODSNAME'"` // 交割商品名称
  16. Goodsunitid int64 `json:"goodsunitid" xorm:"'GOODSUNITID'"` // 交割商品单位ID
  17. Deliverygoodstype int64 `json:"deliverygoodstype" xorm:"'DELIVERYGOODSTYPE'"` // 交割商品类型: 1-整装不拆分 2-散装记录明细 3:整装拆分 4:散装不记录明细
  18. Standardqty int64 `json:"standardqty" xorm:"'STANDARDQTY'"` // 标准数量(库位数量) [标准品特有]
  19. Standardqtyrange float64 `json:"standardqtyrange" xorm:"'STANDARDQTYRANGE'"` // 标准数量偏差范围 [标准品特有]
  20. Issplit int64 `json:"issplit" xorm:"'ISSPLIT'"` // 是否拆分 - 0:不拆分 1:拆分 [整装] 0:不记录明细 1:记录明细 [散货] - 作废整装时不拆分,则标准数量=合约单位;拆分时标准数量为合约单位的整数倍;整装时必须记录明细表数据
  21. Agreeunit int64 `json:"agreeunit" xorm:"'AGREEUNIT'"` // 合约单位[散货时默认为1, 整装时默认为标准数量]
  22. Qtydecimalplace int64 `json:"qtydecimalplace" xorm:"'QTYDECIMALPLACE'"` // 成交量小数位
  23. Categoryid int64 `json:"categoryid" xorm:"'CATEGORYID'"` // 类别ID(SEQ_WRCATEGORY)
  24. }
  25. // TableName is DELIVERYGOODS
  26. func (Deliverygoods) TableName() string {
  27. return "DELIVERYGOODS"
  28. }
  29. // GetAllDeliveryGoods 获取带仓单分类的种类信息
  30. // @Summary 获取带仓单分类的种类信息
  31. // @Produce json
  32. // @Security ApiKeyAuth
  33. // @Success 200 {object} app.Response
  34. // @Failure 500 {object} app.Response
  35. // @Router /WRTrade/GetAllDeliveryGoods [get]
  36. // @Tags 仓单贸易
  37. func GetAllDeliveryGoods(c *gin.Context) {
  38. appG := app.Gin{C: c}
  39. engine := db.GetEngine()
  40. // 获取品种(交割商品)信息
  41. deliveryGoodses := make([]Deliverygoods, 0)
  42. if err := engine.Where("IsValid=1").And("categoryid<>0").Find(&deliveryGoodses); err != nil {
  43. // 查询失败
  44. logger.GetLogger().Errorf("GetAllDeliveryGoods failed: %s", err.Error())
  45. appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
  46. return
  47. }
  48. // 获取与品种相关的所有仓单分类信息
  49. appG.Response(http.StatusOK, e.SUCCESS, deliveryGoodses)
  50. }