diff --git a/cmd/api/internal/config/config.go b/cmd/api/internal/config/config.go index f159af8..14f0701 100644 --- a/cmd/api/internal/config/config.go +++ b/cmd/api/internal/config/config.go @@ -14,7 +14,8 @@ type Config struct { Url string Key string } - YouleHost string + YouleHost string + SupplierSkuId map[string]string } type Rpc struct { diff --git a/cmd/api/internal/logic/yl/ylAsyncLogic.go b/cmd/api/internal/logic/yl/ylAsyncLogic.go index 53c2e1d..1619ef4 100644 --- a/cmd/api/internal/logic/yl/ylAsyncLogic.go +++ b/cmd/api/internal/logic/yl/ylAsyncLogic.go @@ -7,6 +7,7 @@ import ( "rs/cmd/api/internal/logic/vo" "rs/rpc/transfer" "rs/untils/httpclient" + "strconv" "strings" "time" @@ -41,6 +42,13 @@ func (l *YlAsyncLogic) YlAsync(req *types.AsyncReq) (resp *types.AsyncResp, err return nil, fmt.Errorf("extendParam 格式错误") } + var VoucherId = "" + if v, ok := l.svcCtx.Config.SupplierSkuId[strconv.Itoa(int(req.SupplierSkuId))]; ok { + VoucherId = v + } else { + return nil, fmt.Errorf("供货商sku 未配置") + } + reqData = transfer.MarketKeySendReq{ AppId: extendParam.AppId, ReqCode: "voucher.create", @@ -48,7 +56,7 @@ func (l *YlAsyncLogic) YlAsync(req *types.AsyncReq) (resp *types.AsyncResp, err ReqSerialNo: req.DeliverOrderNo, Timestamp: time.Unix(req.CreateTime, 0).Format("20060102150405"), PosId: extendParam.PosId, - VoucherId: extendParam.VoucherId, + VoucherId: VoucherId, VoucherNum: extendParam.Num, MobileNo: extendParam.MobileNo, SendMsg: extendParam.SendMsg, @@ -56,6 +64,7 @@ func (l *YlAsyncLogic) YlAsync(req *types.AsyncReq) (resp *types.AsyncResp, err if reqData.SendMsg == "" { reqData.SendMsg = "2" } + reqData.Sign = l.svcCtx.Config.Sys.PrimaryKey result, err := l.svcCtx.TransferRpc.MarketKeySend(l.ctx, &reqData) if err != nil { diff --git a/cmd/api/internal/types/extraTypes.go b/cmd/api/internal/types/extraTypes.go index 2cc7102..44d921c 100644 --- a/cmd/api/internal/types/extraTypes.go +++ b/cmd/api/internal/types/extraTypes.go @@ -30,10 +30,9 @@ type NotifyTypes struct { } type KeySendExtendParam struct { - AppId string `json:"appId"` - PosId string `json:"posId"` - Num int64 `json:"num"` - MobileNo string `json:"mobileNo"` - SendMsg string `json:"sendMsg"` - VoucherId string `json:"voucherId"` + AppId string `json:"appId"` + PosId string `json:"posId"` + Num int64 `json:"num"` + MobileNo string `json:"mobileNo"` + SendMsg string `json:"sendMsg"` }