package models import ( "fmt" "mtp2_if/db" "time" ) // 100.10仓单贸易 // Deliverygoods 现货品种表 type Deliverygoods struct { Deliverygoodsid int32 `json:"deliverygoodsid" xorm:"'DELIVERYGOODSID'" binding:"required"` // 现货品种ID(SEQ_DELIVERYGOODS) Deliverygoodscode string `json:"deliverygoodscode" xorm:"'DELIVERYGOODSCODE'" binding:"required"` // 现货品种代码 Deliverygoodsname string `json:"deliverygoodsname" xorm:"'DELIVERYGOODSNAME'"` // 现货品种名称 Goodsunitid int32 `json:"goodsunitid" xorm:"'GOODSUNITID'"` // 现货品种单位ID Deliverygoodstype int32 `json:"deliverygoodstype" xorm:"'DELIVERYGOODSTYPE'"` // 现货品种类型: 1-整装不拆分 2-散装记录明细 3:整装拆分 4:散装不记录明细 Standardqty int64 `json:"standardqty" xorm:"'STANDARDQTY'"` // 标准数量(库位数量) [标准品特有] Standardqtyrange float64 `json:"standardqtyrange" xorm:"'STANDARDQTYRANGE'"` // 标准数量偏差范围 [标准品特有] Auditflag int32 `json:"auditflag" xorm:"'AUDITFLAG'"` // 交割是否需要审核 - 0:不需要 1:需要审核 默认为0 Isvalid int32 `json:"isvalid" xorm:"'ISVALID'"` // 是否有效 - 0:无效 1:有效 Issplit int32 `json:"issplit" xorm:"'ISSPLIT'"` // 是否拆分 - 0:不拆分 1:拆分 [整装] 0:不记录明细 1:记录明细 [散货] - 作废整装时不拆分,则标准数量=合约单位;拆分时标准数量为合约单位的整数倍;整装时必须记录明细表数据 Agreeunit int64 `json:"agreeunit" xorm:"'AGREEUNIT'"` // 合约单位[散货时默认为1, 整装时默认为标准数量] Qtydecimalplace int32 `json:"qtydecimalplace" xorm:"'QTYDECIMALPLACE'"` // 成交量小数位 Categoryid int32 `json:"categoryid" xorm:"'CATEGORYID'"` // 类别ID(SEQ_WRCATEGORY) Dgstatus int32 `json:"dgstatus" xorm:"'DGSTATUS'"` // 品种状态 - 作废 - 0:未激活 1:正常 Areauserid int64 `json:"areauserid" xorm:"'AREAUSERID'"` // 所属机构 Remark string `json:"remark" xorm:"'REMARK'"` // 备注 } // TableName is DELIVERYGOODS func (Deliverygoods) TableName() string { return "DELIVERYGOODS" } // Dgfactoryitemtype 品种要素项表 type Dgfactoryitemtype struct { Dgfactoryitemtypeid int64 `json:"dgfactoryitemtypeid" xorm:"'DGFACTORYITEMTYPEID'" binding:"required"` // 要素项类型ID(SEQ_DGFACTORYITEMTYPE)1-999:预留为特殊类型 1:仓库 - 选择项 2.品牌 - 选择项>1000(序列自增) 选择项 录入项 Deliverygoodsid int32 `json:"deliverygoodsid" xorm:"'DELIVERYGOODSID'" binding:"required"` // 品种ID Itemtypename string `json:"itemtypename" xorm:"'ITEMTYPENAME'"` // 要素项类型名称 Itemtypemode int32 `json:"itemtypemode" xorm:"'ITEMTYPEMODE'"` // 要素项类型模式 -1:选择项 2:录入项 Orderindex int32 `json:"orderindex" xorm:"'ORDERINDEX'"` // 顺序 Unitid int32 `json:"unitid" xorm:"'UNITID'"` // 单位ID - [录入项] Minivalue int64 `json:"minivalue" xorm:"'MINIVALUE'"` // 最小变动值 - [录入项] Minivaluedp int64 `json:"minivaluedp" xorm:"'MINIVALUEDP'"` // 最小变动值小数位 - [录入项] Creatorid int64 `json:"creatorid" xorm:"'CREATORID'"` // 创建人 Createtime time.Time `json:"createtime" xorm:"'CREATETIME'"` // 创建时间 Updatorid int64 `json:"updatorid" xorm:"'UPDATORID'"` // 更新人 Updatetime time.Time `json:"updatetime" xorm:"'UPDATETIME'"` // 更新时间 Isvalid int32 `json:"isvalid" xorm:"'ISVALID'"` // 是否有效 - 0:无效 1:有效 } // TableName is DGFACTORYITEMTYPE func (Dgfactoryitemtype) TableName() string { return "DGFACTORYITEMTYPE" } // Dgfactoryitem 品种选择项定义表 type Dgfactoryitem struct { Dgfactoryitemid int64 `json:"dgfactoryitemid" xorm:"'DGFACTORYITEMID'" binding:"required"` // 选择项ID(SEQ_DGFACTORYITEM) Deliverygoodsid int32 `json:"deliverygoodsid" xorm:"'DELIVERYGOODSID'"` // 品种ID Dgfactoryitemtypeid int64 `json:"dgfactoryitemtypeid" xorm:"'DGFACTORYITEMTYPEID'"` // 要素项类型 Dgfactoryitemvalue string `json:"dgfactoryitemvalue" xorm:"'DGFACTORYITEMVALUE'"` // 要素项值(类型为仓库时填写仓库名称) Warehouseid int64 `json:"warehouseid" xorm:"'WAREHOUSEID'"` // 仓库ID(类型为仓库时填写) Isvalid int32 `json:"isvalid" xorm:"'ISVALID'"` // 是否有效 - 0:无效 1:有效 Orderindex int32 `json:"orderindex" xorm:"'ORDERINDEX'"` // 顺序 } // TableName is DGFACTORYITEM func (Dgfactoryitem) TableName() string { return "DGFACTORYITEM" } // Wrstandard 现货品类表 type Wrstandard struct { Wrstandardid int64 `json:"wrstandardid" xorm:"'WRSTANDARDID'" binding:"required"` // 现货品类ID(SEQ_WRSTANDARD) Wrstandardcode string `json:"wrstandardcode" xorm:"'WRSTANDARDCODE'"` // 现货品类代码 Wrstandardname string `json:"wrstandardname" xorm:"'WRSTANDARDNAME'"` // 现货品类名称 Deliverygoodsid int32 `json:"deliverygoodsid" xorm:"'DELIVERYGOODSID'"` // 品种ID Unitid int32 `json:"unitid" xorm:"'UNITID'"` // 单位ID Minivalue int64 `json:"minivalue" xorm:"'MINIVALUE'"` // 最小变动值 Minivaluedp int64 `json:"minivaluedp" xorm:"'MINIVALUEDP'"` // 最小变动值小数位 Realminivalue int64 `json:"realminivalue" xorm:"'REALMINIVALUE'"` // 实际最小变动值 Realminivaluedp int64 `json:"realminivaluedp" xorm:"'REALMINIVALUEDP'"` // 实际最小变动值小数位 Wrsstatus int32 `json:"wrsstatus" xorm:"'WRSSTATUS'"` // 状态 - 作废 - 0:未激活 1:正常 Creatorid int64 `json:"creatorid" xorm:"'CREATORID'"` // 创建人 Createtime time.Time `json:"createtime" xorm:"'CREATETIME'"` // 创建时间 Updatorid int64 `json:"updatorid" xorm:"'UPDATORID'"` // 更新人 Updatetime time.Time `json:"updatetime" xorm:"'UPDATETIME'"` // 更新时间 Factoryitemjson string `json:"factoryitemjson" xorm:"'FACTORYITEMJSON'"` // 要素项定义Json[{"DGFactoryItemTypeID": ,"ItemTypeMode": ,"FactoryItemIDs": },{.....},]DGFactoryItemTypeID - 要素项类型ID --DGFactoryItem->DGFactoryItemTypeIDItemTypeMode - 要素项类型模式 --DGFactoryItem->ItemTypeModeFactoryItemIDs - 选择项IDs--DGFactoryItem->DGFactoryItemID, 逗号分隔 Isvalid int32 `json:"isvalid" xorm:"'ISVALID'"` // 是否有效 - 0:无效 1:有效 Areauserid int64 `json:"areauserid" xorm:"'AREAUSERID'"` // 所属机构 Remark string `json:"remark" xorm:"'REMARK'"` // 备注 Convertfactor float64 `json:"convertfactor" xorm:"'CONVERTFACTOR'"` // 标仓系数 } // TableName is WRSTANDARD func (Wrstandard) TableName() string { return "WRSTANDARD" } // Wrstandardfactoryitem 现货品类要素项定义表 type Wrstandardfactoryitem struct { Wrstandardid int64 `json:"wrstandardid" xorm:"'WRSTANDARDID'" binding:"required"` // 现货品类ID Dgfactoryitemtypeid int64 `json:"dgfactoryitemtypeid" xorm:"'DGFACTORYITEMTYPEID'" binding:"required"` // 要素项类型ID Dgfactoryitemid int64 `json:"dgfactoryitemid" xorm:"'DGFACTORYITEMID'" binding:"required"` // 要素项ID - 输入项默认为0,选择项为选择项ID } // TableName is WRSTANDARDFACTORYITEM func (Wrstandardfactoryitem) TableName() string { return "WRSTANDARDFACTORYITEM" } // Wrfactortype 仓单要素类型表 type Wrfactortype struct { Wrfactortypeid int64 `json:"wrfactortypeid" xorm:"'WRFACTORTYPEID'" binding:"required"` // 仓单要素类型ID(212+Unix秒时间戳(10位)+xxxxxx) Wrfactortypename string `json:"wrfactortypename" xorm:"'WRFACTORTYPENAME'"` // 仓单要素类型名称(选择项要素的名称合并显示,逗号分隔) Deliverygoodsid int32 `json:"deliverygoodsid" xorm:"'DELIVERYGOODSID'"` // 交割商品ID Brandid int64 `json:"brandid" xorm:"'BRANDID'"` // 品牌ID(1交割品种升贴水参数表 AutoID) - 作废 Qualityid int64 `json:"qualityid" xorm:"'QUALITYID'"` // 品质ID(1交割品种升贴水参数表 AutoID) - 作废 Specid int64 `json:"specid" xorm:"'SPECID'"` // 规格ID(1交割品种升贴水参数表 AutoID) - 作废 Warehouseid int64 `json:"warehouseid" xorm:"'WAREHOUSEID'"` // 仓库ID Deliverymonthid int64 `json:"deliverymonthid" xorm:"'DELIVERYMONTHID'"` // 月份ID(1交割品种升贴水参数表 AutoID) - 作废 Wrstandardid int64 `json:"wrstandardid" xorm:"'WRSTANDARDID'"` // 现货品类ID Wrstandardcode string `json:"wrstandardcode" xorm:"'WRSTANDARDCODE'"` // 现货品类代码 Optioncompare string `json:"optioncompare" xorm:"'OPTIONCOMPARE'"` // 选择项比较串【{选择项ID}+{冒号}+选择项值 } ,逗号分隔,头尾加逗号】-- 所有选择项拼接,用于比较 } // TableName is WRFACTORTYPE func (Wrfactortype) TableName() string { return "WRFACTORTYPE" } // Wrfactortypeitem 仓单要素类型选择项表 type Wrfactortypeitem struct { Wrfactortypeid int64 `json:"wrfactortypeid" xorm:"'WRFACTORTYPEID'" binding:"required"` // 仓单要素类型ID(212+Unix秒时间戳(10位)+xxxxxx) Dgfactoryitemtypeid int64 `json:"dgfactoryitemtypeid" xorm:"'DGFACTORYITEMTYPEID'" binding:"required"` // 要素选择项类型ID Dgfactoryitemid int64 `json:"dgfactoryitemid" xorm:"'DGFACTORYITEMID'" binding:"required"` // 选择项ID Creatorid int64 `json:"creatorid" xorm:"'CREATORID'"` // 创建人 Createtime time.Time `json:"createtime" xorm:"'CREATETIME'"` // 创建时间 Updatorid int64 `json:"updatorid" xorm:"'UPDATORID'"` // 更新人 Updatetime time.Time `json:"updatetime" xorm:"'UPDATETIME'"` // 更新时间 } // TableName is WRFACTORTYPEITEM func (Wrfactortypeitem) TableName() string { return "WRFACTORTYPEITEM" } // Warehouseinfo 仓库信息表 type Warehouseinfo struct { Autoid int64 `json:"autoid" xorm:"'AUTOID'" binding:"required"` // 自增ID Warehousecode string `json:"warehousecode" xorm:"'WAREHOUSECODE'" binding:"required"` // 仓库代码 Warehousename string `json:"warehousename" xorm:"'WAREHOUSENAME'"` // 仓库名称 Warehousetype int32 `json:"warehousetype" xorm:"'WAREHOUSETYPE'"` // 仓库类型 - 1 厂库 2 自有库 3 合作库 Areauserid int64 `json:"areauserid" xorm:"'AREAUSERID'"` // 所属机构 Warehousestatus int32 `json:"warehousestatus" xorm:"'WAREHOUSESTATUS'"` // 仓库状态 - 1:正常 2:注销 3:待审核 4:审核拒绝 Countryid int32 `json:"countryid" xorm:"'COUNTRYID'"` // 国家 Provinceid int32 `json:"provinceid" xorm:"'PROVINCEID'"` // 省 Cityid int32 `json:"cityid" xorm:"'CITYID'"` // 市 Districtid int32 `json:"districtid" xorm:"'DISTRICTID'"` // 区 Address string `json:"address" xorm:"'ADDRESS'"` // 详细地址 Remark string `json:"remark" xorm:"'REMARK'"` // 审核备注 Createtime time.Time `json:"createtime" xorm:"'CREATETIME'"` // 创建时间 Hasvideo int32 `json:"hasvideo" xorm:"'HASVIDEO'"` // 是否有视频 - 0:无 1:有 Videourl string `json:"videourl" xorm:"'VIDEOURL'"` // 视频地址 Contactname string `json:"contactname" xorm:"'CONTACTNAME'"` // 联系人 Contactnum string `json:"contactnum" xorm:"'CONTACTNUM'"` // 联系电话 } // TableName is WAREHOUSEINFO func (Warehouseinfo) TableName() string { return "WAREHOUSEINFO" } // Wrcategory 现货分类表 type Wrcategory struct { Categoryid int32 `json:"categoryid" xorm:"'CATEGORYID'" binding:"required"` // 类别ID(SEQ_WRCATEGORY) Categoryname string `json:"categoryname" xorm:"'CATEGORYNAME'"` // 类别名称 Parentcategoryid int32 `json:"parentcategoryid" xorm:"'PARENTCATEGORYID'"` // 父类别ID Categorydesc string `json:"categorydesc" xorm:"'CATEGORYDESC'"` // 类别描述 Isvalid int32 `json:"isvalid" xorm:"'ISVALID'"` // 是否有效 - 0:无效 1:有效 Iconurl string `json:"iconurl" xorm:"'ICONURL'"` // 图标地址 Creatorid int64 `json:"creatorid" xorm:"'CREATORID'"` // 创建人 Createtime time.Time `json:"createtime" xorm:"'CREATETIME'"` // 创建时间 Updatorid int64 `json:"updatorid" xorm:"'UPDATORID'"` // 更新人 Updatetime time.Time `json:"updatetime" xorm:"'UPDATETIME'"` // 更新时间 Orderindex int32 `json:"orderindex" xorm:"'ORDERINDEX'"` // 顺序 Areauserid int64 `json:"areauserid" xorm:"'AREAUSERID'"` // 所属机构 } // TableName is WRCATEGORY func (Wrcategory) TableName() string { return "WRCATEGORY" } // WRStandardInfo 仓库信息 type WRStandardInfo struct { Wrstandard `xorm:"extends"` Unitname string `json:"unitname" xorm:"UNITNAME"` // 单位 Deliverygoodsname string `json:"deliverygoodsname" xorm:"'DELIVERYGOODSNAME'"` // 交割商品名称 } // GetWrstandards 获取有效的仓单标准 func GetWrstandards() ([]WRStandardInfo, error) { engine := db.GetEngine() wrStandards := make([]WRStandardInfo, 0) if err := engine.Table("WRSTANDARD").Select("WRSTANDARD.*, E1.ENUMDICNAME UNITNAME, DG.DELIVERYGOODSNAME"). Join("LEFT", "ENUMDICITEM E1", "E1.ENUMITEMNAME = WRSTANDARD.UNITID and E1.ENUMDICCODE = 'GOODSUNIT'"). Join("LEFT", "DELIVERYGOODS DG", "DG.DELIVERYGOODSID = WRSTANDARD.DELIVERYGOODSID"). Where("WRSTANDARD.ISVALID = 1").Find(&wrStandards); err != nil { return nil, err } return wrStandards, nil } // GetWareHouseinfos 获取有效的仓库信息 func GetWareHouseinfos() ([]Warehouseinfo, error) { engine := db.GetEngine() wareHouseinfos := make([]Warehouseinfo, 0) if err := engine.Where("WAREHOUSESTATUS = 1").Find(&wareHouseinfos); err != nil { return nil, err } return wareHouseinfos, nil } // GetDeliverGoods 获取交割商品 func GetDeliverGoods() ([]Deliverygoods, error) { engine := db.GetEngine() d := make([]Deliverygoods, 0) if err := engine.Where("IsValid=1").And("categoryid<>0").Find(&d); err != nil { return nil, fmt.Errorf("query deleiverygoods fail") } return d, nil }