228 lines
7.5 KiB
Go
228 lines
7.5 KiB
Go
package webapi
|
|
|
|
import (
|
|
"errors"
|
|
"mongo.games.com/game/proto"
|
|
"mongo.games.com/game/protocol/webapi"
|
|
"mongo.games.com/goserver/core/logger"
|
|
"time"
|
|
)
|
|
|
|
type PlayerStatement struct {
|
|
Platform string `json:"platform"` //平台id
|
|
PackageId string `json:"packageTag"` //包标识
|
|
SnId int32 `json:"snid"` //玩家id
|
|
IsBind int32 `json:"is_bind"` //是否是正式账号 1:正式用户 0:非正式
|
|
TotalWin int32 `json:"total_win"` //折算后赢钱数
|
|
TotalLose int32 `json:"total_lose"` //折算后输钱数
|
|
TotaSrclWin int32 `json:"total_src_win"` //赢钱数
|
|
TotaSrclLose int32 `json:"total_src_lose"` //输钱数
|
|
}
|
|
|
|
type PlayerStatementSrc struct {
|
|
Platform string `json:"platform"` //平台id
|
|
PackageId string `json:"packageTag"` //包标识
|
|
SnId int32 `json:"snid"` //玩家id
|
|
IsBind int32 `json:"is_bind"` //是否是正式账号 1:正式用户 0:非正式
|
|
TotalWin float64 `json:"total_win"` //折算后赢钱数
|
|
TotalLose float64 `json:"total_lose"` //折算后输钱数
|
|
TotaSrclWin float64 `json:"total_src_win"` //赢钱数
|
|
TotaSrclLose float64 `json:"total_src_lose"` //输钱数
|
|
}
|
|
|
|
// 推广信息
|
|
type PromoterData struct {
|
|
Platform int32 `json:"platform"` //平台id
|
|
PromoterId int32 `json:"promoter_id"` //推广员id
|
|
ChannelId int32 `json:"channel_id"` //渠道id
|
|
Spreader int32 `json:"spreader"` //推广人id
|
|
PromoterTree int32 `json:"promoter_tree"` //无级推广树id
|
|
Tag string `json:"tag"` //包标识
|
|
}
|
|
|
|
type ImgVerifyMsg struct {
|
|
ImgBase string `json:"img_base"`
|
|
Length int32 `json:"length"`
|
|
Code string `json:"code"`
|
|
}
|
|
|
|
// ApiSendSMS 发送短信验证码
|
|
func ApiSendSMS(appId string, body proto.Message) ([]byte, error) {
|
|
return postRequest(appId, "/send_sms", nil, body, "http", DEFAULT_TIMEOUT)
|
|
}
|
|
|
|
// ApiGetImageVerify 获取图片验证码
|
|
func ApiGetImageVerify(appId string, body proto.Message) ([]byte, error) {
|
|
return getRequest(appId, "/get_img_verify", nil, body, "http", DEFAULT_TIMEOUT)
|
|
}
|
|
|
|
// 获得代理配置
|
|
func API_GetPromoterConfig(appId string) ([]byte, error) {
|
|
//params := make(map[string]string)
|
|
//params["ts"] = strconv.Itoa(int(time.Now().Unix()))
|
|
//return getRequest(appId, "/game_promoter_list", params, "http", time.Duration(time.Second*120))
|
|
return nil, nil
|
|
}
|
|
|
|
// 兑换订单
|
|
func API_CreateExchange(appId string, body proto.Message) ([]byte, error) {
|
|
|
|
return postRequest(appId, "/create_exchange_order", nil, body, "http", DEFAULT_TIMEOUT)
|
|
}
|
|
|
|
// 获取兑换列表
|
|
func API_ExchangeList(appId string, body proto.Message) ([]byte, error) {
|
|
|
|
return postRequest(appId, "/get_exchange_shop", nil, body, "http", DEFAULT_TIMEOUT)
|
|
}
|
|
|
|
// 获取兑换记录
|
|
func API_ExchangeRecord(appId string, body proto.Message) ([]byte, error) {
|
|
|
|
return postRequest(appId, "/get_exchange_order", nil, body, "http", DEFAULT_TIMEOUT)
|
|
}
|
|
|
|
// APIGetMatchAwardCode 获取比赛奖品话费兑换码
|
|
func APIGetMatchAwardCode(appId string, body proto.Message) ([]byte, error) {
|
|
return postRequest(appId, "/get_match_award_code", nil, body, "http", DEFAULT_TIMEOUT)
|
|
}
|
|
|
|
// ApiSendSMS 发送短信验证码
|
|
func ApiSMSConfig(appId string, body proto.Message) ([]byte, error) {
|
|
return postRequest(appId, "/get_SMSConfig", nil, body, "http", DEFAULT_TIMEOUT)
|
|
}
|
|
|
|
func ApiAwardLog(appId string, body proto.Message) ([]byte, error) {
|
|
return postRequest(appId, "/get_AwardLog", nil, body, "http", DEFAULT_TIMEOUT)
|
|
}
|
|
|
|
// 获取弹窗配置
|
|
func ApiPopupWindowsConfig(appId string, body proto.Message) ([]byte, error) {
|
|
return postRequest(appId, "/get_PopupWindowsConfig", nil, body, "http", DEFAULT_TIMEOUT)
|
|
}
|
|
|
|
// 支付订单 商城
|
|
func API_CreateOrder(appId, orderId string, configid, SnId, shopId int32, platform string, packageTag string, os, deviceId, shopname string,
|
|
amount [3]int32, consumptionamount int32, itemInfo []*webapi.ItemInfo, exchangeOrderId, channel, channelId string) *webapi.ASCreateOrder {
|
|
body := &webapi.SACreateOrder{
|
|
OrderId: orderId,
|
|
SnId: SnId,
|
|
ShopId: shopId,
|
|
Platform: platform,
|
|
PackageTag: packageTag,
|
|
Os: DeviceOs(os),
|
|
DeviceId: deviceId,
|
|
ConfigId: configid,
|
|
ShopName: shopname,
|
|
OrderAmount: amount[:],
|
|
ItemInfo: itemInfo,
|
|
DollarAmount: consumptionamount,
|
|
Ts: time.Now().Unix(),
|
|
ExchangeOrderId: exchangeOrderId,
|
|
Channel: channel,
|
|
ChannelID: channelId,
|
|
}
|
|
ret := &webapi.ASCreateOrder{}
|
|
buff, err := postRequest(appId, "/create_order", nil, body, "http", DEFAULT_TIMEOUT)
|
|
if err != nil {
|
|
logger.Logger.Error("API_CreateOrder Request err:", err)
|
|
return nil
|
|
}
|
|
logger.Logger.Trace("API_CreateOrder:", string(buff))
|
|
err = proto.Unmarshal(buff, ret)
|
|
if err != nil {
|
|
logger.Logger.Error("API_CreateOrder Unmarshal err:", err)
|
|
return nil
|
|
}
|
|
return ret
|
|
}
|
|
|
|
// 推送全民推广关系链
|
|
func API_PushSpreadLink(snid int32, platform, packageTag string, inviterId int, isBind, isForce int, appId string) (int32, error) {
|
|
//params := make(map[string]string)
|
|
//params["snid"] = strconv.Itoa(int(snid))
|
|
//params["platform"] = platform
|
|
//params["packageTag"] = packageTag
|
|
//params["inviter"] = strconv.Itoa(inviterId)
|
|
//params["is_bind"] = strconv.Itoa(isBind)
|
|
//params["is_force"] = strconv.Itoa(isForce)
|
|
//buff, err := getRequest(appId, "/push_spread_link", params, "http", DEFAULT_TIMEOUT)
|
|
//if err != nil {
|
|
// return -1, err
|
|
//}
|
|
//type ApiResult struct {
|
|
// Tag int32
|
|
// Msg interface{}
|
|
//}
|
|
////fmt.Println("push_spread_link Response:", string(buff[:]))
|
|
//result := ApiResult{}
|
|
//err = json.Unmarshal(buff, &result)
|
|
//return result.Tag, err
|
|
return 0, nil
|
|
}
|
|
|
|
// 玩家透传API
|
|
func API_PlayerPass(snid int32, platform, channel, promoter, apiName, param, appId string, logicLvls []int32) (string, error) {
|
|
//params := make(map[string]string)
|
|
//if param != "" {
|
|
// cparam := make(map[string]interface{})
|
|
// err := json.Unmarshal([]byte(param), &cparam)
|
|
// if err == nil {
|
|
// for k, v := range cparam {
|
|
// switch v.(type) {
|
|
// case float64:
|
|
// params[k] = fmt.Sprintf("%v", int64(v.(float64)))
|
|
// default:
|
|
// params[k] = fmt.Sprintf("%v", v)
|
|
// }
|
|
// }
|
|
// }
|
|
//}
|
|
//params["snid"] = strconv.Itoa(int(snid))
|
|
//params["platform"] = platform
|
|
//params["channel"] = channel
|
|
//params["promoter"] = promoter
|
|
//params["ts"] = strconv.Itoa(int(time.Now().Unix()))
|
|
//buff, err := getRequest(appId, apiName, params, "http", DEFAULT_TIMEOUT)
|
|
//if err != nil {
|
|
// return "", err
|
|
//}
|
|
//return string(buff[:]), err
|
|
return "", nil
|
|
}
|
|
|
|
// 系统透传API
|
|
func API_SystemPass(apiName, param, cBData, appId string) (string, error) {
|
|
body := &webapi.SAWebAPISystemPass{
|
|
Params: param,
|
|
CBData: cBData,
|
|
Ts: time.Now().Unix(),
|
|
}
|
|
buff, err := postRequest(appId, apiName, nil, body, "http", DEFAULT_TIMEOUT)
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
ret := &webapi.ASWebAPISystemPass{}
|
|
err = proto.Unmarshal(buff, ret)
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
if ret.OpRetCode == 1 {
|
|
return "", errors.New(ret.ErrMsg)
|
|
}
|
|
return ret.Response, err
|
|
}
|
|
|
|
// 活动相关统一配置
|
|
func API_GetActConfig(appId string) ([]byte, error) {
|
|
//params := make(map[string]string)
|
|
//params["ts"] = strconv.Itoa(int(time.Now().Unix()))
|
|
//return getRequest(appId, "/active_act_config", params, "http", DEFAULT_TIMEOUT)
|
|
return nil, nil
|
|
}
|
|
|
|
// ApiGetInviteLink 获取邀请分享链接
|
|
func ApiGetInviteLink(appId string, body proto.Message) ([]byte, error) {
|
|
return postRequest(appId, "/get_invite_link", nil, body, "http", DEFAULT_TIMEOUT)
|
|
}
|