构建镜像
This commit is contained in:
parent
a7664d5ed2
commit
6922b04f70
2
Makefile
2
Makefile
|
@ -24,7 +24,7 @@ apigen:
|
||||||
.PHONY: rpcgen
|
.PHONY: rpcgen
|
||||||
# 根据protoc创建rpc文件
|
# 根据protoc创建rpc文件
|
||||||
rpcgen:
|
rpcgen:
|
||||||
cd cmd/rpc/pb && goctl rpc protoc *.proto --go_out=../pb --go-grpc_out=../pb --zrpc_out=../ --client=false --style=goZero
|
cd cmd/rpc/pb && goctl rpc protoc transfer.proto --go_out=../pb --go-grpc_out=../pb --zrpc_out=../ --client=false --style=goZero
|
||||||
|
|
||||||
.PHONY: apiinitrpc
|
.PHONY: apiinitrpc
|
||||||
# api端生成rpc
|
# api端生成rpc
|
||||||
|
|
|
@ -26,9 +26,10 @@ type RockerMqConfig struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type TopicList struct {
|
type TopicList struct {
|
||||||
Market TopicConfig
|
Market TopicConfig
|
||||||
ZLTX TopicConfig
|
ZLTX TopicConfig
|
||||||
RS TopicConfig
|
RS TopicConfig
|
||||||
|
NewMarket TopicConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
type TopicConfig struct {
|
type TopicConfig struct {
|
||||||
|
|
|
@ -5,6 +5,7 @@ import (
|
||||||
"github.com/zeromicro/go-zero/zrpc"
|
"github.com/zeromicro/go-zero/zrpc"
|
||||||
"trasfer_middleware/cmd/rpc/etc"
|
"trasfer_middleware/cmd/rpc/etc"
|
||||||
marketTypes "trasfer_middleware/cmd/rpc/internal/logic/po/market/types"
|
marketTypes "trasfer_middleware/cmd/rpc/internal/logic/po/market/types"
|
||||||
|
newMarketTypes "trasfer_middleware/cmd/rpc/internal/logic/po/new_market/types"
|
||||||
rsTypes "trasfer_middleware/cmd/rpc/internal/logic/po/rs/types"
|
rsTypes "trasfer_middleware/cmd/rpc/internal/logic/po/rs/types"
|
||||||
zltxTypes "trasfer_middleware/cmd/rpc/internal/logic/po/zltx/types"
|
zltxTypes "trasfer_middleware/cmd/rpc/internal/logic/po/zltx/types"
|
||||||
)
|
)
|
||||||
|
@ -12,11 +13,12 @@ import (
|
||||||
type Config struct {
|
type Config struct {
|
||||||
zrpc.RpcServerConf
|
zrpc.RpcServerConf
|
||||||
etc.ExtraConfig
|
etc.ExtraConfig
|
||||||
Cache cache.CacheConf
|
Cache cache.CacheConf
|
||||||
ZLTX zltxTypes.ZLTXConf
|
ZLTX zltxTypes.ZLTXConf
|
||||||
Market marketTypes.MarketConf
|
Market marketTypes.MarketConf
|
||||||
RS rsTypes.RSConf
|
RS rsTypes.RSConf
|
||||||
DB struct {
|
NewMarket newMarketTypes.NewMarketConf
|
||||||
|
DB struct {
|
||||||
Master struct {
|
Master struct {
|
||||||
DataSource string
|
DataSource string
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,9 @@ func MarketKeyDataSet(order *genModel.ServerOrderMarket, resq string, resp strin
|
||||||
orderInfoRes map[string]interface{}
|
orderInfoRes map[string]interface{}
|
||||||
)
|
)
|
||||||
err = json.Unmarshal([]byte(resp), &orderInfoRes)
|
err = json.Unmarshal([]byte(resp), &orderInfoRes)
|
||||||
|
if _, ok := orderInfoRes["errCode"]; !ok {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
if orderInfoRes["errCode"].(string) != vo.MARKET_SUCCESS {
|
if orderInfoRes["errCode"].(string) != vo.MARKET_SUCCESS {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
package logic
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"trasfer_middleware/cmd/rpc/internal/svc"
|
||||||
|
"trasfer_middleware/cmd/rpc/pb/transfer"
|
||||||
|
|
||||||
|
"github.com/zeromicro/go-zero/core/logx"
|
||||||
|
)
|
||||||
|
|
||||||
|
type NewMarketDiscardLogic struct {
|
||||||
|
ctx context.Context
|
||||||
|
svcCtx *svc.ServiceContext
|
||||||
|
logx.Logger
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewNewMarketDiscardLogic(ctx context.Context, svcCtx *svc.ServiceContext) *NewMarketDiscardLogic {
|
||||||
|
return &NewMarketDiscardLogic{
|
||||||
|
ctx: ctx,
|
||||||
|
svcCtx: svcCtx,
|
||||||
|
Logger: logx.WithContext(ctx),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l *NewMarketDiscardLogic) NewMarketDiscard(in *transfer.NewMarketDiscardReq) (*transfer.NewMarketDiscardRes, error) {
|
||||||
|
res, err := l.svcCtx.NewMarket.Discard(l.ctx, in)
|
||||||
|
return res, err
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
package logic
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"trasfer_middleware/cmd/rpc/internal/svc"
|
||||||
|
"trasfer_middleware/cmd/rpc/pb/transfer"
|
||||||
|
|
||||||
|
"github.com/zeromicro/go-zero/core/logx"
|
||||||
|
)
|
||||||
|
|
||||||
|
type NewMarketOrderLogic struct {
|
||||||
|
ctx context.Context
|
||||||
|
svcCtx *svc.ServiceContext
|
||||||
|
logx.Logger
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewNewMarketOrderLogic(ctx context.Context, svcCtx *svc.ServiceContext) *NewMarketOrderLogic {
|
||||||
|
return &NewMarketOrderLogic{
|
||||||
|
ctx: ctx,
|
||||||
|
svcCtx: svcCtx,
|
||||||
|
Logger: logx.WithContext(ctx),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l *NewMarketOrderLogic) NewMarketOrder(in *transfer.NewMarketOrderReq) (*transfer.NewMarketOrderRes, error) {
|
||||||
|
res, err := l.svcCtx.NewMarket.Order(l.ctx, in)
|
||||||
|
|
||||||
|
return res, err
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
package logic
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"trasfer_middleware/cmd/rpc/internal/svc"
|
||||||
|
"trasfer_middleware/cmd/rpc/pb/transfer"
|
||||||
|
|
||||||
|
"github.com/zeromicro/go-zero/core/logx"
|
||||||
|
)
|
||||||
|
|
||||||
|
type NewMarketQueryLogics struct {
|
||||||
|
ctx context.Context
|
||||||
|
svcCtx *svc.ServiceContext
|
||||||
|
logx.Logger
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewNewMarketQueryLogic(ctx context.Context, svcCtx *svc.ServiceContext) *NewMarketQueryLogics {
|
||||||
|
return &NewMarketQueryLogics{
|
||||||
|
ctx: ctx,
|
||||||
|
svcCtx: svcCtx,
|
||||||
|
Logger: logx.WithContext(ctx),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l *NewMarketQueryLogics) NewMarketQuery(in *transfer.NewMarketQueryReq) (*transfer.NewMarketOrderRes, error) {
|
||||||
|
res, err := l.svcCtx.NewMarket.Query(l.ctx, in)
|
||||||
|
return res, err
|
||||||
|
}
|
|
@ -33,12 +33,12 @@ func NewMarket(conf types.MarketConf) *Market {
|
||||||
|
|
||||||
func (r *Market) SetData(c context.Context, data map[string]interface{}, config *etc.RockerMqConfig) *MarketRequest {
|
func (r *Market) SetData(c context.Context, data map[string]interface{}, config *etc.RockerMqConfig) *MarketRequest {
|
||||||
p := "-----BEGIN RSA PRIVATE KEY-----\n" + data["sign"].(string) + "\n-----END RSA PRIVATE KEY-----"
|
p := "-----BEGIN RSA PRIVATE KEY-----\n" + data["sign"].(string) + "\n-----END RSA PRIVATE KEY-----"
|
||||||
|
|
||||||
sign, err := common.MarketMakeRsaSign(p, data)
|
sign, err := common.MarketMakeRsaSign(p, data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
data["sign"] = sign
|
data["sign"] = sign
|
||||||
|
|
||||||
requestBody := make(map[string]string, len(data))
|
requestBody := make(map[string]string, len(data))
|
||||||
for key, value := range data {
|
for key, value := range data {
|
||||||
requestBody[key] = fmt.Sprintf("%v", value)
|
requestBody[key] = fmt.Sprintf("%v", value)
|
||||||
|
@ -69,7 +69,7 @@ func (r *MarketRequest) request(url string) (*request.Response, error) {
|
||||||
SecurityToken: r.Config.SecurityToken,
|
SecurityToken: r.Config.SecurityToken,
|
||||||
ServerAddress: r.Config.Host,
|
ServerAddress: r.Config.Host,
|
||||||
}
|
}
|
||||||
err := sendMq.Produce(r.ctx, r.Config.TopicPrefix+r.Config.Topic.Market.Name, po.SetMqSendDataMarket(r.RequestStruct, &resp, url))
|
err := sendMq.Produce(r.ctx, r.Config.TopicPrefix+r.Config.Topic.Market.Name, po.SetMqSendDataMarket(r.RequestStruct, &resp, reqUrl))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
sysLog.LogSendMq(r.ctx, err)
|
sysLog.LogSendMq(r.ctx, err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,137 @@
|
||||||
|
package new_market
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"github.com/mitchellh/mapstructure"
|
||||||
|
"github.com/sleepinggodoflove/lansexiongdi-marketing-sdk/api/v1/key"
|
||||||
|
"github.com/sleepinggodoflove/lansexiongdi-marketing-sdk/core"
|
||||||
|
"trasfer_middleware/cmd/rpc/etc"
|
||||||
|
|
||||||
|
"trasfer_middleware/cmd/rpc/internal/logic/po"
|
||||||
|
"trasfer_middleware/cmd/rpc/internal/logic/po/new_market/types"
|
||||||
|
"trasfer_middleware/cmd/rpc/internal/logic/vo"
|
||||||
|
"trasfer_middleware/cmd/rpc/pb/transfer"
|
||||||
|
"trasfer_middleware/cmd/rpc/pkg/mq"
|
||||||
|
"trasfer_middleware/until/common"
|
||||||
|
"trasfer_middleware/until/sysLog"
|
||||||
|
)
|
||||||
|
|
||||||
|
type NewMarketStruct struct {
|
||||||
|
Conf *types.NewMarketConf
|
||||||
|
AppId string
|
||||||
|
CoreConfig *core.Config
|
||||||
|
*po.RequestStruct
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewNewMarket(conf types.NewMarketConf, mq etc.RockerMqConfig) *NewMarketStruct {
|
||||||
|
return &NewMarketStruct{
|
||||||
|
Conf: &conf,
|
||||||
|
CoreConfig: &core.Config{
|
||||||
|
PrivateKey: conf.PRK,
|
||||||
|
PublicKey: conf.PUK,
|
||||||
|
Key: conf.KEY,
|
||||||
|
BaseURL: conf.Host,
|
||||||
|
},
|
||||||
|
RequestStruct: &po.RequestStruct{
|
||||||
|
Config: mq,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *NewMarketStruct) handleLog(ctx context.Context, url string, resp *key.Response, in interface{}) error {
|
||||||
|
r.SetRequestStruct(in)
|
||||||
|
err := r.sendMq(ctx, url, resp)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *NewMarketStruct) Order(ctx context.Context, request *transfer.NewMarketOrderReq) (res *transfer.NewMarketOrderRes, err error) {
|
||||||
|
|
||||||
|
coreKey, err := r.coreKey(request.AppId)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
response, err := coreKey.Order(ctx, &key.OrderRequest{
|
||||||
|
OutBizNo: request.OutBizNo,
|
||||||
|
ActivityNo: request.ActivityNo,
|
||||||
|
Number: request.Number,
|
||||||
|
})
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
_ = mapstructure.Decode(response, &res)
|
||||||
|
|
||||||
|
r.handleLog(ctx, vo.NEW_MARKET_ORDER, response, request)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *NewMarketStruct) Query(ctx context.Context, request *transfer.NewMarketQueryReq) (res *transfer.NewMarketOrderRes, err error) {
|
||||||
|
coreKey, err := r.coreKey(request.AppId)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
response, err := coreKey.Query(ctx, &key.QueryRequest{
|
||||||
|
OutBizNo: request.OutBizNo,
|
||||||
|
TradeNo: request.TradeNo,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
_ = mapstructure.Decode(response, &res)
|
||||||
|
r.handleLog(ctx, vo.NEW_MARKET_ORDER, response, request)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *NewMarketStruct) Discard(ctx context.Context, request *transfer.NewMarketDiscardReq) (res *transfer.NewMarketDiscardRes, err error) {
|
||||||
|
coreKey, err := r.coreKey(request.AppId)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
response, err := coreKey.Discard(ctx, &key.DiscardRequest{
|
||||||
|
OutBizNo: request.OutBizNo,
|
||||||
|
TradeNo: request.TradeNo,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
_ = mapstructure.Decode(response, &res)
|
||||||
|
r.handleLog(ctx, vo.NEW_MARKET_DISCARD, response, request)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *NewMarketStruct) coreKey(appId string) (*key.Key, error) {
|
||||||
|
r.CoreConfig.AppID = appId
|
||||||
|
coreData, err := core.NewCore(r.CoreConfig)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &key.Key{Core: coreData}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *NewMarketStruct) sendMq(ctx context.Context, url string, resp *key.Response) error {
|
||||||
|
//异步存入请求记录
|
||||||
|
sendMq := mq.AliyunRocketMq{
|
||||||
|
AccessKey: r.Config.AccessKey,
|
||||||
|
SecretKey: r.Config.SecretKey,
|
||||||
|
SecurityToken: r.Config.SecurityToken,
|
||||||
|
ServerAddress: r.Config.Host,
|
||||||
|
}
|
||||||
|
err := sendMq.Produce(ctx, r.Config.TopicPrefix+r.Config.Topic.NewMarket.Name, po.SetMqSendDataNewMarket(r.RequestStruct, resp, url))
|
||||||
|
if err != nil {
|
||||||
|
sysLog.LogSendMq(ctx, err)
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *NewMarketStruct) SetRequestStruct(in interface{}) {
|
||||||
|
data := common.StructToMap(in)
|
||||||
|
requestBody := make(map[string]string, len(data))
|
||||||
|
for key, value := range data {
|
||||||
|
requestBody[key] = fmt.Sprintf("%v", value)
|
||||||
|
}
|
||||||
|
r.RequestStruct.RequestBody = requestBody
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
package types
|
||||||
|
|
||||||
|
type PublicRecharge struct {
|
||||||
|
MerchantId int
|
||||||
|
TimeStamp int
|
||||||
|
Sign string
|
||||||
|
}
|
||||||
|
|
||||||
|
type ExtendParameter struct {
|
||||||
|
ExtendParameter string
|
||||||
|
}
|
||||||
|
|
||||||
|
type NewMarketConf struct {
|
||||||
|
Host string
|
||||||
|
SignType string
|
||||||
|
PUK string
|
||||||
|
PRK string
|
||||||
|
KEY string
|
||||||
|
}
|
||||||
|
|
||||||
|
type BaseRes struct {
|
||||||
|
Code string `json:"code"`
|
||||||
|
Message string `json:"message"`
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
package types
|
||||||
|
|
||||||
|
type CardParam struct {
|
||||||
|
OutTradeNo string
|
||||||
|
ProductId int
|
||||||
|
Mobile string
|
||||||
|
AccountType int
|
||||||
|
Number int
|
||||||
|
NotifyUrl string
|
||||||
|
}
|
||||||
|
|
||||||
|
type CardRes struct {
|
||||||
|
Code string `json:"code"`
|
||||||
|
Message string `json:"message"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type CardQueryRes struct {
|
||||||
|
Code string `json:"code"`
|
||||||
|
Message string `json:"message"`
|
||||||
|
Status string `json:"status"`
|
||||||
|
OutTradeNo string `json:"outTradeNo"`
|
||||||
|
CardCode string `json:"cardCode"`
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
package types
|
||||||
|
|
||||||
|
type OrderSmsParam struct {
|
||||||
|
OutTradeNo string
|
||||||
|
}
|
||||||
|
|
||||||
|
type OrderSmsRes struct {
|
||||||
|
Code string `json:"code"`
|
||||||
|
Message string `json:"message"`
|
||||||
|
Status string `json:"status"`
|
||||||
|
OutTradeNo string `json:"outTradeNo"`
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
package types
|
||||||
|
|
||||||
|
type RechargeParam struct {
|
||||||
|
OutTradeNo string
|
||||||
|
ProductId int
|
||||||
|
RechargeAccount string
|
||||||
|
AccountType int
|
||||||
|
Number int
|
||||||
|
NotifyUrl string
|
||||||
|
}
|
||||||
|
|
||||||
|
type RechargeQueryRes struct {
|
||||||
|
Code string `json:"code"`
|
||||||
|
Message string `json:"message"`
|
||||||
|
Status string `json:"status"`
|
||||||
|
OutTradeNo string `json:"outTradeNo"`
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
package types
|
||||||
|
|
||||||
|
type RechargeInfoParam struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
type RechargeInfoRes struct {
|
||||||
|
Code string `json:"code"`
|
||||||
|
Balance string `json:"balance"`
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
package types
|
||||||
|
|
||||||
|
type RechargeProductParam struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
type RechargeProductRes struct {
|
||||||
|
Code string `json:"code"`
|
||||||
|
Products []RechargeProduct `json:"products"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type RechargeProduct struct {
|
||||||
|
ProductId int `json:"product_id"`
|
||||||
|
ChannelPrice string `json:"channel_price"`
|
||||||
|
ItemName string `json:"item_name"`
|
||||||
|
OriginalPrice string `json:"original_price"`
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
package types
|
||||||
|
|
||||||
|
type RsReq struct {
|
||||||
|
VendorNo string `json:"vendorNo"`
|
||||||
|
Data string `json:"data"`
|
||||||
|
Sign string `son:"sign"`
|
||||||
|
}
|
||||||
|
type RSConf struct {
|
||||||
|
Host string
|
||||||
|
}
|
|
@ -2,6 +2,7 @@ package po
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"github.com/sleepinggodoflove/lansexiongdi-marketing-sdk/api/v1/key"
|
||||||
"time"
|
"time"
|
||||||
"trasfer_middleware/cmd/rpc/etc"
|
"trasfer_middleware/cmd/rpc/etc"
|
||||||
"trasfer_middleware/genModel"
|
"trasfer_middleware/genModel"
|
||||||
|
@ -26,6 +27,17 @@ func SetMqSendDataZLTX(reqInfo *RequestStruct, respInfo *request.Response, url s
|
||||||
return logByte
|
return logByte
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func SetMqSendDataNewMarket(reqInfo *RequestStruct, respInfo *key.Response, url string) []byte {
|
||||||
|
|
||||||
|
resp, _ := json.Marshal(respInfo)
|
||||||
|
log := commonMqSendData(reqInfo, &request.Response{
|
||||||
|
Text: string(resp),
|
||||||
|
StatusCode: int(respInfo.Code),
|
||||||
|
}, url)
|
||||||
|
logByte, _ := json.Marshal(log)
|
||||||
|
return logByte
|
||||||
|
}
|
||||||
|
|
||||||
func SetMqSendDataRs(rsReq *RequestStruct, order *genModel.ServerOrderRs, respInfo *request.Response, url string) []byte {
|
func SetMqSendDataRs(rsReq *RequestStruct, order *genModel.ServerOrderRs, respInfo *request.Response, url string) []byte {
|
||||||
log := commonMqSendData(rsReq, respInfo, url)
|
log := commonMqSendData(rsReq, respInfo, url)
|
||||||
OrderMap := common.StructToMap(order)
|
OrderMap := common.StructToMap(order)
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
package vo
|
||||||
|
|
||||||
|
const (
|
||||||
|
// 下单
|
||||||
|
NEW_MARKET_ORDER = "openapi/v1/key/order"
|
||||||
|
|
||||||
|
// 查询
|
||||||
|
NEW_MARKET_QUERY = "openapi/v1/key/query"
|
||||||
|
|
||||||
|
// 作废
|
||||||
|
NEW_MARKET_DISCARD = "openapi/v1/key/discard"
|
||||||
|
)
|
|
@ -31,6 +31,11 @@ type RS struct {
|
||||||
ctx context.Context
|
ctx context.Context
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type NewMarkets struct {
|
||||||
|
svc *mqSvc.ServiceContext
|
||||||
|
ctx context.Context
|
||||||
|
}
|
||||||
|
|
||||||
func NewMarket(svc *mqSvc.ServiceContext, ctx context.Context) *Market {
|
func NewMarket(svc *mqSvc.ServiceContext, ctx context.Context) *Market {
|
||||||
return &Market{
|
return &Market{
|
||||||
svc: svc,
|
svc: svc,
|
||||||
|
@ -52,9 +57,16 @@ func NewRS(svc *mqSvc.ServiceContext, ctx context.Context) *RS {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func NewNewMarkets(svc *mqSvc.ServiceContext, ctx context.Context) *NewMarkets {
|
||||||
|
return &NewMarkets{
|
||||||
|
svc: svc,
|
||||||
|
ctx: ctx,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (m *Market) MessageHandler(tag uint64, ch *amqp.Channel, msg []byte) error {
|
func (m *Market) MessageHandler(tag uint64, ch *amqp.Channel, msg []byte) error {
|
||||||
var market = &genModel.ServerMiddleMarketLogs{}
|
var market = &genModel.ServerMiddleMarketLogs{}
|
||||||
json.Unmarshal(msg, market)
|
err := json.Unmarshal(msg, market)
|
||||||
market.CreateTime = time.Now()
|
market.CreateTime = time.Now()
|
||||||
market.Status = vo.MARKET_LOG_STATU_DEFAULT
|
market.Status = vo.MARKET_LOG_STATU_DEFAULT
|
||||||
logInfo, err := m.svc.DbWrite.MarketLogs.Insert(m.ctx, market)
|
logInfo, err := m.svc.DbWrite.MarketLogs.Insert(m.ctx, market)
|
||||||
|
@ -175,6 +187,49 @@ func (m *RS) saveRsOrder(logId int64, resq string, resp string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *NewMarkets) MessageHandler(tag uint64, ch *amqp.Channel, msg []byte) error {
|
||||||
|
var (
|
||||||
|
rs = &genModel.ServerMiddleRsLogs{}
|
||||||
|
)
|
||||||
|
json.Unmarshal(msg, rs)
|
||||||
|
rs.CreateTime = time.Now()
|
||||||
|
rs.Status = vo.RS_LOG_STATU_DEFAULT
|
||||||
|
logInfo, err := m.svc.DbWrite.RSLogs.Insert(m.ctx, rs)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("rs数据保存失败:%s,原因:%s", msg, err)
|
||||||
|
}
|
||||||
|
logId, err := logInfo.LastInsertId()
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("rs日志数据保存失败:%s,原因:%s", msg, err)
|
||||||
|
}
|
||||||
|
err = m.saveRsOrder(logId, rs.Data, rs.Resp)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("rs订单数据保存失败:%s,原因:%s", msg, err)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *NewMarkets) saveRsOrder(logId int64, resq string, resp string) error {
|
||||||
|
var order = &genModel.ServerOrderRs{}
|
||||||
|
|
||||||
|
order.LogId = logId
|
||||||
|
order.ReqTime = time.Now()
|
||||||
|
order.CreateTime = time.Now()
|
||||||
|
data := do.RsData{Order: order}
|
||||||
|
err := data.SetData(resq, resp)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_, err = m.svc.DbWrite.OrderRs.FindByOutBizId(m.ctx, order.OutBizNo)
|
||||||
|
if err == sqlx.ErrNotFound {
|
||||||
|
_, err = m.svc.DbWrite.OrderRs.Insert(m.ctx, order)
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (m *Market) saveMarketOrder(logId int64, resq string, resp string) error {
|
func (m *Market) saveMarketOrder(logId int64, resq string, resp string) error {
|
||||||
var order = &genModel.ServerOrderMarket{}
|
var order = &genModel.ServerOrderMarket{}
|
||||||
|
|
||||||
|
@ -205,5 +260,6 @@ func AllHandle(c *etc.RockerMqConfig, svc *mqSvc.ServiceContext, ctx context.Con
|
||||||
result[c.TopicPrefix+c.Topic.Market.Name] = NewMarket(svc, ctx)
|
result[c.TopicPrefix+c.Topic.Market.Name] = NewMarket(svc, ctx)
|
||||||
result[c.TopicPrefix+c.Topic.ZLTX.Name] = NewZLTX(svc, ctx)
|
result[c.TopicPrefix+c.Topic.ZLTX.Name] = NewZLTX(svc, ctx)
|
||||||
result[c.TopicPrefix+c.Topic.RS.Name] = NewRS(svc, ctx)
|
result[c.TopicPrefix+c.Topic.RS.Name] = NewRS(svc, ctx)
|
||||||
|
result[c.TopicPrefix+c.Topic.NewMarket.Name] = NewNewMarkets(svc, ctx)
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,3 +81,18 @@ func (s *TransferServer) RsCouponGrant(ctx context.Context, in *transfer.RsCoupo
|
||||||
l := logic.NewRsCouponGrantLogic(ctx, s.svcCtx)
|
l := logic.NewRsCouponGrantLogic(ctx, s.svcCtx)
|
||||||
return l.RsCouponGrant(in)
|
return l.RsCouponGrant(in)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *TransferServer) NewMarketOrder(ctx context.Context, in *transfer.NewMarketOrderReq) (*transfer.NewMarketOrderRes, error) {
|
||||||
|
l := logic.NewNewMarketOrderLogic(ctx, s.svcCtx)
|
||||||
|
return l.NewMarketOrder(in)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *TransferServer) NewMarketQuery(ctx context.Context, in *transfer.NewMarketQueryReq) (*transfer.NewMarketOrderRes, error) {
|
||||||
|
l := logic.NewNewMarketQueryLogic(ctx, s.svcCtx)
|
||||||
|
return l.NewMarketQuery(in)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *TransferServer) NewMarketDiscard(ctx context.Context, in *transfer.NewMarketDiscardReq) (*transfer.NewMarketDiscardRes, error) {
|
||||||
|
l := logic.NewNewMarketDiscardLogic(ctx, s.svcCtx)
|
||||||
|
return l.NewMarketDiscard(in)
|
||||||
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"github.com/zeromicro/go-zero/core/stores/redis"
|
"github.com/zeromicro/go-zero/core/stores/redis"
|
||||||
"trasfer_middleware/cmd/rpc/internal/config"
|
"trasfer_middleware/cmd/rpc/internal/config"
|
||||||
"trasfer_middleware/cmd/rpc/internal/logic/po/market"
|
"trasfer_middleware/cmd/rpc/internal/logic/po/market"
|
||||||
|
"trasfer_middleware/cmd/rpc/internal/logic/po/new_market"
|
||||||
"trasfer_middleware/cmd/rpc/internal/logic/po/rs"
|
"trasfer_middleware/cmd/rpc/internal/logic/po/rs"
|
||||||
"trasfer_middleware/cmd/rpc/internal/logic/po/zltx"
|
"trasfer_middleware/cmd/rpc/internal/logic/po/zltx"
|
||||||
)
|
)
|
||||||
|
@ -14,6 +15,7 @@ type ServiceContext struct {
|
||||||
ZltxOrder *zltx.ZltxOrder
|
ZltxOrder *zltx.ZltxOrder
|
||||||
Market *market.Market
|
Market *market.Market
|
||||||
RS *rs.RS
|
RS *rs.RS
|
||||||
|
NewMarket *new_market.NewMarketStruct
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewServiceContext(c config.Config) *ServiceContext {
|
func NewServiceContext(c config.Config) *ServiceContext {
|
||||||
|
@ -28,18 +30,6 @@ func NewServiceContext(c config.Config) *ServiceContext {
|
||||||
ZltxOrder: zltx.NewZltxOrder(c.ZLTX),
|
ZltxOrder: zltx.NewZltxOrder(c.ZLTX),
|
||||||
Market: market.NewMarket(c.Market),
|
Market: market.NewMarket(c.Market),
|
||||||
RS: rs.NewRs(c.RS),
|
RS: rs.NewRs(c.RS),
|
||||||
|
NewMarket: new_market.NewNewMarket(c.NewMarket, c.Mq),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*func DbModel(datasource string, c config.Config) *Model {
|
|
||||||
sqlConn := sqlx.NewMysql(datasource)
|
|
||||||
return &Model{
|
|
||||||
MarketLogs: genModel.NewServerMiddleMarketLogsModel(sqlConn, c.Cache),
|
|
||||||
ZLTXLogs: genModel.NewServerMiddleZltxLogsModel(sqlConn, c.Cache),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
type Model struct {
|
|
||||||
MarketLogs genModel.ServerMiddleMarketLogsModel
|
|
||||||
ZLTXLogs genModel.ServerMiddleZltxLogsModel
|
|
||||||
}*/
|
|
||||||
|
|
|
@ -33,8 +33,57 @@ service Transfer {
|
||||||
rpc marketQuery(MarketQueryReq) returns(MarketQueryRes);
|
rpc marketQuery(MarketQueryReq) returns(MarketQueryRes);
|
||||||
|
|
||||||
rpc rsCouponGrant(RsCouponGrantReq) returns(RsCouponGrantRes);
|
rpc rsCouponGrant(RsCouponGrantReq) returns(RsCouponGrantRes);
|
||||||
|
|
||||||
|
rpc newMarketOrder(NewMarketOrderReq) returns(NewMarketOrderRes);
|
||||||
|
rpc newMarketQuery(NewMarketQueryReq) returns(NewMarketOrderRes);
|
||||||
|
rpc newMarketDiscard(NewMarketDiscardReq) returns(NewMarketDiscardRes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message NewMarketDiscardReq {
|
||||||
|
string app_id = 1;
|
||||||
|
string out_biz_no = 2;
|
||||||
|
string trade_no = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
message NewMarketDiscardRes {
|
||||||
|
int32 code = 1;
|
||||||
|
string message = 2;
|
||||||
|
string reason=4;
|
||||||
|
}
|
||||||
|
|
||||||
|
message NewMarketQueryReq {
|
||||||
|
string app_id = 1;
|
||||||
|
string out_biz_no = 2;
|
||||||
|
string trade_no = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
message NewMarketOrderReq {
|
||||||
|
string app_id = 4;
|
||||||
|
string out_biz_no = 1;
|
||||||
|
string activity_no = 2;
|
||||||
|
int32 number = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
message NewMarketOrderRes {
|
||||||
|
string message = 2;
|
||||||
|
int32 code = 1;
|
||||||
|
string reason=4;
|
||||||
|
Data data = 5;
|
||||||
|
message Data {
|
||||||
|
string out_biz_no = 1;
|
||||||
|
string trade_no = 2;
|
||||||
|
string key = 3;
|
||||||
|
int32 status = 4;
|
||||||
|
string url = 5;
|
||||||
|
string valid_begin_time = 6;
|
||||||
|
string valid_end_time = 7;
|
||||||
|
string usage_time = 8;
|
||||||
|
string discard_time = 9;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
message RsCouponGrantReq {
|
message RsCouponGrantReq {
|
||||||
string vendorNo = 1;
|
string vendorNo = 1;
|
||||||
string data = 2;
|
string data = 2;
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,516 +0,0 @@
|
||||||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
|
||||||
// versions:
|
|
||||||
// - protoc-gen-go-grpc v1.3.0
|
|
||||||
// - protoc v3.6.1
|
|
||||||
// source: transfer.proto
|
|
||||||
|
|
||||||
package transfer
|
|
||||||
|
|
||||||
import (
|
|
||||||
context "context"
|
|
||||||
grpc "google.golang.org/grpc"
|
|
||||||
codes "google.golang.org/grpc/codes"
|
|
||||||
status "google.golang.org/grpc/status"
|
|
||||||
)
|
|
||||||
|
|
||||||
// This is a compile-time assertion to ensure that this generated file
|
|
||||||
// is compatible with the grpc package it is being compiled against.
|
|
||||||
// Requires gRPC-Go v1.32.0 or later.
|
|
||||||
const _ = grpc.SupportPackageIsVersion7
|
|
||||||
|
|
||||||
const (
|
|
||||||
Transfer_ZltxOrderRecharge_FullMethodName = "/transfer.Transfer/zltxOrderRecharge"
|
|
||||||
Transfer_ZltxOrderRechargeQuery_FullMethodName = "/transfer.Transfer/zltxOrderRechargeQuery"
|
|
||||||
Transfer_ZltxOrderCard_FullMethodName = "/transfer.Transfer/zltxOrderCard"
|
|
||||||
Transfer_ZltxOrderCardQuery_FullMethodName = "/transfer.Transfer/zltxOrderCardQuery"
|
|
||||||
Transfer_ZltxOrderSms_FullMethodName = "/transfer.Transfer/zltxOrderSms"
|
|
||||||
Transfer_ZltxRechargeInfo_FullMethodName = "/transfer.Transfer/zltxRechargeInfo"
|
|
||||||
Transfer_ZltxRechargeProduct_FullMethodName = "/transfer.Transfer/zltxRechargeProduct"
|
|
||||||
Transfer_ZltxRsMiXue_FullMethodName = "/transfer.Transfer/zltxRsMiXue"
|
|
||||||
Transfer_MarketKeySend_FullMethodName = "/transfer.Transfer/marketKeySend"
|
|
||||||
Transfer_MarketKeyDiscard_FullMethodName = "/transfer.Transfer/marketKeyDiscard"
|
|
||||||
Transfer_MarketQuery_FullMethodName = "/transfer.Transfer/marketQuery"
|
|
||||||
Transfer_RsCouponGrant_FullMethodName = "/transfer.Transfer/rsCouponGrant"
|
|
||||||
)
|
|
||||||
|
|
||||||
// TransferClient is the client API for Transfer service.
|
|
||||||
//
|
|
||||||
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
|
|
||||||
type TransferClient interface {
|
|
||||||
ZltxOrderRecharge(ctx context.Context, in *ZltxOrderRechargeReq, opts ...grpc.CallOption) (*DefaultRes, error)
|
|
||||||
ZltxOrderRechargeQuery(ctx context.Context, in *ZltxOrderRechargeQueryReq, opts ...grpc.CallOption) (*ZltxOrderRechargeQueryRes, error)
|
|
||||||
ZltxOrderCard(ctx context.Context, in *ZltxOrderCardReq, opts ...grpc.CallOption) (*DefaultRes, error)
|
|
||||||
ZltxOrderCardQuery(ctx context.Context, in *ZltxOrderCardQueryReq, opts ...grpc.CallOption) (*ZltxOrderCardQueryRes, error)
|
|
||||||
ZltxOrderSms(ctx context.Context, in *ZltxOrderSmsReq, opts ...grpc.CallOption) (*ZltxOrderSmsRes, error)
|
|
||||||
ZltxRechargeInfo(ctx context.Context, in *DefaultReq, opts ...grpc.CallOption) (*ZltxRechargeInfoRes, error)
|
|
||||||
ZltxRechargeProduct(ctx context.Context, in *DefaultReq, opts ...grpc.CallOption) (*ZltxRechargeProductRes, error)
|
|
||||||
ZltxRsMiXue(ctx context.Context, in *RsCouponGrantReq, opts ...grpc.CallOption) (*RsCouponGrantRes, error)
|
|
||||||
MarketKeySend(ctx context.Context, in *MarketKeySendReq, opts ...grpc.CallOption) (*MarketKeySendRes, error)
|
|
||||||
MarketKeyDiscard(ctx context.Context, in *MarketKeyDiscardReq, opts ...grpc.CallOption) (*MarketKeyDiscardRes, error)
|
|
||||||
MarketQuery(ctx context.Context, in *MarketQueryReq, opts ...grpc.CallOption) (*MarketQueryRes, error)
|
|
||||||
RsCouponGrant(ctx context.Context, in *RsCouponGrantReq, opts ...grpc.CallOption) (*RsCouponGrantRes, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
type transferClient struct {
|
|
||||||
cc grpc.ClientConnInterface
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewTransferClient(cc grpc.ClientConnInterface) TransferClient {
|
|
||||||
return &transferClient{cc}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *transferClient) ZltxOrderRecharge(ctx context.Context, in *ZltxOrderRechargeReq, opts ...grpc.CallOption) (*DefaultRes, error) {
|
|
||||||
out := new(DefaultRes)
|
|
||||||
err := c.cc.Invoke(ctx, Transfer_ZltxOrderRecharge_FullMethodName, in, out, opts...)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return out, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *transferClient) ZltxOrderRechargeQuery(ctx context.Context, in *ZltxOrderRechargeQueryReq, opts ...grpc.CallOption) (*ZltxOrderRechargeQueryRes, error) {
|
|
||||||
out := new(ZltxOrderRechargeQueryRes)
|
|
||||||
err := c.cc.Invoke(ctx, Transfer_ZltxOrderRechargeQuery_FullMethodName, in, out, opts...)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return out, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *transferClient) ZltxOrderCard(ctx context.Context, in *ZltxOrderCardReq, opts ...grpc.CallOption) (*DefaultRes, error) {
|
|
||||||
out := new(DefaultRes)
|
|
||||||
err := c.cc.Invoke(ctx, Transfer_ZltxOrderCard_FullMethodName, in, out, opts...)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return out, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *transferClient) ZltxOrderCardQuery(ctx context.Context, in *ZltxOrderCardQueryReq, opts ...grpc.CallOption) (*ZltxOrderCardQueryRes, error) {
|
|
||||||
out := new(ZltxOrderCardQueryRes)
|
|
||||||
err := c.cc.Invoke(ctx, Transfer_ZltxOrderCardQuery_FullMethodName, in, out, opts...)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return out, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *transferClient) ZltxOrderSms(ctx context.Context, in *ZltxOrderSmsReq, opts ...grpc.CallOption) (*ZltxOrderSmsRes, error) {
|
|
||||||
out := new(ZltxOrderSmsRes)
|
|
||||||
err := c.cc.Invoke(ctx, Transfer_ZltxOrderSms_FullMethodName, in, out, opts...)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return out, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *transferClient) ZltxRechargeInfo(ctx context.Context, in *DefaultReq, opts ...grpc.CallOption) (*ZltxRechargeInfoRes, error) {
|
|
||||||
out := new(ZltxRechargeInfoRes)
|
|
||||||
err := c.cc.Invoke(ctx, Transfer_ZltxRechargeInfo_FullMethodName, in, out, opts...)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return out, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *transferClient) ZltxRechargeProduct(ctx context.Context, in *DefaultReq, opts ...grpc.CallOption) (*ZltxRechargeProductRes, error) {
|
|
||||||
out := new(ZltxRechargeProductRes)
|
|
||||||
err := c.cc.Invoke(ctx, Transfer_ZltxRechargeProduct_FullMethodName, in, out, opts...)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return out, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *transferClient) ZltxRsMiXue(ctx context.Context, in *RsCouponGrantReq, opts ...grpc.CallOption) (*RsCouponGrantRes, error) {
|
|
||||||
out := new(RsCouponGrantRes)
|
|
||||||
err := c.cc.Invoke(ctx, Transfer_ZltxRsMiXue_FullMethodName, in, out, opts...)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return out, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *transferClient) MarketKeySend(ctx context.Context, in *MarketKeySendReq, opts ...grpc.CallOption) (*MarketKeySendRes, error) {
|
|
||||||
out := new(MarketKeySendRes)
|
|
||||||
err := c.cc.Invoke(ctx, Transfer_MarketKeySend_FullMethodName, in, out, opts...)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return out, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *transferClient) MarketKeyDiscard(ctx context.Context, in *MarketKeyDiscardReq, opts ...grpc.CallOption) (*MarketKeyDiscardRes, error) {
|
|
||||||
out := new(MarketKeyDiscardRes)
|
|
||||||
err := c.cc.Invoke(ctx, Transfer_MarketKeyDiscard_FullMethodName, in, out, opts...)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return out, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *transferClient) MarketQuery(ctx context.Context, in *MarketQueryReq, opts ...grpc.CallOption) (*MarketQueryRes, error) {
|
|
||||||
out := new(MarketQueryRes)
|
|
||||||
err := c.cc.Invoke(ctx, Transfer_MarketQuery_FullMethodName, in, out, opts...)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return out, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *transferClient) RsCouponGrant(ctx context.Context, in *RsCouponGrantReq, opts ...grpc.CallOption) (*RsCouponGrantRes, error) {
|
|
||||||
out := new(RsCouponGrantRes)
|
|
||||||
err := c.cc.Invoke(ctx, Transfer_RsCouponGrant_FullMethodName, in, out, opts...)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return out, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// TransferServer is the server API for Transfer service.
|
|
||||||
// All implementations must embed UnimplementedTransferServer
|
|
||||||
// for forward compatibility
|
|
||||||
type TransferServer interface {
|
|
||||||
ZltxOrderRecharge(context.Context, *ZltxOrderRechargeReq) (*DefaultRes, error)
|
|
||||||
ZltxOrderRechargeQuery(context.Context, *ZltxOrderRechargeQueryReq) (*ZltxOrderRechargeQueryRes, error)
|
|
||||||
ZltxOrderCard(context.Context, *ZltxOrderCardReq) (*DefaultRes, error)
|
|
||||||
ZltxOrderCardQuery(context.Context, *ZltxOrderCardQueryReq) (*ZltxOrderCardQueryRes, error)
|
|
||||||
ZltxOrderSms(context.Context, *ZltxOrderSmsReq) (*ZltxOrderSmsRes, error)
|
|
||||||
ZltxRechargeInfo(context.Context, *DefaultReq) (*ZltxRechargeInfoRes, error)
|
|
||||||
ZltxRechargeProduct(context.Context, *DefaultReq) (*ZltxRechargeProductRes, error)
|
|
||||||
ZltxRsMiXue(context.Context, *RsCouponGrantReq) (*RsCouponGrantRes, error)
|
|
||||||
MarketKeySend(context.Context, *MarketKeySendReq) (*MarketKeySendRes, error)
|
|
||||||
MarketKeyDiscard(context.Context, *MarketKeyDiscardReq) (*MarketKeyDiscardRes, error)
|
|
||||||
MarketQuery(context.Context, *MarketQueryReq) (*MarketQueryRes, error)
|
|
||||||
RsCouponGrant(context.Context, *RsCouponGrantReq) (*RsCouponGrantRes, error)
|
|
||||||
mustEmbedUnimplementedTransferServer()
|
|
||||||
}
|
|
||||||
|
|
||||||
// UnimplementedTransferServer must be embedded to have forward compatible implementations.
|
|
||||||
type UnimplementedTransferServer struct {
|
|
||||||
}
|
|
||||||
|
|
||||||
func (UnimplementedTransferServer) ZltxOrderRecharge(context.Context, *ZltxOrderRechargeReq) (*DefaultRes, error) {
|
|
||||||
return nil, status.Errorf(codes.Unimplemented, "method ZltxOrderRecharge not implemented")
|
|
||||||
}
|
|
||||||
func (UnimplementedTransferServer) ZltxOrderRechargeQuery(context.Context, *ZltxOrderRechargeQueryReq) (*ZltxOrderRechargeQueryRes, error) {
|
|
||||||
return nil, status.Errorf(codes.Unimplemented, "method ZltxOrderRechargeQuery not implemented")
|
|
||||||
}
|
|
||||||
func (UnimplementedTransferServer) ZltxOrderCard(context.Context, *ZltxOrderCardReq) (*DefaultRes, error) {
|
|
||||||
return nil, status.Errorf(codes.Unimplemented, "method ZltxOrderCard not implemented")
|
|
||||||
}
|
|
||||||
func (UnimplementedTransferServer) ZltxOrderCardQuery(context.Context, *ZltxOrderCardQueryReq) (*ZltxOrderCardQueryRes, error) {
|
|
||||||
return nil, status.Errorf(codes.Unimplemented, "method ZltxOrderCardQuery not implemented")
|
|
||||||
}
|
|
||||||
func (UnimplementedTransferServer) ZltxOrderSms(context.Context, *ZltxOrderSmsReq) (*ZltxOrderSmsRes, error) {
|
|
||||||
return nil, status.Errorf(codes.Unimplemented, "method ZltxOrderSms not implemented")
|
|
||||||
}
|
|
||||||
func (UnimplementedTransferServer) ZltxRechargeInfo(context.Context, *DefaultReq) (*ZltxRechargeInfoRes, error) {
|
|
||||||
return nil, status.Errorf(codes.Unimplemented, "method ZltxRechargeInfo not implemented")
|
|
||||||
}
|
|
||||||
func (UnimplementedTransferServer) ZltxRechargeProduct(context.Context, *DefaultReq) (*ZltxRechargeProductRes, error) {
|
|
||||||
return nil, status.Errorf(codes.Unimplemented, "method ZltxRechargeProduct not implemented")
|
|
||||||
}
|
|
||||||
func (UnimplementedTransferServer) ZltxRsMiXue(context.Context, *RsCouponGrantReq) (*RsCouponGrantRes, error) {
|
|
||||||
return nil, status.Errorf(codes.Unimplemented, "method ZltxRsMiXue not implemented")
|
|
||||||
}
|
|
||||||
func (UnimplementedTransferServer) MarketKeySend(context.Context, *MarketKeySendReq) (*MarketKeySendRes, error) {
|
|
||||||
return nil, status.Errorf(codes.Unimplemented, "method MarketKeySend not implemented")
|
|
||||||
}
|
|
||||||
func (UnimplementedTransferServer) MarketKeyDiscard(context.Context, *MarketKeyDiscardReq) (*MarketKeyDiscardRes, error) {
|
|
||||||
return nil, status.Errorf(codes.Unimplemented, "method MarketKeyDiscard not implemented")
|
|
||||||
}
|
|
||||||
func (UnimplementedTransferServer) MarketQuery(context.Context, *MarketQueryReq) (*MarketQueryRes, error) {
|
|
||||||
return nil, status.Errorf(codes.Unimplemented, "method MarketQuery not implemented")
|
|
||||||
}
|
|
||||||
func (UnimplementedTransferServer) RsCouponGrant(context.Context, *RsCouponGrantReq) (*RsCouponGrantRes, error) {
|
|
||||||
return nil, status.Errorf(codes.Unimplemented, "method RsCouponGrant not implemented")
|
|
||||||
}
|
|
||||||
func (UnimplementedTransferServer) mustEmbedUnimplementedTransferServer() {}
|
|
||||||
|
|
||||||
// UnsafeTransferServer may be embedded to opt out of forward compatibility for this service.
|
|
||||||
// Use of this interface is not recommended, as added methods to TransferServer will
|
|
||||||
// result in compilation errors.
|
|
||||||
type UnsafeTransferServer interface {
|
|
||||||
mustEmbedUnimplementedTransferServer()
|
|
||||||
}
|
|
||||||
|
|
||||||
func RegisterTransferServer(s grpc.ServiceRegistrar, srv TransferServer) {
|
|
||||||
s.RegisterService(&Transfer_ServiceDesc, srv)
|
|
||||||
}
|
|
||||||
|
|
||||||
func _Transfer_ZltxOrderRecharge_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
|
||||||
in := new(ZltxOrderRechargeReq)
|
|
||||||
if err := dec(in); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if interceptor == nil {
|
|
||||||
return srv.(TransferServer).ZltxOrderRecharge(ctx, in)
|
|
||||||
}
|
|
||||||
info := &grpc.UnaryServerInfo{
|
|
||||||
Server: srv,
|
|
||||||
FullMethod: Transfer_ZltxOrderRecharge_FullMethodName,
|
|
||||||
}
|
|
||||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
|
||||||
return srv.(TransferServer).ZltxOrderRecharge(ctx, req.(*ZltxOrderRechargeReq))
|
|
||||||
}
|
|
||||||
return interceptor(ctx, in, info, handler)
|
|
||||||
}
|
|
||||||
|
|
||||||
func _Transfer_ZltxOrderRechargeQuery_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
|
||||||
in := new(ZltxOrderRechargeQueryReq)
|
|
||||||
if err := dec(in); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if interceptor == nil {
|
|
||||||
return srv.(TransferServer).ZltxOrderRechargeQuery(ctx, in)
|
|
||||||
}
|
|
||||||
info := &grpc.UnaryServerInfo{
|
|
||||||
Server: srv,
|
|
||||||
FullMethod: Transfer_ZltxOrderRechargeQuery_FullMethodName,
|
|
||||||
}
|
|
||||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
|
||||||
return srv.(TransferServer).ZltxOrderRechargeQuery(ctx, req.(*ZltxOrderRechargeQueryReq))
|
|
||||||
}
|
|
||||||
return interceptor(ctx, in, info, handler)
|
|
||||||
}
|
|
||||||
|
|
||||||
func _Transfer_ZltxOrderCard_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
|
||||||
in := new(ZltxOrderCardReq)
|
|
||||||
if err := dec(in); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if interceptor == nil {
|
|
||||||
return srv.(TransferServer).ZltxOrderCard(ctx, in)
|
|
||||||
}
|
|
||||||
info := &grpc.UnaryServerInfo{
|
|
||||||
Server: srv,
|
|
||||||
FullMethod: Transfer_ZltxOrderCard_FullMethodName,
|
|
||||||
}
|
|
||||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
|
||||||
return srv.(TransferServer).ZltxOrderCard(ctx, req.(*ZltxOrderCardReq))
|
|
||||||
}
|
|
||||||
return interceptor(ctx, in, info, handler)
|
|
||||||
}
|
|
||||||
|
|
||||||
func _Transfer_ZltxOrderCardQuery_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
|
||||||
in := new(ZltxOrderCardQueryReq)
|
|
||||||
if err := dec(in); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if interceptor == nil {
|
|
||||||
return srv.(TransferServer).ZltxOrderCardQuery(ctx, in)
|
|
||||||
}
|
|
||||||
info := &grpc.UnaryServerInfo{
|
|
||||||
Server: srv,
|
|
||||||
FullMethod: Transfer_ZltxOrderCardQuery_FullMethodName,
|
|
||||||
}
|
|
||||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
|
||||||
return srv.(TransferServer).ZltxOrderCardQuery(ctx, req.(*ZltxOrderCardQueryReq))
|
|
||||||
}
|
|
||||||
return interceptor(ctx, in, info, handler)
|
|
||||||
}
|
|
||||||
|
|
||||||
func _Transfer_ZltxOrderSms_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
|
||||||
in := new(ZltxOrderSmsReq)
|
|
||||||
if err := dec(in); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if interceptor == nil {
|
|
||||||
return srv.(TransferServer).ZltxOrderSms(ctx, in)
|
|
||||||
}
|
|
||||||
info := &grpc.UnaryServerInfo{
|
|
||||||
Server: srv,
|
|
||||||
FullMethod: Transfer_ZltxOrderSms_FullMethodName,
|
|
||||||
}
|
|
||||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
|
||||||
return srv.(TransferServer).ZltxOrderSms(ctx, req.(*ZltxOrderSmsReq))
|
|
||||||
}
|
|
||||||
return interceptor(ctx, in, info, handler)
|
|
||||||
}
|
|
||||||
|
|
||||||
func _Transfer_ZltxRechargeInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
|
||||||
in := new(DefaultReq)
|
|
||||||
if err := dec(in); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if interceptor == nil {
|
|
||||||
return srv.(TransferServer).ZltxRechargeInfo(ctx, in)
|
|
||||||
}
|
|
||||||
info := &grpc.UnaryServerInfo{
|
|
||||||
Server: srv,
|
|
||||||
FullMethod: Transfer_ZltxRechargeInfo_FullMethodName,
|
|
||||||
}
|
|
||||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
|
||||||
return srv.(TransferServer).ZltxRechargeInfo(ctx, req.(*DefaultReq))
|
|
||||||
}
|
|
||||||
return interceptor(ctx, in, info, handler)
|
|
||||||
}
|
|
||||||
|
|
||||||
func _Transfer_ZltxRechargeProduct_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
|
||||||
in := new(DefaultReq)
|
|
||||||
if err := dec(in); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if interceptor == nil {
|
|
||||||
return srv.(TransferServer).ZltxRechargeProduct(ctx, in)
|
|
||||||
}
|
|
||||||
info := &grpc.UnaryServerInfo{
|
|
||||||
Server: srv,
|
|
||||||
FullMethod: Transfer_ZltxRechargeProduct_FullMethodName,
|
|
||||||
}
|
|
||||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
|
||||||
return srv.(TransferServer).ZltxRechargeProduct(ctx, req.(*DefaultReq))
|
|
||||||
}
|
|
||||||
return interceptor(ctx, in, info, handler)
|
|
||||||
}
|
|
||||||
|
|
||||||
func _Transfer_ZltxRsMiXue_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
|
||||||
in := new(RsCouponGrantReq)
|
|
||||||
if err := dec(in); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if interceptor == nil {
|
|
||||||
return srv.(TransferServer).ZltxRsMiXue(ctx, in)
|
|
||||||
}
|
|
||||||
info := &grpc.UnaryServerInfo{
|
|
||||||
Server: srv,
|
|
||||||
FullMethod: Transfer_ZltxRsMiXue_FullMethodName,
|
|
||||||
}
|
|
||||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
|
||||||
return srv.(TransferServer).ZltxRsMiXue(ctx, req.(*RsCouponGrantReq))
|
|
||||||
}
|
|
||||||
return interceptor(ctx, in, info, handler)
|
|
||||||
}
|
|
||||||
|
|
||||||
func _Transfer_MarketKeySend_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
|
||||||
in := new(MarketKeySendReq)
|
|
||||||
if err := dec(in); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if interceptor == nil {
|
|
||||||
return srv.(TransferServer).MarketKeySend(ctx, in)
|
|
||||||
}
|
|
||||||
info := &grpc.UnaryServerInfo{
|
|
||||||
Server: srv,
|
|
||||||
FullMethod: Transfer_MarketKeySend_FullMethodName,
|
|
||||||
}
|
|
||||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
|
||||||
return srv.(TransferServer).MarketKeySend(ctx, req.(*MarketKeySendReq))
|
|
||||||
}
|
|
||||||
return interceptor(ctx, in, info, handler)
|
|
||||||
}
|
|
||||||
|
|
||||||
func _Transfer_MarketKeyDiscard_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
|
||||||
in := new(MarketKeyDiscardReq)
|
|
||||||
if err := dec(in); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if interceptor == nil {
|
|
||||||
return srv.(TransferServer).MarketKeyDiscard(ctx, in)
|
|
||||||
}
|
|
||||||
info := &grpc.UnaryServerInfo{
|
|
||||||
Server: srv,
|
|
||||||
FullMethod: Transfer_MarketKeyDiscard_FullMethodName,
|
|
||||||
}
|
|
||||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
|
||||||
return srv.(TransferServer).MarketKeyDiscard(ctx, req.(*MarketKeyDiscardReq))
|
|
||||||
}
|
|
||||||
return interceptor(ctx, in, info, handler)
|
|
||||||
}
|
|
||||||
|
|
||||||
func _Transfer_MarketQuery_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
|
||||||
in := new(MarketQueryReq)
|
|
||||||
if err := dec(in); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if interceptor == nil {
|
|
||||||
return srv.(TransferServer).MarketQuery(ctx, in)
|
|
||||||
}
|
|
||||||
info := &grpc.UnaryServerInfo{
|
|
||||||
Server: srv,
|
|
||||||
FullMethod: Transfer_MarketQuery_FullMethodName,
|
|
||||||
}
|
|
||||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
|
||||||
return srv.(TransferServer).MarketQuery(ctx, req.(*MarketQueryReq))
|
|
||||||
}
|
|
||||||
return interceptor(ctx, in, info, handler)
|
|
||||||
}
|
|
||||||
|
|
||||||
func _Transfer_RsCouponGrant_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
|
||||||
in := new(RsCouponGrantReq)
|
|
||||||
if err := dec(in); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if interceptor == nil {
|
|
||||||
return srv.(TransferServer).RsCouponGrant(ctx, in)
|
|
||||||
}
|
|
||||||
info := &grpc.UnaryServerInfo{
|
|
||||||
Server: srv,
|
|
||||||
FullMethod: Transfer_RsCouponGrant_FullMethodName,
|
|
||||||
}
|
|
||||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
|
||||||
return srv.(TransferServer).RsCouponGrant(ctx, req.(*RsCouponGrantReq))
|
|
||||||
}
|
|
||||||
return interceptor(ctx, in, info, handler)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Transfer_ServiceDesc is the grpc.ServiceDesc for Transfer service.
|
|
||||||
// It's only intended for direct use with grpc.RegisterService,
|
|
||||||
// and not to be introspected or modified (even as a copy)
|
|
||||||
var Transfer_ServiceDesc = grpc.ServiceDesc{
|
|
||||||
ServiceName: "transfer.Transfer",
|
|
||||||
HandlerType: (*TransferServer)(nil),
|
|
||||||
Methods: []grpc.MethodDesc{
|
|
||||||
{
|
|
||||||
MethodName: "zltxOrderRecharge",
|
|
||||||
Handler: _Transfer_ZltxOrderRecharge_Handler,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
MethodName: "zltxOrderRechargeQuery",
|
|
||||||
Handler: _Transfer_ZltxOrderRechargeQuery_Handler,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
MethodName: "zltxOrderCard",
|
|
||||||
Handler: _Transfer_ZltxOrderCard_Handler,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
MethodName: "zltxOrderCardQuery",
|
|
||||||
Handler: _Transfer_ZltxOrderCardQuery_Handler,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
MethodName: "zltxOrderSms",
|
|
||||||
Handler: _Transfer_ZltxOrderSms_Handler,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
MethodName: "zltxRechargeInfo",
|
|
||||||
Handler: _Transfer_ZltxRechargeInfo_Handler,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
MethodName: "zltxRechargeProduct",
|
|
||||||
Handler: _Transfer_ZltxRechargeProduct_Handler,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
MethodName: "zltxRsMiXue",
|
|
||||||
Handler: _Transfer_ZltxRsMiXue_Handler,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
MethodName: "marketKeySend",
|
|
||||||
Handler: _Transfer_MarketKeySend_Handler,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
MethodName: "marketKeyDiscard",
|
|
||||||
Handler: _Transfer_MarketKeyDiscard_Handler,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
MethodName: "marketQuery",
|
|
||||||
Handler: _Transfer_MarketQuery_Handler,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
MethodName: "rsCouponGrant",
|
|
||||||
Handler: _Transfer_RsCouponGrant_Handler,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Streams: []grpc.StreamDesc{},
|
|
||||||
Metadata: "transfer.proto",
|
|
||||||
}
|
|
|
@ -3,16 +3,18 @@ package main
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"flag"
|
"flag"
|
||||||
|
"fmt"
|
||||||
"github.com/zeromicro/go-zero/core/conf"
|
"github.com/zeromicro/go-zero/core/conf"
|
||||||
"github.com/zeromicro/go-zero/core/service"
|
"github.com/zeromicro/go-zero/core/service"
|
||||||
"trasfer_middleware/cmd/rpc/internal/config"
|
"trasfer_middleware/cmd/rpc/internal/config"
|
||||||
mq2 "trasfer_middleware/cmd/rpc/internal/queue/mq"
|
mq2 "trasfer_middleware/cmd/rpc/internal/queue/mq"
|
||||||
"trasfer_middleware/cmd/rpc/internal/queue/mq/mqServer"
|
"trasfer_middleware/cmd/rpc/internal/queue/mq/mqServer"
|
||||||
"trasfer_middleware/cmd/rpc/internal/queue/mq/mqSvc"
|
"trasfer_middleware/cmd/rpc/internal/queue/mq/mqSvc"
|
||||||
|
"trasfer_middleware/until"
|
||||||
"trasfer_middleware/until/sysLog"
|
"trasfer_middleware/until/sysLog"
|
||||||
)
|
)
|
||||||
|
|
||||||
var configFile = flag.String("f", "../../../config/transfer_produce.yaml", "the config file")
|
var configFile = flag.String("f", fmt.Sprintf("%s%s", "../../../config/", until.GetConfigQueue()), "the config file")
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
|
@ -34,6 +34,7 @@ func main() {
|
||||||
reflection.Register(grpcServer)
|
reflection.Register(grpcServer)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
registerNacos(&c)
|
registerNacos(&c)
|
||||||
defer s.Stop()
|
defer s.Stop()
|
||||||
|
|
||||||
|
|
54
go.mod
54
go.mod
|
@ -1,13 +1,15 @@
|
||||||
module trasfer_middleware
|
module trasfer_middleware
|
||||||
|
|
||||||
go 1.21
|
go 1.22.2
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/apache/rocketmq-client-go/v2 v2.1.2
|
github.com/apache/rocketmq-client-go/v2 v2.1.2
|
||||||
github.com/jinzhu/copier v0.4.0
|
github.com/jinzhu/copier v0.4.0
|
||||||
|
github.com/mitchellh/mapstructure v1.5.0
|
||||||
github.com/nacos-group/nacos-sdk-go/v2 v2.2.3
|
github.com/nacos-group/nacos-sdk-go/v2 v2.2.3
|
||||||
github.com/pkg/errors v0.9.1
|
github.com/pkg/errors v0.9.1
|
||||||
github.com/qit-team/snow-core v0.1.29
|
github.com/sleepinggodoflove/lansexiongdi-marketing-sdk v0.0.14
|
||||||
|
github.com/spf13/cast v1.7.0
|
||||||
github.com/streadway/amqp v1.1.0
|
github.com/streadway/amqp v1.1.0
|
||||||
github.com/zeromicro/go-zero v1.6.5
|
github.com/zeromicro/go-zero v1.6.5
|
||||||
github.com/zeromicro/zero-contrib/zrpc/registry/nacos v0.0.0-20231030135404-af9ae855016f
|
github.com/zeromicro/zero-contrib/zrpc/registry/nacos v0.0.0-20231030135404-af9ae855016f
|
||||||
|
@ -15,8 +17,8 @@ require (
|
||||||
go.opentelemetry.io/otel/exporters/jaeger v1.17.0
|
go.opentelemetry.io/otel/exporters/jaeger v1.17.0
|
||||||
go.opentelemetry.io/otel/sdk v1.19.0
|
go.opentelemetry.io/otel/sdk v1.19.0
|
||||||
go.opentelemetry.io/otel/trace v1.19.0
|
go.opentelemetry.io/otel/trace v1.19.0
|
||||||
google.golang.org/grpc v1.63.2
|
google.golang.org/grpc v1.67.1
|
||||||
google.golang.org/protobuf v1.34.1
|
google.golang.org/protobuf v1.34.2
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
|
@ -24,11 +26,8 @@ require (
|
||||||
github.com/aliyun/alibaba-cloud-sdk-go v1.61.1704 // indirect
|
github.com/aliyun/alibaba-cloud-sdk-go v1.61.1704 // indirect
|
||||||
github.com/beorn7/perks v1.0.1 // indirect
|
github.com/beorn7/perks v1.0.1 // indirect
|
||||||
github.com/buger/jsonparser v1.1.1 // indirect
|
github.com/buger/jsonparser v1.1.1 // indirect
|
||||||
github.com/bytedance/sonic v1.10.2 // indirect
|
|
||||||
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
|
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
|
||||||
github.com/cespare/xxhash/v2 v2.2.0 // indirect
|
github.com/cespare/xxhash/v2 v2.3.0 // indirect
|
||||||
github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d // indirect
|
|
||||||
github.com/chenzhuoyu/iasm v0.9.1 // indirect
|
|
||||||
github.com/coreos/go-semver v0.3.1 // indirect
|
github.com/coreos/go-semver v0.3.1 // indirect
|
||||||
github.com/coreos/go-systemd/v22 v22.5.0 // indirect
|
github.com/coreos/go-systemd/v22 v22.5.0 // indirect
|
||||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||||
|
@ -36,10 +35,7 @@ require (
|
||||||
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
|
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
|
||||||
github.com/emirpasic/gods v1.18.1 // indirect
|
github.com/emirpasic/gods v1.18.1 // indirect
|
||||||
github.com/fatih/color v1.16.0 // indirect
|
github.com/fatih/color v1.16.0 // indirect
|
||||||
github.com/fvbock/endless v0.0.0-20170109170031-447134032cb6 // indirect
|
github.com/gabriel-vasile/mimetype v1.4.3 // indirect
|
||||||
github.com/gabriel-vasile/mimetype v1.4.2 // indirect
|
|
||||||
github.com/gin-contrib/sse v0.1.0 // indirect
|
|
||||||
github.com/gin-gonic/gin v1.9.1 // indirect
|
|
||||||
github.com/go-logr/logr v1.3.0 // indirect
|
github.com/go-logr/logr v1.3.0 // indirect
|
||||||
github.com/go-logr/stdr v1.2.2 // indirect
|
github.com/go-logr/stdr v1.2.2 // indirect
|
||||||
github.com/go-openapi/jsonpointer v0.19.6 // indirect
|
github.com/go-openapi/jsonpointer v0.19.6 // indirect
|
||||||
|
@ -47,9 +43,8 @@ require (
|
||||||
github.com/go-openapi/swag v0.22.4 // indirect
|
github.com/go-openapi/swag v0.22.4 // indirect
|
||||||
github.com/go-playground/locales v0.14.1 // indirect
|
github.com/go-playground/locales v0.14.1 // indirect
|
||||||
github.com/go-playground/universal-translator v0.18.1 // indirect
|
github.com/go-playground/universal-translator v0.18.1 // indirect
|
||||||
github.com/go-playground/validator/v10 v10.14.1 // indirect
|
github.com/go-playground/validator/v10 v10.22.1 // indirect
|
||||||
github.com/go-sql-driver/mysql v1.8.1 // indirect
|
github.com/go-sql-driver/mysql v1.8.1 // indirect
|
||||||
github.com/goccy/go-json v0.10.2 // indirect
|
|
||||||
github.com/gogo/protobuf v1.3.2 // indirect
|
github.com/gogo/protobuf v1.3.2 // indirect
|
||||||
github.com/golang/mock v1.6.0 // indirect
|
github.com/golang/mock v1.6.0 // indirect
|
||||||
github.com/golang/protobuf v1.5.4 // indirect
|
github.com/golang/protobuf v1.5.4 // indirect
|
||||||
|
@ -57,12 +52,12 @@ require (
|
||||||
github.com/google/go-cmp v0.6.0 // indirect
|
github.com/google/go-cmp v0.6.0 // indirect
|
||||||
github.com/google/gofuzz v1.2.0 // indirect
|
github.com/google/gofuzz v1.2.0 // indirect
|
||||||
github.com/google/uuid v1.6.0 // indirect
|
github.com/google/uuid v1.6.0 // indirect
|
||||||
|
github.com/gopherjs/gopherjs v0.0.0-20211111143520-d0d5ecc1a356 // indirect
|
||||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.18.0 // indirect
|
github.com/grpc-ecosystem/grpc-gateway/v2 v2.18.0 // indirect
|
||||||
github.com/jmespath/go-jmespath v0.4.0 // indirect
|
github.com/jmespath/go-jmespath v0.4.0 // indirect
|
||||||
github.com/josharian/intern v1.0.0 // indirect
|
github.com/josharian/intern v1.0.0 // indirect
|
||||||
github.com/json-iterator/go v1.1.12 // indirect
|
github.com/json-iterator/go v1.1.12 // indirect
|
||||||
github.com/klauspost/cpuid/v2 v2.2.6 // indirect
|
github.com/leodido/go-urn v1.4.0 // indirect
|
||||||
github.com/leodido/go-urn v1.2.4 // indirect
|
|
||||||
github.com/mailru/easyjson v0.7.7 // indirect
|
github.com/mailru/easyjson v0.7.7 // indirect
|
||||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||||
|
@ -77,16 +72,14 @@ require (
|
||||||
github.com/prometheus/client_model v0.5.0 // indirect
|
github.com/prometheus/client_model v0.5.0 // indirect
|
||||||
github.com/prometheus/common v0.45.0 // indirect
|
github.com/prometheus/common v0.45.0 // indirect
|
||||||
github.com/prometheus/procfs v0.12.0 // indirect
|
github.com/prometheus/procfs v0.12.0 // indirect
|
||||||
github.com/qit-team/work v0.3.11 // indirect
|
|
||||||
github.com/redis/go-redis/v9 v9.4.0 // indirect
|
github.com/redis/go-redis/v9 v9.4.0 // indirect
|
||||||
github.com/robfig/cron v1.2.0 // indirect
|
|
||||||
github.com/sirupsen/logrus v1.9.3 // indirect
|
github.com/sirupsen/logrus v1.9.3 // indirect
|
||||||
|
github.com/smartystreets/goconvey v1.7.2 // indirect
|
||||||
github.com/spaolacci/murmur3 v1.1.0 // indirect
|
github.com/spaolacci/murmur3 v1.1.0 // indirect
|
||||||
github.com/tidwall/gjson v1.15.0 // indirect
|
github.com/tidwall/gjson v1.15.0 // indirect
|
||||||
github.com/tidwall/match v1.1.1 // indirect
|
github.com/tidwall/match v1.1.1 // indirect
|
||||||
github.com/tidwall/pretty v1.2.1 // indirect
|
github.com/tidwall/pretty v1.2.1 // indirect
|
||||||
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
|
github.com/tjfoc/gmsm v1.4.1 // indirect
|
||||||
github.com/ugorji/go/codec v1.2.11 // indirect
|
|
||||||
go.etcd.io/etcd/api/v3 v3.5.13 // indirect
|
go.etcd.io/etcd/api/v3 v3.5.13 // indirect
|
||||||
go.etcd.io/etcd/client/pkg/v3 v3.5.13 // indirect
|
go.etcd.io/etcd/client/pkg/v3 v3.5.13 // indirect
|
||||||
go.etcd.io/etcd/client/v3 v3.5.13 // indirect
|
go.etcd.io/etcd/client/v3 v3.5.13 // indirect
|
||||||
|
@ -101,19 +94,16 @@ require (
|
||||||
go.uber.org/automaxprocs v1.5.3 // indirect
|
go.uber.org/automaxprocs v1.5.3 // indirect
|
||||||
go.uber.org/multierr v1.9.0 // indirect
|
go.uber.org/multierr v1.9.0 // indirect
|
||||||
go.uber.org/zap v1.24.0 // indirect
|
go.uber.org/zap v1.24.0 // indirect
|
||||||
golang.org/x/arch v0.6.0 // indirect
|
golang.org/x/crypto v0.26.0 // indirect
|
||||||
golang.org/x/crypto v0.23.0 // indirect
|
golang.org/x/net v0.28.0 // indirect
|
||||||
golang.org/x/net v0.25.0 // indirect
|
golang.org/x/oauth2 v0.22.0 // indirect
|
||||||
golang.org/x/oauth2 v0.17.0 // indirect
|
golang.org/x/sync v0.8.0 // indirect
|
||||||
golang.org/x/sync v0.6.0 // indirect
|
golang.org/x/sys v0.24.0 // indirect
|
||||||
golang.org/x/sys v0.20.0 // indirect
|
golang.org/x/term v0.23.0 // indirect
|
||||||
golang.org/x/term v0.20.0 // indirect
|
golang.org/x/text v0.17.0 // indirect
|
||||||
golang.org/x/text v0.15.0 // indirect
|
|
||||||
golang.org/x/time v0.5.0 // indirect
|
golang.org/x/time v0.5.0 // indirect
|
||||||
google.golang.org/appengine v1.6.8 // indirect
|
google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142 // indirect
|
||||||
google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de // indirect
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 // indirect
|
||||||
google.golang.org/genproto/googleapis/api v0.0.0-20240227224415-6ceb2ff114de // indirect
|
|
||||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de // indirect
|
|
||||||
gopkg.in/inf.v0 v0.9.1 // indirect
|
gopkg.in/inf.v0 v0.9.1 // indirect
|
||||||
gopkg.in/ini.v1 v1.66.2 // indirect
|
gopkg.in/ini.v1 v1.66.2 // indirect
|
||||||
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
|
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
|
||||||
|
|
|
@ -4,4 +4,4 @@
|
||||||
Environment="test"
|
Environment="test"
|
||||||
ADDRESS="${TEST_ADDRESS}"
|
ADDRESS="${TEST_ADDRESS}"
|
||||||
echo "test"> $(pwd)/env
|
echo "test"> $(pwd)/env
|
||||||
sh $(pwd)/sh/build.sh
|
. $(pwd)/sh/build.sh
|
||||||
|
|
24
until/env.go
24
until/env.go
|
@ -10,10 +10,28 @@ func GetConfig() string {
|
||||||
pwd, _ := os.Getwd()
|
pwd, _ := os.Getwd()
|
||||||
path := fmt.Sprintf("%s%s", pwd, "/../../env")
|
path := fmt.Sprintf("%s%s", pwd, "/../../env")
|
||||||
bytes, _ := os.ReadFile(path)
|
bytes, _ := os.ReadFile(path)
|
||||||
switch string(bytes) {
|
env := string(bytes)
|
||||||
case "produce":
|
switch env {
|
||||||
|
case "produce\n":
|
||||||
dir = "produce.yaml"
|
dir = "produce.yaml"
|
||||||
case "test":
|
case "test\n":
|
||||||
|
dir = "test.yaml"
|
||||||
|
default:
|
||||||
|
dir = "local.yaml"
|
||||||
|
}
|
||||||
|
return dir
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetConfigQueue() string {
|
||||||
|
var dir string
|
||||||
|
pwd, _ := os.Getwd()
|
||||||
|
path := fmt.Sprintf("%s%s", pwd, "/../../../env")
|
||||||
|
bytes, _ := os.ReadFile(path)
|
||||||
|
env := string(bytes)
|
||||||
|
switch env {
|
||||||
|
case "produce\n":
|
||||||
|
dir = "produce.yaml"
|
||||||
|
case "test\n":
|
||||||
dir = "test.yaml"
|
dir = "test.yaml"
|
||||||
default:
|
default:
|
||||||
dir = "local.yaml"
|
dir = "local.yaml"
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
package test
|
package test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"testing"
|
"testing"
|
||||||
|
"trasfer_middleware/cmd/rpc/pb/transfer"
|
||||||
"trasfer_middleware/until/request"
|
"trasfer_middleware/until/request"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -81,3 +83,10 @@ func TestPostJson(t *testing.T) {
|
||||||
fmt.Printf("响应时间: %f秒\n", resp.Elapsed)
|
fmt.Printf("响应时间: %f秒\n", resp.Elapsed)
|
||||||
fmt.Printf("响应文本: %s\n", resp.Text)
|
fmt.Printf("响应文本: %s\n", resp.Text)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestA(T *testing.T) {
|
||||||
|
var res transfer.MarketKeySendRes
|
||||||
|
data := "{\"errCode\":\"-1\",\"msg\":\"券码库存不足\"}"
|
||||||
|
_ = json.Unmarshal([]byte(data), &res)
|
||||||
|
fmt.Println(res)
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,137 @@
|
||||||
|
package rsa
|
||||||
|
|
||||||
|
import (
|
||||||
|
"crypto"
|
||||||
|
"crypto/rand"
|
||||||
|
"crypto/rsa"
|
||||||
|
"crypto/sha256"
|
||||||
|
"crypto/x509"
|
||||||
|
"encoding/base64"
|
||||||
|
"encoding/pem"
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"sort"
|
||||||
|
)
|
||||||
|
|
||||||
|
// getSignString 使用 xx=aa&yy=bb 的字符串拼接
|
||||||
|
func getSignString(data map[string]interface{}) string {
|
||||||
|
keys := make([]string, 0, len(data))
|
||||||
|
for key := range data {
|
||||||
|
keys = append(keys, key)
|
||||||
|
}
|
||||||
|
sort.Strings(keys)
|
||||||
|
|
||||||
|
signString := ""
|
||||||
|
separator := ""
|
||||||
|
for _, key := range keys {
|
||||||
|
value := data[key]
|
||||||
|
if key == "sign" || key == "mobile_no" || value == nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
signString += fmt.Sprintf("%s%s=%v", separator, key, value)
|
||||||
|
separator = "&"
|
||||||
|
}
|
||||||
|
return signString
|
||||||
|
}
|
||||||
|
|
||||||
|
// VerifyRsaSign 签名验证
|
||||||
|
func VerifyRsaSign(publicKey string, data map[string]interface{}) (map[string]interface{}, error) {
|
||||||
|
// 对 sign nonce timestamp appId 升序排序
|
||||||
|
// 使用 xx=aa&yy=bb 的字符串拼接
|
||||||
|
// 商户的公钥验签 RSA2验签
|
||||||
|
signString := getSignString(data)
|
||||||
|
|
||||||
|
rsaPubKey, err := parseRSAPublicKeyFromPEM([]byte(publicKey))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
signature, err := base64.StdEncoding.DecodeString(data["sign"].(string))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
hashed := sha256.Sum256([]byte(signString))
|
||||||
|
err = rsa.VerifyPKCS1v15(rsaPubKey, crypto.SHA256, hashed[:], signature)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.New("签名验证失败")
|
||||||
|
}
|
||||||
|
|
||||||
|
return data, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// MakeRsaSign 生成签名
|
||||||
|
func MakeRsaSign(privateKey string, data map[string]interface{}) (string, error) {
|
||||||
|
// 对 sign nonce timestamp appId 升序排序
|
||||||
|
// 使用 xx=aa&yy=bb 的字符串拼接
|
||||||
|
// 营销系统生成的私钥生成签名 RSA2加签
|
||||||
|
signString := getSignString(data)
|
||||||
|
|
||||||
|
privKey, err := parseRSAPrivateKeyFromPEM([]byte(privateKey))
|
||||||
|
if err != nil {
|
||||||
|
return "", errors.New("私钥解析失败")
|
||||||
|
}
|
||||||
|
|
||||||
|
hashed := sha256.Sum256([]byte(signString))
|
||||||
|
signature, err := rsa.SignPKCS1v15(rand.Reader, privKey, crypto.SHA256, hashed[:])
|
||||||
|
if err != nil {
|
||||||
|
return "", errors.New("签名失败")
|
||||||
|
}
|
||||||
|
|
||||||
|
return base64.StdEncoding.EncodeToString(signature), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ParseRSAPrivateKeyFromPEM 解析私钥
|
||||||
|
func parseRSAPrivateKeyFromPEM(key []byte) (*rsa.PrivateKey, error) {
|
||||||
|
var err error
|
||||||
|
|
||||||
|
// Parse PEM block
|
||||||
|
var block *pem.Block
|
||||||
|
if block, _ = pem.Decode(key); block == nil {
|
||||||
|
return nil, errors.New("私钥解析失败: 无效的PEM格式")
|
||||||
|
}
|
||||||
|
|
||||||
|
var parsedKey interface{}
|
||||||
|
if parsedKey, err = x509.ParsePKCS1PrivateKey(block.Bytes); err != nil {
|
||||||
|
if parsedKey, err = x509.ParsePKCS8PrivateKey(block.Bytes); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var pkey *rsa.PrivateKey
|
||||||
|
var ok bool
|
||||||
|
if pkey, ok = parsedKey.(*rsa.PrivateKey); !ok {
|
||||||
|
return nil, errors.New("密钥不是有效的RSA私钥")
|
||||||
|
}
|
||||||
|
|
||||||
|
return pkey, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// parseRSAPublicKeyFromPEM parses a PEM encoded PKCS1 or PKCS8 public key
|
||||||
|
func parseRSAPublicKeyFromPEM(key []byte) (*rsa.PublicKey, error) {
|
||||||
|
var err error
|
||||||
|
|
||||||
|
// Parse PEM block
|
||||||
|
var block *pem.Block
|
||||||
|
if block, _ = pem.Decode(key); block == nil {
|
||||||
|
return nil, errors.New("公钥解析失败: 无效的PEM格式")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Parse the key
|
||||||
|
var parsedKey interface{}
|
||||||
|
if parsedKey, err = x509.ParsePKIXPublicKey(block.Bytes); err != nil {
|
||||||
|
if cert, err := x509.ParseCertificate(block.Bytes); err == nil {
|
||||||
|
parsedKey = cert.PublicKey
|
||||||
|
} else {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var pkey *rsa.PublicKey
|
||||||
|
var ok bool
|
||||||
|
if pkey, ok = parsedKey.(*rsa.PublicKey); !ok {
|
||||||
|
return nil, errors.New("密钥不是有效的RSA公钥")
|
||||||
|
}
|
||||||
|
|
||||||
|
return pkey, nil
|
||||||
|
}
|
|
@ -0,0 +1,66 @@
|
||||||
|
package rsa
|
||||||
|
|
||||||
|
import (
|
||||||
|
"crypto/sha256"
|
||||||
|
"encoding/base64"
|
||||||
|
"encoding/hex"
|
||||||
|
"fmt"
|
||||||
|
"github.com/spf13/cast"
|
||||||
|
"sort"
|
||||||
|
)
|
||||||
|
|
||||||
|
var filterKeys = []string{"sign", "extendParams", "msg"}
|
||||||
|
|
||||||
|
func GetSign(data map[string]interface{}, primary string) (string, error) {
|
||||||
|
filterData(&data)
|
||||||
|
sysSign, err := hash256AndBase64(sortValue(data, primary))
|
||||||
|
if err != nil {
|
||||||
|
return "", fmt.Errorf("参数加密失败")
|
||||||
|
}
|
||||||
|
return sysSign, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func filterData(data *map[string]interface{}) {
|
||||||
|
for _, key := range filterKeys {
|
||||||
|
delete(*data, key)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func sortValue(data map[string]interface{}, primary string) string {
|
||||||
|
var sortValueString string
|
||||||
|
|
||||||
|
data["key"] = primary
|
||||||
|
|
||||||
|
keys := make([]string, 0, len(data))
|
||||||
|
|
||||||
|
for k := range data {
|
||||||
|
keys = append(keys, k)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 对键进行排序
|
||||||
|
sort.Strings(keys)
|
||||||
|
|
||||||
|
// 按照排序后的键的顺序输出map的值
|
||||||
|
for _, v := range keys {
|
||||||
|
sortValueString += cast.ToString(data[v])
|
||||||
|
}
|
||||||
|
return sortValueString
|
||||||
|
}
|
||||||
|
|
||||||
|
func hash256AndBase64(valueString string) (string, error) {
|
||||||
|
// 创建一个新的hash.Hash计算器,并指定算法为sha256
|
||||||
|
hasher := sha256.New()
|
||||||
|
|
||||||
|
// 写入数据到hash计算器
|
||||||
|
hasher.Write([]byte(valueString))
|
||||||
|
|
||||||
|
// Sum方法返回计算出的哈希值的字节切片
|
||||||
|
hashBytes := hasher.Sum(nil)
|
||||||
|
|
||||||
|
//将字符串编码为16进制格式,返回字符串
|
||||||
|
hashCode := hex.EncodeToString(hashBytes)
|
||||||
|
// 将哈希值的字节切片编码为Base64字符串
|
||||||
|
hashBase64 := base64.StdEncoding.EncodeToString([]byte(hashCode))
|
||||||
|
|
||||||
|
return hashBase64, nil
|
||||||
|
}
|
Loading…
Reference in New Issue