| | |
| | | }, |
| | | "productId": { |
| | | "description": "产品id", |
| | | "type": "string" |
| | | "type": "integer" |
| | | }, |
| | | "purchaseId": { |
| | | "description": "采购id", |
| | |
| | | }, |
| | | "productId": { |
| | | "description": "产品id", |
| | | "type": "string" |
| | | "type": "integer" |
| | | }, |
| | | "purchaseId": { |
| | | "description": "采购id", |
| | |
| | | type: number |
| | | productId: |
| | | description: 产品id |
| | | type: string |
| | | type: integer |
| | | purchaseId: |
| | | description: 采购id |
| | | type: integer |
| | |
| | | type PurchaseProducts struct { |
| | | global.GVA_MODEL |
| | | PurchaseId int `json:"purchaseId" form:"purchaseType" gorm:"type:int(11);not null;default 0;comment:采购类型id"` // 采购id |
| | | ProductId int `json:"productId" form:"productId" gorm:"type:varchar(255);not null;default '';comment:产品id"` // 产品id |
| | | ProductId int `json:"productId" form:"productId" gorm:"type:int;not null;default 0;comment:产品id"` // 产品id |
| | | Product test.SupplierMaterial `json:"-" gorm:"foreignKey:ProductId"` |
| | | Amount decimal.Decimal `json:"amount" form:"amount" gorm:"type:decimal(12,2);not null;default 0;comment:采购数量"` // 采购数量 |
| | | Price decimal.Decimal `json:"price" form:"price" gorm:"type:decimal(12,2);not null;default 0.00;comment:采购单价"` // 采购单价 |
| | |
| | | var purchaseList = make([]*purchase.Purchase, 0) |
| | | if info.Keyword != "" { |
| | | db.Distinct("srm_purchase.id").Joins("left join srm_purchase_products on srm_purchase_products.purchase_id = srm_purchase.id"). |
| | | Joins("left join material on material.id = srm_purchase_products.product_id"). |
| | | Joins("left join srm_supplier_material on srm_supplier_material.supplier_id = srm_purchase.id"). |
| | | Joins("left join srm_supplier on srm_supplier.Id = srm_purchase.supplier_id"). |
| | | Where("srm_purchase.name like ?", "%"+info.Keyword+"%"). |
| | | Or("material.name like ?", "%"+info.Keyword+"%"). |
| | | Or("srm_supplier_material.name like ?", "%"+info.Keyword+"%"). |
| | | Or("srm_supplier.name like ?", "%"+info.Keyword+"%") |
| | | err = db.Limit(limit).Offset(offset).Find(&ids).Error |
| | | if err != nil { |
| | |
| | | } |
| | | if len(ids) != 0 { |
| | | db = global.GVA_DB.Model(&purchase.Purchase{}) |
| | | err = db.Where("id in (?)", ids).Find(&purchaseList).Error |
| | | err = db.Where("id in (?)", ids).Preload("Supplier").Order("updated_at desc").Find(&purchaseList).Error |
| | | } else { |
| | | err = db.Limit(limit).Offset(offset).Find(&purchaseList).Error |
| | | err = db.Limit(limit).Offset(offset).Preload("Supplier").Order("updated_at desc").Find(&purchaseList).Error |
| | | } |
| | | |
| | | return purchaseList, total, err |