feat: 发货通知接口调整

This commit is contained in:
wolter 2024-11-06 10:58:51 +08:00
parent 86b9079ffc
commit e5dac17d5f
7 changed files with 96 additions and 37 deletions

View File

@ -25,5 +25,9 @@ service yl {
@doc "卡密异步发放接口" @doc "卡密异步发放接口"
@handler ylAsync @handler ylAsync
post /key/asyncSend (AsyncReq) returns (AsyncResp) post /key/asyncSend (AsyncReq) returns (AsyncResp)
@doc "订单查询接口"
@handler getOrder
post /order/get (GetOrderReq) returns (GetOrderRsp)
} }

View File

@ -48,3 +48,27 @@ type AsyncResp {
Msg string `json:"msg"` // 返回信息 Msg string `json:"msg"` // 返回信息
Status int `json:"status"` // 错误码: 0-成功 1-失败 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"` // 卡密兑换地址,可为空字符串
}

View File

@ -15,7 +15,7 @@ type Config struct {
Key string Key string
} }
YouleHost string YouleHost string
SupplierSkuId map[string]string MarketConfig MarketConfig
} }
type Rpc struct { type Rpc struct {
@ -25,3 +25,9 @@ type Rpc struct {
type Nacos struct { type Nacos struct {
Endpoints []string Endpoints []string
} }
type MarketConfig struct {
AppId string
PosId string
SupplierSkuId map[string]string
}

View File

@ -29,6 +29,12 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
Path: "/key/send", Path: "/key/send",
Handler: yl.YlHandler(serverCtx), Handler: yl.YlHandler(serverCtx),
}, },
{
// 订单查询接口
Method: http.MethodPost,
Path: "/order/get",
Handler: yl.GetOrderHandler(serverCtx),
},
}..., }...,
), ),
rest.WithPrefix("/market"), rest.WithPrefix("/market"),

View File

@ -38,31 +38,26 @@ func NewYlAsyncLogic(ctx context.Context, svcCtx *svc.ServiceContext) *YlAsyncLo
func (l *YlAsyncLogic) YlAsync(req *types.AsyncReq) (resp *types.AsyncResp, err error) { func (l *YlAsyncLogic) YlAsync(req *types.AsyncReq) (resp *types.AsyncResp, err error) {
var ( var (
reqData transfer.MarketKeySendReq reqData transfer.MarketKeySendReq
extendParam types.KeySendExtendParam 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.MarketConfig.SupplierSkuId[strconv.Itoa(int(req.SupplierSkuId))]; ok {
if v, ok := l.svcCtx.Config.SupplierSkuId[strconv.Itoa(int(req.SupplierSkuId))]; ok {
VoucherId = v VoucherId = v
} else { } else {
return nil, fmt.Errorf("供货商sku 未配置") return nil, fmt.Errorf("供货商sku 未配置")
} }
reqData = transfer.MarketKeySendReq{ reqData = transfer.MarketKeySendReq{
AppId: extendParam.AppId, AppId: l.svcCtx.Config.MarketConfig.AppId,
ReqCode: "voucher.create", ReqCode: "voucher.create",
MemId: fmt.Sprintf("%d", req.SupplierId), MemId: fmt.Sprintf("%d", req.SupplierId),
ReqSerialNo: req.DeliverOrderNo, ReqSerialNo: req.DeliverOrderNo,
Timestamp: time.Unix(req.CreateTime, 0).Format("20060102150405"), Timestamp: time.Unix(req.CreateTime, 0).Format("20060102150405"),
PosId: extendParam.PosId, PosId: l.svcCtx.Config.MarketConfig.PosId,
VoucherId: VoucherId, VoucherId: VoucherId,
VoucherNum: extendParam.Num, VoucherNum: 1,
MobileNo: extendParam.MobileNo, //MobileNo: extendParam.MobileNo,
SendMsg: extendParam.SendMsg, //SendMsg: extendParam.SendMsg,
} }
if reqData.SendMsg == "" { if reqData.SendMsg == "" {
reqData.SendMsg = "2" reqData.SendMsg = "2"

View File

@ -36,3 +36,25 @@ type KeySendExtendParam struct {
MobileNo string `json:"mobileNo"` MobileNo string `json:"mobileNo"`
SendMsg string `json:"sendMsg"` 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"` // 返回信息
}

View File

@ -26,6 +26,30 @@ type AsyncResp struct {
type Empty 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 { type Req struct {
DeliverOrderNo string `json:"deliverOrderNo"` DeliverOrderNo string `json:"deliverOrderNo"`
RequestTime int64 `json:"requestTime"` RequestTime int64 `json:"requestTime"`
@ -45,25 +69,3 @@ type Resp struct {
StartTime string `json:"startTime"` StartTime string `json:"startTime"`
EndTime string `json:"endTime"` 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"` // 返回信息
}