package webapi import ( "errors" "time" "mongo.games.com/goserver/core/logger" "mongo.games.com/game/model" "mongo.games.com/game/mq" "mongo.games.com/game/proto" "mongo.games.com/game/protocol/webapi" ) 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) } // 获取娃娃兑换记录 func API_DollExchangeRecord(appId string, body proto.Message) ([]byte, error) { return postRequest(appId, "/get_dollExchange_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, buyType int32) *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, BuyType: buyType, } 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 } mq.Write(model.GenerateActivityLog(SnId, platform, buyType, 0)) 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) } // 平台创建账号请求 type PlatfromCreateAccountReq struct { Username string `json:"username"` Channel string `json:"channel"` Nickname string `json:"nickname"` Avatar string `json:"avatar"` Timestamp string `json:"timestamp"` } // 平台登录返回 type PlatfromGameLoginRsp struct { Code int `json:"code"` Data struct { Url string `json:"url"` } `json:"data"` Message string `json:"message"` Success bool `json:"success"` } // 上分请求 type PlatfromUpScoreReq struct { Username string `json:"username"` Channel string `json:"channel"` Timestamp string `json:"timestamp"` Count string `json:"count"` TransferID string `json:"transferid"` } // 上分返回 type PlatfromUpScoreRsp struct { Code int `json:"code"` Data struct { Count int64 `json:"count"` TransferID string `json:"transferid"` } `json:"data"` Message string `json:"message"` Success bool `json:"success"` } // 下分请求 type PlatfromDownScoreReq struct { Username string `json:"username"` Channel string `json:"channel"` Timestamp string `json:"timestamp"` TransferID string `json:"transferid"` } // 下分返回 type PlatfromDownScoreRsp struct { Code int `json:"code"` Data struct { Money string `json:"money"` TransferID string `json:"transferid"` } `json:"data"` Message string `json:"message"` Success bool `json:"success"` } // 查询玩家游戏状态请求 type PlatfromPlayerStatusReq struct { Username string `json:"username"` Channel string `json:"channel"` Timestamp string `json:"timestamp"` } // 查询游戏状态返回 type PlatfromPlayerStatusRsp struct { Code int `json:"code"` Data struct { Money int64 `json:"money"` IsOnline bool `json:"isOnline"` } `json:"data"` Message string `json:"message"` Success bool `json:"success"` } // 查询玩家游戏状态请求 type PlatfromGamedetailReq struct { Channel string `json:"channel"` Timestamp string `json:"timestamp"` Start string `json:"start"` End string `json:"end"` } type PlatfromPlayerScoreInfo struct { Index string `json:"index"` //序号 SnId int32 `json:"snid"` //用户Id UserName string `json:"username"` // 账号 BeforeCount int64 `json:"beforecount"` //账号变化前数量 Count int64 `json:"count"` //帐变数量 RestCount int64 `json:"resetcount"` //余额 CoinAdd int64 `json:"coinadd"` //金币加成 BaseCoin int64 `json:"basecoin"` //底分 LogType int32 `json:"logtype"` //账变类型 Remark string `json:"remark"` //备注 GameEndTime string `json:"gameendtime"` //游戏结束时间 } // 查询游戏状态返回 type PlatfromGamedetaiRsp struct { Code int `json:"code"` Data struct { PlayersInfo []PlatfromPlayerScoreInfo `json:"playersinfo"` } `json:"data"` Message string `json:"message"` Success bool `json:"success"` }