wrTrade.go 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. package models
  2. import (
  3. "mtp2_if/db"
  4. "time"
  5. )
  6. // 100.10仓单贸易
  7. // Deliverygoods 现货品种表
  8. type Deliverygoods struct {
  9. Deliverygoodsid int32 `json:"deliverygoodsid" xorm:"'DELIVERYGOODSID'" binding:"required"` // 现货品种ID(SEQ_DELIVERYGOODS)
  10. Deliverygoodscode string `json:"deliverygoodscode" xorm:"'DELIVERYGOODSCODE'" binding:"required"` // 现货品种代码
  11. Deliverygoodsname string `json:"deliverygoodsname" xorm:"'DELIVERYGOODSNAME'"` // 现货品种名称
  12. Goodsunitid int32 `json:"goodsunitid" xorm:"'GOODSUNITID'"` // 现货品种单位ID
  13. Deliverygoodstype int32 `json:"deliverygoodstype" xorm:"'DELIVERYGOODSTYPE'"` // 现货品种类型: 1-整装不拆分 2-散装记录明细 3:整装拆分 4:散装不记录明细
  14. Standardqty int64 `json:"standardqty" xorm:"'STANDARDQTY'"` // 标准数量(库位数量) [标准品特有]
  15. Standardqtyrange float64 `json:"standardqtyrange" xorm:"'STANDARDQTYRANGE'"` // 标准数量偏差范围 [标准品特有]
  16. Auditflag int32 `json:"auditflag" xorm:"'AUDITFLAG'"` // 交割是否需要审核 - 0:不需要 1:需要审核 默认为0
  17. Isvalid int32 `json:"isvalid" xorm:"'ISVALID'"` // 是否有效 - 0:无效 1:有效
  18. Issplit int32 `json:"issplit" xorm:"'ISSPLIT'"` // 是否拆分 - 0:不拆分 1:拆分 [整装] 0:不记录明细 1:记录明细 [散货] - 作废整装时不拆分,则标准数量=合约单位;拆分时标准数量为合约单位的整数倍;整装时必须记录明细表数据
  19. Agreeunit int64 `json:"agreeunit" xorm:"'AGREEUNIT'"` // 合约单位[散货时默认为1, 整装时默认为标准数量]
  20. Qtydecimalplace int32 `json:"qtydecimalplace" xorm:"'QTYDECIMALPLACE'"` // 成交量小数位
  21. Categoryid int32 `json:"categoryid" xorm:"'CATEGORYID'"` // 类别ID(SEQ_WRCATEGORY)
  22. Dgstatus int32 `json:"dgstatus" xorm:"'DGSTATUS'"` // 品种状态 - 作废 - 0:未激活 1:正常
  23. Areauserid int64 `json:"areauserid" xorm:"'AREAUSERID'"` // 所属机构
  24. Remark string `json:"remark" xorm:"'REMARK'"` // 备注
  25. }
  26. // TableName is DELIVERYGOODS
  27. func (Deliverygoods) TableName() string {
  28. return "DELIVERYGOODS"
  29. }
  30. // Dgfactoryitemtype 品种要素项表
  31. type Dgfactoryitemtype struct {
  32. Dgfactoryitemtypeid int64 `json:"dgfactoryitemtypeid" xorm:"'DGFACTORYITEMTYPEID'" binding:"required"` // 要素项类型ID(SEQ_DGFACTORYITEMTYPE)1-999:预留为特殊类型 1:仓库 - 选择项 2.品牌 - 选择项>1000(序列自增) 选择项 录入项
  33. Deliverygoodsid int32 `json:"deliverygoodsid" xorm:"'DELIVERYGOODSID'" binding:"required"` // 品种ID
  34. Itemtypename string `json:"itemtypename" xorm:"'ITEMTYPENAME'"` // 要素项类型名称
  35. Itemtypemode int32 `json:"itemtypemode" xorm:"'ITEMTYPEMODE'"` // 要素项类型模式 -1:选择项 2:录入项
  36. Orderindex int32 `json:"orderindex" xorm:"'ORDERINDEX'"` // 顺序
  37. Unitid int32 `json:"unitid" xorm:"'UNITID'"` // 单位ID - [录入项]
  38. Minivalue int64 `json:"minivalue" xorm:"'MINIVALUE'"` // 最小变动值 - [录入项]
  39. Minivaluedp int64 `json:"minivaluedp" xorm:"'MINIVALUEDP'"` // 最小变动值小数位 - [录入项]
  40. Creatorid int64 `json:"creatorid" xorm:"'CREATORID'"` // 创建人
  41. Createtime time.Time `json:"createtime" xorm:"'CREATETIME'"` // 创建时间
  42. Updatorid int64 `json:"updatorid" xorm:"'UPDATORID'"` // 更新人
  43. Updatetime time.Time `json:"updatetime" xorm:"'UPDATETIME'"` // 更新时间
  44. Isvalid int32 `json:"isvalid" xorm:"'ISVALID'"` // 是否有效 - 0:无效 1:有效
  45. }
  46. // TableName is DGFACTORYITEMTYPE
  47. func (Dgfactoryitemtype) TableName() string {
  48. return "DGFACTORYITEMTYPE"
  49. }
  50. // Dgfactoryitem 品种选择项定义表
  51. type Dgfactoryitem struct {
  52. Dgfactoryitemid int64 `json:"dgfactoryitemid" xorm:"'DGFACTORYITEMID'" binding:"required"` // 选择项ID(SEQ_DGFACTORYITEM)
  53. Deliverygoodsid int32 `json:"deliverygoodsid" xorm:"'DELIVERYGOODSID'"` // 品种ID
  54. Dgfactoryitemtypeid int64 `json:"dgfactoryitemtypeid" xorm:"'DGFACTORYITEMTYPEID'"` // 要素项类型
  55. Dgfactoryitemvalue string `json:"dgfactoryitemvalue" xorm:"'DGFACTORYITEMVALUE'"` // 要素项值(类型为仓库时填写仓库名称)
  56. Warehouseid int64 `json:"warehouseid" xorm:"'WAREHOUSEID'"` // 仓库ID(类型为仓库时填写)
  57. Isvalid int32 `json:"isvalid" xorm:"'ISVALID'"` // 是否有效 - 0:无效 1:有效
  58. Orderindex int32 `json:"orderindex" xorm:"'ORDERINDEX'"` // 顺序
  59. }
  60. // TableName is DGFACTORYITEM
  61. func (Dgfactoryitem) TableName() string {
  62. return "DGFACTORYITEM"
  63. }
  64. // Wrstandard 现货品类表
  65. type Wrstandard struct {
  66. Wrstandardid int64 `json:"wrstandardid" xorm:"'WRSTANDARDID'" binding:"required"` // 现货品类ID(SEQ_WRSTANDARD)
  67. Wrstandardcode string `json:"wrstandardcode" xorm:"'WRSTANDARDCODE'"` // 现货品类代码
  68. Wrstandardname string `json:"wrstandardname" xorm:"'WRSTANDARDNAME'"` // 现货品类名称
  69. Deliverygoodsid int32 `json:"deliverygoodsid" xorm:"'DELIVERYGOODSID'"` // 品种ID
  70. Unitid int32 `json:"unitid" xorm:"'UNITID'"` // 单位ID
  71. Minivalue int64 `json:"minivalue" xorm:"'MINIVALUE'"` // 最小变动值
  72. Minivaluedp int64 `json:"minivaluedp" xorm:"'MINIVALUEDP'"` // 最小变动值小数位
  73. Realminivalue int64 `json:"realminivalue" xorm:"'REALMINIVALUE'"` // 实际最小变动值
  74. Realminivaluedp int64 `json:"realminivaluedp" xorm:"'REALMINIVALUEDP'"` // 实际最小变动值小数位
  75. Wrsstatus int32 `json:"wrsstatus" xorm:"'WRSSTATUS'"` // 状态 - 作废 - 0:未激活 1:正常
  76. Creatorid int64 `json:"creatorid" xorm:"'CREATORID'"` // 创建人
  77. Createtime time.Time `json:"createtime" xorm:"'CREATETIME'"` // 创建时间
  78. Updatorid int64 `json:"updatorid" xorm:"'UPDATORID'"` // 更新人
  79. Updatetime time.Time `json:"updatetime" xorm:"'UPDATETIME'"` // 更新时间
  80. Factoryitemjson string `json:"factoryitemjson" xorm:"'FACTORYITEMJSON'"` // 要素项定义Json[{"DGFactoryItemTypeID": ,"ItemTypeMode": ,"FactoryItemIDs": },{.....},]DGFactoryItemTypeID - 要素项类型ID --DGFactoryItem->DGFactoryItemTypeIDItemTypeMode - 要素项类型模式 --DGFactoryItem->ItemTypeModeFactoryItemIDs - 选择项IDs--DGFactoryItem->DGFactoryItemID, 逗号分隔
  81. Isvalid int32 `json:"isvalid" xorm:"'ISVALID'"` // 是否有效 - 0:无效 1:有效
  82. Areauserid int64 `json:"areauserid" xorm:"'AREAUSERID'"` // 所属机构
  83. Remark string `json:"remark" xorm:"'REMARK'"` // 备注
  84. Convertfactor float64 `json:"convertfactor" xorm:"'CONVERTFACTOR'"` // 标仓系数
  85. }
  86. // TableName is WRSTANDARD
  87. func (Wrstandard) TableName() string {
  88. return "WRSTANDARD"
  89. }
  90. // Wrstandardfactoryitem 现货品类要素项定义表
  91. type Wrstandardfactoryitem struct {
  92. Wrstandardid int64 `json:"wrstandardid" xorm:"'WRSTANDARDID'" binding:"required"` // 现货品类ID
  93. Dgfactoryitemtypeid int64 `json:"dgfactoryitemtypeid" xorm:"'DGFACTORYITEMTYPEID'" binding:"required"` // 要素项类型ID
  94. Dgfactoryitemid int64 `json:"dgfactoryitemid" xorm:"'DGFACTORYITEMID'" binding:"required"` // 要素项ID - 输入项默认为0,选择项为选择项ID
  95. }
  96. // TableName is WRSTANDARDFACTORYITEM
  97. func (Wrstandardfactoryitem) TableName() string {
  98. return "WRSTANDARDFACTORYITEM"
  99. }
  100. // Wrfactortype 仓单要素类型表
  101. type Wrfactortype struct {
  102. Wrfactortypeid int64 `json:"wrfactortypeid" xorm:"'WRFACTORTYPEID'" binding:"required"` // 仓单要素类型ID(212+Unix秒时间戳(10位)+xxxxxx)
  103. Wrfactortypename string `json:"wrfactortypename" xorm:"'WRFACTORTYPENAME'"` // 仓单要素类型名称(选择项要素的名称合并显示,逗号分隔)
  104. Deliverygoodsid int32 `json:"deliverygoodsid" xorm:"'DELIVERYGOODSID'"` // 交割商品ID
  105. Brandid int64 `json:"brandid" xorm:"'BRANDID'"` // 品牌ID(1交割品种升贴水参数表 AutoID) - 作废
  106. Qualityid int64 `json:"qualityid" xorm:"'QUALITYID'"` // 品质ID(1交割品种升贴水参数表 AutoID) - 作废
  107. Specid int64 `json:"specid" xorm:"'SPECID'"` // 规格ID(1交割品种升贴水参数表 AutoID) - 作废
  108. Warehouseid int64 `json:"warehouseid" xorm:"'WAREHOUSEID'"` // 仓库ID
  109. Deliverymonthid int64 `json:"deliverymonthid" xorm:"'DELIVERYMONTHID'"` // 月份ID(1交割品种升贴水参数表 AutoID) - 作废
  110. Wrstandardid int64 `json:"wrstandardid" xorm:"'WRSTANDARDID'"` // 现货品类ID
  111. Wrstandardcode string `json:"wrstandardcode" xorm:"'WRSTANDARDCODE'"` // 现货品类代码
  112. Optioncompare string `json:"optioncompare" xorm:"'OPTIONCOMPARE'"` // 选择项比较串【{选择项ID}+{冒号}+选择项值 } ,逗号分隔,头尾加逗号】-- 所有选择项拼接,用于比较
  113. }
  114. // TableName is WRFACTORTYPE
  115. func (Wrfactortype) TableName() string {
  116. return "WRFACTORTYPE"
  117. }
  118. // Wrfactortypeitem 仓单要素类型选择项表
  119. type Wrfactortypeitem struct {
  120. Wrfactortypeid int64 `json:"wrfactortypeid" xorm:"'WRFACTORTYPEID'" binding:"required"` // 仓单要素类型ID(212+Unix秒时间戳(10位)+xxxxxx)
  121. Dgfactoryitemtypeid int64 `json:"dgfactoryitemtypeid" xorm:"'DGFACTORYITEMTYPEID'" binding:"required"` // 要素选择项类型ID
  122. Dgfactoryitemid int64 `json:"dgfactoryitemid" xorm:"'DGFACTORYITEMID'" binding:"required"` // 选择项ID
  123. Creatorid int64 `json:"creatorid" xorm:"'CREATORID'"` // 创建人
  124. Createtime time.Time `json:"createtime" xorm:"'CREATETIME'"` // 创建时间
  125. Updatorid int64 `json:"updatorid" xorm:"'UPDATORID'"` // 更新人
  126. Updatetime time.Time `json:"updatetime" xorm:"'UPDATETIME'"` // 更新时间
  127. }
  128. // TableName is WRFACTORTYPEITEM
  129. func (Wrfactortypeitem) TableName() string {
  130. return "WRFACTORTYPEITEM"
  131. }
  132. // Warehouseinfo 仓库信息表
  133. type Warehouseinfo struct {
  134. Autoid int64 `json:"autoid" xorm:"'AUTOID'" binding:"required"` // 自增ID
  135. Warehousecode string `json:"warehousecode" xorm:"'WAREHOUSECODE'" binding:"required"` // 仓库代码
  136. Warehousename string `json:"warehousename" xorm:"'WAREHOUSENAME'"` // 仓库名称
  137. Warehousetype int32 `json:"warehousetype" xorm:"'WAREHOUSETYPE'"` // 仓库类型 - 1 厂库 2 自有库 3 合作库
  138. Areauserid int64 `json:"areauserid" xorm:"'AREAUSERID'"` // 所属机构
  139. Warehousestatus int32 `json:"warehousestatus" xorm:"'WAREHOUSESTATUS'"` // 仓库状态 - 1:正常 2:注销 3:待审核 4:审核拒绝
  140. Countryid int32 `json:"countryid" xorm:"'COUNTRYID'"` // 国家
  141. Provinceid int32 `json:"provinceid" xorm:"'PROVINCEID'"` // 省
  142. Cityid int32 `json:"cityid" xorm:"'CITYID'"` // 市
  143. Districtid int32 `json:"districtid" xorm:"'DISTRICTID'"` // 区
  144. Address string `json:"address" xorm:"'ADDRESS'"` // 详细地址
  145. Remark string `json:"remark" xorm:"'REMARK'"` // 审核备注
  146. Createtime time.Time `json:"createtime" xorm:"'CREATETIME'"` // 创建时间
  147. Hasvideo int32 `json:"hasvideo" xorm:"'HASVIDEO'"` // 是否有视频 - 0:无 1:有
  148. Videourl string `json:"videourl" xorm:"'VIDEOURL'"` // 视频地址
  149. Contactname string `json:"contactname" xorm:"'CONTACTNAME'"` // 联系人
  150. Contactnum string `json:"contactnum" xorm:"'CONTACTNUM'"` // 联系电话
  151. }
  152. // TableName is WAREHOUSEINFO
  153. func (Warehouseinfo) TableName() string {
  154. return "WAREHOUSEINFO"
  155. }
  156. // Wrcategory 现货分类表
  157. type Wrcategory struct {
  158. Categoryid int32 `json:"categoryid" xorm:"'CATEGORYID'" binding:"required"` // 类别ID(SEQ_WRCATEGORY)
  159. Categoryname string `json:"categoryname" xorm:"'CATEGORYNAME'"` // 类别名称
  160. Parentcategoryid int32 `json:"parentcategoryid" xorm:"'PARENTCATEGORYID'"` // 父类别ID
  161. Categorydesc string `json:"categorydesc" xorm:"'CATEGORYDESC'"` // 类别描述
  162. Isvalid int32 `json:"isvalid" xorm:"'ISVALID'"` // 是否有效 - 0:无效 1:有效
  163. Iconurl string `json:"iconurl" xorm:"'ICONURL'"` // 图标地址
  164. Creatorid int64 `json:"creatorid" xorm:"'CREATORID'"` // 创建人
  165. Createtime time.Time `json:"createtime" xorm:"'CREATETIME'"` // 创建时间
  166. Updatorid int64 `json:"updatorid" xorm:"'UPDATORID'"` // 更新人
  167. Updatetime time.Time `json:"updatetime" xorm:"'UPDATETIME'"` // 更新时间
  168. Orderindex int32 `json:"orderindex" xorm:"'ORDERINDEX'"` // 顺序
  169. Areauserid int64 `json:"areauserid" xorm:"'AREAUSERID'"` // 所属机构
  170. }
  171. // TableName is WRCATEGORY
  172. func (Wrcategory) TableName() string {
  173. return "WRCATEGORY"
  174. }
  175. // WRStandardInfo 仓库信息
  176. type WRStandardInfo struct {
  177. Wrstandard `xorm:"extends"`
  178. Unitname string `json:"unitname" xorm:"UNITNAME"` // 单位
  179. Deliverygoodsname string `json:"deliverygoodsname" xorm:"'DELIVERYGOODSNAME'"` // 交割商品名称
  180. }
  181. // GetWrstandards 获取有效的仓单标准
  182. func GetWrstandards() ([]WRStandardInfo, error) {
  183. engine := db.GetEngine()
  184. wrStandards := make([]WRStandardInfo, 0)
  185. if err := engine.Table("WRSTANDARD").Select("WRSTANDARD.*, E1.ENUMDICNAME UNITNAME, DG.DELIVERYGOODSNAME").
  186. Join("LEFT", "ENUMDICITEM E1", "E1.ENUMITEMNAME = WRSTANDARD.UNITID and E1.ENUMDICCODE = 'GOODSUNIT'").
  187. Join("LEFT", "DELIVERYGOODS DG", "DG.DELIVERYGOODSID = WRSTANDARD.DELIVERYGOODSID").
  188. Where("WRSTANDARD.ISVALID = 1").Find(&wrStandards); err != nil {
  189. return nil, err
  190. }
  191. return wrStandards, nil
  192. }
  193. // GetWareHouseinfos 获取有效的仓库信息
  194. func GetWareHouseinfos() ([]Warehouseinfo, error) {
  195. engine := db.GetEngine()
  196. wareHouseinfos := make([]Warehouseinfo, 0)
  197. if err := engine.Where("WAREHOUSESTATUS = 1").Find(&wareHouseinfos); err != nil {
  198. return nil, err
  199. }
  200. return wareHouseinfos, nil
  201. }