add 添加订单号
This commit is contained in:
parent
5614a844b6
commit
fec3f97533
|
@ -34,6 +34,7 @@ func CoinLogsCollection(plt string) *mongo.Collection {
|
||||||
c_coinlogrec.EnsureIndex(mgo.Index{Key: []string{"ts"}, Background: true, Sparse: true})
|
c_coinlogrec.EnsureIndex(mgo.Index{Key: []string{"ts"}, Background: true, Sparse: true})
|
||||||
c_coinlogrec.EnsureIndex(mgo.Index{Key: []string{"channel"}, Background: true, Sparse: true})
|
c_coinlogrec.EnsureIndex(mgo.Index{Key: []string{"channel"}, Background: true, Sparse: true})
|
||||||
c_coinlogrec.EnsureIndex(mgo.Index{Key: []string{"-ts", "logtype", "cointype", "channel"}, Background: true, Sparse: true})
|
c_coinlogrec.EnsureIndex(mgo.Index{Key: []string{"-ts", "logtype", "cointype", "channel"}, Background: true, Sparse: true})
|
||||||
|
c_coinlogrec.EnsureIndex(mgo.Index{Key: []string{"transferid"}, Background: true, Sparse: true})
|
||||||
}
|
}
|
||||||
return c_coinlogrec
|
return c_coinlogrec
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,6 +44,7 @@ type CoinLog struct {
|
||||||
DiamondAdd int64 // 钻石加成
|
DiamondAdd int64 // 钻石加成
|
||||||
GameFreeId int64 // 场次id
|
GameFreeId int64 // 场次id
|
||||||
BaseCoin int64 // 底分
|
BaseCoin int64 // 底分
|
||||||
|
TransferID string // 订单号
|
||||||
}
|
}
|
||||||
|
|
||||||
type CoinLogV1 struct {
|
type CoinLogV1 struct {
|
||||||
|
@ -90,6 +91,7 @@ type CoinLogParam struct {
|
||||||
BaseCoin int64 // 底注
|
BaseCoin int64 // 底注
|
||||||
Operator string // 操作人
|
Operator string // 操作人
|
||||||
Remark string // 备注
|
Remark string // 备注
|
||||||
|
TransferID string
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewCoinLogEx(param *CoinLogParam) *CoinLog {
|
func NewCoinLogEx(param *CoinLogParam) *CoinLog {
|
||||||
|
@ -110,6 +112,7 @@ func NewCoinLogEx(param *CoinLogParam) *CoinLog {
|
||||||
cl.Ts = tNow.Unix()
|
cl.Ts = tNow.Unix()
|
||||||
cl.GameFreeId = param.GameFreeID
|
cl.GameFreeId = param.GameFreeID
|
||||||
cl.BaseCoin = param.BaseCoin
|
cl.BaseCoin = param.BaseCoin
|
||||||
|
cl.TransferID = param.TransferID
|
||||||
|
|
||||||
//todo 后期修改数据结构,余额,加成,各用一个字段存储; NewCoinLogExV2
|
//todo 后期修改数据结构,余额,加成,各用一个字段存储; NewCoinLogExV2
|
||||||
switch param.ChangeType {
|
switch param.ChangeType {
|
||||||
|
|
|
@ -259,17 +259,19 @@ type PlatfromGameLoginRsp struct {
|
||||||
|
|
||||||
// 上分请求
|
// 上分请求
|
||||||
type PlatfromUpScoreReq struct {
|
type PlatfromUpScoreReq struct {
|
||||||
Username string `json:"username"`
|
Username string `json:"username"`
|
||||||
Channel string `json:"channel"`
|
Channel string `json:"channel"`
|
||||||
Timestamp string `json:"timestamp"`
|
Timestamp string `json:"timestamp"`
|
||||||
Count string `json:"count"`
|
Count string `json:"count"`
|
||||||
|
TransferID string `json:"transferid"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// 上分返回
|
// 上分返回
|
||||||
type PlatfromUpScoreRsp struct {
|
type PlatfromUpScoreRsp struct {
|
||||||
Code int `json:"code"`
|
Code int `json:"code"`
|
||||||
Data struct {
|
Data struct {
|
||||||
Count int64 `json:"count"`
|
Count int64 `json:"count"`
|
||||||
|
TransferID string `json:"transferid"`
|
||||||
} `json:"data"`
|
} `json:"data"`
|
||||||
Message string `json:"message"`
|
Message string `json:"message"`
|
||||||
Success bool `json:"success"`
|
Success bool `json:"success"`
|
||||||
|
@ -277,16 +279,18 @@ type PlatfromUpScoreRsp struct {
|
||||||
|
|
||||||
// 下分请求
|
// 下分请求
|
||||||
type PlatfromDownScoreReq struct {
|
type PlatfromDownScoreReq struct {
|
||||||
Username string `json:"username"`
|
Username string `json:"username"`
|
||||||
Channel string `json:"channel"`
|
Channel string `json:"channel"`
|
||||||
Timestamp string `json:"timestamp"`
|
Timestamp string `json:"timestamp"`
|
||||||
|
TransferID string `json:"transferid"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// 下分返回
|
// 下分返回
|
||||||
type PlatfromDownScoreRsp struct {
|
type PlatfromDownScoreRsp struct {
|
||||||
Code int `json:"code"`
|
Code int `json:"code"`
|
||||||
Data struct {
|
Data struct {
|
||||||
Money string `json:"money"`
|
Money string `json:"money"`
|
||||||
|
TransferID string `json:"transferid"`
|
||||||
} `json:"data"`
|
} `json:"data"`
|
||||||
Message string `json:"message"`
|
Message string `json:"message"`
|
||||||
Success bool `json:"success"`
|
Success bool `json:"success"`
|
||||||
|
|
|
@ -129,6 +129,25 @@ func (this *CacheDataManager) ClearCacheBill(billNo int, platform string) {
|
||||||
this.HourCache.Delete(key)
|
this.HourCache.Delete(key)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (this *CacheDataManager) CacheBillStr(billNo string, platform string) {
|
||||||
|
key := fmt.Sprintf("BillNo-%v-%v", billNo, platform)
|
||||||
|
this.addCacheData(AfterHour, key, key)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *CacheDataManager) CacheBillStrCheck(billNo string, platform string) bool {
|
||||||
|
key := fmt.Sprintf("BillNo-%v-%v", billNo, platform)
|
||||||
|
if _, ok := this.HourCache.Load(key); ok {
|
||||||
|
return true
|
||||||
|
} else {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *CacheDataManager) ClearCacheStrBill(billNo string, platform string) {
|
||||||
|
key := fmt.Sprintf("BillNo-%v-%v", billNo, platform)
|
||||||
|
this.HourCache.Delete(key)
|
||||||
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
common.ClockMgrSingleton.RegisterSinker(CacheDataMgr)
|
common.ClockMgrSingleton.RegisterSinker(CacheDataMgr)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1436,7 +1436,7 @@ func (this *Player) AddDiamond(num, add int64, gainWay int32, oper, remark strin
|
||||||
// AddCoin 添加钻石
|
// AddCoin 添加钻石
|
||||||
// num 总数
|
// num 总数
|
||||||
// add num总数中有多少是加成获得
|
// add num总数中有多少是加成获得
|
||||||
func (this *Player) AddCoin(num, add int64, gainWay int32, oper, remark string) {
|
func (this *Player) AddCoin(num, add int64, gainWay int32, oper, remark string, param ...string) {
|
||||||
if num == 0 {
|
if num == 0 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -1467,6 +1467,10 @@ func (this *Player) AddCoin(num, add int64, gainWay int32, oper, remark string)
|
||||||
|
|
||||||
this.SendDiffData()
|
this.SendDiffData()
|
||||||
if !this.IsRob {
|
if !this.IsRob {
|
||||||
|
var transferID string
|
||||||
|
if len(param) > 0 {
|
||||||
|
transferID = param[0]
|
||||||
|
}
|
||||||
log := model.NewCoinLogEx(&model.CoinLogParam{
|
log := model.NewCoinLogEx(&model.CoinLogParam{
|
||||||
Platform: this.Platform,
|
Platform: this.Platform,
|
||||||
SnID: this.SnId,
|
SnID: this.SnId,
|
||||||
|
@ -1482,7 +1486,9 @@ func (this *Player) AddCoin(num, add int64, gainWay int32, oper, remark string)
|
||||||
BaseCoin: 0,
|
BaseCoin: 0,
|
||||||
Operator: oper,
|
Operator: oper,
|
||||||
Remark: remark,
|
Remark: remark,
|
||||||
|
TransferID: transferID,
|
||||||
})
|
})
|
||||||
|
|
||||||
if log != nil {
|
if log != nil {
|
||||||
mq.Write(log)
|
mq.Write(log)
|
||||||
}
|
}
|
||||||
|
|
|
@ -3010,8 +3010,15 @@ func init() {
|
||||||
|
|
||||||
//玩家在线
|
//玩家在线
|
||||||
if player != nil {
|
if player != nil {
|
||||||
|
if CacheDataMgr.CacheBillStrCheck(msg.TransferID, player.Platform) {
|
||||||
|
jsonDataRsp, err = json.Marshal(pack)
|
||||||
|
return common.ResponseTag_ParamError, jsonDataRsp
|
||||||
|
}
|
||||||
|
CacheDataMgr.CacheBillStr(msg.TransferID, player.Platform)
|
||||||
|
|
||||||
remainNum = player.Coin
|
remainNum = player.Coin
|
||||||
if player.Coin+addCoin < 0 {
|
if player.Coin+addCoin < 0 {
|
||||||
|
CacheDataMgr.ClearCacheStrBill(msg.TransferID, player.Platform)
|
||||||
pack.Code = int(webapiproto.TagCode_FAILED)
|
pack.Code = int(webapiproto.TagCode_FAILED)
|
||||||
pack.Message = "coin not enough!"
|
pack.Message = "coin not enough!"
|
||||||
return common.ResponseTag_ParamError, pack
|
return common.ResponseTag_ParamError, pack
|
||||||
|
@ -3030,7 +3037,7 @@ func init() {
|
||||||
pack.Code = int(webapiproto.TagCode_SUCCESS)
|
pack.Code = int(webapiproto.TagCode_SUCCESS)
|
||||||
pack.Message = data.(error).Error()
|
pack.Message = data.(error).Error()
|
||||||
} else {
|
} else {
|
||||||
player.AddCoin(addCoin, 0, common.GainWayPlatformUpScore, "platform", "平台上分")
|
player.AddCoin(addCoin, 0, common.GainWayPlatformUpScore, "platform", "平台上分", msg.TransferID)
|
||||||
player.SendDiffData()
|
player.SendDiffData()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3043,15 +3050,23 @@ func init() {
|
||||||
|
|
||||||
tNode.TransRep.RetFiels = jsonDataRsp
|
tNode.TransRep.RetFiels = jsonDataRsp
|
||||||
tNode.Resume()
|
tNode.Resume()
|
||||||
|
CacheDataMgr.ClearCacheStrBill(msg.TransferID, player.Platform)
|
||||||
}), "/api/platform/upscore").StartByFixExecutor("UserName:" + msg.Username)
|
}), "/api/platform/upscore").StartByFixExecutor("UserName:" + msg.Username)
|
||||||
} else {
|
} else {
|
||||||
//玩家不在线
|
//玩家不在线
|
||||||
var acc *model.Account
|
var acc *model.Account
|
||||||
acc, err = model.GetAccountByName("1", msg.Username)
|
|
||||||
if acc == nil {
|
|
||||||
return common.ResponseTag_ParamError, pack
|
|
||||||
}
|
|
||||||
task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} {
|
task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} {
|
||||||
|
acc, err = model.GetAccountByName("1", msg.Username)
|
||||||
|
if acc == nil {
|
||||||
|
return errors.New("not found")
|
||||||
|
}
|
||||||
|
|
||||||
|
if CacheDataMgr.CacheBillStrCheck(msg.TransferID, acc.Platform) {
|
||||||
|
jsonDataRsp, err = json.Marshal(pack)
|
||||||
|
return errors.New("transfer repeat")
|
||||||
|
}
|
||||||
|
CacheDataMgr.CacheBillStr(msg.TransferID, acc.Platform)
|
||||||
|
|
||||||
findPlayer, _ := model.GetPlayerDataBySnId("1", int32(acc.SnId), false, true)
|
findPlayer, _ := model.GetPlayerDataBySnId("1", int32(acc.SnId), false, true)
|
||||||
if findPlayer != nil {
|
if findPlayer != nil {
|
||||||
remainNum = findPlayer.Coin
|
remainNum = findPlayer.Coin
|
||||||
|
@ -3072,13 +3087,14 @@ func init() {
|
||||||
BaseCoin: 0,
|
BaseCoin: 0,
|
||||||
Operator: "休闲平台",
|
Operator: "休闲平台",
|
||||||
Remark: "不在线平台上分",
|
Remark: "不在线平台上分",
|
||||||
|
TransferID: msg.TransferID,
|
||||||
})
|
})
|
||||||
|
|
||||||
err := model.UpdatePlayerCoin(findPlayer.Platform, findPlayer.SnId, findPlayer.Coin+addCoin,
|
err := model.UpdatePlayerCoin(findPlayer.Platform, findPlayer.SnId, findPlayer.Coin+addCoin,
|
||||||
findPlayer.Diamond, findPlayer.SafeBoxCoin, findPlayer.CoinPayTs, findPlayer.SafeBoxCoinTs, findPlayer.MoneyPayTotal, findPlayer.ShopID)
|
findPlayer.Diamond, findPlayer.SafeBoxCoin, findPlayer.CoinPayTs, findPlayer.SafeBoxCoinTs, findPlayer.MoneyPayTotal, findPlayer.ShopID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Logger.Errorf("model.UpdatePlayerCoin err:%v.", err)
|
logger.Logger.Errorf("model.UpdatePlayerCoin err:%v.", err)
|
||||||
return nil
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
//账变记录
|
//账变记录
|
||||||
|
@ -3113,6 +3129,7 @@ func init() {
|
||||||
|
|
||||||
tNode.TransRep.RetFiels = jsonDataRsp
|
tNode.TransRep.RetFiels = jsonDataRsp
|
||||||
tNode.Resume()
|
tNode.Resume()
|
||||||
|
CacheDataMgr.ClearCacheStrBill(msg.TransferID, acc.Platform)
|
||||||
}), "/api/platform/upscore").StartByFixExecutor("UserName:" + msg.Username)
|
}), "/api/platform/upscore").StartByFixExecutor("UserName:" + msg.Username)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3159,6 +3176,12 @@ func init() {
|
||||||
return common.ResponseTag_ParamError, jsonDataRsp
|
return common.ResponseTag_ParamError, jsonDataRsp
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if CacheDataMgr.CacheBillStrCheck(msg.TransferID, player.Platform) {
|
||||||
|
jsonDataRsp, err = json.Marshal(pack)
|
||||||
|
return common.ResponseTag_ParamError, jsonDataRsp
|
||||||
|
}
|
||||||
|
CacheDataMgr.CacheBillStr(msg.TransferID, player.Platform)
|
||||||
|
|
||||||
task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} {
|
task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} {
|
||||||
return nil
|
return nil
|
||||||
}), task.CompleteNotifyWrapper(func(data interface{}, t task.Task) {
|
}), task.CompleteNotifyWrapper(func(data interface{}, t task.Task) {
|
||||||
|
@ -3167,7 +3190,7 @@ func init() {
|
||||||
remainNum = player.Coin
|
remainNum = player.Coin
|
||||||
|
|
||||||
logger.Logger.Tracef("/api/platform/downscore player online snid:%v, player.Coin:%v", player.SnId, player.Coin)
|
logger.Logger.Tracef("/api/platform/downscore player online snid:%v, player.Coin:%v", player.SnId, player.Coin)
|
||||||
player.AddCoin(addCoin, 0, common.GainWayPlatformDownScore, "platform", "平台下分")
|
player.AddCoin(addCoin, 0, common.GainWayPlatformDownScore, "platform", "平台下分", msg.TransferID)
|
||||||
player.SendDiffData()
|
player.SendDiffData()
|
||||||
|
|
||||||
pack.Code = int(webapiproto.TagCode_SUCCESS)
|
pack.Code = int(webapiproto.TagCode_SUCCESS)
|
||||||
|
@ -3182,16 +3205,23 @@ func init() {
|
||||||
|
|
||||||
tNode.TransRep.RetFiels = jsonDataRsp
|
tNode.TransRep.RetFiels = jsonDataRsp
|
||||||
tNode.Resume()
|
tNode.Resume()
|
||||||
|
CacheDataMgr.ClearCacheStrBill(msg.TransferID, player.Platform)
|
||||||
}), "/api/platform/downscore").StartByFixExecutor("UserName:" + msg.Username)
|
}), "/api/platform/downscore").StartByFixExecutor("UserName:" + msg.Username)
|
||||||
} else {
|
} else {
|
||||||
//玩家不在线
|
//玩家不在线
|
||||||
|
var acc *model.Account
|
||||||
task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} {
|
task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} {
|
||||||
var acc *model.Account
|
|
||||||
acc, err = model.GetAccountByName("1", msg.Username)
|
acc, err = model.GetAccountByName("1", msg.Username)
|
||||||
if acc == nil {
|
if acc == nil {
|
||||||
return nil
|
return errors.New("not found")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if CacheDataMgr.CacheBillStrCheck(msg.TransferID, acc.Platform) {
|
||||||
|
jsonDataRsp, err = json.Marshal(pack)
|
||||||
|
return errors.New("transfer repeat")
|
||||||
|
}
|
||||||
|
CacheDataMgr.CacheBillStr(msg.TransferID, acc.Platform)
|
||||||
|
|
||||||
findPlayer, _ := model.GetPlayerDataBySnId(acc.Platform, int32(acc.SnId), false, true)
|
findPlayer, _ := model.GetPlayerDataBySnId(acc.Platform, int32(acc.SnId), false, true)
|
||||||
if findPlayer != nil {
|
if findPlayer != nil {
|
||||||
|
|
||||||
|
@ -3219,13 +3249,14 @@ func init() {
|
||||||
BaseCoin: 0,
|
BaseCoin: 0,
|
||||||
Operator: "休闲平台",
|
Operator: "休闲平台",
|
||||||
Remark: "不在线平台下分",
|
Remark: "不在线平台下分",
|
||||||
|
TransferID: msg.TransferID,
|
||||||
})
|
})
|
||||||
|
|
||||||
err := model.UpdatePlayerCoin(findPlayer.Platform, findPlayer.SnId, findPlayer.Coin+addCoin,
|
err := model.UpdatePlayerCoin(findPlayer.Platform, findPlayer.SnId, findPlayer.Coin+addCoin,
|
||||||
findPlayer.Diamond, findPlayer.SafeBoxCoin, findPlayer.CoinPayTs, findPlayer.SafeBoxCoinTs, findPlayer.MoneyPayTotal, findPlayer.ShopID)
|
findPlayer.Diamond, findPlayer.SafeBoxCoin, findPlayer.CoinPayTs, findPlayer.SafeBoxCoinTs, findPlayer.MoneyPayTotal, findPlayer.ShopID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Logger.Errorf("model.UpdatePlayerCoin err:%v.", err)
|
logger.Logger.Errorf("model.UpdatePlayerCoin err:%v.", err)
|
||||||
return nil
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
//账变记录
|
//账变记录
|
||||||
|
@ -3260,6 +3291,7 @@ func init() {
|
||||||
|
|
||||||
tNode.TransRep.RetFiels = jsonDataRsp
|
tNode.TransRep.RetFiels = jsonDataRsp
|
||||||
tNode.Resume()
|
tNode.Resume()
|
||||||
|
CacheDataMgr.ClearCacheStrBill(msg.TransferID, acc.Platform)
|
||||||
}), "/api/platform/downscore").StartByFixExecutor("UserName:" + msg.Username)
|
}), "/api/platform/downscore").StartByFixExecutor("UserName:" + msg.Username)
|
||||||
}
|
}
|
||||||
return common.ResponseTag_TransactYield, jsonDataRsp
|
return common.ResponseTag_TransactYield, jsonDataRsp
|
||||||
|
|
Loading…
Reference in New Issue