diff --git a/cmd/api/doc/api.api b/cmd/api/doc/api.api index 25b6023..b94f8fc 100644 --- a/cmd/api/doc/api.api +++ b/cmd/api/doc/api.api @@ -25,5 +25,9 @@ service yl { @doc "卡密异步发放接口" @handler ylAsync post /key/asyncSend (AsyncReq) returns (AsyncResp) + + @doc "订单查询接口" + @handler getOrder + post /order/get (GetOrderReq) returns (GetOrderRsp) } diff --git a/cmd/api/doc/vo/base.api b/cmd/api/doc/vo/base.api index 176c2f7..b359d66 100644 --- a/cmd/api/doc/vo/base.api +++ b/cmd/api/doc/vo/base.api @@ -48,3 +48,27 @@ type AsyncResp { Msg string `json:"msg"` // 返回信息 Status int `json:"status"` // 错误码: 0-成功 1-失败 } + +type GetOrderReq { + DeliverOrderNo string `json:"deliverOrderNo"` // 平台订单号 + SupplierId int64 `json:"supplierId"` // 供货商id + RequestTime int64 `json:"requestTime"` // 请求时间 + Sign string `json:"sign"` + SupplierOrderNo string `json:"supplierOrderNo"` // 供货商订单号 +} + +type GetOrderRsp { + DeliverOrderNo string `json:"deliverOrderNo"` // 平台订单号 + SupplierOrderNo string `json:"supplierOrderNo"` // 供货商订单号 + SupplierSkuId int64 `json:"supplierSkuId"` // 供货商sku + Count int64 `json:"count"` //数量(此字段只目前支持是金豆,积分等虚拟资产,其他商品不支持) + SendStatus int `json:"sendStatus"` // 发货状态: 0-发货中 1-发货成功 2-发货失败 + Price int64 `json:"price"` //结算价格(单位:厘) + StatusTime int64 `json:"statusTime"` // 成功/失败时间 + Msg string `json:"msg"` // 失败原因 + SupplierId int64 `json:"supplierId"` // 供货商id + CardNo string `json:"cardNo"` // 卡号,可为空字符串 + CardKey string `json:"cardKey"` // 卡密,可为空字符串 + CardExpireTime string `json:"cardExpireTime"` // 卡密过期时间,可为空字符串 + CardExchangeUrl string `json:"cardExchangeUrl"` // 卡密兑换地址,可为空字符串 +} \ No newline at end of file diff --git a/cmd/api/internal/config/config.go b/cmd/api/internal/config/config.go index 14f0701..982a638 100644 --- a/cmd/api/internal/config/config.go +++ b/cmd/api/internal/config/config.go @@ -14,8 +14,8 @@ type Config struct { Url string Key string } - YouleHost string - SupplierSkuId map[string]string + YouleHost string + MarketConfig MarketConfig } type Rpc struct { @@ -25,3 +25,9 @@ type Rpc struct { type Nacos struct { Endpoints []string } + +type MarketConfig struct { + AppId string + PosId string + SupplierSkuId map[string]string +} diff --git a/cmd/api/internal/handler/routes.go b/cmd/api/internal/handler/routes.go index 636f824..9faf1a0 100644 --- a/cmd/api/internal/handler/routes.go +++ b/cmd/api/internal/handler/routes.go @@ -29,6 +29,12 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { Path: "/key/send", Handler: yl.YlHandler(serverCtx), }, + { + // 订单查询接口 + Method: http.MethodPost, + Path: "/order/get", + Handler: yl.GetOrderHandler(serverCtx), + }, }..., ), rest.WithPrefix("/market"), diff --git a/cmd/api/internal/logic/yl/ylAsyncLogic.go b/cmd/api/internal/logic/yl/ylAsyncLogic.go index 03fab73..d58e403 100644 --- a/cmd/api/internal/logic/yl/ylAsyncLogic.go +++ b/cmd/api/internal/logic/yl/ylAsyncLogic.go @@ -37,32 +37,27 @@ func NewYlAsyncLogic(ctx context.Context, svcCtx *svc.ServiceContext) *YlAsyncLo func (l *YlAsyncLogic) YlAsync(req *types.AsyncReq) (resp *types.AsyncResp, err error) { var ( - reqData transfer.MarketKeySendReq - extendParam types.KeySendExtendParam + reqData transfer.MarketKeySendReq + VoucherId string ) - err = sonic.Unmarshal([]byte(req.ExtendParams), &extendParam) - if err != nil { - return nil, fmt.Errorf("extendParam 格式错误") - } - var VoucherId = "" - if v, ok := l.svcCtx.Config.SupplierSkuId[strconv.Itoa(int(req.SupplierSkuId))]; ok { + if v, ok := l.svcCtx.Config.MarketConfig.SupplierSkuId[strconv.Itoa(int(req.SupplierSkuId))]; ok { VoucherId = v } else { return nil, fmt.Errorf("供货商sku 未配置") } reqData = transfer.MarketKeySendReq{ - AppId: extendParam.AppId, + AppId: l.svcCtx.Config.MarketConfig.AppId, ReqCode: "voucher.create", MemId: fmt.Sprintf("%d", req.SupplierId), ReqSerialNo: req.DeliverOrderNo, Timestamp: time.Unix(req.CreateTime, 0).Format("20060102150405"), - PosId: extendParam.PosId, + PosId: l.svcCtx.Config.MarketConfig.PosId, VoucherId: VoucherId, - VoucherNum: extendParam.Num, - MobileNo: extendParam.MobileNo, - SendMsg: extendParam.SendMsg, + VoucherNum: 1, + //MobileNo: extendParam.MobileNo, + //SendMsg: extendParam.SendMsg, } if reqData.SendMsg == "" { reqData.SendMsg = "2" diff --git a/cmd/api/internal/types/extraTypes.go b/cmd/api/internal/types/extraTypes.go index 44d921c..d3daea0 100644 --- a/cmd/api/internal/types/extraTypes.go +++ b/cmd/api/internal/types/extraTypes.go @@ -36,3 +36,25 @@ type KeySendExtendParam struct { MobileNo string `json:"mobileNo"` SendMsg string `json:"sendMsg"` } + +type NotifyReq struct { + DeliverOrderNo string `json:"deliverOrderNo"` // 平台订单号 + SupplierOrderNo string `json:"supplierOrderNo"` // 供货商订单号 + SupplierSkuId int64 `json:"supplierSkuId"` // 供货商sku + RequestTime int64 `json:"requestTime"` // 请求时间 + Account string `json:"thirdSkuId"` // 充值账号 + Status int `json:"status"` //错误码: 1-发货成功 2-发货失败 + Msg string `json:"msg"` // 错误信息 + Price int64 `json:"price"` //结算价格(单位:厘) + SupplierId int64 `json:"supplierId"` // 供货商id + CardNo string `json:"cardNo"` // 卡号,可为空字符串 + CardKey string `json:"cardKey"` // 卡密,可为空字符串 + CardExpireTime string `json:"cardExpireTime"` // 卡密过期时间,可为空字符串 + CardExchangeUrl string `json:"cardExchangeUrl"` // 卡密兑换地址,可为空字符串 + Sign string `json:"sign"` +} + +type NotifyResp struct { + Status int `json:"status"` // 错误码: 0-成功 1-失败 + Msg string `json:"msg"` // 返回信息 +} diff --git a/cmd/api/internal/types/types.go b/cmd/api/internal/types/types.go index b686059..ca988ea 100644 --- a/cmd/api/internal/types/types.go +++ b/cmd/api/internal/types/types.go @@ -26,6 +26,30 @@ type AsyncResp struct { type Empty struct { } +type GetOrderReq struct { + DeliverOrderNo string `json:"deliverOrderNo"` // 平台订单号 + SupplierId int64 `json:"supplierId"` // 供货商id + RequestTime int64 `json:"requestTime"` // 请求时间 + Sign string `json:"sign"` + SupplierOrderNo string `json:"supplierOrderNo"` // 供货商订单号 +} + +type GetOrderRsp struct { + DeliverOrderNo string `json:"deliverOrderNo"` // 平台订单号 + SupplierOrderNo string `json:"supplierOrderNo"` // 供货商订单号 + SupplierSkuId int64 `json:"supplierSkuId"` // 供货商sku + Count int64 `json:"count"` //数量(此字段只目前支持是金豆,积分等虚拟资产,其他商品不支持) + SendStatus int `json:"sendStatus"` // 发货状态: 0-发货中 1-发货成功 2-发货失败 + Price int64 `json:"price"` //结算价格(单位:厘) + StatusTime int64 `json:"statusTime"` // 成功/失败时间 + Msg string `json:"msg"` // 失败原因 + SupplierId int64 `json:"supplierId"` // 供货商id + CardNo string `json:"cardNo"` // 卡号,可为空字符串 + CardKey string `json:"cardKey"` // 卡密,可为空字符串 + CardExpireTime string `json:"cardExpireTime"` // 卡密过期时间,可为空字符串 + CardExchangeUrl string `json:"cardExchangeUrl"` // 卡密兑换地址,可为空字符串 +} + type Req struct { DeliverOrderNo string `json:"deliverOrderNo"` RequestTime int64 `json:"requestTime"` @@ -45,25 +69,3 @@ type Resp struct { StartTime string `json:"startTime"` EndTime string `json:"endTime"` } - -type NotifyReq struct { - DeliverOrderNo string `json:"deliverOrderNo"` // 平台订单号 - SupplierOrderNo string `json:"supplierOrderNo"` // 供货商订单号 - SupplierSkuId int64 `json:"supplierSkuId"` // 供货商sku - RequestTime int64 `json:"requestTime"` // 请求时间 - Account string `json:"thirdSkuId"` // 充值账号 - Status int `json:"status"` //错误码: 1-发货成功 2-发货失败 - Msg string `json:"msg"` // 错误信息 - Price int64 `json:"price"` //结算价格(单位:厘) - SupplierId int64 `json:"supplierId"` // 供货商id - CardNo string `json:"cardNo"` // 卡号,可为空字符串 - CardKey string `json:"cardKey"` // 卡密,可为空字符串 - CardExpireTime string `json:"cardExpireTime"` // 卡密过期时间,可为空字符串 - CardExchangeUrl string `json:"cardExchangeUrl"` // 卡密兑换地址,可为空字符串 - Sign string `json:"sign"` -} - -type NotifyResp struct { - Status int `json:"status"` // 错误码: 0-成功 1-失败 - Msg string `json:"msg"` // 返回信息 -}