| | |
| | | "errors" |
| | | "fmt" |
| | | "github.com/shopspring/decimal" |
| | | "gorm.io/gorm" |
| | | "strconv" |
| | | "strings" |
| | | "time" |
| | |
| | | resp.Msg = "success" |
| | | return resp, nil |
| | | } |
| | | |
| | | func (s *Server) GetOutputOperationInfo(ctx context.Context, req *GetOutputOperationInfoRequest) (*GetOutputOperationInfoResponse, error) { |
| | | if req.Number == "" { |
| | | return nil, errors.New("参数不能为空") |
| | | } |
| | | result := new(GetOutputOperationInfoResponse) |
| | | first, err := models.NewOperationSearch().SetSourceNumber(req.Number).SetStatus(constvar.OperationStatus_Finish).First() |
| | | if err != nil { |
| | | if err == gorm.ErrRecordNotFound { |
| | | return result, nil |
| | | } |
| | | return nil, err |
| | | } |
| | | details, err := models.NewOperationDetailsSearch().SetOperationId(first.Id).FindNotTotal() |
| | | if err != nil { |
| | | return nil, err |
| | | } |
| | | list := make([]*OutputProduct, 0) |
| | | for _, detail := range details { |
| | | var op OutputProduct |
| | | op.Number = detail.ProductId |
| | | op.Amount = detail.Amount.String() |
| | | list = append(list, &op) |
| | | } |
| | | result.Products = list |
| | | |
| | | return result, nil |
| | | } |