package yapingtech import ( "context" "encoding/json" "fmt" "github.com/zeromicro/go-zero/core/logx" "repository.lenntc.com/lenntc/third-platform-sdk/client" ) // YaPingTechApi 亚平平台 type YaPingTechApi interface { QueryOrderList(ctx context.Context, req QueryOrderListRequest) ([]*QueryOrderListItem, error) } type yaPingTechApiImpl struct { log logx.Logger client *Client } func newYaPingTechApiImpl(log logx.Logger, client *Client) YaPingTechApi { return &yaPingTechApiImpl{ log: log, client: client, } } func (s *yaPingTechApiImpl) QueryOrderList(ctx context.Context, req QueryOrderListRequest) ([]*QueryOrderListItem, error) { params := map[string]any{ "page": req.Page, "out_order_sn": req.OutOrderSn, } if req.Type != "" { params["type"] = req.Type } //加密参数 paramsStr, _ := json.Marshal(params) jsonData, err := Encrypt(string(paramsStr), s.client.authConfig.AppSecret) if err != nil { return nil, fmt.Errorf("yapingtech encrypt failed: %v", err) } args := map[string]any{ "app_id": s.client.authConfig.AppId, "json_data": jsonData, } request := &client.HttpRequest{Headers: s.client.headers, BodyArgs: args} response := new(QueryOrderListResponse) if err := s.client.HttpPost(GetOrderListUrl, request, &client.HttpResponse{Result: response}); err != nil { return nil, fmt.Errorf("yapingtech http post failed: %v", err) } if response.Code != 200 { return nil, fmt.Errorf(response.Message) } return response.Data.Items, nil }