| | |
| | | |
| | | import ( |
| | | "context" |
| | | "errors" |
| | | "github.com/shopspring/decimal" |
| | | "strconv" |
| | | "time" |
| | |
| | | resp.List = list |
| | | return resp, nil |
| | | } |
| | | |
| | | func (s *Server) GetOperationInfo(ctx context.Context, req *GetOperationInfoRequest) (*GetOperationInfoResponse, error) { |
| | | if len(req.SourceNumber) == 0 && len(req.SalesDetailsNumber) == 0 { |
| | | return nil, errors.New("来源编码和销售明细编码不能同时为空") |
| | | } |
| | | operations, err := models.NewOperationSearch().SetSourceNumbers(req.SourceNumber).SetSalesDetailsNumbers(req.SalesDetailsNumber). |
| | | SetStatus(constvar.OperationStatus(req.Status)).SetPreload(true).FindNotTotal() |
| | | if err != nil { |
| | | return nil, err |
| | | } |
| | | resp := new(GetOperationInfoResponse) |
| | | list := make([]*OperationInfo, 0) |
| | | for _, operation := range operations { |
| | | var ol OperationInfo |
| | | ol.SourceNumber = operation.SourceNumber |
| | | ol.SalesDetailsNumber = operation.SalesDetailsNumber |
| | | for _, detail := range operation.Details { |
| | | o := ol |
| | | o.ProductId = detail.ProductId |
| | | o.Amount = detail.Amount.IntPart() |
| | | list = append(list, &o) |
| | | } |
| | | } |
| | | resp.List = list |
| | | return resp, nil |
| | | } |