新增游戏人生领取奖励相关接口
This commit is contained in:
@ -2,10 +2,27 @@ package reward
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/md5"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"server/api/reward/v1"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) Callback(ctx context.Context, req *v1.CallbackReq) (res *v1.CallbackRes, err error) {
|
||||
fromCtx := g.RequestFromCtx(ctx)
|
||||
appid := fromCtx.Header.Get("Custom-Data-Appid")
|
||||
timestamp := fromCtx.Header.Get("Custom-Data-Timestamp")
|
||||
nonce := fromCtx.Header.Get("Custom-Data-Nonce")
|
||||
auth := fromCtx.Header.Get("Custom-Data-Auth")
|
||||
|
||||
return nil, err
|
||||
data := fmt.Sprintf("%s%s%s%s%d%d%d%s%s%s#%s", req.Uid, req.OrderId, req.PrizeChannelId, req.PrizeId, req.PrizeType, req.PrizeSubType, req.Num, appid, timestamp, nonce, auth)
|
||||
stateOri := md5.Sum([]byte(data))
|
||||
state := hex.EncodeToString(stateOri[:])
|
||||
myAuth := strings.ToUpper(state)
|
||||
if myAuth != auth {
|
||||
return &v1.CallbackRes{Errcode: 252151000, OrderId: req.OrderId, Datas: []v1.CallbackData{{PrizeCode: req.OrderId}}}, err
|
||||
}
|
||||
return &v1.CallbackRes{Errcode: 0, OrderId: req.OrderId, Datas: []v1.CallbackData{{PrizeCode: req.OrderId}}}, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user