diff --git a/plugins/zltx/internal/transform.go b/plugins/zltx/internal/transform.go index 8b4437c..aeb16f4 100644 --- a/plugins/zltx/internal/transform.go +++ b/plugins/zltx/internal/transform.go @@ -22,13 +22,13 @@ func rechargeReq(c *proto.OrderRequest) *po.OrderReq { } } -func rechargeResp(resp po.OrderResp) *proto.OrderResponse { +func rechargeResp(request *proto.OrderRequest, resp po.OrderResp) *proto.OrderResponse { data, _ := json.Marshal(resp) return &proto.OrderResponse{ Result: &proto.Result{ Status: proto.Status_ING, - OrderNo: "", - TradeNo: "", + OrderNo: request.Order.OrderNo, + TradeNo: "", // 下单无该值返回 Message: resp.Message, Data: data, }, @@ -44,13 +44,13 @@ func queryReq(in *proto.QueryRequest) *po.QueryReq { } } -func queryResp(resp po.QueryResp) *proto.QueryResponse { +func queryResp(request *proto.QueryRequest, resp po.QueryResp) *proto.QueryResponse { data, _ := json.Marshal(resp) return &proto.QueryResponse{ Result: &proto.Result{ Status: resp.Status.GetOrderStatus(), - OrderNo: "", - TradeNo: "", + OrderNo: request.Order.OrderNo, + TradeNo: request.Order.TradeNo, Message: resp.Message, Data: data, }, diff --git a/plugins/zltx/internal/util.go b/plugins/zltx/internal/util.go index 8f320e7..016ca0d 100644 --- a/plugins/zltx/internal/util.go +++ b/plugins/zltx/internal/util.go @@ -40,3 +40,18 @@ func req(req po.Req, appKey string) (url.Values, error) { } return urlValues(req, appKey), nil } + +func verify(notify po.Notify, appKey string) bool { + kvRows := utils.SortStruct(req) + var kvStr []string + + for _, kv := range kvRows { + if kv.Key != "sign" && kv.Key != "version" { + kvStr = append(kvStr, kv.Key+"="+kv.Value) + } + } + kvStr = append(kvStr, "key="+appKey) + signStr := strings.Join(kvStr, "&") + + return sign([]byte(signStr)) == notify.Sign +} diff --git a/plugins/zltx/internal/zltx.go b/plugins/zltx/internal/zltx.go index 22dbc2c..3be4140 100644 --- a/plugins/zltx/internal/zltx.go +++ b/plugins/zltx/internal/zltx.go @@ -36,7 +36,7 @@ func (p *ZltxService) Order(ctx context.Context, request *proto.OrderRequest) (* return nil, fmt.Errorf("请求错误,msg:" + response.Message) } - return rechargeResp(response), nil + return rechargeResp(request, response), nil } func (p *ZltxService) Query(ctx context.Context, request *proto.QueryRequest) (*proto.QueryResponse, error) { @@ -55,7 +55,7 @@ func (p *ZltxService) Query(ctx context.Context, request *proto.QueryRequest) (* return nil, errors.New("请求错误,msg:" + response.Message) } - return queryResp(response), nil + return queryResp(request, response), nil } func (p *ZltxService) Notify(ctx context.Context, request *proto.NotifyRequest) (*proto.NotifyResponse, error) {