78 lines
2.1 KiB
Go
78 lines
2.1 KiB
Go
package user
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/pb"
|
|
cfg "go_dreamfactory/sys/configure/structs"
|
|
)
|
|
|
|
//参数校验
|
|
func (this *apiComp) PuzzleAwardCheck(session comm.IUserSession, req *pb.UserPuzzleAwardReq) (errdata *pb.ErrorData) {
|
|
|
|
return
|
|
}
|
|
|
|
//拼图领奖
|
|
func (this *apiComp) PuzzleAward(session comm.IUserSession, req *pb.UserPuzzleAwardReq) (errdata *pb.ErrorData) {
|
|
var (
|
|
sign *pb.DBSign
|
|
err error
|
|
completeCount int32
|
|
res []*cfg.Gameatn
|
|
)
|
|
|
|
if sign, err = this.module.modelSign.GetUserSign(session.GetUserId()); err != nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_DBError,
|
|
Title: pb.ErrorCode_DBError.ToString(),
|
|
Message: err.Error(),
|
|
}
|
|
return
|
|
}
|
|
if sign.Puzzle[req.Index] != 0 {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_ReqParameterError,
|
|
Title: pb.ErrorCode_ReqParameterError.ToString(),
|
|
}
|
|
return
|
|
}
|
|
_data := this.module.configure.GetSignConf(req.Index, sign.Group)
|
|
if _data != nil { // 发奖
|
|
res = append(res, _data.Gamegift...)
|
|
// if errdata = this.module.DispenseRes(session, _data.Gamegift, true); errdata != nil {
|
|
// return
|
|
// }
|
|
}
|
|
|
|
sign.Puzzle[req.Index] = 1
|
|
for _, v := range sign.Puzzle {
|
|
if v == 1 {
|
|
completeCount++
|
|
}
|
|
}
|
|
if conf := this.module.configure.GetSignExtarConf(completeCount, sign.Group); conf != nil {
|
|
//this.module.DispenseRes(session, conf.Extra, true) // 签到额外奖励
|
|
res = append(res, conf.Extra...)
|
|
}
|
|
if errdata = this.module.DispenseRes(session, res, true); errdata != nil {
|
|
return
|
|
}
|
|
if err = this.module.modelSign.Change(session.GetUserId(), map[string]interface{}{
|
|
"puzzle": sign.Puzzle,
|
|
}); err != nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_DBError,
|
|
Title: pb.ErrorCode_DBError.ToString(),
|
|
Message: err.Error(),
|
|
}
|
|
return
|
|
}
|
|
session.SendMsg(string(this.module.GetType()), "puzzleaward", &pb.UserPuzzleAwardResp{
|
|
Index: req.Index,
|
|
})
|
|
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
|
|
this.module.WriteUserLog(session.GetUserId(), "UserPuzzleAwardReq", res)
|
|
})
|
|
return
|
|
}
|