兼容以0开头的手机号登录
This commit is contained in:
parent
23b44237d8
commit
9338164838
|
@ -126,6 +126,9 @@ func (svc *AccountSvc) AccountIsExist(args *model.AccIsExistArg, ret *model.AccR
|
||||||
acc.Tel = args.Tel
|
acc.Tel = args.Tel
|
||||||
caccounts.Update(bson.M{"_id": acc.AccountId}, bson.D{{"$set", bson.D{{"tel", args.Tel}}}})
|
caccounts.Update(bson.M{"_id": acc.AccountId}, bson.D{{"$set", bson.D{{"tel", args.Tel}}}})
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
ret.Tag = common.LoginNew
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -218,8 +218,8 @@ func (this *TienLenPlayerData) LeaveAutoState(s *base.Scene) {
|
||||||
// 能否用记牌器
|
// 能否用记牌器
|
||||||
func (this *TienLenPlayerData) CanUseRecordItem() bool {
|
func (this *TienLenPlayerData) CanUseRecordItem() bool {
|
||||||
itemData := srvdata.PBDB_GameItemMgr.GetData(common.ItemIDTienlenRecord)
|
itemData := srvdata.PBDB_GameItemMgr.GetData(common.ItemIDTienlenRecord)
|
||||||
if itemData != nil {
|
if itemData != nil && this.Items != nil {
|
||||||
if item, ok := this.Items[common.ItemIDTienlenRecord]; ok {
|
if item, ok := this.Items[common.ItemIDTienlenRecord]; ok && item != nil {
|
||||||
if item.ItemNum >= 1 && item.ExpireTime >= time.Now().Unix() {
|
if item.ItemNum >= 1 && item.ExpireTime >= time.Now().Unix() {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
|
@ -611,302 +611,302 @@ func _LeaveTransferThird2SystemTask(p *Player) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 进入三方
|
// 进入三方
|
||||||
type CSEnterThridGamePacketFactory struct {
|
//type CSEnterThridGamePacketFactory struct {
|
||||||
}
|
//}
|
||||||
type CSEnterThridGameHandler struct {
|
//type CSEnterThridGameHandler struct {
|
||||||
}
|
//}
|
||||||
|
|
||||||
func (this *CSEnterThridGamePacketFactory) CreatePacket() interface{} {
|
//func (this *CSEnterThridGamePacketFactory) CreatePacket() interface{} {
|
||||||
pack := &gamehall.CSEnterThridGame{}
|
// pack := &gamehall.CSEnterThridGame{}
|
||||||
return pack
|
// return pack
|
||||||
}
|
//}
|
||||||
|
|
||||||
func (this *CSEnterThridGameHandler) Process(s *netlib.Session, packetid int, data interface{}, sid int64) error {
|
//func (this *CSEnterThridGameHandler) Process(s *netlib.Session, packetid int, data interface{}, sid int64) error {
|
||||||
logger.Logger.Trace("CSEnterThridGameHandler Process recv ", data)
|
// logger.Logger.Trace("CSEnterThridGameHandler Process recv ", data)
|
||||||
p := PlayerMgrSington.GetPlayer(sid)
|
// p := PlayerMgrSington.GetPlayer(sid)
|
||||||
if p == nil {
|
// if p == nil {
|
||||||
logger.Logger.Warn("CSEnterThridGameHandler p == nil")
|
// logger.Logger.Warn("CSEnterThridGameHandler p == nil")
|
||||||
return nil
|
// return nil
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
// if msg, ok := data.(*gamehall.CSEnterThridGame); ok {
|
||||||
|
// // msg.ThridGameId = proto.Int32(9010001)
|
||||||
|
// returnErrorCodeFunc := func(code gamehall.OpResultCode_Game) {
|
||||||
|
// pack := &gamehall.SCEnterThridGame{}
|
||||||
|
// pack.OpRetCode = code
|
||||||
|
// pack.ThridGameId = msg.ThridGameId
|
||||||
|
// p.SendToClient(int(gamehall.GameHallPacketID_PACKET_SC_ENTERTHRIDGAME), pack)
|
||||||
|
// logger.Trace(pack)
|
||||||
|
// }
|
||||||
|
// //正在请求刷新余额中不能进入三方
|
||||||
|
// if p.thridBalanceRefreshReqing {
|
||||||
|
// logger.Logger.Warn("CSEnterThridGameHandler client req thridBalanceRefreshReqing", p.SnId)
|
||||||
|
// returnErrorCodeFunc(gamehall.OpResultCode_Game_OPRC_ThirdPltProcessing_Game)
|
||||||
|
// return nil
|
||||||
|
// }
|
||||||
|
// //msg.ThridGameId=proto.Int32(430010001)
|
||||||
|
//
|
||||||
|
// //找到对应的平台
|
||||||
|
// thridPltGameItem, plt := ThirdPltGameMappingConfig.FindThirdInfoBySystemGameId(msg.ThridGameId)
|
||||||
|
// if thridPltGameItem == nil || plt == nil {
|
||||||
|
// logger.Logger.Infof("Player %v no platform", p.SnId)
|
||||||
|
// returnErrorCodeFunc(gamehall.OpResultCode_Game_OPRC_RoomHadClosed_Game)
|
||||||
|
// return nil
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if p.thrscene != 0 && p.thrscene != plt.GetPlatformBase().BaseGameID {
|
||||||
|
// logger.Logger.Infof("Player %v in game.", p.SnId)
|
||||||
|
// returnErrorCodeFunc(gamehall.OpResultCode_Game_OPRC_ThirdPltProcessing_Game)
|
||||||
|
// return nil
|
||||||
|
// }
|
||||||
|
// if p.isDelete {
|
||||||
|
// returnErrorCodeFunc(gamehall.OpResultCode_Game_OPRC_RoomHadClosed_Game)
|
||||||
|
// return nil
|
||||||
|
// }
|
||||||
|
// //pt := PlatformMgrSingleton.GetPackageTag(p.PackageID)
|
||||||
|
// //if pt != nil && pt.IsForceBind == 1 {
|
||||||
|
// // if p.BeUnderAgentCode == "" || p.BeUnderAgentCode == "0" {
|
||||||
|
// // returnErrorCodeFunc(gamehall.OpResultCode_Game_OPRC_MustBindPromoter_Game)
|
||||||
|
// // return nil
|
||||||
|
// // }
|
||||||
|
// //}
|
||||||
|
//
|
||||||
|
// //检测房间状态是否开启
|
||||||
|
// gps := PlatformMgrSingleton.GetGameFree(p.Platform, msg.GetThridGameId())
|
||||||
|
// if gps == nil {
|
||||||
|
// logger.Logger.Infof("Player %v no cfg room close", p.SnId)
|
||||||
|
//
|
||||||
|
// returnErrorCodeFunc(gamehall.OpResultCode_Game_OPRC_RoomHadClosed_Game)
|
||||||
|
// return nil
|
||||||
|
// }
|
||||||
|
// dbGameFree := gps.DbGameFree
|
||||||
|
// if dbGameFree == nil {
|
||||||
|
// logger.Logger.Infof("Player %v no gamefree", p.SnId)
|
||||||
|
// returnErrorCodeFunc(gamehall.OpResultCode_Game_OPRC_RoomHadClosed_Game)
|
||||||
|
// return nil
|
||||||
|
// }
|
||||||
|
// pfConfig := PlatformMgrSingleton.GetPlatform(p.Platform)
|
||||||
|
// if pfConfig == nil || pfConfig.ThirdGameMerchant == nil || pfConfig.ThirdGameMerchant[int32(plt.GetPlatformBase().BaseGameID)] == 0 {
|
||||||
|
// logger.Logger.Infof("Player %v no pfcfg", p.SnId)
|
||||||
|
//
|
||||||
|
// // returnErrorCodeFunc(gamehall.OpResultCode_Game_OPRC_RoomHadClosed_Game)
|
||||||
|
// // return nil
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// //检查限额,金额不足
|
||||||
|
// if dbGameFree.GetLimitCoin() != 0 && p.GetCoin() < int64(dbGameFree.GetLimitCoin()) {
|
||||||
|
// returnErrorCodeFunc(gamehall.OpResultCode_Game_OPRC_CoinNotEnough_Game)
|
||||||
|
// return nil
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// //检查平台配额是否足够
|
||||||
|
// /*if plt.GetPlatformBase().IsNeedCheckQuota {
|
||||||
|
// dgQuota := ThirdPlatformMgrSington.GetThirdPlatformCoin(p.Platform, plt.GetPlatformBase().Tag)
|
||||||
|
// if dgQuota <= 0 || dgQuota <= p.GetCoin() {
|
||||||
|
// logger.Logger.Infof("Player snid %v %v platfrom Quota of game not enough.", p.SnId, plt.GetPlatformBase().Name)
|
||||||
|
// returnErrorCodeFunc(gamehall.OpResultCode_Game_OPRC_Dg_QuotaNotEnough_Game)
|
||||||
|
// return nil
|
||||||
|
// }
|
||||||
|
// }*/
|
||||||
|
//
|
||||||
|
// //检查场景是否开放或者存在,预设数据
|
||||||
|
// //scene := SceneMgrSingleton.GetThirdScene(plt)
|
||||||
|
// //if scene != nil {
|
||||||
|
// p.thrscene = plt.GetPlatformBase().BaseGameID
|
||||||
|
// //检查场景是否开放或者存在,预设数据
|
||||||
|
// scene := SceneMgrSingleton.GetThirdScene(plt) //仅用于占位
|
||||||
|
// if scene != nil {
|
||||||
|
// p.scene = scene
|
||||||
|
// }
|
||||||
|
// //} else {
|
||||||
|
// // logger.Logger.Infof("Player %v no scene", p.SnId)
|
||||||
|
//
|
||||||
|
// // returnErrorCodeFunc(gamehall.OpResultCode_Game_OPRC_RoomHadClosed_Game)
|
||||||
|
// // return nil
|
||||||
|
// //}
|
||||||
|
//
|
||||||
|
// AskEnterThridGame(p, plt, thridPltGameItem, s)
|
||||||
|
// }
|
||||||
|
// return nil
|
||||||
|
//}
|
||||||
|
//func AskEnterThridGame(p *Player, plt webapi.IThirdPlatform, thridPltGameItem *server.DB_ThirdPlatformGameMapping,
|
||||||
|
// s *netlib.Session) {
|
||||||
|
// pack := &gamehall.SCEnterThridGame{}
|
||||||
|
// pack.ThridGameId = thridPltGameItem.SystemGameID
|
||||||
|
// amount := p.GetCoin()
|
||||||
|
// if plt.GetPlatformBase().TransferInteger {
|
||||||
|
// amount = (amount / 100) * 100
|
||||||
|
// }
|
||||||
|
// p.Coin = p.GetCoin() - amount
|
||||||
|
// gainway := common.GainWay_Transfer_System2Thrid
|
||||||
|
// oper := "System2" + plt.GetPlatformBase().Name
|
||||||
|
// timeStamp := time.Now().UnixNano()
|
||||||
|
// p.thridBalanceRefreshReqing = true
|
||||||
|
// transferTimeOut := false
|
||||||
|
// task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} {
|
||||||
|
// var err error
|
||||||
|
// //var ok bool
|
||||||
|
// url := ""
|
||||||
|
// remark := "转入" + plt.GetPlatformBase().Name + thridPltGameItem.GetDesc()
|
||||||
|
// //thridPlatformCoin := int64(0)
|
||||||
|
// var coinLog *model.PayCoinLog
|
||||||
|
// var coinlogex *model.CoinLog
|
||||||
|
// /*err = ensureThridPltUserName(plt, p, amount, s.RemoteAddr())
|
||||||
|
// if err != nil && err != webapi.ErrNoCreated {
|
||||||
|
// goto Rollback
|
||||||
|
// }*/
|
||||||
|
// //ok = utils.RunPanicless(func() {
|
||||||
|
// err, url = enterThridPltUserName(plt, p, amount, thridPltGameItem.GetThirdGameID(), s.RemoteAddr())
|
||||||
|
// //err, url = plt.ReqEnterGame(p.SnId, thridGameId, s.RemoteAddr(), p.Platform, p.Channel, p.Ip)
|
||||||
|
// //})
|
||||||
|
// if err == webapi.ErrRequestTimeout { // 超时
|
||||||
|
// transferTimeOut = true
|
||||||
|
// }
|
||||||
|
// //ok = true
|
||||||
|
// if err != nil && !transferTimeOut {
|
||||||
|
// logger.Logger.Errorf("plt.ReqEnterGame() snid:%v error: %v", p.SnId, err)
|
||||||
|
// if thrErr, ok := err.(webapi.ThirdError); ok {
|
||||||
|
// if thrErr.IsClose() {
|
||||||
|
// pack.OpRetCode = gamehall.OpResultCode_Game_OPRC_Thr_GameClose_Game
|
||||||
|
// } else {
|
||||||
|
// pack.OpRetCode = gamehall.OpResultCode_Game_OPRC_Error_Game
|
||||||
|
// }
|
||||||
|
// } else {
|
||||||
|
// pack.OpRetCode = gamehall.OpResultCode_Game_OPRC_Error_Game
|
||||||
|
// }
|
||||||
|
// goto Rollback
|
||||||
|
// }
|
||||||
|
// coinLog = model.NewPayCoinLog(timeStamp, int32(p.SnId), -amount, int32(gainway), oper, model.PayCoinLogType_Coin, 0)
|
||||||
|
// timeStamp = coinLog.TimeStamp
|
||||||
|
// err = model.InsertPayCoinLogs(p.Platform, coinLog)
|
||||||
|
// if err != nil {
|
||||||
|
// goto Rollback
|
||||||
|
// }
|
||||||
|
// coinlogex = model.NewCoinLogEx(&model.CoinLogParam{
|
||||||
|
// Platform: p.Platform,
|
||||||
|
// SnID: p.SnId,
|
||||||
|
// ChangeType: common.BillTypeCoin,
|
||||||
|
// ChangeNum: -amount,
|
||||||
|
// RemainNum: p.Coin,
|
||||||
|
// Add: 0,
|
||||||
|
// LogType: int32(gainway),
|
||||||
|
// GameID: 0,
|
||||||
|
// GameFreeID: 0,
|
||||||
|
// BaseCoin: 0,
|
||||||
|
// Operator: oper,
|
||||||
|
// Remark: remark,
|
||||||
|
// })
|
||||||
|
// err = model.InsertCoinLog(coinlogex)
|
||||||
|
// if err != nil {
|
||||||
|
// goto Rollback
|
||||||
|
// }
|
||||||
|
// //
|
||||||
|
// //err, transferTimeOut = plt.ReqTransfer(p.SnId, amount, strconv.FormatInt(timeStamp, 10), p.Platform, p.Channel, p.Ip)
|
||||||
|
// if transferTimeOut {
|
||||||
|
// logger.Logger.Errorf("plt.ReqTransfer() snid:%v error:%v", p.SnId, err)
|
||||||
|
// pack.OpRetCode = gamehall.OpResultCode_Game_OPRC_Error_Game
|
||||||
|
// goto Rollback
|
||||||
|
// }
|
||||||
|
// pack.OpRetCode = gamehall.OpResultCode_Game_OPRC_Sucess_Game
|
||||||
|
// pack.ScreenOrientationType = proto.Int32(thridPltGameItem.GetScreenOrientationType())
|
||||||
|
// pack.EnterUrl = proto.String(url)
|
||||||
|
// return nil
|
||||||
|
// Rollback:
|
||||||
|
// pack.OpRetCode = gamehall.OpResultCode_Game_OPRC_Error_Game
|
||||||
|
// if coinLog != nil {
|
||||||
|
// model.RemovePayCoinLog(p.Platform, coinLog.LogId)
|
||||||
|
// }
|
||||||
|
// if coinlogex != nil {
|
||||||
|
// if transferTimeOut {
|
||||||
|
// err2 := model.UpdateCoinLogRemark(coinlogex.Platform, coinlogex.LogId, plt.GetPlatformBase().Name+"需人工处理")
|
||||||
|
// if err2 != nil {
|
||||||
|
// logger.Logger.Errorf("thr UpdateCoinLogRemark(%v) error: %v", coinlogex.LogId, err2)
|
||||||
|
// }
|
||||||
|
// } else {
|
||||||
|
// model.RemoveCoinLogOne(coinlogex.Platform, coinlogex.LogId)
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
// return errors.New("system->third transfer rollback!")
|
||||||
|
// }), task.CompleteNotifyWrapper(func(data interface{}, tt task.Task) {
|
||||||
|
// if pack.GetOpRetCode() == gamehall.OpResultCode_Game_OPRC_Sucess_Game {
|
||||||
|
// // ThirdPlatformMgrSington.AddThirdPlatformCoin(p.Platform, plt.GetPlatformBase().Tag, -amount)
|
||||||
|
// p.SetPayTs(timeStamp)
|
||||||
|
// } else {
|
||||||
|
// //如帐变出现问题,就在日志里面查下面的输出信息!!!
|
||||||
|
// //如果转账超时,三方的转账是否成功就是未知的,这时不能将金币再加到玩家身上。
|
||||||
|
// //如果出现超时问题,就需要人工对账。
|
||||||
|
// //注意:这个地方说的超时已经包含CG工程Check订单后的超时
|
||||||
|
// if transferTimeOut {
|
||||||
|
// logger.Logger.Errorf("CSEnterThridGameHandler player snid:%v transfer %v to %v timeout:", p.SnId, amount, plt.GetPlatformBase().Name)
|
||||||
|
// } else {
|
||||||
|
// p.Coin += amount
|
||||||
|
// }
|
||||||
|
// p.thrscene = 0
|
||||||
|
// pack.OpRetCode = gamehall.OpResultCode_Game_OPRC_Error_Game
|
||||||
|
// logger.Logger.Trace("enterThridPltUserName system->third transfer error:", data)
|
||||||
|
// }
|
||||||
|
// p.dirty = true
|
||||||
|
// p.thirdBalanceRefreshMark[plt.GetPlatformBase().Name] = false
|
||||||
|
//
|
||||||
|
// p.SendDiffData()
|
||||||
|
// p.SendToClient(int(gamehall.GameHallPacketID_PACKET_SC_ENTERTHRIDGAME), pack)
|
||||||
|
// p.thridBalanceRefreshReqing = false
|
||||||
|
// logger.Logger.Trace("CSEnterThridGameHandler send client:", pack)
|
||||||
|
// return
|
||||||
|
// }), "CSEnterThridGameHandler").Start()
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//func ensureThridPltUserName(pltform webapi.IThirdPlatform, p *Player, amount int64, ip string) error {
|
||||||
|
// var err error
|
||||||
|
// err = pltform.ReqCreateAccount(p.SnId, p.Platform, p.Channel, p.GetIP())
|
||||||
|
// if err != nil {
|
||||||
|
// if err != webapi.ErrNoCreated {
|
||||||
|
// logger.Logger.Errorf("Snid=%v Plt=%v ReqCreateAccount error:%v", p.SnId, pltform.GetPlatformBase().Name, err)
|
||||||
|
// }
|
||||||
|
// return err
|
||||||
|
// }
|
||||||
|
// return nil
|
||||||
|
//}
|
||||||
|
|
||||||
if msg, ok := data.(*gamehall.CSEnterThridGame); ok {
|
//func enterThridPltUserName(pltform webapi.IThirdPlatform, p *Player, amount int64, gameId, ip string) (err error, url string) {
|
||||||
// msg.ThridGameId = proto.Int32(9010001)
|
// // (snId int32, gameId string, clientIP string, platform, channel string, amount int64)
|
||||||
returnErrorCodeFunc := func(code gamehall.OpResultCode_Game) {
|
// err, url = pltform.ReqEnterGame(p.SnId, "", p.GetIP(), p.Platform, p.Channel, amount)
|
||||||
pack := &gamehall.SCEnterThridGame{}
|
// if err != nil {
|
||||||
pack.OpRetCode = code
|
// if err != webapi.ErrNoCreated {
|
||||||
pack.ThridGameId = msg.ThridGameId
|
// logger.Logger.Errorf("Snid=%v Plt=%v ReqEnterGame error:%v", p.SnId, pltform.GetPlatformBase().Name, err)
|
||||||
p.SendToClient(int(gamehall.GameHallPacketID_PACKET_SC_ENTERTHRIDGAME), pack)
|
// }
|
||||||
logger.Trace(pack)
|
// return err, ""
|
||||||
}
|
// }
|
||||||
//正在请求刷新余额中不能进入三方
|
// return
|
||||||
if p.thridBalanceRefreshReqing {
|
//}
|
||||||
logger.Logger.Warn("CSEnterThridGameHandler client req thridBalanceRefreshReqing", p.SnId)
|
|
||||||
returnErrorCodeFunc(gamehall.OpResultCode_Game_OPRC_ThirdPltProcessing_Game)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
//msg.ThridGameId=proto.Int32(430010001)
|
|
||||||
|
|
||||||
//找到对应的平台
|
|
||||||
thridPltGameItem, plt := ThirdPltGameMappingConfig.FindThirdInfoBySystemGameId(msg.ThridGameId)
|
|
||||||
if thridPltGameItem == nil || plt == nil {
|
|
||||||
logger.Logger.Infof("Player %v no platform", p.SnId)
|
|
||||||
returnErrorCodeFunc(gamehall.OpResultCode_Game_OPRC_RoomHadClosed_Game)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
if p.thrscene != 0 && p.thrscene != plt.GetPlatformBase().BaseGameID {
|
|
||||||
logger.Logger.Infof("Player %v in game.", p.SnId)
|
|
||||||
returnErrorCodeFunc(gamehall.OpResultCode_Game_OPRC_ThirdPltProcessing_Game)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
if p.isDelete {
|
|
||||||
returnErrorCodeFunc(gamehall.OpResultCode_Game_OPRC_RoomHadClosed_Game)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
//pt := PlatformMgrSingleton.GetPackageTag(p.PackageID)
|
|
||||||
//if pt != nil && pt.IsForceBind == 1 {
|
|
||||||
// if p.BeUnderAgentCode == "" || p.BeUnderAgentCode == "0" {
|
|
||||||
// returnErrorCodeFunc(gamehall.OpResultCode_Game_OPRC_MustBindPromoter_Game)
|
|
||||||
// return nil
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
//检测房间状态是否开启
|
|
||||||
gps := PlatformMgrSingleton.GetGameFree(p.Platform, msg.GetThridGameId())
|
|
||||||
if gps == nil {
|
|
||||||
logger.Logger.Infof("Player %v no cfg room close", p.SnId)
|
|
||||||
|
|
||||||
returnErrorCodeFunc(gamehall.OpResultCode_Game_OPRC_RoomHadClosed_Game)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
dbGameFree := gps.DbGameFree
|
|
||||||
if dbGameFree == nil {
|
|
||||||
logger.Logger.Infof("Player %v no gamefree", p.SnId)
|
|
||||||
returnErrorCodeFunc(gamehall.OpResultCode_Game_OPRC_RoomHadClosed_Game)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
pfConfig := PlatformMgrSingleton.GetPlatform(p.Platform)
|
|
||||||
if pfConfig == nil || pfConfig.ThirdGameMerchant == nil || pfConfig.ThirdGameMerchant[int32(plt.GetPlatformBase().BaseGameID)] == 0 {
|
|
||||||
logger.Logger.Infof("Player %v no pfcfg", p.SnId)
|
|
||||||
|
|
||||||
// returnErrorCodeFunc(gamehall.OpResultCode_Game_OPRC_RoomHadClosed_Game)
|
|
||||||
// return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
//检查限额,金额不足
|
|
||||||
if dbGameFree.GetLimitCoin() != 0 && p.GetCoin() < int64(dbGameFree.GetLimitCoin()) {
|
|
||||||
returnErrorCodeFunc(gamehall.OpResultCode_Game_OPRC_CoinNotEnough_Game)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
//检查平台配额是否足够
|
|
||||||
/*if plt.GetPlatformBase().IsNeedCheckQuota {
|
|
||||||
dgQuota := ThirdPlatformMgrSington.GetThirdPlatformCoin(p.Platform, plt.GetPlatformBase().Tag)
|
|
||||||
if dgQuota <= 0 || dgQuota <= p.GetCoin() {
|
|
||||||
logger.Logger.Infof("Player snid %v %v platfrom Quota of game not enough.", p.SnId, plt.GetPlatformBase().Name)
|
|
||||||
returnErrorCodeFunc(gamehall.OpResultCode_Game_OPRC_Dg_QuotaNotEnough_Game)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
//检查场景是否开放或者存在,预设数据
|
|
||||||
//scene := SceneMgrSingleton.GetThirdScene(plt)
|
|
||||||
//if scene != nil {
|
|
||||||
p.thrscene = plt.GetPlatformBase().BaseGameID
|
|
||||||
//检查场景是否开放或者存在,预设数据
|
|
||||||
scene := SceneMgrSingleton.GetThirdScene(plt) //仅用于占位
|
|
||||||
if scene != nil {
|
|
||||||
p.scene = scene
|
|
||||||
}
|
|
||||||
//} else {
|
|
||||||
// logger.Logger.Infof("Player %v no scene", p.SnId)
|
|
||||||
|
|
||||||
// returnErrorCodeFunc(gamehall.OpResultCode_Game_OPRC_RoomHadClosed_Game)
|
|
||||||
// return nil
|
|
||||||
//}
|
|
||||||
|
|
||||||
AskEnterThridGame(p, plt, thridPltGameItem, s)
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
func AskEnterThridGame(p *Player, plt webapi.IThirdPlatform, thridPltGameItem *server.DB_ThirdPlatformGameMapping,
|
|
||||||
s *netlib.Session) {
|
|
||||||
pack := &gamehall.SCEnterThridGame{}
|
|
||||||
pack.ThridGameId = thridPltGameItem.SystemGameID
|
|
||||||
amount := p.GetCoin()
|
|
||||||
if plt.GetPlatformBase().TransferInteger {
|
|
||||||
amount = (amount / 100) * 100
|
|
||||||
}
|
|
||||||
p.Coin = p.GetCoin() - amount
|
|
||||||
gainway := common.GainWay_Transfer_System2Thrid
|
|
||||||
oper := "System2" + plt.GetPlatformBase().Name
|
|
||||||
timeStamp := time.Now().UnixNano()
|
|
||||||
p.thridBalanceRefreshReqing = true
|
|
||||||
transferTimeOut := false
|
|
||||||
task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} {
|
|
||||||
var err error
|
|
||||||
//var ok bool
|
|
||||||
url := ""
|
|
||||||
remark := "转入" + plt.GetPlatformBase().Name + thridPltGameItem.GetDesc()
|
|
||||||
//thridPlatformCoin := int64(0)
|
|
||||||
var coinLog *model.PayCoinLog
|
|
||||||
var coinlogex *model.CoinLog
|
|
||||||
/*err = ensureThridPltUserName(plt, p, amount, s.RemoteAddr())
|
|
||||||
if err != nil && err != webapi.ErrNoCreated {
|
|
||||||
goto Rollback
|
|
||||||
}*/
|
|
||||||
//ok = utils.RunPanicless(func() {
|
|
||||||
err, url = enterThridPltUserName(plt, p, amount, thridPltGameItem.GetThirdGameID(), s.RemoteAddr())
|
|
||||||
//err, url = plt.ReqEnterGame(p.SnId, thridGameId, s.RemoteAddr(), p.Platform, p.Channel, p.Ip)
|
|
||||||
//})
|
|
||||||
if err == webapi.ErrRequestTimeout { // 超时
|
|
||||||
transferTimeOut = true
|
|
||||||
}
|
|
||||||
//ok = true
|
|
||||||
if err != nil && !transferTimeOut {
|
|
||||||
logger.Logger.Errorf("plt.ReqEnterGame() snid:%v error: %v", p.SnId, err)
|
|
||||||
if thrErr, ok := err.(webapi.ThirdError); ok {
|
|
||||||
if thrErr.IsClose() {
|
|
||||||
pack.OpRetCode = gamehall.OpResultCode_Game_OPRC_Thr_GameClose_Game
|
|
||||||
} else {
|
|
||||||
pack.OpRetCode = gamehall.OpResultCode_Game_OPRC_Error_Game
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
pack.OpRetCode = gamehall.OpResultCode_Game_OPRC_Error_Game
|
|
||||||
}
|
|
||||||
goto Rollback
|
|
||||||
}
|
|
||||||
coinLog = model.NewPayCoinLog(timeStamp, int32(p.SnId), -amount, int32(gainway), oper, model.PayCoinLogType_Coin, 0)
|
|
||||||
timeStamp = coinLog.TimeStamp
|
|
||||||
err = model.InsertPayCoinLogs(p.Platform, coinLog)
|
|
||||||
if err != nil {
|
|
||||||
goto Rollback
|
|
||||||
}
|
|
||||||
coinlogex = model.NewCoinLogEx(&model.CoinLogParam{
|
|
||||||
Platform: p.Platform,
|
|
||||||
SnID: p.SnId,
|
|
||||||
ChangeType: common.BillTypeCoin,
|
|
||||||
ChangeNum: -amount,
|
|
||||||
RemainNum: p.Coin,
|
|
||||||
Add: 0,
|
|
||||||
LogType: int32(gainway),
|
|
||||||
GameID: 0,
|
|
||||||
GameFreeID: 0,
|
|
||||||
BaseCoin: 0,
|
|
||||||
Operator: oper,
|
|
||||||
Remark: remark,
|
|
||||||
})
|
|
||||||
err = model.InsertCoinLog(coinlogex)
|
|
||||||
if err != nil {
|
|
||||||
goto Rollback
|
|
||||||
}
|
|
||||||
//
|
|
||||||
//err, transferTimeOut = plt.ReqTransfer(p.SnId, amount, strconv.FormatInt(timeStamp, 10), p.Platform, p.Channel, p.Ip)
|
|
||||||
if transferTimeOut {
|
|
||||||
logger.Logger.Errorf("plt.ReqTransfer() snid:%v error:%v", p.SnId, err)
|
|
||||||
pack.OpRetCode = gamehall.OpResultCode_Game_OPRC_Error_Game
|
|
||||||
goto Rollback
|
|
||||||
}
|
|
||||||
pack.OpRetCode = gamehall.OpResultCode_Game_OPRC_Sucess_Game
|
|
||||||
pack.ScreenOrientationType = proto.Int32(thridPltGameItem.GetScreenOrientationType())
|
|
||||||
pack.EnterUrl = proto.String(url)
|
|
||||||
return nil
|
|
||||||
Rollback:
|
|
||||||
pack.OpRetCode = gamehall.OpResultCode_Game_OPRC_Error_Game
|
|
||||||
if coinLog != nil {
|
|
||||||
model.RemovePayCoinLog(p.Platform, coinLog.LogId)
|
|
||||||
}
|
|
||||||
if coinlogex != nil {
|
|
||||||
if transferTimeOut {
|
|
||||||
err2 := model.UpdateCoinLogRemark(coinlogex.Platform, coinlogex.LogId, plt.GetPlatformBase().Name+"需人工处理")
|
|
||||||
if err2 != nil {
|
|
||||||
logger.Logger.Errorf("thr UpdateCoinLogRemark(%v) error: %v", coinlogex.LogId, err2)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
model.RemoveCoinLogOne(coinlogex.Platform, coinlogex.LogId)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
return errors.New("system->third transfer rollback!")
|
|
||||||
}), task.CompleteNotifyWrapper(func(data interface{}, tt task.Task) {
|
|
||||||
if pack.GetOpRetCode() == gamehall.OpResultCode_Game_OPRC_Sucess_Game {
|
|
||||||
// ThirdPlatformMgrSington.AddThirdPlatformCoin(p.Platform, plt.GetPlatformBase().Tag, -amount)
|
|
||||||
p.SetPayTs(timeStamp)
|
|
||||||
} else {
|
|
||||||
//如帐变出现问题,就在日志里面查下面的输出信息!!!
|
|
||||||
//如果转账超时,三方的转账是否成功就是未知的,这时不能将金币再加到玩家身上。
|
|
||||||
//如果出现超时问题,就需要人工对账。
|
|
||||||
//注意:这个地方说的超时已经包含CG工程Check订单后的超时
|
|
||||||
if transferTimeOut {
|
|
||||||
logger.Logger.Errorf("CSEnterThridGameHandler player snid:%v transfer %v to %v timeout:", p.SnId, amount, plt.GetPlatformBase().Name)
|
|
||||||
} else {
|
|
||||||
p.Coin += amount
|
|
||||||
}
|
|
||||||
p.thrscene = 0
|
|
||||||
pack.OpRetCode = gamehall.OpResultCode_Game_OPRC_Error_Game
|
|
||||||
logger.Logger.Trace("enterThridPltUserName system->third transfer error:", data)
|
|
||||||
}
|
|
||||||
p.dirty = true
|
|
||||||
p.thirdBalanceRefreshMark[plt.GetPlatformBase().Name] = false
|
|
||||||
|
|
||||||
p.SendDiffData()
|
|
||||||
p.SendToClient(int(gamehall.GameHallPacketID_PACKET_SC_ENTERTHRIDGAME), pack)
|
|
||||||
p.thridBalanceRefreshReqing = false
|
|
||||||
logger.Logger.Trace("CSEnterThridGameHandler send client:", pack)
|
|
||||||
return
|
|
||||||
}), "CSEnterThridGameHandler").Start()
|
|
||||||
}
|
|
||||||
|
|
||||||
func ensureThridPltUserName(pltform webapi.IThirdPlatform, p *Player, amount int64, ip string) error {
|
|
||||||
var err error
|
|
||||||
err = pltform.ReqCreateAccount(p.SnId, p.Platform, p.Channel, p.GetIP())
|
|
||||||
if err != nil {
|
|
||||||
if err != webapi.ErrNoCreated {
|
|
||||||
logger.Logger.Errorf("Snid=%v Plt=%v ReqCreateAccount error:%v", p.SnId, pltform.GetPlatformBase().Name, err)
|
|
||||||
}
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func enterThridPltUserName(pltform webapi.IThirdPlatform, p *Player, amount int64, gameId, ip string) (err error, url string) {
|
|
||||||
// (snId int32, gameId string, clientIP string, platform, channel string, amount int64)
|
|
||||||
err, url = pltform.ReqEnterGame(p.SnId, "", p.GetIP(), p.Platform, p.Channel, amount)
|
|
||||||
if err != nil {
|
|
||||||
if err != webapi.ErrNoCreated {
|
|
||||||
logger.Logger.Errorf("Snid=%v Plt=%v ReqEnterGame error:%v", p.SnId, pltform.GetPlatformBase().Name, err)
|
|
||||||
}
|
|
||||||
return err, ""
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// 离开三方
|
// 离开三方
|
||||||
type CSLeaveThridGamePacketFactory struct {
|
//type CSLeaveThridGamePacketFactory struct {
|
||||||
}
|
//}
|
||||||
type CSLeaveThridGameHandler struct {
|
//type CSLeaveThridGameHandler struct {
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
func (this *CSLeaveThridGamePacketFactory) CreatePacket() interface{} {
|
//func (this *CSLeaveThridGamePacketFactory) CreatePacket() interface{} {
|
||||||
pack := &gamehall.CSLeaveThridGame{}
|
// pack := &gamehall.CSLeaveThridGame{}
|
||||||
return pack
|
// return pack
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
func (this *CSLeaveThridGameHandler) Process(s *netlib.Session, packetid int, data interface{}, sid int64) error {
|
//func (this *CSLeaveThridGameHandler) Process(s *netlib.Session, packetid int, data interface{}, sid int64) error {
|
||||||
if _, ok := data.(*gamehall.CSLeaveThridGame); ok {
|
// if _, ok := data.(*gamehall.CSLeaveThridGame); ok {
|
||||||
p := PlayerMgrSington.GetPlayer(sid)
|
// p := PlayerMgrSington.GetPlayer(sid)
|
||||||
if p == nil {
|
// if p == nil {
|
||||||
logger.Logger.Warn("CSLeaveThridGameHandler p == nil")
|
// logger.Logger.Warn("CSLeaveThridGameHandler p == nil")
|
||||||
return nil
|
// return nil
|
||||||
}
|
// }
|
||||||
logger.Logger.Trace("CSLeaveThridGameHandler Process recv ", p.SnId)
|
// logger.Logger.Trace("CSLeaveThridGameHandler Process recv ", p.SnId)
|
||||||
_LeaveTransferThird2SystemTask(p)
|
// _LeaveTransferThird2SystemTask(p)
|
||||||
pack := &gamehall.SCLeaveThridGame{}
|
// pack := &gamehall.SCLeaveThridGame{}
|
||||||
pack.OpRetCode = gamehall.OpResultCode_Game_OPRC_Sucess_Game
|
// pack.OpRetCode = gamehall.OpResultCode_Game_OPRC_Sucess_Game
|
||||||
p.SendToClient(int(gamehall.GameHallPacketID_PACKET_SC_LEAVETHRIDGAME), pack)
|
// p.SendToClient(int(gamehall.GameHallPacketID_PACKET_SC_LEAVETHRIDGAME), pack)
|
||||||
}
|
// }
|
||||||
return nil
|
// return nil
|
||||||
}
|
//}
|
||||||
|
|
||||||
// 刷新
|
// 刷新
|
||||||
type CSThridBalanceRefreshPacketFactory struct {
|
type CSThridBalanceRefreshPacketFactory struct {
|
||||||
|
@ -2239,17 +2239,17 @@ func init() {
|
||||||
common.RegisterHandler(int(player.PlayerPacketID_PACKET_CS_GETDATALOG), &CSGetDataLogHandler{})
|
common.RegisterHandler(int(player.PlayerPacketID_PACKET_CS_GETDATALOG), &CSGetDataLogHandler{})
|
||||||
netlib.RegisterFactory(int(player.PlayerPacketID_PACKET_CS_GETDATALOG), &CSGetDataLogPacketFactory{})
|
netlib.RegisterFactory(int(player.PlayerPacketID_PACKET_CS_GETDATALOG), &CSGetDataLogPacketFactory{})
|
||||||
|
|
||||||
common.RegisterHandler(int(gamehall.GameHallPacketID_PACKET_CS_ENTERTHRIDGAME), &CSEnterThridGameHandler{})
|
//common.RegisterHandler(int(gamehall.GameHallPacketID_PACKET_CS_ENTERTHRIDGAME), &CSEnterThridGameHandler{})
|
||||||
netlib.RegisterFactory(int(gamehall.GameHallPacketID_PACKET_CS_ENTERTHRIDGAME), &CSEnterThridGamePacketFactory{})
|
//netlib.RegisterFactory(int(gamehall.GameHallPacketID_PACKET_CS_ENTERTHRIDGAME), &CSEnterThridGamePacketFactory{})
|
||||||
|
|
||||||
common.RegisterHandler(int(gamehall.GameHallPacketID_PACKET_CS_LEAVETHRIDGAME), &CSLeaveThridGameHandler{})
|
//common.RegisterHandler(int(gamehall.GameHallPacketID_PACKET_CS_LEAVETHRIDGAME), &CSLeaveThridGameHandler{})
|
||||||
netlib.RegisterFactory(int(gamehall.GameHallPacketID_PACKET_CS_LEAVETHRIDGAME), &CSLeaveThridGamePacketFactory{})
|
//netlib.RegisterFactory(int(gamehall.GameHallPacketID_PACKET_CS_LEAVETHRIDGAME), &CSLeaveThridGamePacketFactory{})
|
||||||
|
|
||||||
common.RegisterHandler(int(gamehall.GameHallPacketID_PACKET_CS_THRIDGAMEBALANCEUPDATE), &CSThridBalanceRefreshHandler{})
|
//common.RegisterHandler(int(gamehall.GameHallPacketID_PACKET_CS_THRIDGAMEBALANCEUPDATE), &CSThridBalanceRefreshHandler{})
|
||||||
netlib.RegisterFactory(int(gamehall.GameHallPacketID_PACKET_CS_THRIDGAMEBALANCEUPDATE), &CSThridBalanceRefreshPacketFactory{})
|
//netlib.RegisterFactory(int(gamehall.GameHallPacketID_PACKET_CS_THRIDGAMEBALANCEUPDATE), &CSThridBalanceRefreshPacketFactory{})
|
||||||
|
|
||||||
common.RegisterHandler(int(gamehall.GameHallPacketID_PACKET_CS_GETPRIVATEROOMHISTORY), &CSGetPrivateRoomHistoryHandler{})
|
//common.RegisterHandler(int(gamehall.GameHallPacketID_PACKET_CS_GETPRIVATEROOMHISTORY), &CSGetPrivateRoomHistoryHandler{})
|
||||||
netlib.RegisterFactory(int(gamehall.GameHallPacketID_PACKET_CS_GETPRIVATEROOMHISTORY), &CSGetPrivateRoomHistoryPacketFactory{})
|
//netlib.RegisterFactory(int(gamehall.GameHallPacketID_PACKET_CS_GETPRIVATEROOMHISTORY), &CSGetPrivateRoomHistoryPacketFactory{})
|
||||||
|
|
||||||
common.RegisterHandler(int(gamehall.GameHallPacketID_PACKET_CS_LOTTERYLOG), &CSLotteryLogHandler{})
|
common.RegisterHandler(int(gamehall.GameHallPacketID_PACKET_CS_LOTTERYLOG), &CSLotteryLogHandler{})
|
||||||
netlib.RegisterFactory(int(gamehall.GameHallPacketID_PACKET_CS_LOTTERYLOG), &CSLotteryLogPacketFactory{})
|
netlib.RegisterFactory(int(gamehall.GameHallPacketID_PACKET_CS_LOTTERYLOG), &CSLotteryLogPacketFactory{})
|
||||||
|
|
Loading…
Reference in New Issue