| | |
| | | "aps_crm/constvar" |
| | | "aps_crm/model" |
| | | "aps_crm/model/grpc_init" |
| | | "aps_crm/pkg/ecode" |
| | | "aps_crm/proto/product_inventory" |
| | | "aps_crm/service" |
| | | "context" |
| | | "errors" |
| | | "fmt" |
| | | "github.com/shopspring/decimal" |
| | | ) |
| | | |
| | |
| | | } |
| | | return new(SendSalesDetailsAndProjectToCrmResponse), nil |
| | | } |
| | | |
| | | func (s *Server) GetClientList(ctx context.Context, req *GetClientListRequest) (*GetClientListResponse, error) { |
| | | if req.Page <= 0 || req.PageSize == 0 { |
| | | return nil, errors.New("参数错误") |
| | | } |
| | | clientService := new(service.ClientService) |
| | | params := map[string]interface{}{} |
| | | if req.Keyword != "" { |
| | | params["name"] = req.Keyword |
| | | } |
| | | clients, total, errCode := clientService.GetClientList(int(req.Page), int(req.PageSize), params) |
| | | if errCode != ecode.OK { |
| | | return nil, errors.New(fmt.Sprintf("内部错误, code:%v", errCode)) |
| | | } |
| | | resp := new(GetClientListResponse) |
| | | resp.Total = total |
| | | resp.List = make([]*Client, 0, len(clients)) |
| | | for _, client := range clients { |
| | | resp.List = append(resp.List, &Client{ |
| | | Number: client.Number, |
| | | Name: client.Name, |
| | | }) |
| | | } |
| | | return resp, nil |
| | | } |