syntax = "proto3"; package proto; option go_package = "./platform/adapterv1;adapterv1"; import "validate/validate.proto"; service PlatformAdapter { rpc Recharge(RechargeReq) returns (Result); rpc Query(QueryReq) returns(Result); rpc Notify(NotifyReq) returns (Result); rpc NotifyReply(NotifyReplyReq) returns (NotifyData); rpc Balance(Tag) returns (WalletResp); rpc CallCustom(CallCustomReq) returns(CallCustomResp); rpc Template(TmplReq) returns(TmplResp); rpc TemplateByAdapterName(TmplByAdapterNameReq) returns(TmplResp); rpc TemplateValidate(TmplValidateReq) returns(TmplValidateResp); rpc TemplateValidateByAdapterName(TmplValidateByAdapterNameReq) returns(TmplValidateResp); rpc IsIdempotent(Tag) returns(BoolResp); rpc IsUsePlatformOrderNumber(Tag) returns(BoolResp); rpc IsNotQuery(Tag) returns(BoolResp); rpc List(ListReq) returns (ListResp); rpc IsExist(Tag) returns (BoolResp); rpc CustomNotify(CustomNotifyReq) returns (CustomNotifyResponse); rpc CustomNotifyReply(CustomNotifyReplyReq) returns (NotifyData); } //充值信息,账户,数量等 message RechargeInfo { string account = 1; uint32 quantity = 2; bytes extra = 3; //扩展信息 JSON,扩展 FV 信息,用户 IP 信息,设备类型信息 } //商品相关信息 message RechargeProduct{ string code = 1; //商品编码 double price = 2; //商品授权价格(上游给我们的授权价格) string template = 3; //商品模板信息 bytes extra = 4; //商品配置的扩展信息 JSON } //其他交易(订单)相关信息 message RechargeTrade { string trade_number = 1; double trade_price = 2; //交易单价(我们实际给下游的) bytes extra = 3;//?? } message RechargeReq{ string tag = 1; RechargeInfo info = 2; RechargeProduct product = 3; RechargeTrade trade = 4; } enum ResultStatus{ INVALID = 0; // 无效的状态 FAIL = 1; // 订单处理失败 SUCCESS = 2; // 订单处理成功 ING = 3; // 订单处理中 NOT_FOUND = 4; // 未找到订单 EXIST = 5;// 订单已存在 } message Result { //外部平台交易号 string out_trade_number = 2; string trade_number = 3; ResultStatus status = 4; double trade_price = 5;//上游实际产生的交易价 bytes data = 6; //原始信息 json string message = 7; bool timeout = 8; // 请求是否超时 } //todo 官方信息是否返回给下游 message QueryReq{ string tag = 1; string trade_number = 2; //外部平台交易号 string out_trade_number = 3; //商品信息或商品类型?? RechargeProduct product = 4; //交易时商品信息 //根据充值账号,查询时间段的充值信息??? bytes extra = 5;//扩展信息,卡密转直充,可能根据卡密进行查询 } message NotifyData{ bytes queries = 1; //url 地址中的参数 json bytes headers = 2; //header 头里面的参数 json bytes body = 3; //通过 form 表单或者 body 提交的数据 json } message NotifyReq{ string tag = 1; NotifyData data = 2; string extra = 3; } message NotifyReplyReq{ string tag = 1; bool ok = 2; //响应状态,true 成功,false 失败 Result result = 3; //处理结果 string extra = 4; } message CallCustomReq{ string tag = 1 [(validate.rules).string = {min_len: 1}]; string method = 2 [(validate.rules).string = {min_len: 1}]; //请求方法 bytes parameter = 3; //请求数据 json } message CallCustomResp{ bytes result = 1; } message Tag{ string tag = 1; } message TmplReq{ string tag = 1; string name = 2; bool detail = 3; } message TmplResp{ string content = 1; } message TmplByAdapterNameReq{ string adapter_name = 1; string name = 2; bool detail = 3; } message TmplValidateReq{ string tag = 1; string name = 2; bytes data = 3; } message TmplValidateResp{ bool ok = 1; string msg = 2; // 加密后的数据 bytes data = 3; } message TmplValidateByAdapterNameReq{ string adapter_name = 1; string name = 2; bytes data = 3; } message WalletResp{ double balance = 1; double credit = 2; } message BoolResp{ bool ok = 1; } message ListReq { } message AdapterInfo{ string bin = 9; string name = 1; string version = 2; string author = 3; string company = 4; bool is_idempotent = 5; bool is_use_platform_order_number = 6; map handles = 7; map pre_handles = 8; } message ListResp { repeated AdapterInfo list = 1; } message CustomNotifyReq{ string tag = 1; string method = 2 ; //请求方法 NotifyData data = 3; } message CustomNotifyResponse{ bytes result = 1; } message CustomNotifyReplyReq{ string tag = 1; string method = 2 ; //请求方法 bool ok = 3; //响应状态,true 成功,false 失败 bytes result = 4; //处理结果 }