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{"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
|
||||
}
|
||||
|
|
|
@ -44,6 +44,7 @@ type CoinLog struct {
|
|||
DiamondAdd int64 // 钻石加成
|
||||
GameFreeId int64 // 场次id
|
||||
BaseCoin int64 // 底分
|
||||
TransferID string // 订单号
|
||||
}
|
||||
|
||||
type CoinLogV1 struct {
|
||||
|
@ -90,6 +91,7 @@ type CoinLogParam struct {
|
|||
BaseCoin int64 // 底注
|
||||
Operator string // 操作人
|
||||
Remark string // 备注
|
||||
TransferID string
|
||||
}
|
||||
|
||||
func NewCoinLogEx(param *CoinLogParam) *CoinLog {
|
||||
|
@ -110,6 +112,7 @@ func NewCoinLogEx(param *CoinLogParam) *CoinLog {
|
|||
cl.Ts = tNow.Unix()
|
||||
cl.GameFreeId = param.GameFreeID
|
||||
cl.BaseCoin = param.BaseCoin
|
||||
cl.TransferID = param.TransferID
|
||||
|
||||
//todo 后期修改数据结构,余额,加成,各用一个字段存储; NewCoinLogExV2
|
||||
switch param.ChangeType {
|
||||
|
|
|
@ -263,6 +263,7 @@ type PlatfromUpScoreReq struct {
|
|||
Channel string `json:"channel"`
|
||||
Timestamp string `json:"timestamp"`
|
||||
Count string `json:"count"`
|
||||
TransferID string `json:"transferid"`
|
||||
}
|
||||
|
||||
// 上分返回
|
||||
|
@ -270,6 +271,7 @@ 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"`
|
||||
|
@ -280,6 +282,7 @@ type PlatfromDownScoreReq struct {
|
|||
Username string `json:"username"`
|
||||
Channel string `json:"channel"`
|
||||
Timestamp string `json:"timestamp"`
|
||||
TransferID string `json:"transferid"`
|
||||
}
|
||||
|
||||
// 下分返回
|
||||
|
@ -287,6 +290,7 @@ 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"`
|
||||
|
|
|
@ -129,6 +129,25 @@ func (this *CacheDataManager) ClearCacheBill(billNo int, platform string) {
|
|||
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() {
|
||||
common.ClockMgrSingleton.RegisterSinker(CacheDataMgr)
|
||||
}
|
||||
|
|
|
@ -1436,7 +1436,7 @@ func (this *Player) AddDiamond(num, add int64, gainWay int32, oper, remark strin
|
|||
// AddCoin 添加钻石
|
||||
// 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 {
|
||||
return
|
||||
}
|
||||
|
@ -1467,6 +1467,10 @@ func (this *Player) AddCoin(num, add int64, gainWay int32, oper, remark string)
|
|||
|
||||
this.SendDiffData()
|
||||
if !this.IsRob {
|
||||
var transferID string
|
||||
if len(param) > 0 {
|
||||
transferID = param[0]
|
||||
}
|
||||
log := model.NewCoinLogEx(&model.CoinLogParam{
|
||||
Platform: this.Platform,
|
||||
SnID: this.SnId,
|
||||
|
@ -1482,7 +1486,9 @@ func (this *Player) AddCoin(num, add int64, gainWay int32, oper, remark string)
|
|||
BaseCoin: 0,
|
||||
Operator: oper,
|
||||
Remark: remark,
|
||||
TransferID: transferID,
|
||||
})
|
||||
|
||||
if log != nil {
|
||||
mq.Write(log)
|
||||
}
|
||||
|
|
|
@ -3010,8 +3010,15 @@ func init() {
|
|||
|
||||
//玩家在线
|
||||
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
|
||||
if player.Coin+addCoin < 0 {
|
||||
CacheDataMgr.ClearCacheStrBill(msg.TransferID, player.Platform)
|
||||
pack.Code = int(webapiproto.TagCode_FAILED)
|
||||
pack.Message = "coin not enough!"
|
||||
return common.ResponseTag_ParamError, pack
|
||||
|
@ -3030,7 +3037,7 @@ func init() {
|
|||
pack.Code = int(webapiproto.TagCode_SUCCESS)
|
||||
pack.Message = data.(error).Error()
|
||||
} else {
|
||||
player.AddCoin(addCoin, 0, common.GainWayPlatformUpScore, "platform", "平台上分")
|
||||
player.AddCoin(addCoin, 0, common.GainWayPlatformUpScore, "platform", "平台上分", msg.TransferID)
|
||||
player.SendDiffData()
|
||||
}
|
||||
|
||||
|
@ -3043,15 +3050,23 @@ func init() {
|
|||
|
||||
tNode.TransRep.RetFiels = jsonDataRsp
|
||||
tNode.Resume()
|
||||
CacheDataMgr.ClearCacheStrBill(msg.TransferID, player.Platform)
|
||||
}), "/api/platform/upscore").StartByFixExecutor("UserName:" + msg.Username)
|
||||
} else {
|
||||
//玩家不在线
|
||||
var acc *model.Account
|
||||
task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} {
|
||||
acc, err = model.GetAccountByName("1", msg.Username)
|
||||
if acc == nil {
|
||||
return common.ResponseTag_ParamError, pack
|
||||
return errors.New("not found")
|
||||
}
|
||||
task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} {
|
||||
|
||||
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)
|
||||
if findPlayer != nil {
|
||||
remainNum = findPlayer.Coin
|
||||
|
@ -3072,13 +3087,14 @@ func init() {
|
|||
BaseCoin: 0,
|
||||
Operator: "休闲平台",
|
||||
Remark: "不在线平台上分",
|
||||
TransferID: msg.TransferID,
|
||||
})
|
||||
|
||||
err := model.UpdatePlayerCoin(findPlayer.Platform, findPlayer.SnId, findPlayer.Coin+addCoin,
|
||||
findPlayer.Diamond, findPlayer.SafeBoxCoin, findPlayer.CoinPayTs, findPlayer.SafeBoxCoinTs, findPlayer.MoneyPayTotal, findPlayer.ShopID)
|
||||
if err != nil {
|
||||
logger.Logger.Errorf("model.UpdatePlayerCoin err:%v.", err)
|
||||
return nil
|
||||
return err
|
||||
}
|
||||
|
||||
//账变记录
|
||||
|
@ -3113,6 +3129,7 @@ func init() {
|
|||
|
||||
tNode.TransRep.RetFiels = jsonDataRsp
|
||||
tNode.Resume()
|
||||
CacheDataMgr.ClearCacheStrBill(msg.TransferID, acc.Platform)
|
||||
}), "/api/platform/upscore").StartByFixExecutor("UserName:" + msg.Username)
|
||||
}
|
||||
|
||||
|
@ -3159,6 +3176,12 @@ func init() {
|
|||
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{} {
|
||||
return nil
|
||||
}), task.CompleteNotifyWrapper(func(data interface{}, t task.Task) {
|
||||
|
@ -3167,7 +3190,7 @@ func init() {
|
|||
remainNum = 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()
|
||||
|
||||
pack.Code = int(webapiproto.TagCode_SUCCESS)
|
||||
|
@ -3182,16 +3205,23 @@ func init() {
|
|||
|
||||
tNode.TransRep.RetFiels = jsonDataRsp
|
||||
tNode.Resume()
|
||||
CacheDataMgr.ClearCacheStrBill(msg.TransferID, player.Platform)
|
||||
}), "/api/platform/downscore").StartByFixExecutor("UserName:" + msg.Username)
|
||||
} else {
|
||||
//玩家不在线
|
||||
task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} {
|
||||
var acc *model.Account
|
||||
task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} {
|
||||
acc, err = model.GetAccountByName("1", msg.Username)
|
||||
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)
|
||||
if findPlayer != nil {
|
||||
|
||||
|
@ -3219,13 +3249,14 @@ func init() {
|
|||
BaseCoin: 0,
|
||||
Operator: "休闲平台",
|
||||
Remark: "不在线平台下分",
|
||||
TransferID: msg.TransferID,
|
||||
})
|
||||
|
||||
err := model.UpdatePlayerCoin(findPlayer.Platform, findPlayer.SnId, findPlayer.Coin+addCoin,
|
||||
findPlayer.Diamond, findPlayer.SafeBoxCoin, findPlayer.CoinPayTs, findPlayer.SafeBoxCoinTs, findPlayer.MoneyPayTotal, findPlayer.ShopID)
|
||||
if err != nil {
|
||||
logger.Logger.Errorf("model.UpdatePlayerCoin err:%v.", err)
|
||||
return nil
|
||||
return err
|
||||
}
|
||||
|
||||
//账变记录
|
||||
|
@ -3260,6 +3291,7 @@ func init() {
|
|||
|
||||
tNode.TransRep.RetFiels = jsonDataRsp
|
||||
tNode.Resume()
|
||||
CacheDataMgr.ClearCacheStrBill(msg.TransferID, acc.Platform)
|
||||
}), "/api/platform/downscore").StartByFixExecutor("UserName:" + msg.Username)
|
||||
}
|
||||
return common.ResponseTag_TransactYield, jsonDataRsp
|
||||
|
|
Loading…
Reference in New Issue