| | |
| | | if req.Number == "" { |
| | | return nil, errors.New("采购编号不能为空") |
| | | } |
| | | err := global.GVA_DB.Model(&purchase.Purchase{}).Where("number = ?", req.Number). |
| | | Updates(map[string]interface{}{"status": purchase.OrderStatusStored}).Error |
| | | m := make(map[string]interface{}) |
| | | m["status"] = purchase.OrderStatusStored |
| | | if req.Status > 0 { |
| | | m["status"] = req.Status |
| | | } |
| | | err := global.GVA_DB.Model(&purchase.Purchase{}).Where("number = ?", req.Number).Updates(m).Error |
| | | return new(UpdatePurchaseStatusResponse), err |
| | | } |
| | | |
| | |
| | | info.PurchaseNumber = p.Number |
| | | info.PurchaseName = p.Name |
| | | info.SupplierName = p.Supplier.Name |
| | | info.Amount = p.Quantity.IntPart() |
| | | info.Status = int64(p.Status) |
| | | if p.Status == purchase.OrderStatusStored || p.Status == purchase.OrderStatusCompleted { |
| | | info.FinishAmount = info.Amount |
| | | } |
| | | for _, pp := range pps { |
| | | if int(p.ID) == pp.PurchaseId { |
| | | info.ProductId = pp.Product.Number |
| | | info.ProductName = pp.Product.Name |
| | | info.Specs = pp.Product.Specifications |
| | | info.Unit = pp.Product.Unit |
| | | ni := info |
| | | ni.ProductId = pp.Product.Number |
| | | ni.ProductName = pp.Product.Name |
| | | ni.Specs = pp.Product.Specifications |
| | | ni.Unit = pp.Product.Unit |
| | | ni.Amount = pp.Amount.IntPart() |
| | | infos = append(infos, &ni) |
| | | } |
| | | } |
| | | infos = append(infos, &info) |
| | | } |
| | | resp := new(GetPurchaseInfoResponse) |
| | | resp.Infos = infos |